Skip to content

Commit

Permalink
* vm_insnhelper.h: remove magical code "lfp[0] & 0x02".
Browse files Browse the repository at this point in the history
  Current VM doesn't use this bit.
* vm_core.h (RUBY_VM_GET_BLOCK_PTR): added.
* eval.c (rb_block_given_p): use RUBY_VM_GET_BLOCK_PTR().
* vm_eval.c (rb_f_block_given_p): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35908 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
ko1 committed Jun 4, 2012
1 parent 82aa434 commit 06513cc
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 8 deletions.
11 changes: 11 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
Mon Jun 4 16:13:00 2012 Koichi Sasada <[email protected]>

* vm_insnhelper.h: remove magical code "lfp[0] & 0x02".
Current VM doesn't use this bit.

* vm_core.h (RUBY_VM_GET_BLOCK_PTR): added.

* eval.c (rb_block_given_p): use RUBY_VM_GET_BLOCK_PTR().

* vm_eval.c (rb_f_block_given_p): ditto.

Mon Jun 4 15:39:33 2012 Nobuyoshi Nakada <[email protected]>

* win32/win32.c (constat_apply): apply VT100 functions.
Expand Down
3 changes: 1 addition & 2 deletions eval.c
Original file line number Diff line number Diff line change
Expand Up @@ -604,8 +604,7 @@ rb_block_given_p(void)
{
rb_thread_t *th = GET_THREAD();

if ((th->cfp->lfp[0] & 0x02) == 0 &&
GC_GUARDED_PTR_REF(th->cfp->lfp[0])) {
if (RUBY_VM_GET_BLOCK_PTR(th->cfp)) {
return TRUE;
}
else {
Expand Down
2 changes: 2 additions & 0 deletions vm_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,8 @@ typedef rb_control_frame_t *
#define GC_GUARDED_PTR_REF(p) ((void *)(((VALUE)(p)) & ~0x03))
#define GC_GUARDED_PTR_P(p) (((VALUE)(p)) & 0x01)

#define RUBY_VM_GET_BLOCK_PTR(cfp) ((rb_block_t *)(GC_GUARDED_PTR_REF((cfp)->lfp[0])))

#define RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp) ((cfp)+1)
#define RUBY_VM_NEXT_CONTROL_FRAME(cfp) ((cfp)-1)
#define RUBY_VM_END_CONTROL_FRAME(th) \
Expand Down
4 changes: 1 addition & 3 deletions vm_eval.c
Original file line number Diff line number Diff line change
Expand Up @@ -1660,9 +1660,7 @@ rb_f_block_given_p(void)
rb_control_frame_t *cfp = th->cfp;
cfp = vm_get_ruby_level_caller_cfp(th, RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp));

if (cfp != 0 &&
(cfp->lfp[0] & 0x02) == 0 &&
GC_GUARDED_PTR_REF(cfp->lfp[0])) {
if (cfp != 0 && RUBY_VM_GET_BLOCK_PTR(cfp)) {
return Qtrue;
}
else {
Expand Down
4 changes: 1 addition & 3 deletions vm_insnhelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,7 @@ extern VALUE ruby_vm_const_missing_count;
} \
} while (0)

#define GET_BLOCK_PTR() \
((rb_block_t *)(GC_GUARDED_PTR_REF(GET_LFP()[0] & \
((GET_LFP()[0] & 0x02) - 0x02))))
#define GET_BLOCK_PTR() ((rb_block_t *)(GC_GUARDED_PTR_REF(GET_LFP()[0])))

/**********************************************************/
/* deal with control flow 3: exception */
Expand Down

0 comments on commit 06513cc

Please sign in to comment.