Skip to content

Commit

Permalink
* vm.c, eval_intern.h (PASS_PASSED_BLOCK):
Browse files Browse the repository at this point in the history
  set a VM_FRAME_FLAG_PASSED flag to skip this frame when
  searching ruby-level-cfp.
* eval.c, eval_intern.h, proc.c: fix to check cfp.  if there is
  no valid ruby-level-cfp, cause RuntimeError exception.
  [ruby-dev:34128]
* vm_core.h, vm_evalbody.c, vm.c, vm_dump.c, vm_insnhelper.c,
  insns.def: rename FRAME_MAGIC_* to VM_FRAME_MAGIC_*.
* KNOWNBUGS.rb, bootstraptest/test*.rb: move solved bugs.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17084 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
ko1 committed Jun 10, 2008
1 parent e6697a6 commit 9e324fd
Show file tree
Hide file tree
Showing 17 changed files with 241 additions and 190 deletions.
15 changes: 15 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
Wed Jun 11 05:53:20 2008 Koichi Sasada <[email protected]>

* vm.c, eval_intern.h (PASS_PASSED_BLOCK):
set a VM_FRAME_FLAG_PASSED flag to skip this frame when
searching ruby-level-cfp.

* eval.c, eval_intern.h, proc.c: fix to check cfp. if there is
no valid ruby-level-cfp, cause RuntimeError exception.
[ruby-dev:34128]

* vm_core.h, vm_evalbody.c, vm.c, vm_dump.c, vm_insnhelper.c,
insns.def: rename FRAME_MAGIC_* to VM_FRAME_MAGIC_*.

* KNOWNBUGS.rb, bootstraptest/test*.rb: move solved bugs.

Wed Jun 11 05:55:31 2008 Hidetoshi NAGAI <[email protected]>

* ext/tk/tcltklib.c: SEGV when tcltk-stubs is enabled.
Expand Down
64 changes: 0 additions & 64 deletions KNOWNBUGS.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,49 +29,6 @@ class C
C.new.foo
}, '[ruby-core:14813]'

assert_equal 'ok', %q{
a = lambda {|x, y, &b| b }
b = a.curry[1]
if b.call(2){} == nil
:ng
else
:ok
end
}, '[ruby-core:15551]'

assert_normal_exit %q{
g = Module.enum_for(:new)
loop { g.next }
}, '[ruby-dev:34128]'

assert_normal_exit %q{
Fiber.new(&Object.method(:class_eval)).resume("foo")
}, '[ruby-dev:34128]'

assert_normal_exit %q{
Thread.new("foo", &Object.method(:class_eval)).join
}, '[ruby-dev:34128]'

assert_normal_exit %q{
g = enum_for(:local_variables)
loop { g.next }
}, '[ruby-dev:34128]'

assert_normal_exit %q{
g = enum_for(:block_given?)
loop { g.next }
}, '[ruby-dev:34128]'

assert_normal_exit %q{
g = enum_for(:binding)
loop { g.next }
}, '[ruby-dev:34128]'

assert_normal_exit %q{
g = "abc".enum_for(:scan, /./)
loop { g.next }
}, '[ruby-dev:34128]'

assert_equal %q{[:bar, :foo]}, %q{
def foo
klass = Class.new do
Expand All @@ -84,24 +41,3 @@ def foo
foo
}, "[ ruby-Bugs-19304 ]"

assert_equal 'ok', %q{
lambda {
break :ok
:ng
}.call
}, '[ruby-dev:34646]'

assert_normal_exit %q{
eval("", method(:proc).call {}.binding)
}

assert_normal_exit %q{
a = []
100.times {|i| a << i << nil << nil }
p a.compact!
}

assert_equal 'ok', %q{
a = [false]
(a[0] &&= true) == false ? :ok : :ng
}, '[ruby-dev:34679]'
4 changes: 4 additions & 0 deletions bootstraptest/test_eval.rb
Original file line number Diff line number Diff line change
Expand Up @@ -282,3 +282,7 @@ def a() :a end
:ok
end
}, '[ruby-core:16796]'

