Skip to content

Commit

Permalink
Add asm interpreter implementation of LOAD_ATTR_INSTANCE_SLOT_DESCR
Browse files Browse the repository at this point in the history
For richards.py this occurs 25330 times, according to the bpftrace
script. It is not the hottest, but it is easy to implement.

(smaller)
...
@interpreter_deopt[usdt:./build/bin/python:python:InterpreterDeopt_COMPARE_IN_MONOMORPHIC]: 14073
@interpreter_deopt[usdt:./build/bin/python:python:InterpreterDeopt_COMPARE_EQ_STR]: 17581
@interpreter_deopt[usdt:./build/bin/python:python:InterpreterDeopt_LOAD_ATTR_INSTANCE_TYPE]: 19845
@interpreter_deopt[usdt:./build/bin/python:python:InterpreterDeopt_LOAD_ATTR_INSTANCE_SLOT_DESCR]: 25330
@interpreter_deopt[usdt:./build/bin/python:python:InterpreterDeopt_BUILD_TUPLE]: 27540
@interpreter_deopt[usdt:./build/bin/python:python:InterpreterDeopt_GET_ITER]: 44881
@interpreter_deopt[usdt:./build/bin/python:python:InterpreterDeopt_INPLACE_OP_MONOMORPHIC]: 56030
@interpreter_deopt[usdt:./build/bin/python:python:InterpreterDeopt_BINARY_FLOORDIV_SMALLINT]: 57701
@interpreter_deopt[usdt:./build/bin/python:python:InterpreterDeopt_BINARY_OP_MONOMORPHIC]: 58618
(higher)
  • Loading branch information
tekknolagi committed Apr 17, 2023
1 parent 14b270e commit d106b9c
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions runtime/interpreter-gen-x64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1223,6 +1223,35 @@ void emitHandler<LOAD_ATTR_INSTANCE>(EmitEnv* env) {
emitJumpToGenericHandler(env);
}

template <>
void emitHandler<LOAD_ATTR_INSTANCE_SLOT_DESCR>(EmitEnv* env) {
ScratchReg r_base(env);
ScratchReg r_layout_id(env);
ScratchReg r_offset(env);
ScratchReg r_caches(env);
ScratchReg r_result(env);
Label slow_path;
__ popq(r_base);
emitGetLayoutId(env, r_layout_id, r_base);
__ movq(r_caches, Address(env->frame, Frame::kCachesOffset));
emitIcLookupMonomorphic(env, &slow_path, r_offset, r_layout_id, r_caches);

emitConvertFromSmallInt(env, r_offset);
__ movq(r_result, Address(r_base, r_offset, TIMES_1, heapObjectDisp(0)));
__ cmpl(r_result, Immediate(Unbound::object().raw()));
__ jcc(EQUAL, &slow_path, Assembler::kNearJump);
__ pushq(r_result);
emitNextOpcode(env);

__ bind(&slow_path);
__ pushq(r_base);
if (env->in_jit) {
emitJumpToDeopt(env);
return;
}
emitJumpToGenericHandler(env);
}

template <>
void emitHandler<LOAD_ATTR_INSTANCE_TYPE_BOUND_METHOD>(EmitEnv* env) {
ScratchReg r_base(env);
Expand Down

0 comments on commit d106b9c

Please sign in to comment.