ytljit 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/ext/code_alloc.c +6 -0
- data/ext/memory.c +82 -0
- data/ext/ytljit.c +9 -0
- data/ext/ytljit.h +18 -0
- data/lib/runtime/gc.rb +41 -0
- data/lib/runtime/object.rb +18 -0
- data/lib/ytljit.rb +9 -0
- data/lib/ytljit/arena.rb +63 -0
- data/lib/ytljit/asm.rb +5 -1
- data/lib/ytljit/asmext.rb +42 -6
- data/lib/ytljit/asmutil.rb +26 -0
- data/lib/ytljit/instruction_ia.rb +28 -2
- data/lib/ytljit/type.rb +11 -5
- data/lib/ytljit/vm.rb +620 -173
- data/lib/ytljit/vm_codegen.rb +123 -26
- data/lib/ytljit/vm_cruby_obj.rb +91 -0
- data/lib/ytljit/vm_inline_method.rb +27 -19
- data/lib/ytljit/vm_sendnode.rb +416 -136
- data/lib/ytljit/vm_trans.rb +79 -19
- data/lib/ytljit/vm_type.rb +25 -19
- data/lib/ytljit/vm_type_gen.rb +55 -2
- data/test/test_arena.rb +60 -0
- data/test/test_assemble2.rb +25 -2
- metadata +10 -3
data/test/test_arena.rb
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'ytljit'
|
3
|
+
|
4
|
+
include YTLJit
|
5
|
+
include YTLJit::Runtime
|
6
|
+
|
7
|
+
class ArenaTests < Test::Unit::TestCase
|
8
|
+
VALUE = AsmType::MACHINE_WORD
|
9
|
+
P_CHAR = AsmType::Pointer.new(AsmType::INT8)
|
10
|
+
|
11
|
+
RBasic = AsmType::Struct.new(
|
12
|
+
VALUE, :flags,
|
13
|
+
VALUE, :klass
|
14
|
+
)
|
15
|
+
RString = AsmType::Struct.new(
|
16
|
+
RBasic, :basic,
|
17
|
+
AsmType::Union.new(
|
18
|
+
AsmType::Struct.new(
|
19
|
+
AsmType::INT32, :len,
|
20
|
+
P_CHAR, :ptr,
|
21
|
+
AsmType::Union.new(
|
22
|
+
AsmType::INT32, :capa,
|
23
|
+
VALUE, :shared,
|
24
|
+
), :aux
|
25
|
+
), :heap,
|
26
|
+
AsmType::Array.new(
|
27
|
+
AsmType::INT8,
|
28
|
+
24
|
29
|
+
), :ary
|
30
|
+
), :as
|
31
|
+
)
|
32
|
+
ARR = AsmType::Array.new(VALUE, 100)
|
33
|
+
|
34
|
+
def test_arena
|
35
|
+
arena = Arena.new
|
36
|
+
foo = TypedDataArena.new(RString, arena, 32)
|
37
|
+
foo[:basic][:flags].ref = 10
|
38
|
+
foo[:as][:heap][:aux][:capa].ref = 320
|
39
|
+
bar = TypedDataArena.new(ARR, arena, 256)
|
40
|
+
bar[0].ref = 1
|
41
|
+
bar[10].ref = 122
|
42
|
+
bar[99].ref = 230
|
43
|
+
assert_equal(foo[:basic][:flags].ref, 10)
|
44
|
+
assert_equal(foo[:as][:heap][:aux][:shared].ref, 320)
|
45
|
+
assert_equal(bar[0].ref, 1)
|
46
|
+
assert_equal(bar[10].ref, 122)
|
47
|
+
assert_equal(bar[99].ref, 230)
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_malloc
|
51
|
+
gc = GCCopy.new
|
52
|
+
str = gc.malloc(RString) {|res|
|
53
|
+
res[:header].ref = 12234
|
54
|
+
res[:traverse_func].ref = 1233
|
55
|
+
}
|
56
|
+
p str[:as][:heap].address.to_s(16)
|
57
|
+
p str.address.to_s(16)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
data/test/test_assemble2.rb
CHANGED
@@ -123,7 +123,7 @@ class InstructionTests < Test::Unit::TestCase
|
|
123
123
|
end
|
124
124
|
|
125
125
|
def test_asm
|
126
|
-
[:mov, :add, :or, :adc, :sbb, :and, :sub, :xor, :cmp].each do |mnm|
|
126
|
+
[:mov, :add, :or, :adc, :sbb, :and, :sub, :xor, :cmp,].each do |mnm|
|
127
127
|
# Pattern reg, immidiate
|
128
128
|
@regs.each do |reg|
|
129
129
|
@lits.each do |src|
|
@@ -214,6 +214,28 @@ class InstructionTests < Test::Unit::TestCase
|
|
214
214
|
end
|
215
215
|
end
|
216
216
|
|
217
|
+
def test_div
|
218
|
+
[:idiv, :imul].each do |mnm|
|
219
|
+
@indirects.each do |dst|
|
220
|
+
asm_ytljit(mnm, dst, nil)
|
221
|
+
asm_gas((mnm.to_s + "l").to_sym, dst, nil)
|
222
|
+
end
|
223
|
+
|
224
|
+
@regs.each do |dst|
|
225
|
+
asm_ytljit(mnm, dst, nil)
|
226
|
+
asm_gas((mnm.to_s + "l").to_sym, dst, nil)
|
227
|
+
end
|
228
|
+
|
229
|
+
ytlres = disasm_ytljit(@cs)
|
230
|
+
gasres = disasm_gas(@cs)
|
231
|
+
ytlres.each_with_index do |lin, i|
|
232
|
+
assert_equal(gasres[i], lin)
|
233
|
+
end
|
234
|
+
@cs.reset
|
235
|
+
@asout = ""
|
236
|
+
end
|
237
|
+
end
|
238
|
+
|
217
239
|
def test_xmm_mov
|
218
240
|
[:movss, :movsd].each do |mnm|
|
219
241
|
|
@@ -256,7 +278,8 @@ class InstructionTests < Test::Unit::TestCase
|
|
256
278
|
|
257
279
|
def test_xmm_arith
|
258
280
|
[:addss, :addsd, :subss, :subsd,
|
259
|
-
:mulss, :mulsd, :divss, :divsd
|
281
|
+
:mulss, :mulsd, :divss, :divsd,
|
282
|
+
:comisd].each do |mnm|
|
260
283
|
|
261
284
|
# Pattern reg, reg
|
262
285
|
@xmmregs.each do |reg|
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 4
|
9
|
+
version: 0.0.4
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Hideki Miura
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-12-10 00:00:00 +09:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -40,6 +40,7 @@ extra_rdoc_files: []
|
|
40
40
|
|
41
41
|
files:
|
42
42
|
- lib/ytljit.rb
|
43
|
+
- lib/ytljit/arena.rb
|
43
44
|
- lib/ytljit/asm.rb
|
44
45
|
- lib/ytljit/asmext.rb
|
45
46
|
- lib/ytljit/asmext_x64.rb
|
@@ -59,6 +60,7 @@ files:
|
|
59
60
|
- lib/ytljit/util.rb
|
60
61
|
- lib/ytljit/vm.rb
|
61
62
|
- lib/ytljit/vm_codegen.rb
|
63
|
+
- lib/ytljit/vm_cruby_obj.rb
|
62
64
|
- lib/ytljit/vm_inline_method.rb
|
63
65
|
- lib/ytljit/vm_inspect.rb
|
64
66
|
- lib/ytljit/vm_sendnode.rb
|
@@ -66,13 +68,17 @@ files:
|
|
66
68
|
- lib/ytljit/vm_type.rb
|
67
69
|
- lib/ytljit/vm_typeinf.rb
|
68
70
|
- lib/ytljit/vm_type_gen.rb
|
71
|
+
- lib/runtime/gc.rb
|
72
|
+
- lib/runtime/object.rb
|
69
73
|
- ext/code_alloc.c
|
74
|
+
- ext/memory.c
|
70
75
|
- ext/ytljit.c
|
71
76
|
- ext/ytljit.h
|
72
77
|
- ext/extconf.rb
|
73
78
|
- test/asmsample.rb
|
74
79
|
- test/cstest.rb
|
75
80
|
- test/marshaltest.rb
|
81
|
+
- test/test_arena.rb
|
76
82
|
- test/test_assemble.rb
|
77
83
|
- test/test_assemble2.rb
|
78
84
|
- test/test_codespace.rb
|
@@ -121,6 +127,7 @@ test_files:
|
|
121
127
|
- test/asmsample.rb
|
122
128
|
- test/cstest.rb
|
123
129
|
- test/marshaltest.rb
|
130
|
+
- test/test_arena.rb
|
124
131
|
- test/test_assemble.rb
|
125
132
|
- test/test_assemble2.rb
|
126
133
|
- test/test_codespace.rb
|