@@ -12,10 +12,10 @@ class InstructionSequence
12
12
# and other transformations like instruction specialization.
13
13
class InstructionList
14
14
class Node
15
- attr_accessor :instruction , :next_node
15
+ attr_accessor :value , :next_node
16
16
17
- def initialize ( instruction , next_node = nil )
18
- @instruction = instruction
17
+ def initialize ( value , next_node = nil )
18
+ @value = value
19
19
@next_node = next_node
20
20
end
21
21
end
@@ -29,15 +29,15 @@ def initialize
29
29
30
30
def each
31
31
return to_enum ( __method__ ) unless block_given?
32
- each_node { |node | yield node . instruction }
32
+ each_node { |node | yield node . value }
33
33
end
34
34
35
35
def each_node
36
36
return to_enum ( __method__ ) unless block_given?
37
37
node = head_node
38
38
39
39
while node
40
- yield node
40
+ yield node , node . value
41
41
node = node . next_node
42
42
end
43
43
end
@@ -274,62 +274,56 @@ def to_a
274
274
end
275
275
276
276
def specialize_instructions!
277
- insns . each_node do |node |
278
- case node . instruction
277
+ insns . each_node do |node , value |
278
+ case value
279
279
when NewArray
280
280
next unless node . next_node
281
281
282
282
next_node = node . next_node
283
- next unless next_node . instruction . is_a? ( Send )
284
- next if next_node . instruction . block_iseq
283
+ next unless next_node . value . is_a? ( Send )
284
+ next if next_node . value . block_iseq
285
285
286
- calldata = next_node . instruction . calldata
286
+ calldata = next_node . value . calldata
287
287
next unless calldata . flags == CallData ::CALL_ARGS_SIMPLE
288
288
next unless calldata . argc == 0
289
289
290
290
case calldata . method
291
291
when :max
292
- node . instruction = OptNewArrayMax . new ( node . instruction . number )
292
+ node . value = OptNewArrayMax . new ( value . number )
293
293
node . next_node = next_node . next_node
294
294
when :min
295
- node . instruction = OptNewArrayMin . new ( node . instruction . number )
295
+ node . value = OptNewArrayMin . new ( value . number )
296
296
node . next_node = next_node . next_node
297
297
end
298
298
when PutObject , PutString
299
299
next unless node . next_node
300
- if node . instruction . is_a? ( PutObject ) &&
301
- !node . instruction . object . is_a? ( String )
302
- next
303
- end
300
+ next if value . is_a? ( PutObject ) && !value . object . is_a? ( String )
304
301
305
302
next_node = node . next_node
306
- next unless next_node . instruction . is_a? ( Send )
307
- next if next_node . instruction . block_iseq
303
+ next unless next_node . value . is_a? ( Send )
304
+ next if next_node . value . block_iseq
308
305
309
- calldata = next_node . instruction . calldata
306
+ calldata = next_node . value . calldata
310
307
next unless calldata . flags == CallData ::CALL_ARGS_SIMPLE
311
308
next unless calldata . argc == 0
312
309
313
310
case calldata . method
314
311
when :freeze
315
- node . instruction =
316
- OptStrFreeze . new ( node . instruction . object , calldata )
312
+ node . value = OptStrFreeze . new ( value . object , calldata )
317
313
node . next_node = next_node . next_node
318
314
when :-@
319
- node . instruction =
320
- OptStrUMinus . new ( node . instruction . object , calldata )
315
+ node . value = OptStrUMinus . new ( value . object , calldata )
321
316
node . next_node = next_node . next_node
322
317
end
323
318
when Send
324
- calldata = node . instruction . calldata
319
+ calldata = value . calldata
325
320
326
- if !node . instruction . block_iseq &&
327
- !calldata . flag? ( CallData ::CALL_ARGS_BLOCKARG )
321
+ if !value . block_iseq && !calldata . flag? ( CallData ::CALL_ARGS_BLOCKARG )
328
322
# Specialize the send instruction. If it doesn't have a block
329
323
# attached, then we will replace it with an opt_send_without_block
330
324
# and do further specializations based on the called method and
331
325
# the number of arguments.
332
- node . instruction =
326
+ node . value =
333
327
case [ calldata . method , calldata . argc ]
334
328
when [ :length , 0 ]
335
329
OptLength . new ( calldata )
0 commit comments