From 706d15fa216e320be3dfb0001989da683bd4f0c4 Mon Sep 17 00:00:00 2001 From: Stefan Marr Date: Sat, 24 Feb 2024 18:17:28 +0000 Subject: [PATCH] =?UTF-8?q?Don=E2=80=99t=20use=20bytecode=20length=20array?= =?UTF-8?q?=20in=20interpreter?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Instead, hardcode the bytecode length. This should avoid another check on each bytecode. Signed-off-by: Stefan Marr --- src/som/interpreter/bc/bytecodes.py | 144 +++++++++++++------------- src/som/interpreter/bc/interpreter.py | 130 +++++++++++++++-------- 2 files changed, 160 insertions(+), 114 deletions(-) diff --git a/src/som/interpreter/bc/bytecodes.py b/src/som/interpreter/bc/bytecodes.py index b1edf678..c8481b2e 100644 --- a/src/som/interpreter/bc/bytecodes.py +++ b/src/som/interpreter/bc/bytecodes.py @@ -1,5 +1,9 @@ from rlib import jit +LEN_NO_ARGS = 1 +LEN_ONE_ARG = 2 +LEN_TWO_ARGS = 3 + class Bytecodes(object): # Bytecodes used by the Simple Object Machine (SOM) @@ -196,77 +200,77 @@ def is_one_of(bytecode, candidates): ] _BYTECODE_LENGTH = [ - 1, # halt - 1, # dup - 3, # push_frame - 3, # push_frame_0 - 3, # push_frame_1 - 3, # push_frame_2 - 3, # push_inner - 3, # push_inner_0 - 3, # push_inner_1 - 3, # push_inner_2 - 3, # push_field - 1, # push_field_0 - 1, # push_field_1 - 2, # push_block - 2, # push_block_no_ctx - 2, # push_constant - 1, # push_constant_0 - 1, # push_constant_1 - 1, # push_constant_2 - 1, # push_0 - 1, # push_1 - 1, # push_nil - 2, # push_global - 1, # pop - 3, # pop_frame - 3, # pop_frame_0 - 3, # pop_frame_1 - 3, # pop_frame_2 - 3, # pop_inner - 3, # pop_inner_0 - 3, # pop_inner_1 - 3, # pop_inner_2 - 3, # pop_field - 1, # pop_field_0 - 1, # pop_field_1 - 2, # send_1 - 2, # send_2 - 2, # send_3 - 2, # send_n - 2, # super_send - 1, # return_local - 2, # return_non_local - 1, # return_self - 1, # return_field_0 - 1, # return_field_1 - 1, # return_field_2 - 1, # inc - 1, # dec - 3, # inc_field - 3, # inc_field_push - 3, # jump - 3, # jump_on_true_top_nil - 3, # jump_on_false_top_nil - 3, # jump_on_true_pop - 3, # jump_on_false_pop - 3, # jump_backward - 3, # jump2 - 3, # jump2_on_true_top_nil - 3, # jump2_on_false_top_nil - 3, # jump2_on_true_pop - 3, # jump2_on_false_pop - 3, # jump2_backward - 2, # q_super_send_1 - 2, # q_super_send_2 - 2, # q_super_send_3 - 2, # q_super_send_n + LEN_NO_ARGS, # halt + LEN_NO_ARGS, # dup + LEN_TWO_ARGS, # push_frame + LEN_TWO_ARGS, # push_frame_0 + LEN_TWO_ARGS, # push_frame_1 + LEN_TWO_ARGS, # push_frame_2 + LEN_TWO_ARGS, # push_inner + LEN_TWO_ARGS, # push_inner_0 + LEN_TWO_ARGS, # push_inner_1 + LEN_TWO_ARGS, # push_inner_2 + LEN_TWO_ARGS, # push_field + LEN_NO_ARGS, # push_field_0 + LEN_NO_ARGS, # push_field_1 + LEN_ONE_ARG, # push_block + LEN_ONE_ARG, # push_block_no_ctx + LEN_ONE_ARG, # push_constant + LEN_NO_ARGS, # push_constant_0 + LEN_NO_ARGS, # push_constant_1 + LEN_NO_ARGS, # push_constant_2 + LEN_NO_ARGS, # push_0 + LEN_NO_ARGS, # push_1 + LEN_NO_ARGS, # push_nil + LEN_ONE_ARG, # push_global + LEN_NO_ARGS, # pop + LEN_TWO_ARGS, # pop_frame + LEN_TWO_ARGS, # pop_frame_0 + LEN_TWO_ARGS, # pop_frame_1 + LEN_TWO_ARGS, # pop_frame_2 + LEN_TWO_ARGS, # pop_inner + LEN_TWO_ARGS, # pop_inner_0 + LEN_TWO_ARGS, # pop_inner_1 + LEN_TWO_ARGS, # pop_inner_2 + LEN_TWO_ARGS, # pop_field + LEN_NO_ARGS, # pop_field_0 + LEN_NO_ARGS, # pop_field_1 + LEN_ONE_ARG, # send_1 + LEN_ONE_ARG, # send_2 + LEN_ONE_ARG, # send_3 + LEN_ONE_ARG, # send_n + LEN_ONE_ARG, # super_send + LEN_NO_ARGS, # return_local + LEN_ONE_ARG, # return_non_local + LEN_NO_ARGS, # return_self + LEN_NO_ARGS, # return_field_0 + LEN_NO_ARGS, # return_field_1 + LEN_NO_ARGS, # return_field_2 + LEN_NO_ARGS, # inc + LEN_NO_ARGS, # dec + LEN_TWO_ARGS, # inc_field + LEN_TWO_ARGS, # inc_field_push + LEN_TWO_ARGS, # jump + LEN_TWO_ARGS, # jump_on_true_top_nil + LEN_TWO_ARGS, # jump_on_false_top_nil + LEN_TWO_ARGS, # jump_on_true_pop + LEN_TWO_ARGS, # jump_on_false_pop + LEN_TWO_ARGS, # jump_backward + LEN_TWO_ARGS, # jump2 + LEN_TWO_ARGS, # jump2_on_true_top_nil + LEN_TWO_ARGS, # jump2_on_false_top_nil + LEN_TWO_ARGS, # jump2_on_true_pop + LEN_TWO_ARGS, # jump2_on_false_pop + LEN_TWO_ARGS, # jump2_backward + LEN_ONE_ARG, # q_super_send_1 + LEN_ONE_ARG, # q_super_send_2 + LEN_ONE_ARG, # q_super_send_3 + LEN_ONE_ARG, # q_super_send_n # rewritten on first use - 3, # push_local - 3, # push_argument - 3, # pop_local - 3, # pop_argument + LEN_TWO_ARGS, # push_local + LEN_TWO_ARGS, # push_argument + LEN_TWO_ARGS, # pop_local + LEN_TWO_ARGS, # pop_argument ] diff --git a/src/som/interpreter/bc/interpreter.py b/src/som/interpreter/bc/interpreter.py index 42ea7228..770f3705 100644 --- a/src/som/interpreter/bc/interpreter.py +++ b/src/som/interpreter/bc/interpreter.py @@ -11,7 +11,13 @@ INLINE_CACHE_SIZE, GenericDispatchNode, ) -from som.interpreter.bc.bytecodes import bytecode_length, Bytecodes, bytecode_as_str +from som.interpreter.bc.bytecodes import ( + LEN_NO_ARGS, + LEN_ONE_ARG, + LEN_TWO_ARGS, + Bytecodes, + bytecode_as_str, +) from som.interpreter.bc.frame import ( get_block_at, get_self_dynamically, @@ -127,12 +133,6 @@ def interpret(method, frame, max_stack_size): bytecode = method.get_bytecode(current_bc_idx) - # Get the length of the current bytecode - bc_length = bytecode_length(bytecode) - - # Compute the next bytecode index - next_bc_idx = current_bc_idx + bc_length - promote(stack_ptr) # Handle the current bytecode @@ -143,24 +143,29 @@ def interpret(method, frame, max_stack_size): val = stack[stack_ptr] stack_ptr += 1 stack[stack_ptr] = val + current_bc_idx += LEN_NO_ARGS elif bytecode == Bytecodes.push_frame: stack_ptr += 1 stack[stack_ptr] = read_frame( frame, method.get_bytecode(current_bc_idx + 1) ) + current_bc_idx += LEN_TWO_ARGS elif bytecode == Bytecodes.push_frame_0: stack_ptr += 1 stack[stack_ptr] = read_frame(frame, FRAME_AND_INNER_RCVR_IDX + 0) + current_bc_idx += LEN_TWO_ARGS elif bytecode == Bytecodes.push_frame_1: stack_ptr += 1 stack[stack_ptr] = read_frame(frame, FRAME_AND_INNER_RCVR_IDX + 1) + current_bc_idx += LEN_TWO_ARGS elif bytecode == Bytecodes.push_frame_2: stack_ptr += 1 stack[stack_ptr] = read_frame(frame, FRAME_AND_INNER_RCVR_IDX + 2) + current_bc_idx += LEN_TWO_ARGS elif bytecode == Bytecodes.push_inner: idx = method.get_bytecode(current_bc_idx + 1) @@ -172,18 +177,22 @@ def interpret(method, frame, max_stack_size): else: block = get_block_at(frame, ctx_level) stack[stack_ptr] = block.get_from_outer(idx) + current_bc_idx += LEN_TWO_ARGS elif bytecode == Bytecodes.push_inner_0: stack_ptr += 1 stack[stack_ptr] = read_inner(frame, FRAME_AND_INNER_RCVR_IDX + 0) + current_bc_idx += LEN_TWO_ARGS elif bytecode == Bytecodes.push_inner_1: stack_ptr += 1 stack[stack_ptr] = read_inner(frame, FRAME_AND_INNER_RCVR_IDX + 1) + current_bc_idx += LEN_TWO_ARGS elif bytecode == Bytecodes.push_inner_2: stack_ptr += 1 stack[stack_ptr] = read_inner(frame, FRAME_AND_INNER_RCVR_IDX + 2) + current_bc_idx += LEN_TWO_ARGS elif bytecode == Bytecodes.push_field: field_idx = method.get_bytecode(current_bc_idx + 1) @@ -191,54 +200,66 @@ def interpret(method, frame, max_stack_size): self_obj = get_self(frame, ctx_level) stack_ptr += 1 stack[stack_ptr] = self_obj.get_field(field_idx) + current_bc_idx += LEN_TWO_ARGS elif bytecode == Bytecodes.push_field_0: self_obj = read_frame(frame, FRAME_AND_INNER_RCVR_IDX) stack_ptr += 1 stack[stack_ptr] = self_obj.get_field(0) + current_bc_idx += LEN_NO_ARGS elif bytecode == Bytecodes.push_field_1: self_obj = read_frame(frame, FRAME_AND_INNER_RCVR_IDX) stack_ptr += 1 stack[stack_ptr] = self_obj.get_field(1) + current_bc_idx += LEN_NO_ARGS elif bytecode == Bytecodes.push_block: block_method = method.get_constant(current_bc_idx) stack_ptr += 1 stack[stack_ptr] = BcBlock(block_method, get_inner_as_context(frame)) + current_bc_idx += LEN_ONE_ARG elif bytecode == Bytecodes.push_block_no_ctx: block_method = method.get_constant(current_bc_idx) stack_ptr += 1 stack[stack_ptr] = BcBlock(block_method, None) + current_bc_idx += LEN_ONE_ARG elif bytecode == Bytecodes.push_constant: stack_ptr += 1 stack[stack_ptr] = method.get_constant(current_bc_idx) + current_bc_idx += LEN_ONE_ARG elif bytecode == Bytecodes.push_constant_0: stack_ptr += 1 stack[stack_ptr] = method._literals[0] # pylint: disable=protected-access + current_bc_idx += LEN_NO_ARGS elif bytecode == Bytecodes.push_constant_1: stack_ptr += 1 stack[stack_ptr] = method._literals[1] # pylint: disable=protected-access + current_bc_idx += LEN_NO_ARGS elif bytecode == Bytecodes.push_constant_2: stack_ptr += 1 stack[stack_ptr] = method._literals[2] # pylint: disable=protected-access + current_bc_idx += LEN_NO_ARGS elif bytecode == Bytecodes.push_0: stack_ptr += 1 stack[stack_ptr] = int_0 + current_bc_idx += LEN_NO_ARGS elif bytecode == Bytecodes.push_1: stack_ptr += 1 stack[stack_ptr] = int_1 + current_bc_idx += LEN_NO_ARGS elif bytecode == Bytecodes.push_nil: stack_ptr += 1 stack[stack_ptr] = nilObject + current_bc_idx += LEN_NO_ARGS elif bytecode == Bytecodes.push_global: global_name = method.get_constant(current_bc_idx) @@ -251,11 +272,13 @@ def interpret(method, frame, max_stack_size): stack[stack_ptr] = lookup_and_send_2( get_self_dynamically(frame), global_name, "unknownGlobal:" ) + current_bc_idx += LEN_ONE_ARG elif bytecode == Bytecodes.pop: if we_are_jitted(): stack[stack_ptr] = None stack_ptr -= 1 + current_bc_idx += LEN_NO_ARGS elif bytecode == Bytecodes.pop_frame: value = stack[stack_ptr] @@ -263,6 +286,7 @@ def interpret(method, frame, max_stack_size): stack[stack_ptr] = None stack_ptr -= 1 write_frame(frame, method.get_bytecode(current_bc_idx + 1), value) + current_bc_idx += LEN_TWO_ARGS elif bytecode == Bytecodes.pop_frame_0: value = stack[stack_ptr] @@ -270,6 +294,7 @@ def interpret(method, frame, max_stack_size): stack[stack_ptr] = None stack_ptr -= 1 write_frame(frame, FRAME_AND_INNER_RCVR_IDX + 0, value) + current_bc_idx += LEN_TWO_ARGS elif bytecode == Bytecodes.pop_frame_1: value = stack[stack_ptr] @@ -277,6 +302,7 @@ def interpret(method, frame, max_stack_size): stack[stack_ptr] = None stack_ptr -= 1 write_frame(frame, FRAME_AND_INNER_RCVR_IDX + 1, value) + current_bc_idx += LEN_TWO_ARGS elif bytecode == Bytecodes.pop_frame_2: value = stack[stack_ptr] @@ -284,6 +310,7 @@ def interpret(method, frame, max_stack_size): stack[stack_ptr] = None stack_ptr -= 1 write_frame(frame, FRAME_AND_INNER_RCVR_IDX + 2, value) + current_bc_idx += LEN_TWO_ARGS elif bytecode == Bytecodes.pop_inner: idx = method.get_bytecode(current_bc_idx + 1) @@ -298,6 +325,7 @@ def interpret(method, frame, max_stack_size): else: block = get_block_at(frame, ctx_level) block.set_outer(idx, value) + current_bc_idx += LEN_TWO_ARGS elif bytecode == Bytecodes.pop_inner_0: value = stack[stack_ptr] @@ -306,6 +334,7 @@ def interpret(method, frame, max_stack_size): stack_ptr -= 1 write_inner(frame, FRAME_AND_INNER_RCVR_IDX + 0, value) + current_bc_idx += LEN_TWO_ARGS elif bytecode == Bytecodes.pop_inner_1: value = stack[stack_ptr] @@ -314,6 +343,7 @@ def interpret(method, frame, max_stack_size): stack_ptr -= 1 write_inner(frame, FRAME_AND_INNER_RCVR_IDX + 1, value) + current_bc_idx += LEN_TWO_ARGS elif bytecode == Bytecodes.pop_inner_2: value = stack[stack_ptr] @@ -322,6 +352,7 @@ def interpret(method, frame, max_stack_size): stack_ptr -= 1 write_inner(frame, FRAME_AND_INNER_RCVR_IDX + 2, value) + current_bc_idx += LEN_TWO_ARGS elif bytecode == Bytecodes.pop_field: field_idx = method.get_bytecode(current_bc_idx + 1) @@ -334,6 +365,7 @@ def interpret(method, frame, max_stack_size): stack_ptr -= 1 self_obj.set_field(field_idx, value) + current_bc_idx += LEN_TWO_ARGS elif bytecode == Bytecodes.pop_field_0: self_obj = read_frame(frame, FRAME_AND_INNER_RCVR_IDX) @@ -344,6 +376,7 @@ def interpret(method, frame, max_stack_size): stack_ptr -= 1 self_obj.set_field(0, value) + current_bc_idx += LEN_NO_ARGS elif bytecode == Bytecodes.pop_field_1: self_obj = read_frame(frame, FRAME_AND_INNER_RCVR_IDX) @@ -354,6 +387,7 @@ def interpret(method, frame, max_stack_size): stack_ptr -= 1 self_obj.set_field(1, value) + current_bc_idx += LEN_NO_ARGS elif bytecode == Bytecodes.send_1: receiver = stack[stack_ptr] @@ -367,6 +401,7 @@ def interpret(method, frame, max_stack_size): ) stack[stack_ptr] = dispatch_node.dispatch_1(receiver) + current_bc_idx += LEN_ONE_ARG elif bytecode == Bytecodes.send_2: receiver = stack[stack_ptr - 1] @@ -385,6 +420,7 @@ def interpret(method, frame, max_stack_size): stack_ptr -= 1 stack[stack_ptr] = dispatch_node.dispatch_2(receiver, arg) + current_bc_idx += LEN_ONE_ARG elif bytecode == Bytecodes.send_3: receiver = stack[stack_ptr - 2] @@ -405,6 +441,7 @@ def interpret(method, frame, max_stack_size): stack_ptr -= 2 stack[stack_ptr] = dispatch_node.dispatch_3(receiver, arg1, arg2) + current_bc_idx += LEN_ONE_ARG elif bytecode == Bytecodes.send_n: signature = method.get_constant(current_bc_idx) @@ -421,9 +458,11 @@ def interpret(method, frame, max_stack_size): ) stack_ptr = dispatch_node.dispatch_n_bc(stack, stack_ptr, receiver) + current_bc_idx += LEN_ONE_ARG elif bytecode == Bytecodes.super_send: stack_ptr = _do_super_send(current_bc_idx, method, stack, stack_ptr) + current_bc_idx += LEN_ONE_ARG elif bytecode == Bytecodes.return_local: return stack[stack_ptr] @@ -464,6 +503,7 @@ def interpret(method, frame, max_stack_size): else: return _not_yet_implemented() stack[stack_ptr] = result + current_bc_idx += LEN_NO_ARGS elif bytecode == Bytecodes.dec: val = stack[stack_ptr] @@ -480,6 +520,7 @@ def interpret(method, frame, max_stack_size): else: return _not_yet_implemented() stack[stack_ptr] = result + current_bc_idx += LEN_NO_ARGS elif bytecode == Bytecodes.inc_field: field_idx = method.get_bytecode(current_bc_idx + 1) @@ -487,6 +528,7 @@ def interpret(method, frame, max_stack_size): self_obj = get_self(frame, ctx_level) self_obj.inc_field(field_idx) + current_bc_idx += LEN_TWO_ARGS elif bytecode == Bytecodes.inc_field_push: field_idx = method.get_bytecode(current_bc_idx + 1) @@ -495,34 +537,39 @@ def interpret(method, frame, max_stack_size): stack_ptr += 1 stack[stack_ptr] = self_obj.inc_field(field_idx) + current_bc_idx += LEN_TWO_ARGS elif bytecode == Bytecodes.jump: - next_bc_idx = current_bc_idx + method.get_bytecode(current_bc_idx + 1) + current_bc_idx += method.get_bytecode(current_bc_idx + 1) elif bytecode == Bytecodes.jump_on_true_top_nil: val = stack[stack_ptr] if val is trueObject: - next_bc_idx = current_bc_idx + method.get_bytecode(current_bc_idx + 1) + current_bc_idx += method.get_bytecode(current_bc_idx + 1) stack[stack_ptr] = nilObject else: if we_are_jitted(): stack[stack_ptr] = None stack_ptr -= 1 + current_bc_idx += LEN_TWO_ARGS elif bytecode == Bytecodes.jump_on_false_top_nil: val = stack[stack_ptr] if val is falseObject: - next_bc_idx = current_bc_idx + method.get_bytecode(current_bc_idx + 1) + current_bc_idx += method.get_bytecode(current_bc_idx + 1) stack[stack_ptr] = nilObject else: if we_are_jitted(): stack[stack_ptr] = None stack_ptr -= 1 + current_bc_idx += LEN_TWO_ARGS elif bytecode == Bytecodes.jump_on_true_pop: val = stack[stack_ptr] if val is trueObject: - next_bc_idx = current_bc_idx + method.get_bytecode(current_bc_idx + 1) + current_bc_idx += method.get_bytecode(current_bc_idx + 1) + else: + current_bc_idx += LEN_TWO_ARGS if we_are_jitted(): stack[stack_ptr] = None stack_ptr -= 1 @@ -530,15 +577,17 @@ def interpret(method, frame, max_stack_size): elif bytecode == Bytecodes.jump_on_false_pop: val = stack[stack_ptr] if val is falseObject: - next_bc_idx = current_bc_idx + method.get_bytecode(current_bc_idx + 1) + current_bc_idx += method.get_bytecode(current_bc_idx + 1) + else: + current_bc_idx += LEN_TWO_ARGS if we_are_jitted(): stack[stack_ptr] = None stack_ptr -= 1 elif bytecode == Bytecodes.jump_backward: - next_bc_idx = current_bc_idx - method.get_bytecode(current_bc_idx + 1) + current_bc_idx -= method.get_bytecode(current_bc_idx + 1) jitdriver.can_enter_jit( - current_bc_idx=next_bc_idx, + current_bc_idx=current_bc_idx, stack_ptr=stack_ptr, method=method, frame=frame, @@ -546,48 +595,44 @@ def interpret(method, frame, max_stack_size): ) elif bytecode == Bytecodes.jump2: - next_bc_idx = ( - current_bc_idx - + method.get_bytecode(current_bc_idx + 1) - + (method.get_bytecode(current_bc_idx + 2) << 8) + current_bc_idx += method.get_bytecode(current_bc_idx + 1) + ( + method.get_bytecode(current_bc_idx + 2) << 8 ) elif bytecode == Bytecodes.jump2_on_true_top_nil: val = stack[stack_ptr] if val is trueObject: - next_bc_idx = ( - current_bc_idx - + method.get_bytecode(current_bc_idx + 1) - + (method.get_bytecode(current_bc_idx + 2) << 8) + current_bc_idx += method.get_bytecode(current_bc_idx + 1) + ( + method.get_bytecode(current_bc_idx + 2) << 8 ) stack[stack_ptr] = nilObject else: if we_are_jitted(): stack[stack_ptr] = None stack_ptr -= 1 + current_bc_idx += LEN_TWO_ARGS elif bytecode == Bytecodes.jump2_on_false_top_nil: val = stack[stack_ptr] if val is falseObject: - next_bc_idx = ( - current_bc_idx - + method.get_bytecode(current_bc_idx + 1) - + (method.get_bytecode(current_bc_idx + 2) << 8) + current_bc_idx += method.get_bytecode(current_bc_idx + 1) + ( + method.get_bytecode(current_bc_idx + 2) << 8 ) stack[stack_ptr] = nilObject else: if we_are_jitted(): stack[stack_ptr] = None stack_ptr -= 1 + current_bc_idx += LEN_TWO_ARGS elif bytecode == Bytecodes.jump2_on_true_pop: val = stack[stack_ptr] if val is trueObject: - next_bc_idx = ( - current_bc_idx - + method.get_bytecode(current_bc_idx + 1) - + (method.get_bytecode(current_bc_idx + 2) << 8) + current_bc_idx += method.get_bytecode(current_bc_idx + 1) + ( + method.get_bytecode(current_bc_idx + 2) << 8 ) + else: + current_bc_idx += LEN_TWO_ARGS if we_are_jitted(): stack[stack_ptr] = None stack_ptr -= 1 @@ -595,22 +640,21 @@ def interpret(method, frame, max_stack_size): elif bytecode == Bytecodes.jump2_on_false_pop: val = stack[stack_ptr] if val is falseObject: - next_bc_idx = ( - current_bc_idx - + method.get_bytecode(current_bc_idx + 1) - + (method.get_bytecode(current_bc_idx + 2) << 8) + current_bc_idx += method.get_bytecode(current_bc_idx + 1) + ( + method.get_bytecode(current_bc_idx + 2) << 8 ) + else: + current_bc_idx += LEN_TWO_ARGS if we_are_jitted(): stack[stack_ptr] = None stack_ptr -= 1 elif bytecode == Bytecodes.jump2_backward: - next_bc_idx = current_bc_idx - ( - method.get_bytecode(current_bc_idx + 1) - + (method.get_bytecode(current_bc_idx + 2) << 8) + current_bc_idx -= method.get_bytecode(current_bc_idx + 1) + ( + method.get_bytecode(current_bc_idx + 2) << 8 ) jitdriver.can_enter_jit( - current_bc_idx=next_bc_idx, + current_bc_idx=current_bc_idx, stack_ptr=stack_ptr, method=method, frame=frame, @@ -620,6 +664,7 @@ def interpret(method, frame, max_stack_size): elif bytecode == Bytecodes.q_super_send_1: dispatch_node = method.get_inline_cache(current_bc_idx) stack[stack_ptr] = dispatch_node.dispatch_1(stack[stack_ptr]) + current_bc_idx += LEN_ONE_ARG elif bytecode == Bytecodes.q_super_send_2: dispatch_node = method.get_inline_cache(current_bc_idx) @@ -628,6 +673,7 @@ def interpret(method, frame, max_stack_size): stack[stack_ptr] = None stack_ptr -= 1 stack[stack_ptr] = dispatch_node.dispatch_2(stack[stack_ptr], arg) + current_bc_idx += LEN_ONE_ARG elif bytecode == Bytecodes.q_super_send_3: dispatch_node = method.get_inline_cache(current_bc_idx) @@ -638,32 +684,28 @@ def interpret(method, frame, max_stack_size): stack[stack_ptr - 1] = None stack_ptr -= 2 stack[stack_ptr] = dispatch_node.dispatch_3(stack[stack_ptr], arg1, arg2) + current_bc_idx += LEN_ONE_ARG elif bytecode == Bytecodes.q_super_send_n: dispatch_node = method.get_inline_cache(current_bc_idx) stack_ptr = dispatch_node.dispatch_n_bc(stack, stack_ptr, None) + current_bc_idx += LEN_ONE_ARG elif bytecode == Bytecodes.push_local: method.patch_variable_access(current_bc_idx) # retry bytecode after patching - next_bc_idx = current_bc_idx elif bytecode == Bytecodes.push_argument: method.patch_variable_access(current_bc_idx) # retry bytecode after patching - next_bc_idx = current_bc_idx elif bytecode == Bytecodes.pop_local: method.patch_variable_access(current_bc_idx) # retry bytecode after patching - next_bc_idx = current_bc_idx elif bytecode == Bytecodes.pop_argument: method.patch_variable_access(current_bc_idx) # retry bytecode after patching - next_bc_idx = current_bc_idx else: _unknown_bytecode(bytecode, current_bc_idx, method) - current_bc_idx = next_bc_idx - def _not_yet_implemented(): raise Exception("Not yet implemented")