Class: YTLJit::VM::Node::BaseNode
Direct Known Subclasses
BranchCommonNode, CApiCommonNode, ClassValueNode, GuardNode, JumpNode, LetNode, LiteralNode, LocalFrameInfoNode, LocalLabel, LocalVarNode, MethodEndNode, MethodSelectNode, MultiplexNode, PhiNode, SendNode, SetResultNode, SpecialObjectNode, SystemValueNode, TopNode, VariableRefCommonNode, YieldNode
Constant Summary
Constants included
from AbsArch
AbsArch::AL, AbsArch::BL, AbsArch::CL, AbsArch::DL, AbsArch::FUNC_ARG, AbsArch::FUNC_ARG_YTL, AbsArch::FUNC_FLOAT_ARG, AbsArch::FUNC_FLOAT_ARG_YTL, AbsArch::INDIRECT_BPR, AbsArch::INDIRECT_RETR, AbsArch::INDIRECT_SPR, AbsArch::INDIRECT_TMPR, AbsArch::INDIRECT_TMPR2, AbsArch::INDIRECT_TMPR3
Constants included
from SSE
SSE::XMM0, SSE::XMM1, SSE::XMM2, SSE::XMM3, SSE::XMM4, SSE::XMM5, SSE::XMM6, SSE::XMM7
Instance Attribute Summary collapse
Instance Method Summary
collapse
-
#add_element_node(sig, enode, index, context) ⇒ Object
-
#collect_candidate_type(context) ⇒ Object
-
#collect_info(context) ⇒ Object
-
#compile(context) ⇒ Object
-
#decide_type(sig) ⇒ Object
-
#decide_type_core(tlist, local_cache = {}) ⇒ Object
-
#decide_type_once(sig, local_cache = {}) ⇒ Object
-
#gen_type_inference_proc(code) ⇒ Object
-
#get_constant_value ⇒ Object
-
#inference_type ⇒ Object
-
#initialize(parent) ⇒ BaseNode
constructor
A new instance of BaseNode.
-
#merge_type(dst, src) ⇒ Object
-
#same_type(dst, src, dsig, ssig, context) ⇒ Object
-
#ti_add_observer(dst, dsig, ssig, context) ⇒ Object
-
#ti_changed ⇒ Object
-
#ti_del_link(visitnode = {}) ⇒ Object
-
#ti_reset(visitnode = {}) ⇒ Object
-
#ti_update(dst, src, dsig, ssig, context) ⇒ Object
#add_type, #set_type_list, #type_list, #type_list_initvar
Methods included from Inspect
#inspect_by_graph
Constructor Details
#initialize(parent) ⇒ BaseNode
Returns a new instance of BaseNode.
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
|
# File 'lib/ytljit/vm.rb', line 150
def initialize(parent)
cs = CodeSpace.new
asm = Assembler.new(cs)
asm.with_retry do
asm.mov(TMPR, 4)
asm.ret
end
@parent = parent
@code_space = nil
@id = nil
if @parent then
@id = @parent.id.dup
@id[-1] = @id[-1] + 1
else
@id = [0]
end
@type = nil
@type_list = type_list_initvar
@element_node_list = []
@my_element_node = nil
@type_inference_proc = cs
@type_cache = nil
@is_escape = false
@ti_observer = {}
@ti_observee = []
@debug_info = nil
end
|
Instance Attribute Details
#code_space ⇒ Object
Returns the value of attribute code_space.
185
186
187
|
# File 'lib/ytljit/vm.rb', line 185
def code_space
@code_space
end
|
#debug_info ⇒ Object
Returns the value of attribute debug_info.
195
196
197
|
# File 'lib/ytljit/vm.rb', line 195
def debug_info
@debug_info
end
|
#element_node_list ⇒ Object
Returns the value of attribute element_node_list.
189
190
191
|
# File 'lib/ytljit/vm.rb', line 189
def element_node_list
@element_node_list
end
|
Returns the value of attribute id.
186
187
188
|
# File 'lib/ytljit/vm.rb', line 186
def id
@id
end
|
#is_escape ⇒ Object
Returns the value of attribute is_escape.
190
191
192
|
# File 'lib/ytljit/vm.rb', line 190
def is_escape
@is_escape
end
|
Returns the value of attribute parent.
184
185
186
|
# File 'lib/ytljit/vm.rb', line 184
def parent
@parent
end
|
#ti_observee ⇒ Object
Returns the value of attribute ti_observee.
193
194
195
|
# File 'lib/ytljit/vm.rb', line 193
def ti_observee
@ti_observee
end
|
#ti_observer ⇒ Object
Returns the value of attribute ti_observer.
192
193
194
|
# File 'lib/ytljit/vm.rb', line 192
def ti_observer
@ti_observer
end
|
Returns the value of attribute type.
188
189
190
|
# File 'lib/ytljit/vm.rb', line 188
def type
@type
end
|
Instance Method Details
#add_element_node(sig, enode, index, context) ⇒ Object
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
|
# File 'lib/ytljit/vm.rb', line 330
def add_element_node(sig, enode, index, context)
slfetnode = @element_node_list
unless slfetnode.include?(enode)
if @element_node_list == nil and index != nil then
@element_node_list.push [sig, enode, nil]
end
@element_node_list.push [sig, enode, index]
orgsig = @element_node_list[0][0]
orgnode = @element_node_list[0][1]
if orgnode != enode then
same_type(orgnode, enode, orgsig, sig, context)
end
if index != nil then
@element_node_list.each do |orgsig, orgnode, orgindex|
if orgindex == index and
orgnode != enode then
same_type(orgnode, enode, orgsig, sig, context)
end
end
end
ti_changed
end
end
|
#collect_candidate_type(context) ⇒ Object
356
357
358
359
|
# File 'lib/ytljit/vm.rb', line 356
def collect_candidate_type(context)
raise "You must define collect_candidate_type per node"
context
end
|
#collect_info(context) ⇒ Object
197
198
199
200
201
202
203
204
205
|
# File 'lib/ytljit/vm.rb', line 197
def collect_info(context)
if is_a?(HaveChildlenMixin) then
traverse_childlen {|rec|
context = rec.collect_info(context)
}
end
context
end
|
#compile(context) ⇒ Object
423
424
425
426
|
# File 'lib/ytljit/vm.rb', line 423
def compile(context)
@code_space = context.code_space
context
end
|
#decide_type(sig) ⇒ Object
405
406
407
408
409
410
411
412
413
|
# File 'lib/ytljit/vm.rb', line 405
def decide_type(sig)
decide_type_once(sig)
if is_a?(HaveChildlenMixin) then
traverse_childlen {|rec|
rec.decide_type(sig)
}
end
end
|
#decide_type_core(tlist, local_cache = {}) ⇒ Object
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
|
# File 'lib/ytljit/vm.rb', line 361
def decide_type_core(tlist, local_cache = {})
tlist = tlist.select {|e| e.class != RubyType::DefaultType0 }
case tlist.size
when 0
RubyType::DefaultType0.new
when 1
local_cache[self] = tlist[0]
if tlist[0].have_element? then
sig = @element_node_list[0][0]
node = @element_node_list[0][1]
node.decide_type_once(sig, local_cache)
tlist[0].element_type = node.type
end
tlist[0]
when 2
if tlist[0].ruby_type == tlist[1].ruby_type and
tlist[0].boxed then
tlist[0]
else
tlist[1]
end
else
RubyType::DefaultType0.new
end
end
|
#decide_type_once(sig, local_cache = {}) ⇒ Object
390
391
392
393
394
395
396
397
398
399
400
401
402
403
|
# File 'lib/ytljit/vm.rb', line 390
def decide_type_once(sig, local_cache = {})
if local_cache[self] then
return local_cache[self]
end
if @type.equal?(nil) or @type.is_a?(RubyType::DefaultType0) then
tlist = type_list(sig).flatten.uniq
@type = decide_type_core(tlist, local_cache)
else
@type
end
@type
end
|
#gen_type_inference_proc(code) ⇒ Object
420
421
|
# File 'lib/ytljit/vm.rb', line 420
def gen_type_inference_proc(code)
end
|
#get_constant_value ⇒ Object
428
429
430
|
# File 'lib/ytljit/vm.rb', line 428
def get_constant_value
nil
end
|
#inference_type ⇒ Object
415
416
417
418
|
# File 'lib/ytljit/vm.rb', line 415
def inference_type
cs = @type_inference_proc
cs.call(cs.var_base_address)
end
|
#merge_type(dst, src) ⇒ Object
264
265
266
267
268
269
270
271
272
273
|
# File 'lib/ytljit/vm.rb', line 264
def merge_type(dst, src)
res = dst
src.each do |sele|
if !res.include? sele then
res.push sele
end
end
res
end
|
#same_type(dst, src, dsig, ssig, context) ⇒ Object
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
|
# File 'lib/ytljit/vm.rb', line 309
def same_type(dst, src, dsig, ssig, context)
=begin
print "#{src.class} -> #{dst.class} \n"
if dst.is_a?(LocalVarNode) then
print "#{dst.name} \n"
end
if dst.is_a?(LiteralNode) then
print "#{dst.value.inspect} \n"
end
if dst.is_a?(SendNode) then
print "#{dst.func.name} \n"
end
=end
if dst.is_a?(BaseNode) then
src.ti_add_observer(dst, dsig, ssig, context)
end
ti_update(dst, src, dsig, ssig, context)
end
|
#ti_add_observer(dst, dsig, ssig, context) ⇒ Object
207
208
209
210
211
212
213
214
215
216
217
218
219
|
# File 'lib/ytljit/vm.rb', line 207
def ti_add_observer(dst, dsig, ssig, context)
if @ti_observer[dst] == nil then
@ti_observer[dst] = []
dst.ti_observee.push self
end
if @ti_observer[dst].all? {|edsig, essig, eprc|
(edsig != dsig) or (essig != ssig)
} then
prc = lambda { send(:ti_update, dst, self, dsig, ssig, context) }
@ti_observer[dst].push [dsig, ssig, prc]
end
end
|
#ti_changed ⇒ Object
221
222
223
224
225
226
227
|
# File 'lib/ytljit/vm.rb', line 221
def ti_changed
@ti_observer.each do |rec, lst|
lst.each do |dsig, ssig, prc|
prc.call
end
end
end
|
#ti_del_link(visitnode = {}) ⇒ Object
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
|
# File 'lib/ytljit/vm.rb', line 244
def ti_del_link(visitnode = {})
if visitnode[self] then
return
end
visitnode[self] = true
@ti_observer.each do |rec, lst|
delent = []
lst.each do |ent|
delent.push ent
rec.ti_del_link(visitnode)
end
delent.each do |ent|
lst.delete(ent)
end
end
end
|
#ti_reset(visitnode = {}) ⇒ Object
229
230
231
232
233
234
235
236
237
238
239
240
241
242
|
# File 'lib/ytljit/vm.rb', line 229
def ti_reset(visitnode = {})
if visitnode[self] then
return
end
visitnode[self] = true
@ti_observer.each do |rec, lst|
lst.each do |dsig, ssig, prc|
rec.type_list(dsig)[1] = []
rec.ti_reset(visitnode)
end
end
end
|
#ti_update(dst, src, dsig, ssig, context) ⇒ Object
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
|
# File 'lib/ytljit/vm.rb', line 275
def ti_update(dst, src, dsig, ssig, context)
dtlistorg = dst.type_list(dsig)
dtlist = dtlistorg.flatten
stlist = src.type_list(ssig).flatten
=begin
print "UPDATE TYPE\n"
print "#{src.class} #{ssig.inspect} -> #{dst.class} #{dsig.inspect}\n"
print dtlist.map(&:ruby_type), "\n"
print stlist.map(&:ruby_type), "\n"
=end
orgsize = dtlist.size
newdt = merge_type(dtlistorg[1], stlist)
dst.set_type_list(dsig, newdt)
dtsize = dtlistorg[0].size + newdt.size
if orgsize != dtsize then
dst.type = nil
dst.ti_changed
context.convergent = false
end
dtlist = dst.element_node_list
stlist = src.element_node_list
orgsize = dtlist.size
dst.element_node_list = merge_type(dtlist, stlist)
if orgsize != dtlist.size then
dst.ti_changed
context.convergent = false
end
dst.is_escape ||= src.is_escape
end
|