ruby-internal 0.7.3 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/ruby-internal-node-dump +1 -1
- data/bin/ruby-internal-obfuscate +1 -1
- data/ext/cached/ruby-1.8.4/internal/method/{method.h → internal_method.h} +12 -0
- data/ext/cached/ruby-1.8.4/internal/module/getcfp.h +13 -0
- data/ext/cached/ruby-1.8.4/internal/node/global_entry.h +94 -0
- data/ext/cached/ruby-1.8.4/internal/node/node_type_descrip.c +41 -41
- data/ext/cached/ruby-1.8.4/internal/node/nodeinfo.c +288 -273
- data/ext/cached/ruby-1.8.4/internal/vm/instruction/insns_info.c +3 -0
- data/ext/cached/ruby-1.8.4/internal/vm/iseq/iseq_load.inc +21 -2
- data/ext/cached/{ruby-1.8.3/internal/method/method.h → ruby-1.8.5/internal/method/internal_method.h} +12 -0
- data/ext/cached/ruby-1.8.5/internal/module/getcfp.h +13 -0
- data/ext/cached/ruby-1.8.5/internal/node/global_entry.h +94 -0
- data/ext/cached/ruby-1.8.5/internal/node/node_type_descrip.c +45 -45
- data/ext/cached/ruby-1.8.5/internal/node/nodeinfo.c +310 -295
- data/ext/cached/ruby-1.8.5/internal/vm/instruction/insns_info.c +3 -0
- data/ext/cached/ruby-1.8.5/internal/vm/iseq/iseq_load.inc +21 -2
- data/ext/cached/{ruby-1.8.5/internal/method/method.h → ruby-1.8.6/internal/method/internal_method.h} +12 -0
- data/ext/cached/ruby-1.8.6/internal/module/getcfp.h +13 -0
- data/ext/cached/ruby-1.8.6/internal/node/global_entry.h +94 -0
- data/ext/cached/ruby-1.8.6/internal/node/node_type_descrip.c +48 -48
- data/ext/cached/ruby-1.8.6/internal/node/nodeinfo.c +323 -308
- data/ext/cached/ruby-1.8.6/internal/vm/instruction/insns_info.c +3 -0
- data/ext/cached/ruby-1.8.6/internal/vm/iseq/iseq_load.inc +21 -2
- data/ext/cached/{ruby-1.8.6/internal/method/method.h → ruby-1.8.7/internal/method/internal_method.h} +12 -0
- data/ext/cached/ruby-1.8.7/internal/module/getcfp.h +13 -0
- data/ext/cached/ruby-1.8.7/internal/node/global_entry.h +98 -0
- data/ext/cached/ruby-1.8.7/internal/node/node_type_descrip.c +42 -42
- data/ext/cached/ruby-1.8.7/internal/node/nodeinfo.c +276 -261
- data/ext/cached/ruby-1.8.7/internal/vm/instruction/insns_info.c +3 -0
- data/ext/cached/ruby-1.8.7/internal/vm/iseq/iseq_load.inc +21 -2
- data/ext/cached/{ruby-1.9.0/internal/method/method.h → ruby-1.9.1/internal/method/internal_method.h} +12 -0
- data/ext/cached/ruby-1.9.1/internal/module/classpath.c +12 -14
- data/ext/cached/ruby-1.9.1/internal/module/getcfp.h +25 -0
- data/ext/cached/ruby-1.9.1/internal/node/global_entry.h +86 -0
- data/ext/cached/ruby-1.9.1/internal/node/node_type_descrip.c +46 -48
- data/ext/cached/ruby-1.9.1/internal/node/nodeinfo.c +311 -412
- data/ext/cached/ruby-1.9.1/internal/vm/instruction/insns_info.c +3 -0
- data/ext/cached/ruby-1.9.1/internal/vm/iseq/iseq_load.inc +28 -6
- data/ext/cached/ruby-1.9.1/internal/yarv-headers/iseq.h +1 -0
- data/ext/cached/ruby-1.9.1/internal/yarv-headers/parse.h +6 -6
- data/ext/cached/ruby-1.9.1/internal/yarv-headers/revision.h +1 -1
- data/ext/cached/ruby-1.9.1/internal/yarv-headers/version.h +6 -5
- data/ext/cached/ruby-1.9.1/internal/yarv-headers/vm_core.h +3 -2
- data/ext/cached/ruby-1.9.1/internal/yarv-headers/vm_insnhelper.h +1 -0
- data/ext/cached/{ruby-1.9.0 → ruby-1.9.2}/internal/binding/block.h +0 -0
- data/ext/cached/{ruby-1.9.1/internal/method/method.h → ruby-1.9.2/internal/method/internal_method.h} +16 -5
- data/ext/cached/ruby-1.9.2/internal/module/classpath.c +40 -0
- data/ext/cached/{ruby-1.9.0 → ruby-1.9.2}/internal/module/classpath.h +0 -0
- data/ext/cached/ruby-1.9.2/internal/module/getcfp.h +25 -0
- data/ext/cached/{ruby-1.9.0 → ruby-1.9.2}/internal/node/block.h +0 -0
- data/ext/cached/ruby-1.9.2/internal/node/global_entry.h +93 -0
- data/ext/cached/{ruby-1.9.0 → ruby-1.9.2}/internal/node/node_type_descrip.c +44 -48
- data/ext/cached/{ruby-1.9.0 → ruby-1.9.2}/internal/node/nodeinfo.c +291 -439
- data/ext/cached/{ruby-1.9.0 → ruby-1.9.2}/internal/node/nodeinfo.h +0 -0
- data/ext/cached/{ruby-1.9.0 → ruby-1.9.2}/internal/proc/block.h +0 -0
- data/ext/cached/{ruby-1.9.0 → ruby-1.9.2}/internal/tag/tag.h +0 -0
- data/ext/cached/{ruby-1.9.0 → ruby-1.9.2}/internal/vm/instruction/insns_info.c +141 -64
- data/ext/cached/{ruby-1.9.0 → ruby-1.9.2}/internal/vm/instruction/insns_info.h +88 -80
- data/ext/cached/{ruby-1.9.0 → ruby-1.9.2}/internal/vm/iseq/insns_info.inc +77 -70
- data/ext/cached/ruby-1.9.2/internal/vm/iseq/iseq_load.inc +426 -0
- data/ext/cached/{ruby-1.9.0 → ruby-1.9.2}/internal/yarv-headers/debug.h +1 -1
- data/ext/cached/{ruby-1.9.0 → ruby-1.9.2}/internal/yarv-headers/dln.h +3 -3
- data/ext/cached/{ruby-1.9.0 → ruby-1.9.2}/internal/yarv-headers/encdb.h +18 -2
- data/ext/cached/{ruby-1.9.0 → ruby-1.9.2}/internal/yarv-headers/eval_intern.h +39 -28
- data/ext/cached/{ruby-1.9.0 → ruby-1.9.2}/internal/yarv-headers/gc.h +7 -5
- data/ext/cached/ruby-1.9.2/internal/yarv-headers/id.h +170 -0
- data/ext/cached/{ruby-1.9.0 → ruby-1.9.2}/internal/yarv-headers/iseq.h +20 -10
- data/ext/cached/ruby-1.9.2/internal/yarv-headers/method.h +103 -0
- data/ext/cached/{ruby-1.9.0 → ruby-1.9.2}/internal/yarv-headers/node.h +14 -47
- data/ext/cached/{ruby-1.9.0 → ruby-1.9.2}/internal/yarv-headers/parse.h +31 -148
- data/ext/cached/{ruby-1.9.0 → ruby-1.9.2}/internal/yarv-headers/regenc.h +7 -3
- data/ext/cached/{ruby-1.9.0 → ruby-1.9.2}/internal/yarv-headers/regint.h +16 -17
- data/ext/cached/{ruby-1.9.0 → ruby-1.9.2}/internal/yarv-headers/regparse.h +4 -1
- data/ext/cached/ruby-1.9.2/internal/yarv-headers/revision.h +1 -0
- data/ext/cached/{ruby-1.9.0 → ruby-1.9.2}/internal/yarv-headers/thread_pthread.h +4 -1
- data/ext/cached/{ruby-1.9.0 → ruby-1.9.2}/internal/yarv-headers/thread_win32.h +1 -1
- data/ext/cached/ruby-1.9.2/internal/yarv-headers/timev.h +21 -0
- data/ext/cached/{ruby-1.9.0 → ruby-1.9.2}/internal/yarv-headers/transcode_data.h +20 -10
- data/ext/cached/ruby-1.9.2/internal/yarv-headers/transdb.h +179 -0
- data/ext/cached/ruby-1.9.2/internal/yarv-headers/version.h +55 -0
- data/ext/cached/{ruby-1.9.0 → ruby-1.9.2}/internal/yarv-headers/vm_core.h +127 -84
- data/ext/cached/{ruby-1.9.0 → ruby-1.9.2}/internal/yarv-headers/vm_exec.h +4 -7
- data/ext/cached/{ruby-1.9.0 → ruby-1.9.2}/internal/yarv-headers/vm_insnhelper.h +53 -36
- data/ext/cached/{ruby-1.9.0 → ruby-1.9.2}/internal/yarv-headers/vm_opts.h +1 -1
- data/ext/cached/ruby-1.9.3/internal/binding/block.h +12 -0
- data/ext/cached/ruby-1.9.3/internal/method/internal_method.h +32 -0
- data/ext/cached/ruby-1.9.3/internal/module/classpath.c +40 -0
- data/ext/cached/{ruby-1.8.0 → ruby-1.9.3}/internal/module/classpath.h +5 -2
- data/ext/cached/ruby-1.9.3/internal/module/getcfp.h +25 -0
- data/ext/cached/ruby-1.9.3/internal/node/block.h +12 -0
- data/ext/cached/ruby-1.9.3/internal/node/global_entry.h +93 -0
- data/ext/cached/{ruby-1.8.3 → ruby-1.9.3}/internal/node/node_type_descrip.c +48 -57
- data/ext/cached/{ruby-1.6.8 → ruby-1.9.3}/internal/node/nodeinfo.c +589 -740
- data/ext/cached/{ruby-1.8.0 → ruby-1.9.3}/internal/node/nodeinfo.h +4 -3
- data/ext/cached/ruby-1.9.3/internal/proc/block.h +12 -0
- data/ext/cached/ruby-1.9.3/internal/tag/tag.h +6 -0
- data/ext/cached/ruby-1.9.3/internal/vm/instruction/insns_info.c +6013 -0
- data/ext/cached/ruby-1.9.3/internal/vm/instruction/insns_info.h +899 -0
- data/ext/cached/ruby-1.9.3/internal/vm/iseq/insns_info.inc +707 -0
- data/ext/cached/ruby-1.9.3/internal/vm/iseq/iseq_load.inc +423 -0
- data/ext/cached/ruby-1.9.3/internal/yarv-headers/addr2line.h +21 -0
- data/ext/cached/ruby-1.9.3/internal/yarv-headers/atomic.h +56 -0
- data/ext/cached/ruby-1.9.3/internal/yarv-headers/constant.h +34 -0
- data/ext/cached/ruby-1.9.3/internal/yarv-headers/debug.h +41 -0
- data/ext/cached/ruby-1.9.3/internal/yarv-headers/dln.h +50 -0
- data/ext/cached/ruby-1.9.3/internal/yarv-headers/encdb.h +167 -0
- data/ext/cached/ruby-1.9.3/internal/yarv-headers/eval_intern.h +234 -0
- data/ext/cached/ruby-1.9.3/internal/yarv-headers/gc.h +98 -0
- data/ext/cached/ruby-1.9.3/internal/yarv-headers/id.h +175 -0
- data/ext/cached/ruby-1.9.3/internal/yarv-headers/internal.h +232 -0
- data/ext/cached/ruby-1.9.3/internal/yarv-headers/iseq.h +125 -0
- data/ext/cached/ruby-1.9.3/internal/yarv-headers/method.h +105 -0
- data/ext/cached/ruby-1.9.3/internal/yarv-headers/node.h +503 -0
- data/ext/cached/ruby-1.9.3/internal/yarv-headers/parse.h +186 -0
- data/ext/cached/ruby-1.9.3/internal/yarv-headers/regenc.h +219 -0
- data/ext/cached/ruby-1.9.3/internal/yarv-headers/regint.h +850 -0
- data/ext/cached/ruby-1.9.3/internal/yarv-headers/regparse.h +362 -0
- data/ext/cached/ruby-1.9.3/internal/yarv-headers/revision.h +1 -0
- data/ext/cached/ruby-1.9.3/internal/yarv-headers/thread_pthread.h +51 -0
- data/ext/cached/ruby-1.9.3/internal/yarv-headers/thread_win32.h +40 -0
- data/ext/cached/ruby-1.9.3/internal/yarv-headers/timev.h +21 -0
- data/ext/cached/ruby-1.9.3/internal/yarv-headers/transcode_data.h +117 -0
- data/ext/cached/ruby-1.9.3/internal/yarv-headers/transdb.h +189 -0
- data/ext/cached/ruby-1.9.3/internal/yarv-headers/version.h +52 -0
- data/ext/cached/ruby-1.9.3/internal/yarv-headers/vm_core.h +756 -0
- data/ext/cached/ruby-1.9.3/internal/yarv-headers/vm_exec.h +184 -0
- data/ext/cached/ruby-1.9.3/internal/yarv-headers/vm_insnhelper.h +220 -0
- data/ext/cached/ruby-1.9.3/internal/yarv-headers/vm_opts.h +51 -0
- data/ext/internal/binding/block.h +20 -0
- data/ext/internal/method/internal_method.h +5 -38
- data/ext/internal/method/internal_method.h.rpp +0 -7
- data/ext/internal/method/method.c +52 -32
- data/ext/internal/module/classpath.c +18 -13
- data/ext/internal/module/classpath.h +3 -3
- data/ext/internal/module/extconf.rb +3 -2
- data/ext/internal/module/getcfp.h +13 -0
- data/ext/internal/module/getcfp.h.rpp +44 -0
- data/ext/internal/module/module.c +58 -21
- data/ext/internal/node/block.h +20 -0
- data/ext/internal/node/extconf.rb +2 -0
- data/ext/internal/node/global_entry.h +69 -13
- data/ext/internal/node/global_entry.h.rpp +11 -2
- data/ext/internal/node/node.c +30 -3
- data/ext/internal/node/node_type_descrip.c +47 -38
- data/ext/internal/node/nodeinfo.c +622 -306
- data/ext/internal/node/nodeinfo.h +1 -4
- data/ext/internal/proc/block.h +20 -0
- data/ext/internal/tag/tag.h +10 -0
- data/ext/internal/thread/thread.c +9 -3
- data/ext/internal/vm/extconf.rb +1 -0
- data/ext/internal/vm/instruction/insns_info.c +3 -5974
- data/ext/internal/vm/instruction/insns_info.h +0 -878
- data/ext/internal/vm/iseq/extconf.rb +1 -0
- data/ext/internal/vm/iseq/iseq.c +38 -4
- data/ext/internal/vm/iseq/iseq_load.inc.rpp +23 -5
- data/ext/internal/vm/vm.c +28 -0
- data/lib/internal/classtree.rb +28 -0
- data/lib/internal/debug.rb +10 -2
- data/lib/internal/method/as_code.rb +25 -0
- data/lib/internal/method/as_expression.rb +2 -3
- data/lib/internal/method/origin.rb +29 -0
- data/lib/internal/method/signature.rb +5 -300
- data/lib/internal/method/signature/argument.rb +102 -0
- data/lib/internal/method/signature/iseq.rb +52 -0
- data/lib/internal/method/signature/node.rb +160 -0
- data/lib/internal/method/signature/signature.rb +23 -0
- data/lib/internal/proc/as_code.rb +2 -0
- data/lib/internal/proc/as_expression.rb +2 -0
- data/lib/internal/vm/bytedecoder.rb +5 -5
- data/lib/internal/vm/iseq/as_code.rb +2 -2
- data/lib/internal/vm/iseq/as_expression.rb +2 -2
- data/test/test_dump_method.rb +1 -1
- data/test/test_method.rb +21 -3
- data/test/test_node.rb +20 -4
- metadata +152 -155
- data/ext/cached/ruby-1.6.8/internal/binding/block.h +0 -35
- data/ext/cached/ruby-1.6.8/internal/method/method.h +0 -19
- data/ext/cached/ruby-1.6.8/internal/module/classpath.c +0 -3
- data/ext/cached/ruby-1.6.8/internal/module/classpath.h +0 -8
- data/ext/cached/ruby-1.6.8/internal/node/block.h +0 -35
- data/ext/cached/ruby-1.6.8/internal/node/global_entry.h +0 -15
- data/ext/cached/ruby-1.6.8/internal/node/node_type_descrip.c +0 -149
- data/ext/cached/ruby-1.6.8/internal/node/nodeinfo.h +0 -69
- data/ext/cached/ruby-1.6.8/internal/proc/block.h +0 -35
- data/ext/cached/ruby-1.6.8/internal/tag/tag.h +0 -15
- data/ext/cached/ruby-1.6.8/internal/vm/instruction/insns_info.c +0 -39
- data/ext/cached/ruby-1.6.8/internal/vm/instruction/insns_info.h +0 -21
- data/ext/cached/ruby-1.6.8/internal/vm/iseq/insns_info.inc +0 -12
- data/ext/cached/ruby-1.6.8/internal/vm/iseq/iseq_load.inc +0 -9
- data/ext/cached/ruby-1.8.0/internal/binding/block.h +0 -37
- data/ext/cached/ruby-1.8.0/internal/method/method.h +0 -19
- data/ext/cached/ruby-1.8.0/internal/module/classpath.c +0 -27
- data/ext/cached/ruby-1.8.0/internal/node/block.h +0 -37
- data/ext/cached/ruby-1.8.0/internal/node/global_entry.h +0 -10
- data/ext/cached/ruby-1.8.0/internal/node/node_type_descrip.c +0 -155
- data/ext/cached/ruby-1.8.0/internal/node/nodeinfo.c +0 -5744
- data/ext/cached/ruby-1.8.0/internal/proc/block.h +0 -37
- data/ext/cached/ruby-1.8.0/internal/tag/tag.h +0 -15
- data/ext/cached/ruby-1.8.0/internal/vm/instruction/insns_info.c +0 -39
- data/ext/cached/ruby-1.8.0/internal/vm/instruction/insns_info.h +0 -21
- data/ext/cached/ruby-1.8.0/internal/vm/iseq/insns_info.inc +0 -12
- data/ext/cached/ruby-1.8.0/internal/vm/iseq/iseq_load.inc +0 -9
- data/ext/cached/ruby-1.8.1/internal/binding/block.h +0 -31
- data/ext/cached/ruby-1.8.1/internal/method/method.h +0 -19
- data/ext/cached/ruby-1.8.1/internal/module/classpath.c +0 -27
- data/ext/cached/ruby-1.8.1/internal/module/classpath.h +0 -14
- data/ext/cached/ruby-1.8.1/internal/node/block.h +0 -31
- data/ext/cached/ruby-1.8.1/internal/node/global_entry.h +0 -10
- data/ext/cached/ruby-1.8.1/internal/node/node_type_descrip.c +0 -154
- data/ext/cached/ruby-1.8.1/internal/node/nodeinfo.c +0 -5736
- data/ext/cached/ruby-1.8.1/internal/node/nodeinfo.h +0 -69
- data/ext/cached/ruby-1.8.1/internal/proc/block.h +0 -31
- data/ext/cached/ruby-1.8.1/internal/tag/tag.h +0 -16
- data/ext/cached/ruby-1.8.1/internal/vm/instruction/insns_info.c +0 -39
- data/ext/cached/ruby-1.8.1/internal/vm/instruction/insns_info.h +0 -21
- data/ext/cached/ruby-1.8.1/internal/vm/iseq/insns_info.inc +0 -12
- data/ext/cached/ruby-1.8.1/internal/vm/iseq/iseq_load.inc +0 -9
- data/ext/cached/ruby-1.8.2/internal/binding/block.h +0 -32
- data/ext/cached/ruby-1.8.2/internal/method/method.h +0 -19
- data/ext/cached/ruby-1.8.2/internal/module/classpath.c +0 -45
- data/ext/cached/ruby-1.8.2/internal/module/classpath.h +0 -17
- data/ext/cached/ruby-1.8.2/internal/node/block.h +0 -32
- data/ext/cached/ruby-1.8.2/internal/node/global_entry.h +0 -10
- data/ext/cached/ruby-1.8.2/internal/node/node_type_descrip.c +0 -154
- data/ext/cached/ruby-1.8.2/internal/node/nodeinfo.c +0 -5736
- data/ext/cached/ruby-1.8.2/internal/node/nodeinfo.h +0 -69
- data/ext/cached/ruby-1.8.2/internal/proc/block.h +0 -32
- data/ext/cached/ruby-1.8.2/internal/tag/tag.h +0 -16
- data/ext/cached/ruby-1.8.2/internal/vm/instruction/insns_info.c +0 -39
- data/ext/cached/ruby-1.8.2/internal/vm/instruction/insns_info.h +0 -21
- data/ext/cached/ruby-1.8.2/internal/vm/iseq/insns_info.inc +0 -12
- data/ext/cached/ruby-1.8.2/internal/vm/iseq/iseq_load.inc +0 -9
- data/ext/cached/ruby-1.8.3/internal/binding/block.h +0 -32
- data/ext/cached/ruby-1.8.3/internal/module/classpath.c +0 -45
- data/ext/cached/ruby-1.8.3/internal/module/classpath.h +0 -17
- data/ext/cached/ruby-1.8.3/internal/node/block.h +0 -32
- data/ext/cached/ruby-1.8.3/internal/node/global_entry.h +0 -10
- data/ext/cached/ruby-1.8.3/internal/node/nodeinfo.c +0 -5736
- data/ext/cached/ruby-1.8.3/internal/node/nodeinfo.h +0 -69
- data/ext/cached/ruby-1.8.3/internal/proc/block.h +0 -32
- data/ext/cached/ruby-1.8.3/internal/tag/tag.h +0 -16
- data/ext/cached/ruby-1.8.3/internal/vm/instruction/insns_info.c +0 -39
- data/ext/cached/ruby-1.8.3/internal/vm/instruction/insns_info.h +0 -21
- data/ext/cached/ruby-1.8.3/internal/vm/iseq/insns_info.inc +0 -12
- data/ext/cached/ruby-1.8.3/internal/vm/iseq/iseq_load.inc +0 -9
- data/ext/cached/ruby-1.8.7/internal/method/method.h +0 -20
- data/ext/cached/ruby-1.9.0/internal/module/classpath.c +0 -42
- data/ext/cached/ruby-1.9.0/internal/node/global_entry.h +0 -10
- data/ext/cached/ruby-1.9.0/internal/vm/iseq/iseq_load.inc +0 -13
- data/ext/cached/ruby-1.9.0/internal/yarv-headers/id.h +0 -83
- data/ext/cached/ruby-1.9.0/internal/yarv-headers/revision.h +0 -1
- data/ext/cached/ruby-1.9.0/internal/yarv-headers/transdb.h +0 -67
- data/ext/cached/ruby-1.9.0/internal/yarv-headers/version.h +0 -57
- data/ext/internal/module/cfp.h +0 -13
@@ -0,0 +1,423 @@
|
|
1
|
+
#ifndef ruby_internal_iseq_load__inc_
|
2
|
+
#define ruby_internal_iseq_load__inc_
|
3
|
+
|
4
|
+
#ifdef HAVE_TYPE_STRUCT_RTYPEDDATA
|
5
|
+
|
6
|
+
static rb_data_type_t const * p_iseq_data_type;
|
7
|
+
|
8
|
+
static void init_iseq_data_type()
|
9
|
+
{
|
10
|
+
rb_proc_t * p;
|
11
|
+
VALUE body;
|
12
|
+
|
13
|
+
VALUE binding = rb_binding_new();
|
14
|
+
VALUE new_proc = rb_funcall(
|
15
|
+
rb_cObject, rb_intern("eval"), 2, rb_str_new2("proc { }"), binding);
|
16
|
+
GetProcPtr(new_proc, p);
|
17
|
+
body = p->block.iseq->self;
|
18
|
+
|
19
|
+
p_iseq_data_type = RTYPEDDATA_TYPE(body);
|
20
|
+
}
|
21
|
+
|
22
|
+
#else
|
23
|
+
|
24
|
+
#endif
|
25
|
+
#
|
26
|
+
static void
|
27
|
+
compile_data_free(struct iseq_compile_data *compile_data)
|
28
|
+
{
|
29
|
+
if (compile_data) {
|
30
|
+
struct iseq_compile_data_storage *cur, *next;
|
31
|
+
cur = compile_data->storage_head;
|
32
|
+
while (cur) {
|
33
|
+
next = cur->next;
|
34
|
+
ruby_xfree(cur);
|
35
|
+
cur = next;
|
36
|
+
}
|
37
|
+
ruby_xfree(compile_data);
|
38
|
+
}
|
39
|
+
}
|
40
|
+
static void
|
41
|
+
iseq_free(void *ptr)
|
42
|
+
{
|
43
|
+
rb_iseq_t *iseq;
|
44
|
+
RUBY_FREE_ENTER("iseq");
|
45
|
+
|
46
|
+
if (ptr) {
|
47
|
+
iseq = ptr;
|
48
|
+
if (!iseq->orig) {
|
49
|
+
/* It's possible that strings are freed */
|
50
|
+
if (0) {
|
51
|
+
RUBY_GC_INFO("%s @ %s\n", RSTRING_PTR(iseq->name),
|
52
|
+
RSTRING_PTR(iseq->filename));
|
53
|
+
}
|
54
|
+
|
55
|
+
if (iseq->iseq != iseq->iseq_encoded) {
|
56
|
+
RUBY_FREE_UNLESS_NULL(iseq->iseq_encoded);
|
57
|
+
}
|
58
|
+
|
59
|
+
RUBY_FREE_UNLESS_NULL(iseq->iseq);
|
60
|
+
RUBY_FREE_UNLESS_NULL(iseq->insn_info_table);
|
61
|
+
RUBY_FREE_UNLESS_NULL(iseq->local_table);
|
62
|
+
RUBY_FREE_UNLESS_NULL(iseq->ic_entries);
|
63
|
+
RUBY_FREE_UNLESS_NULL(iseq->catch_table);
|
64
|
+
RUBY_FREE_UNLESS_NULL(iseq->arg_opt_table);
|
65
|
+
compile_data_free(iseq->compile_data);
|
66
|
+
}
|
67
|
+
ruby_xfree(ptr);
|
68
|
+
}
|
69
|
+
RUBY_FREE_LEAVE("iseq");
|
70
|
+
}
|
71
|
+
static void
|
72
|
+
iseq_mark(void *ptr)
|
73
|
+
{
|
74
|
+
RUBY_MARK_ENTER("iseq");
|
75
|
+
|
76
|
+
if (ptr) {
|
77
|
+
rb_iseq_t *iseq = ptr;
|
78
|
+
|
79
|
+
RUBY_GC_INFO("%s @ %s\n", RSTRING_PTR(iseq->name), RSTRING_PTR(iseq->filename));
|
80
|
+
RUBY_MARK_UNLESS_NULL(iseq->mark_ary);
|
81
|
+
RUBY_MARK_UNLESS_NULL(iseq->name);
|
82
|
+
RUBY_MARK_UNLESS_NULL(iseq->filename);
|
83
|
+
RUBY_MARK_UNLESS_NULL(iseq->filepath);
|
84
|
+
RUBY_MARK_UNLESS_NULL((VALUE)iseq->cref_stack);
|
85
|
+
RUBY_MARK_UNLESS_NULL(iseq->klass);
|
86
|
+
RUBY_MARK_UNLESS_NULL(iseq->coverage);
|
87
|
+
#if 0
|
88
|
+
RUBY_MARK_UNLESS_NULL((VALUE)iseq->node);
|
89
|
+
RUBY_MARK_UNLESS_NULL(iseq->cached_special_block);
|
90
|
+
#endif
|
91
|
+
RUBY_MARK_UNLESS_NULL(iseq->orig);
|
92
|
+
|
93
|
+
if (iseq->compile_data != 0) {
|
94
|
+
struct iseq_compile_data *const compile_data = iseq->compile_data;
|
95
|
+
RUBY_MARK_UNLESS_NULL(compile_data->mark_ary);
|
96
|
+
RUBY_MARK_UNLESS_NULL(compile_data->err_info);
|
97
|
+
RUBY_MARK_UNLESS_NULL(compile_data->catch_table_ary);
|
98
|
+
}
|
99
|
+
}
|
100
|
+
RUBY_MARK_LEAVE("iseq");
|
101
|
+
}
|
102
|
+
static size_t
|
103
|
+
iseq_memsize(const void *ptr)
|
104
|
+
{
|
105
|
+
size_t size = sizeof(rb_iseq_t);
|
106
|
+
const rb_iseq_t *iseq;
|
107
|
+
|
108
|
+
if (ptr) {
|
109
|
+
iseq = ptr;
|
110
|
+
if (!iseq->orig) {
|
111
|
+
if (iseq->iseq != iseq->iseq_encoded) {
|
112
|
+
size += iseq->iseq_size * sizeof(VALUE);
|
113
|
+
}
|
114
|
+
|
115
|
+
size += iseq->iseq_size * sizeof(VALUE);
|
116
|
+
size += iseq->insn_info_size * sizeof(struct iseq_insn_info_entry);
|
117
|
+
size += iseq->local_table_size * sizeof(ID);
|
118
|
+
size += iseq->catch_table_size * sizeof(struct iseq_catch_table_entry);
|
119
|
+
size += iseq->arg_opts * sizeof(VALUE);
|
120
|
+
size += iseq->ic_size * sizeof(struct iseq_inline_cache_entry);
|
121
|
+
|
122
|
+
if (iseq->compile_data) {
|
123
|
+
struct iseq_compile_data_storage *cur;
|
124
|
+
|
125
|
+
cur = iseq->compile_data->storage_head;
|
126
|
+
while (cur) {
|
127
|
+
size += cur->size + sizeof(struct iseq_compile_data_storage);
|
128
|
+
cur = cur->next;
|
129
|
+
}
|
130
|
+
size += sizeof(struct iseq_compile_data);
|
131
|
+
}
|
132
|
+
}
|
133
|
+
}
|
134
|
+
|
135
|
+
return size;
|
136
|
+
}
|
137
|
+
static VALUE
|
138
|
+
iseq_alloc(VALUE klass)
|
139
|
+
{
|
140
|
+
rb_iseq_t *iseq;
|
141
|
+
return TypedData_Make_Struct(klass, rb_iseq_t, p_iseq_data_type, iseq);
|
142
|
+
}
|
143
|
+
static void
|
144
|
+
set_relation(rb_iseq_t *iseq, const VALUE parent)
|
145
|
+
{
|
146
|
+
const VALUE type = iseq->type;
|
147
|
+
rb_thread_t *th = GET_THREAD();
|
148
|
+
|
149
|
+
/* set class nest stack */
|
150
|
+
if (type == ISEQ_TYPE_TOP) {
|
151
|
+
/* toplevel is private */
|
152
|
+
iseq->cref_stack = NEW_BLOCK(rb_cObject);
|
153
|
+
iseq->cref_stack->nd_visi = NOEX_PRIVATE;
|
154
|
+
if (th->top_wrapper) {
|
155
|
+
NODE *cref = NEW_BLOCK(th->top_wrapper);
|
156
|
+
cref->nd_visi = NOEX_PRIVATE;
|
157
|
+
cref->nd_next = iseq->cref_stack;
|
158
|
+
iseq->cref_stack = cref;
|
159
|
+
}
|
160
|
+
}
|
161
|
+
else if (type == ISEQ_TYPE_METHOD || type == ISEQ_TYPE_CLASS) {
|
162
|
+
iseq->cref_stack = NEW_BLOCK(0); /* place holder */
|
163
|
+
}
|
164
|
+
else if (RTEST(parent)) {
|
165
|
+
rb_iseq_t *piseq;
|
166
|
+
GetISeqPtr(parent, piseq);
|
167
|
+
iseq->cref_stack = piseq->cref_stack;
|
168
|
+
}
|
169
|
+
|
170
|
+
if (type == ISEQ_TYPE_TOP ||
|
171
|
+
type == ISEQ_TYPE_METHOD || type == ISEQ_TYPE_CLASS) {
|
172
|
+
iseq->local_iseq = iseq;
|
173
|
+
}
|
174
|
+
else if (RTEST(parent)) {
|
175
|
+
rb_iseq_t *piseq;
|
176
|
+
GetISeqPtr(parent, piseq);
|
177
|
+
iseq->local_iseq = piseq->local_iseq;
|
178
|
+
}
|
179
|
+
|
180
|
+
if (RTEST(parent)) {
|
181
|
+
rb_iseq_t *piseq;
|
182
|
+
GetISeqPtr(parent, piseq);
|
183
|
+
iseq->parent_iseq = piseq;
|
184
|
+
}
|
185
|
+
}
|
186
|
+
static VALUE
|
187
|
+
prepare_iseq_build(rb_iseq_t *iseq,
|
188
|
+
VALUE name, VALUE filename, VALUE filepath, VALUE line_no,
|
189
|
+
VALUE parent, enum iseq_type type, VALUE block_opt,
|
190
|
+
const rb_compile_option_t *option)
|
191
|
+
{
|
192
|
+
OBJ_FREEZE(name);
|
193
|
+
OBJ_FREEZE(filename);
|
194
|
+
|
195
|
+
iseq->name = name;
|
196
|
+
iseq->filename = filename;
|
197
|
+
iseq->filepath = filepath;
|
198
|
+
iseq->line_no = (unsigned short)line_no; /* TODO: really enough? */
|
199
|
+
iseq->defined_method_id = 0;
|
200
|
+
iseq->mark_ary = rb_ary_tmp_new(3);
|
201
|
+
OBJ_UNTRUST(iseq->mark_ary);
|
202
|
+
RBASIC(iseq->mark_ary)->klass = 0;
|
203
|
+
|
204
|
+
iseq->type = type;
|
205
|
+
iseq->arg_rest = -1;
|
206
|
+
iseq->arg_block = -1;
|
207
|
+
iseq->klass = 0;
|
208
|
+
|
209
|
+
/*
|
210
|
+
* iseq->special_block_builder = GC_GUARDED_PTR_REF(block_opt);
|
211
|
+
* iseq->cached_special_block_builder = 0;
|
212
|
+
* iseq->cached_special_block = 0;
|
213
|
+
*/
|
214
|
+
|
215
|
+
iseq->compile_data = ALLOC(struct iseq_compile_data);
|
216
|
+
MEMZERO(iseq->compile_data, struct iseq_compile_data, 1);
|
217
|
+
iseq->compile_data->err_info = Qnil;
|
218
|
+
iseq->compile_data->mark_ary = rb_ary_tmp_new(3);
|
219
|
+
|
220
|
+
iseq->compile_data->storage_head = iseq->compile_data->storage_current =
|
221
|
+
(struct iseq_compile_data_storage *)
|
222
|
+
ALLOC_N(char, INITIAL_ISEQ_COMPILE_DATA_STORAGE_BUFF_SIZE +
|
223
|
+
sizeof(struct iseq_compile_data_storage));
|
224
|
+
|
225
|
+
iseq->compile_data->catch_table_ary = rb_ary_new();
|
226
|
+
iseq->compile_data->storage_head->pos = 0;
|
227
|
+
iseq->compile_data->storage_head->next = 0;
|
228
|
+
iseq->compile_data->storage_head->size =
|
229
|
+
INITIAL_ISEQ_COMPILE_DATA_STORAGE_BUFF_SIZE;
|
230
|
+
iseq->compile_data->storage_head->buff =
|
231
|
+
(char *)(&iseq->compile_data->storage_head->buff + 1);
|
232
|
+
iseq->compile_data->option = option;
|
233
|
+
iseq->compile_data->last_coverable_line = -1;
|
234
|
+
|
235
|
+
set_relation(iseq, parent);
|
236
|
+
|
237
|
+
iseq->coverage = Qfalse;
|
238
|
+
if (!GET_THREAD()->parse_in_eval) {
|
239
|
+
VALUE coverages = rb_get_coverages();
|
240
|
+
if (RTEST(coverages)) {
|
241
|
+
iseq->coverage = rb_hash_lookup(coverages, filename);
|
242
|
+
if (NIL_P(iseq->coverage)) iseq->coverage = Qfalse;
|
243
|
+
}
|
244
|
+
}
|
245
|
+
|
246
|
+
return Qtrue;
|
247
|
+
}
|
248
|
+
static VALUE
|
249
|
+
cleanup_iseq_build(rb_iseq_t *iseq)
|
250
|
+
{
|
251
|
+
struct iseq_compile_data *data = iseq->compile_data;
|
252
|
+
VALUE err = data->err_info;
|
253
|
+
iseq->compile_data = 0;
|
254
|
+
compile_data_free(data);
|
255
|
+
|
256
|
+
if (RTEST(err)) {
|
257
|
+
rb_funcall2(err, rb_intern("set_backtrace"), 1, &iseq->filename);
|
258
|
+
rb_exc_raise(err);
|
259
|
+
}
|
260
|
+
return Qtrue;
|
261
|
+
}
|
262
|
+
static rb_compile_option_t COMPILE_OPTION_DEFAULT = {
|
263
|
+
OPT_INLINE_CONST_CACHE, /* int inline_const_cache; */
|
264
|
+
OPT_PEEPHOLE_OPTIMIZATION, /* int peephole_optimization; */
|
265
|
+
OPT_TAILCALL_OPTIMIZATION, /* int tailcall_optimization */
|
266
|
+
OPT_SPECIALISED_INSTRUCTION, /* int specialized_instruction; */
|
267
|
+
OPT_OPERANDS_UNIFICATION, /* int operands_unification; */
|
268
|
+
OPT_INSTRUCTIONS_UNIFICATION, /* int instructions_unification; */
|
269
|
+
OPT_STACK_CACHING, /* int stack_caching; */
|
270
|
+
OPT_TRACE_INSTRUCTION, /* int trace_instruction */
|
271
|
+
};
|
272
|
+
static const rb_compile_option_t COMPILE_OPTION_FALSE = {0};
|
273
|
+
static void
|
274
|
+
make_compile_option(rb_compile_option_t *option, VALUE opt)
|
275
|
+
{
|
276
|
+
if (opt == Qnil) {
|
277
|
+
*option = COMPILE_OPTION_DEFAULT;
|
278
|
+
}
|
279
|
+
else if (opt == Qfalse) {
|
280
|
+
*option = COMPILE_OPTION_FALSE;
|
281
|
+
}
|
282
|
+
else if (opt == Qtrue) {
|
283
|
+
memset(option, 1, sizeof(rb_compile_option_t));
|
284
|
+
}
|
285
|
+
else if (CLASS_OF(opt) == rb_cHash) {
|
286
|
+
*option = COMPILE_OPTION_DEFAULT;
|
287
|
+
|
288
|
+
#define SET_COMPILE_OPTION(o, h, mem) \
|
289
|
+
{ VALUE flag = rb_hash_aref((h), ID2SYM(rb_intern(#mem))); \
|
290
|
+
if (flag == Qtrue) { (o)->mem = 1; } \
|
291
|
+
else if (flag == Qfalse) { (o)->mem = 0; } \
|
292
|
+
}
|
293
|
+
#define SET_COMPILE_OPTION_NUM(o, h, mem) \
|
294
|
+
{ VALUE num = rb_hash_aref(opt, ID2SYM(rb_intern(#mem))); \
|
295
|
+
if (!NIL_P(num)) (o)->mem = NUM2INT(num); \
|
296
|
+
}
|
297
|
+
SET_COMPILE_OPTION(option, opt, inline_const_cache);
|
298
|
+
SET_COMPILE_OPTION(option, opt, peephole_optimization);
|
299
|
+
SET_COMPILE_OPTION(option, opt, tailcall_optimization);
|
300
|
+
SET_COMPILE_OPTION(option, opt, specialized_instruction);
|
301
|
+
SET_COMPILE_OPTION(option, opt, operands_unification);
|
302
|
+
SET_COMPILE_OPTION(option, opt, instructions_unification);
|
303
|
+
SET_COMPILE_OPTION(option, opt, stack_caching);
|
304
|
+
SET_COMPILE_OPTION(option, opt, trace_instruction);
|
305
|
+
SET_COMPILE_OPTION_NUM(option, opt, debug_level);
|
306
|
+
#undef SET_COMPILE_OPTION
|
307
|
+
#undef SET_COMPILE_OPTION_NUM
|
308
|
+
}
|
309
|
+
else {
|
310
|
+
rb_raise(rb_eTypeError, "Compile option must be Hash/true/false/nil");
|
311
|
+
}
|
312
|
+
}
|
313
|
+
static VALUE
|
314
|
+
make_compile_option_value(rb_compile_option_t *option)
|
315
|
+
{
|
316
|
+
VALUE opt = rb_hash_new();
|
317
|
+
#define SET_COMPILE_OPTION(o, h, mem) \
|
318
|
+
rb_hash_aset((h), ID2SYM(rb_intern(#mem)), (o)->mem ? Qtrue : Qfalse)
|
319
|
+
#define SET_COMPILE_OPTION_NUM(o, h, mem) \
|
320
|
+
rb_hash_aset((h), ID2SYM(rb_intern(#mem)), INT2NUM((o)->mem))
|
321
|
+
{
|
322
|
+
SET_COMPILE_OPTION(option, opt, inline_const_cache);
|
323
|
+
SET_COMPILE_OPTION(option, opt, peephole_optimization);
|
324
|
+
SET_COMPILE_OPTION(option, opt, tailcall_optimization);
|
325
|
+
SET_COMPILE_OPTION(option, opt, specialized_instruction);
|
326
|
+
SET_COMPILE_OPTION(option, opt, operands_unification);
|
327
|
+
SET_COMPILE_OPTION(option, opt, instructions_unification);
|
328
|
+
SET_COMPILE_OPTION(option, opt, stack_caching);
|
329
|
+
SET_COMPILE_OPTION_NUM(option, opt, debug_level);
|
330
|
+
}
|
331
|
+
#undef SET_COMPILE_OPTION
|
332
|
+
#undef SET_COMPILE_OPTION_NUM
|
333
|
+
return opt;
|
334
|
+
}
|
335
|
+
#define CHECK_ARRAY(v) rb_convert_type((v), T_ARRAY, "Array", "to_ary")
|
336
|
+
#define CHECK_STRING(v) rb_convert_type((v), T_STRING, "String", "to_str")
|
337
|
+
#define CHECK_SYMBOL(v) rb_convert_type((v), T_SYMBOL, "Symbol", "to_sym")
|
338
|
+
static inline VALUE CHECK_INTEGER(VALUE v) {(void)NUM2LONG(v); return v;}
|
339
|
+
static VALUE
|
340
|
+
iseq_load(VALUE self, VALUE data, VALUE parent, VALUE opt)
|
341
|
+
{
|
342
|
+
VALUE iseqval = iseq_alloc(self);
|
343
|
+
|
344
|
+
VALUE magic, version1, version2, format_type, misc;
|
345
|
+
VALUE name, filename, filepath, line_no;
|
346
|
+
VALUE type, body, locals, args, exception;
|
347
|
+
|
348
|
+
st_data_t iseq_type;
|
349
|
+
struct st_table *type_map = 0;
|
350
|
+
rb_iseq_t *iseq;
|
351
|
+
rb_compile_option_t option;
|
352
|
+
int i = 0;
|
353
|
+
|
354
|
+
/* [magic, major_version, minor_version, format_type, misc,
|
355
|
+
* name, filename, line_no,
|
356
|
+
* type, locals, args, exception_table, body]
|
357
|
+
*/
|
358
|
+
|
359
|
+
data = CHECK_ARRAY(data);
|
360
|
+
|
361
|
+
magic = CHECK_STRING(rb_ary_entry(data, i++));
|
362
|
+
version1 = CHECK_INTEGER(rb_ary_entry(data, i++));
|
363
|
+
version2 = CHECK_INTEGER(rb_ary_entry(data, i++));
|
364
|
+
format_type = CHECK_INTEGER(rb_ary_entry(data, i++));
|
365
|
+
misc = rb_ary_entry(data, i++); /* TODO */
|
366
|
+
|
367
|
+
name = CHECK_STRING(rb_ary_entry(data, i++));
|
368
|
+
filename = CHECK_STRING(rb_ary_entry(data, i++));
|
369
|
+
filepath = rb_ary_entry(data, i++);
|
370
|
+
filepath = NIL_P(filepath) ? Qnil : CHECK_STRING(filepath);
|
371
|
+
line_no = CHECK_INTEGER(rb_ary_entry(data, i++));
|
372
|
+
|
373
|
+
type = CHECK_SYMBOL(rb_ary_entry(data, i++));
|
374
|
+
locals = CHECK_ARRAY(rb_ary_entry(data, i++));
|
375
|
+
|
376
|
+
args = rb_ary_entry(data, i++);
|
377
|
+
if (FIXNUM_P(args) || (args = CHECK_ARRAY(args))) {
|
378
|
+
/* */
|
379
|
+
}
|
380
|
+
|
381
|
+
exception = CHECK_ARRAY(rb_ary_entry(data, i++));
|
382
|
+
body = CHECK_ARRAY(rb_ary_entry(data, i++));
|
383
|
+
|
384
|
+
GetISeqPtr(iseqval, iseq);
|
385
|
+
iseq->self = iseqval;
|
386
|
+
|
387
|
+
if (type_map == 0) {
|
388
|
+
type_map = st_init_numtable();
|
389
|
+
st_insert(type_map, ID2SYM(rb_intern("top")), ISEQ_TYPE_TOP);
|
390
|
+
st_insert(type_map, ID2SYM(rb_intern("method")), ISEQ_TYPE_METHOD);
|
391
|
+
st_insert(type_map, ID2SYM(rb_intern("block")), ISEQ_TYPE_BLOCK);
|
392
|
+
st_insert(type_map, ID2SYM(rb_intern("class")), ISEQ_TYPE_CLASS);
|
393
|
+
st_insert(type_map, ID2SYM(rb_intern("rescue")), ISEQ_TYPE_RESCUE);
|
394
|
+
st_insert(type_map, ID2SYM(rb_intern("ensure")), ISEQ_TYPE_ENSURE);
|
395
|
+
st_insert(type_map, ID2SYM(rb_intern("eval")), ISEQ_TYPE_EVAL);
|
396
|
+
st_insert(type_map, ID2SYM(rb_intern("main")), ISEQ_TYPE_MAIN);
|
397
|
+
st_insert(type_map, ID2SYM(rb_intern("defined_guard")), ISEQ_TYPE_DEFINED_GUARD);
|
398
|
+
}
|
399
|
+
|
400
|
+
if (st_lookup(type_map, type, &iseq_type) == 0) {
|
401
|
+
const char *typename = rb_id2name(type);
|
402
|
+
if (typename)
|
403
|
+
rb_raise(rb_eTypeError, "unsupport type: :%s", typename);
|
404
|
+
else
|
405
|
+
rb_raise(rb_eTypeError, "unsupport type: %p", (void *)type);
|
406
|
+
}
|
407
|
+
|
408
|
+
if (parent == Qnil) {
|
409
|
+
parent = 0;
|
410
|
+
}
|
411
|
+
|
412
|
+
make_compile_option(&option, opt);
|
413
|
+
prepare_iseq_build(iseq, name, filename, filepath, line_no,
|
414
|
+
parent, (enum iseq_type)iseq_type, 0, &option);
|
415
|
+
|
416
|
+
rb_iseq_build_from_ary(iseq, locals, args, exception, body);
|
417
|
+
|
418
|
+
cleanup_iseq_build(iseq);
|
419
|
+
return iseqval;
|
420
|
+
}
|
421
|
+
|
422
|
+
#endif
|
423
|
+
|
@@ -0,0 +1,21 @@
|
|
1
|
+
/**********************************************************************
|
2
|
+
|
3
|
+
addr2line.h -
|
4
|
+
|
5
|
+
$Author$
|
6
|
+
|
7
|
+
Copyright (C) 2010 Shinichiro Hamaji
|
8
|
+
|
9
|
+
**********************************************************************/
|
10
|
+
|
11
|
+
#ifndef RUBY_ADDR2LINE_H
|
12
|
+
#define RUBY_ADDR2LINE_H
|
13
|
+
|
14
|
+
#ifdef USE_ELF
|
15
|
+
|
16
|
+
void
|
17
|
+
rb_dump_backtrace_with_lines(int num_traces, void **traces, char **syms);
|
18
|
+
|
19
|
+
#endif /* USE_ELF */
|
20
|
+
|
21
|
+
#endif /* RUBY_ADDR2LINE_H */
|
@@ -0,0 +1,56 @@
|
|
1
|
+
#ifndef RUBY_ATOMIC_H
|
2
|
+
#define RUBY_ATOMIC_H
|
3
|
+
|
4
|
+
#ifdef _WIN32
|
5
|
+
#if defined _MSC_VER && _MSC_VER > 1200
|
6
|
+
#pragma intrinsic(_InterlockedOr)
|
7
|
+
#endif
|
8
|
+
typedef LONG rb_atomic_t;
|
9
|
+
|
10
|
+
# define ATOMIC_SET(var, val) InterlockedExchange(&(var), (val))
|
11
|
+
# define ATOMIC_INC(var) InterlockedIncrement(&(var))
|
12
|
+
# define ATOMIC_DEC(var) InterlockedDecrement(&(var))
|
13
|
+
#if defined __GNUC__
|
14
|
+
# define ATOMIC_OR(var, val) __asm__("lock\n\t" "orl\t%1, %0" : "=m"(var) : "Ir"(val))
|
15
|
+
#elif defined _MSC_VER && _MSC_VER <= 1200
|
16
|
+
# define ATOMIC_OR(var, val) rb_w32_atomic_or(&(var), (val))
|
17
|
+
static inline void
|
18
|
+
rb_w32_atomic_or(volatile rb_atomic_t *var, rb_atomic_t val)
|
19
|
+
{
|
20
|
+
#ifdef _M_IX86
|
21
|
+
__asm mov eax, var;
|
22
|
+
__asm mov ecx, val;
|
23
|
+
__asm lock or [eax], ecx;
|
24
|
+
#else
|
25
|
+
#error unsupported architecture
|
26
|
+
#endif
|
27
|
+
}
|
28
|
+
#else
|
29
|
+
# define ATOMIC_OR(var, val) _InterlockedOr(&(var), (val))
|
30
|
+
#endif
|
31
|
+
# define ATOMIC_EXCHANGE(var, val) InterlockedExchange(&(var), (val))
|
32
|
+
|
33
|
+
#elif defined HAVE_GCC_ATOMIC_BUILTINS
|
34
|
+
/* @shyouhei hack to support atomic operations in case of gcc. Gcc
|
35
|
+
* has its own pseudo-insns to support them. See info, or
|
36
|
+
* http://gcc.gnu.org/onlinedocs/gcc/Atomic-Builtins.html */
|
37
|
+
|
38
|
+
typedef unsigned int rb_atomic_t; /* Anything OK */
|
39
|
+
# define ATOMIC_SET(var, val) __sync_lock_test_and_set(&(var), (val))
|
40
|
+
# define ATOMIC_INC(var) __sync_fetch_and_add(&(var), 1)
|
41
|
+
# define ATOMIC_DEC(var) __sync_fetch_and_sub(&(var), 1)
|
42
|
+
# define ATOMIC_OR(var, val) __sync_or_and_fetch(&(var), (val))
|
43
|
+
# define ATOMIC_EXCHANGE(var, val) __sync_lock_test_and_set(&(var), (val))
|
44
|
+
|
45
|
+
#else
|
46
|
+
typedef int rb_atomic_t;
|
47
|
+
extern rb_atomic_t ruby_atomic_exchange(rb_atomic_t *ptr, rb_atomic_t val);
|
48
|
+
|
49
|
+
# define ATOMIC_SET(var, val) ((var) = (val))
|
50
|
+
# define ATOMIC_INC(var) (++(var))
|
51
|
+
# define ATOMIC_DEC(var) (--(var))
|
52
|
+
# define ATOMIC_OR(var, val) ((var) |= (val))
|
53
|
+
# define ATOMIC_EXCHANGE(var, val) ruby_atomic_exchange(&(var), (val))
|
54
|
+
#endif
|
55
|
+
|
56
|
+
#endif /* RUBY_ATOMIC_H */
|