aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog11
-rw-r--r--eval.c3
-rw-r--r--vm_core.h2
-rw-r--r--vm_eval.c4
-rw-r--r--vm_insnhelper.h4
5 files changed, 16 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index c5a59dbe8a..ed5e6f302b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+Mon Jun 4 16:13:00 2012 Koichi Sasada <ko1@atdot.net>
+
+ * 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 <nobu@ruby-lang.org>
* win32/win32.c (constat_apply): apply VT100 functions.
diff --git a/eval.c b/eval.c
index 298326a556..54884850e9 100644
--- a/eval.c
+++ b/eval.c
@@ -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 {
diff --git a/vm_core.h b/vm_core.h
index c831d60e4a..d71e34a899 100644
--- a/vm_core.h
+++ b/vm_core.h
@@ -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) \
diff --git a/vm_eval.c b/vm_eval.c
index c1b79f5061..8ea149c459 100644
--- a/vm_eval.c
+++ b/vm_eval.c
@@ -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 {
diff --git a/vm_insnhelper.h b/vm_insnhelper.h
index 050b8d8ae0..97e2b1e2ba 100644
--- a/vm_insnhelper.h
+++ b/vm_insnhelper.h
@@ -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 */