ytljit 0.0.5 → 0.0.6

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.
@@ -26,12 +26,13 @@ module YTLJit
26
26
  end
27
27
 
28
28
  def inspect
29
- "{ #{boxed ? "BOXED" : "UNBOXED"} #{ruby_type}}"
29
+ "{ #{boxed ? "BOXED" : "UNBOXED"} #{@ruby_type}}"
30
30
  end
31
31
  end
32
32
 
33
33
  module FixnumTypeUnboxedCodeGen
34
34
  include AbsArch
35
+ include CommonCodeGen
35
36
 
36
37
  def gen_boxing(context)
37
38
  asm = context.assembler
@@ -57,6 +58,7 @@ module YTLJit
57
58
 
58
59
  module FixnumTypeBoxedCodeGen
59
60
  include AbsArch
61
+ include CommonCodeGen
60
62
 
61
63
  def gen_boxing(context)
62
64
  context
@@ -80,6 +82,7 @@ module YTLJit
80
82
 
81
83
  module FloatTypeBoxedCodeGen
82
84
  include AbsArch
85
+ include CommonCodeGen
83
86
 
84
87
  def gen_boxing(context)
85
88
  context
@@ -99,21 +102,29 @@ module YTLJit
99
102
 
100
103
  module FloatTypeUnboxedCodeGen
101
104
  include AbsArch
105
+ include CommonCodeGen
102
106
 
103
107
  def gen_boxing(context)
104
108
  asm = context.assembler
105
109
  val = context.ret_reg
106
110
  vnode = context.ret_node
107
111
  context.start_using_reg(TMPR2)
108
- context.start_using_reg(TMPR3)
109
- context.start_using_reg(FUNC_FLOAT_ARG[0])
112
+ context.start_arg_reg(FUNC_FLOAT_ARG)
113
+ context.start_arg_reg
110
114
  rbfloatnew = OpMemAddress.new(address_of("rb_float_new"))
115
+ =begin
116
+ # This is sample of backtrace
117
+ sh = OpMemAddress.new(address_of("ytl_step_handler"))
118
+ context = gen_call(context, sh, 0, vnode)
119
+ =end
111
120
  asm.with_retry do
112
121
  asm.mov(FUNC_FLOAT_ARG[0], val)
113
- asm.call_with_arg(rbfloatnew, 1)
114
122
  end
115
- context.end_using_reg(FUNC_FLOAT_ARG[0])
116
- context.end_using_reg(TMPR3)
123
+ context.set_reg_content(FUNC_FLOAT_ARG[0].dst_opecode, vnode)
124
+ context = gen_call(context, rbfloatnew, 1, vnode)
125
+ context.end_arg_reg
126
+ context.end_arg_reg(FUNC_FLOAT_ARG)
127
+ # context.end_using_reg(TMPR3)
117
128
  context.end_using_reg(TMPR2)
118
129
  context.ret_reg = RETR
119
130
  context
@@ -126,6 +137,7 @@ module YTLJit
126
137
 
127
138
  module ArrayTypeBoxedCodeGen
128
139
  include AbsArch
140
+ include CommonCodeGen
129
141
 
130
142
  def instance
131
143
  ni = self.dup
@@ -147,30 +159,34 @@ module YTLJit
147
159
  def gen_copy(context)
148
160
  asm = context.assembler
149
161
  val = context.ret_reg
150
- context.start_using_reg(TMPR2)
162
+ vnode = context.ret_node
151
163
  context.start_using_reg(TMPR3)
152
- context.start_using_reg(FUNC_ARG[0])
164
+ context.start_arg_reg
153
165
  rbarydup = OpMemAddress.new(address_of("rb_ary_dup"))
154
166
  asm.with_retry do
155
167
  asm.mov(FUNC_ARG[0], val)
156
- asm.call_with_arg(rbarydup, 1)
157
168
  end
158
- context.end_using_reg(FUNC_ARG[0])
169
+ context.set_reg_content(FUNC_ARG[0].dst_opecode, vnode)
170
+ context = gen_call(context, rbarydup, 1, vnode)
171
+ context.end_arg_reg
159
172
  context.end_using_reg(TMPR3)
160
- context.end_using_reg(TMPR2)
161
173
  context.ret_reg = RETR
162
174
 
163
175
  context
164
176
  end
165
177
 
166
178
  def ==(other)
167
- other.is_a?(self.class) and
168
- self.class == other.class and
169
- @element_type == other.element_type
179
+ if other then
180
+ oc = other.ruby_type
181
+ sc = self.ruby_type
182
+ sc == oc and
183
+ @element_type == other.element_type
184
+ else
185
+ false
186
+ end
170
187
  end
171
188
 
172
189
  def eql?(other)
173
- other.is_a?(self.class) and
174
190
  self.class == other.class and
175
191
  @element_type == other.element_type
176
192
  end
@@ -178,20 +194,21 @@ module YTLJit
178
194
 
179
195
  module StringTypeBoxedCodeGen
180
196
  include AbsArch
197
+ include CommonCodeGen
181
198
 
182
199
  def gen_copy(context)
183
200
  asm = context.assembler
184
201
  val = context.ret_reg
202
+ vnode = context.ret_node
185
203
  context.start_using_reg(TMPR2)
186
- context.start_using_reg(TMPR3)
187
- context.start_using_reg(FUNC_ARG[0])
204
+ context.start_arg_reg
188
205
  rbstrresurrect = OpMemAddress.new(address_of("rb_str_resurrect"))
189
206
  asm.with_retry do
190
207
  asm.mov(FUNC_ARG[0], val)
191
- asm.call_with_arg(rbstrresurrect, 1)
192
208
  end