assert_normal_exit %q{
eval("", method(:proc).call {}.binding)
}
17 changes: 17 additions & 0 deletions bootstraptest/test_proc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -259,3 +259,20 @@ class A; def get_block; proc {puts "ok"} end end
GC.start
block.call
}, '[ruby-core:14885]'

assert_equal 'ok', %q{
a = lambda {|x, y, &b| b }
b = a.curry[1]
if b.call(2){} == nil
:ng
else
:ok
end
}, '[ruby-core:15551]'

assert_equal 'ok', %q{
lambda {
break :ok
:ng
}.call
}, '[ruby-dev:34646]'
11 changes: 11 additions & 0 deletions bootstraptest/test_syntax.rb
Original file line number Diff line number Diff line change
Expand Up @@ -817,3 +817,14 @@ class X < RuntimeError;end
end
}, '[ruby-core:14537]'

assert_equal 'ok', %q{
a = [false]
(a[0] &&= true) == false ? :ok : :ng
}, '[ruby-dev:34679]'

assert_normal_exit %q{
a = []
100.times {|i| a << i << nil << nil }
p a.compact!
}

34 changes: 34 additions & 0 deletions bootstraptest/test_thread.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Thread and Fiber

assert_equal %q{ok}, %q{
Thread.new{
}.join
Expand Down Expand Up @@ -268,3 +270,35 @@ def m
at_exit { Fiber.new{}.resume }
}

assert_normal_exit %q{
g = enum_for(:local_variables)
loop { g.next }
}, '[ruby-dev:34128]'

assert_normal_exit %q{
g = enum_for(:block_given?)
loop { g.next }
}, '[ruby-dev:34128]'

assert_normal_exit %q{
g = enum_for(:binding)
loop { g.next }
}, '[ruby-dev:34128]'

assert_normal_exit %q{
g = "abc".enum_for(:scan, /./)
loop { g.next }
}, '[ruby-dev:34128]'

assert_normal_exit %q{
g = Module.enum_for(:new)
loop { g.next }
}, '[ruby-dev:34128]'

assert_normal_exit %q{
Fiber.new(&Object.method(:class_eval)).resume("foo")
}, '[ruby-dev:34128]'

assert_normal_exit %q{
Thread.new("foo", &Object.method(:class_eval)).join
}, '[ruby-dev:34128]'
10 changes: 4 additions & 6 deletions eval.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ VALUE proc_invoke(VALUE, VALUE, VALUE, VALUE);
VALUE rb_binding_new(void);
NORETURN(void rb_raise_jump(VALUE));

VALUE rb_f_block_given_p(void);

ID rb_frame_callee(void);
VALUE rb_eLocalJumpError;
VALUE rb_eSysStackError;
Expand Down Expand Up @@ -586,9 +584,9 @@ rb_f_block_given_p(void)
{
rb_thread_t *th = GET_THREAD();
rb_control_frame_t *cfp = th->cfp;
cfp = vm_get_ruby_level_cfp(th, RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp));
cfp = vm_get_ruby_level_caller_cfp(th, RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp));

