summaryrefslogtreecommitdiff
path: root/vm_insnhelper.h
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-08-23 07:22:40 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-08-23 07:22:40 +0000
commitb3b5e626ad69bf22be3228f847f94e1b68f40888 (patch)
tree17e1c7ec5995e9ab60632bd2a9756695b32b614c /vm_insnhelper.h
parentce5af582a0552d1ccbe66e8b3ee3ca046f6b18c3 (diff)
downloadruby-b3b5e626ad69bf22be3228f847f94e1b68f40888.tar.gz
* include/ruby/ruby.h: introduce flonum technique for
64bit CPU environment (sizeof(double) == sizeof(VALUE)). flonum technique enables to avoid double object creation if the double value d is in range about between 1.72723e-77 < |d| <= 1.15792e+77 or 0.0. flonum Float value is immediate and their lowest two bits are b10. If flonum is activated, then USE_FLONUM macro is 1. I'll write detailed in this technique on https://bugs.ruby-lang.org/projects/ruby-trunk/wiki/Flonum_tech * benchmark/bmx_temp.rb: add an benchmark for simple Float calculation. * gc.c (id2ref, rb_obj_id): add flonum Float support. * include/ruby/intern.h: move decl of rb_float_new(double) to include/ruby/ruby.h. * insns.def, vm.c, vm_insnhelper.c: add flonum optimization and simplify source code. * vm_insnhelper.h (FLONUM_2_P): added. * marshal.c: support flonum output. * numeric.c (rb_float_new_in_heap): added. * parse.y: support flonum. * random.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36798 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm_insnhelper.h')
-rw-r--r--vm_insnhelper.h10
1 files changed, 8 insertions, 2 deletions
diff --git a/vm_insnhelper.h b/vm_insnhelper.h
index d78a84c3dc..4d5f0e36b6 100644
--- a/vm_insnhelper.h
+++ b/vm_insnhelper.h
@@ -211,9 +211,15 @@ enum vm_regan_acttype {
#define SYMBOL_REDEFINED_OP_FLAG (1 << 6)
#define TIME_REDEFINED_OP_FLAG (1 << 7)
-#define FIXNUM_2_P(a, b) ((a) & (b) & 1)
#define BASIC_OP_UNREDEFINED_P(op, klass) (LIKELY((ruby_vm_redefined_flag[(op)]&(klass)) == 0))
-#define HEAP_CLASS_OF(obj) RBASIC(obj)->klass
+
+#define FIXNUM_2_P(a, b) ((a) & (b) & 1)
+#if USE_FLONUM
+#define FLONUM_2_P(a, b) (((((a)^2) | ((b)^2)) & 3) == 0) /* (FLONUM_P(a) && FLONUM_P(b)) */
+#else
+#define FLONUM_2_P(a, b) 0
+#endif
+#define HEAP_CLASS_OF(obj) (RBASIC(obj)->klass)
#ifndef USE_IC_FOR_SPECIALIZED_METHOD
#define USE_IC_FOR_SPECIALIZED_METHOD 1