Skip to content

Commit

Permalink
Make sure we use the specialized bytecodes (#38)
Browse files Browse the repository at this point in the history
This fixes some minor omissions when inlining.
  • Loading branch information
smarr authored Aug 2, 2024
2 parents d58e27c + cf723f7 commit 0797e2e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions rebench.conf
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ reporting:

runs:
max_invocation_time: 300
min_iteration_time: 10

benchmark_suites:
macro:
Expand Down
11 changes: 11 additions & 0 deletions src/interpreter/Interpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,10 @@ void Interpreter::doPushLocal(long bytecodeIndex) {
uint8_t bc1 = method->GetBytecode(bytecodeIndex + 1);
uint8_t bc2 = method->GetBytecode(bytecodeIndex + 2);

assert(!(bc1 == 0 && bc2 == 0 && "should have been BC_PUSH_LOCAL_0"));
assert(!(bc1 == 1 && bc2 == 0 && "should have been BC_PUSH_LOCAL_1"));
assert(!(bc1 == 2 && bc2 == 0 && "should have been BC_PUSH_LOCAL_2"));

vm_oop_t local = GetFrame()->GetLocal(bc1, bc2);

GetFrame()->Push(local);
Expand All @@ -207,13 +211,20 @@ void Interpreter::doPushArgument(long bytecodeIndex) {
uint8_t bc1 = method->GetBytecode(bytecodeIndex + 1);
uint8_t bc2 = method->GetBytecode(bytecodeIndex + 2);

assert(!(bc1 == 0 && bc2 == 0 && "should have been BC_PUSH_SELF"));
assert(!(bc1 == 1 && bc2 == 0 && "should have been BC_PUSH_ARG_1"));
assert(!(bc1 == 2 && bc2 == 0 && "should have been BC_PUSH_ARG_2"));

vm_oop_t argument = GetFrame()->GetArgument(bc1, bc2);

GetFrame()->Push(argument);
}

void Interpreter::doPushField(long bytecodeIndex) {
uint8_t fieldIndex = method->GetBytecode(bytecodeIndex + 1);
assert(fieldIndex != 0 && fieldIndex != 1 &&
"should have been BC_PUSH_FIELD_0|1");

doPushFieldWithIndex(fieldIndex);
}

Expand Down
4 changes: 2 additions & 2 deletions src/vmobjects/VMMethod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,9 +283,9 @@ void VMMethod::inlineInto(MethodGenerationContext& mgenc) {
}

if (bytecode == BC_PUSH_LOCAL) {
Emit3(mgenc, bytecode, idx, ctxLevel, 1);
EmitPUSHLOCAL(mgenc, idx, ctxLevel);
} else {
Emit3(mgenc, bytecode, idx, ctxLevel, -1);
EmitPOPLOCAL(mgenc, idx, ctxLevel);
}
break;
}
Expand Down

0 comments on commit 0797e2e

Please sign in to comment.