if (GC_GUARDED_PTR_REF(cfp->lfp[0])) {
if (cfp != 0 && GC_GUARDED_PTR_REF(cfp->lfp[0])) {
return Qtrue;
}
else {
Expand Down Expand Up @@ -1089,10 +1087,10 @@ rb_f_local_variables(void)
VALUE ary = rb_ary_new();
rb_thread_t *th = GET_THREAD();
rb_control_frame_t *cfp =
vm_get_ruby_level_cfp(th, RUBY_VM_PREVIOUS_CONTROL_FRAME(th->cfp));
vm_get_ruby_level_caller_cfp(th, RUBY_VM_PREVIOUS_CONTROL_FRAME(th->cfp));
int i;

while (1) {
while (cfp) {
if (cfp->iseq) {
for (i = 0; i < cfp->iseq->local_table_size; i++) {
ID lid = cfp->iseq->local_table[i];
Expand Down
14 changes: 10 additions & 4 deletions eval_intern.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@
#ifndef RUBY_EVAL_INTERN_H
#define RUBY_EVAL_INTERN_H

#define PASS_PASSED_BLOCK() \
(GET_THREAD()->passed_block = \
GC_GUARDED_PTR_REF((rb_block_t *)GET_THREAD()->cfp->lfp[0]))
#define PASS_PASSED_BLOCK_TH(th) do { \
(th)->passed_block = GC_GUARDED_PTR_REF((rb_block_t *)(th)->cfp->lfp[0]); \
(th)->cfp->flag |= VM_FRAME_FLAG_PASSED; \
} while (0)

#define PASS_PASSED_BLOCK() do { \
rb_thread_t * const __th__ = GET_THREAD(); \
PASS_PASSED_BLOCK_TH(__th__); \
} while (0)

#include "ruby/ruby.h"
#include "ruby/node.h"
Expand Down Expand Up @@ -219,7 +225,7 @@ NORETURN(void vm_jump_tag_but_local_jump(int, VALUE));

VALUE vm_make_jump_tag_but_local_jump(int state, VALUE val);
NODE *vm_cref(void);
rb_control_frame_t *vm_get_ruby_level_cfp(rb_thread_t *th, rb_control_frame_t *cfp);
rb_control_frame_t *vm_get_ruby_level_caller_cfp(rb_thread_t *th, rb_control_frame_t *cfp);
VALUE rb_obj_is_proc(VALUE);
VALUE rb_vm_call_cfunc(VALUE recv, VALUE (*func)(VALUE), VALUE arg, const rb_block_t *blockptr, VALUE filename);
void rb_thread_terminate_all(void);
Expand Down
2 changes: 1 addition & 1 deletion insns.def
Original file line number Diff line number Diff line change
Expand Up @@ -996,7 +996,7 @@ defineclass

/* enter scope */
vm_push_frame(th, class_iseq,
FRAME_MAGIC_CLASS, klass, (VALUE) GET_DFP() | 0x02,
VM_FRAME_MAGIC_CLASS, klass, (VALUE) GET_DFP() | 0x02,
class_iseq->iseq_encoded, GET_SP(), 0,
class_iseq->local_size);
RESTORE_REGS();
Expand Down
11 changes: 8 additions & 3 deletions proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -275,10 +275,14 @@ VALUE
rb_binding_new(void)
{
rb_thread_t *th = GET_THREAD();
rb_control_frame_t *cfp = vm_get_ruby_level_cfp(th, th->cfp);
rb_control_frame_t *cfp = vm_get_ruby_level_caller_cfp(th, th->cfp);
VALUE bindval = binding_alloc(rb_cBinding);
rb_binding_t *bind;

if (cfp == 0) {
rb_raise(rb_eRuntimeError, "Can't create Binding Object on top of Fiber.");
}

GetBindingPtr(bindval, bind);
bind->env = vm_make_env_object(th, cfp);
return bindval;
Expand Down Expand Up @@ -1187,11 +1191,12 @@ rb_method_call(int argc, VALUE *argv, VALUE method)
}
}
if ((state = EXEC_TAG()) == 0) {
rb_thread_t *th = GET_THREAD();
VALUE rb_vm_call(rb_thread_t * th, VALUE klass, VALUE recv, VALUE id, ID oid,
int argc, const VALUE *argv, const NODE *body, int nosuper);

PASS_PASSED_BLOCK();
result = rb_vm_call(GET_THREAD(), data->oclass, data->recv, data->id, data->oid,
PASS_PASSED_BLOCK_TH(th);
result = rb_vm_call(th, data->oclass, data->recv, data->id, data->oid,
argc, argv, data->body, 0);
}
POP_TAG();
Expand Down
Loading

0 comments on commit 9e324fd

Please sign in to comment.