193
- context.end_using_reg(FUNC_ARG[0])
194
- context.end_using_reg(TMPR3)
209
+ context.set_reg_content(FUNC_ARG[0].dst_opecode, vnode)
210
+ context = gen_call(context, rbstrresurrect, 1, vnode)
211
+ context.end_arg_reg
195
212
  context.end_using_reg(TMPR2)
196
213
  context.ret_reg = RETR
197
214
 
@@ -199,7 +216,72 @@ module YTLJit
199
216
  end
200
217
  end
201
218
 
219
+ module RangeTypeUnboxedCodeGen
220
+ include AbsArch
221
+ include CommonCodeGen
222
+
223
+ def instance
224
+ ni = self.dup
225
+ ni.instance_eval { extend RangeTypeUnboxedCodeGen }
226
+ ni.init
227
+ ni
228
+ end
229
+
230
+ def init
231
+ @args = nil
232
+ end
233
+
234
+ attr_accessor :args
235
+
236
+ def gen_boxing(context)
237
+ rtype = args[0].decide_type_once(context.to_signature)
238
+
239
+ base = context.ret_reg
240
+ rbrangenew = OpMemAddress.new(address_of("rb_range_new"))
241
+ begoff = OpIndirect.new(TMPR2, 0)
242
+ endoff = OpIndirect.new(TMPR2, AsmType::MACHINE_WORD.size)
243
+ excoff = OpIndirect.new(TMPR2, AsmType::MACHINE_WORD.size * 2)
244
+
245
+ context.start_using_reg(TMPR2)
246
+ context.start_arg_reg
247
+ asm = context.assembler
248
+ asm.with_retry do
249
+ asm.mov(TMPR2, base)
250
+ end
251
+
252
+ context.ret_reg = begoff
253
+ context = rtype.gen_boxing(context)
254
+ asm.with_retry do
255
+ asm.mov(FUNC_ARG[0], context.ret_reg)
256
+ end
257
+
258
+ context.ret_reg = endoff
259
+ context = rtype.gen_boxing(context)
260
+ asm.with_retry do
261
+ asm.mov(FUNC_ARG[1], context.ret_reg)
262
+ end
263
+
264
+ asm.with_retry do
265
+ asm.mov(FUNC_ARG[2], excoff)
266
+ asm.call_with_arg(rbrangenew, 3)
267
+ end
268
+
269
+ context.end_arg_reg
270
+ context.end_using_reg(TMPR2)
271
+ context.ret_reg = RETR
272
+ context
273
+ end
274
+
275
+ def ==(other)
276
+ self.class == other.class and
277
+ @args == other.args
278
+ end
279
+ end
280
+
202
281
  module ArrayTypeUnboxedCodeGen
282
+ include AbsArch
283
+ include CommonCodeGen
284
+
203
285
  def have_element?
204
286
  true
205
287
  end
@@ -5,7 +5,7 @@ include YTLJit
5
5
 
6
6
  class Integer
7
7
  def to_as
8
- "$0X#{self.to_s(16)}"
8
+ "$0x#{self.to_s(16)}"
9
9
  end
10
10
  end
11
11
 
@@ -17,19 +17,23 @@ class InstructionTests < Test::Unit::TestCase
17
17
  @cs = CodeSpace.new
18
18
  @asm = Assembler.new(@cs, GeneratorExtend)
19
19
  @asout = ""
20
- @regs = [EAX, ECX, EDX, EBX, EBP, EDI, ESI, ESP]
20
+ # @regs = [EAX, ECX, EDX, EBX, EBP, EDI, ESI, ESP]
21
21
  @regs8 = [AL, CL, DL, BL]
22
- # @regs = [RAX, RCX, RDX, RBX, RBP, RDI, RSI, RSP, R8, R9, R10,
23
- # R11, R12, R13, R14, R15]
22
+ @regs = [RAX, RCX, RDX, RBX, RBP, RDI, RSI, RSP, R8, R9, R10,
23
+ R11, R12, R13, R14, R15]
24
24
 
25
25
  @xmmregs = [XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7]
26
26
  @lits = [OpImmidiate32.new(0x0), OpImmidiate32.new(0x92),
27
27
  OpImmidiate32.new(0x8212), OpImmidiate32.new(0x12345678),
28
28
  0, 0x92, 0x8212, 0x12345678]# , 0xffffffff]
29
29
  @indirects = []
30
- [EBP, EDI, ESI, ESP].each do |reg|
31
- # [RBP, RDI, RSI, RSP].each do |reg|
32
- [0, 12, 255, 8192, 65535].each do |offset|
30
+ # [EBP, EDI, ESI, ESP].each do |reg|
31
+ [RBP, RDI, RSI, RSP, R8, R9, R10, R11, R12].each do |reg|
32
+ [
33
+ # -65535, -8192, -256, -255, -80, -12, -8,
34
+ -80, -8, 0, 8,
35
+ # 0, 12, 255, 8192, 65535
36
+ ].each do |offset|
33
37
  @indirects.push OpIndirect.new(reg, offset)
34
38
  end
35
39
  end
@@ -160,7 +164,6 @@ class InstructionTests < Test::Unit::TestCase
160
164
 
161
165
  ytlres = disasm_ytljit(@cs)
162
166
  gasres = disasm_gas(@cs)
163
- # print @asout
164
167
  ytlres.each_with_index do |lin, i|
165
168
  assert_equal(gasres[i], lin)
166
169
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 5
9
- version: 0.0.5
8
+ - 6
9
+ version: 0.0.6
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-12-17 00:00:00 +09:00
17
+ date: 2011-01-27 00:00:00 +09:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency