Commit 5676aaa2 authored by Marius Wachtler's avatar Marius Wachtler

bjit: inline trivial helper functions

parent 8728a053
......@@ -1570,6 +1570,10 @@ Value ASTInterpreter::visit_attribute(AST_Attribute* node) {
}
int ASTInterpreterJitInterface::getBoxedLocalsOffset() {
return offsetof(ASTInterpreter, frame_info.boxedLocals);
}
int ASTInterpreterJitInterface::getCurrentBlockOffset() {
return offsetof(ASTInterpreter, current_block);
}
......@@ -1578,6 +1582,14 @@ int ASTInterpreterJitInterface::getCurrentInstOffset() {
return offsetof(ASTInterpreter, current_inst);
}
int ASTInterpreterJitInterface::getGeneratorOffset() {
return offsetof(ASTInterpreter, generator);
}
int ASTInterpreterJitInterface::getGlobalsOffset() {
return offsetof(ASTInterpreter, globals);
}
Box* ASTInterpreterJitInterface::derefHelper(void* _interpreter, InternedString s) {
ASTInterpreter* interpreter = (ASTInterpreter*)_interpreter;
DerefInfo deref_info = interpreter->scope_info->getDerefInfo(s);
......@@ -1601,16 +1613,6 @@ Box* ASTInterpreterJitInterface::doOSRHelper(void* _interpreter, AST_Jump* node)
return NULL;
}
Box* ASTInterpreterJitInterface::getBoxedLocalHelper(void* _interpreter, BoxedString* s) {
ASTInterpreter* interpreter = (ASTInterpreter*)_interpreter;
return boxedLocalsGet(interpreter->frame_info.boxedLocals, s, interpreter->globals);
}
Box* ASTInterpreterJitInterface::getBoxedLocalsHelper(void* _interpreter) {
ASTInterpreter* interpreter = (ASTInterpreter*)_interpreter;
return interpreter->frame_info.boxedLocals;
}
Box* ASTInterpreterJitInterface::getLocalHelper(void* _interpreter, InternedString id) {
ASTInterpreter* interpreter = (ASTInterpreter*)_interpreter;
......@@ -1648,17 +1650,6 @@ Box* ASTInterpreterJitInterface::uncacheExcInfoHelper(void* _interpreter) {
return None;
}
Box* ASTInterpreterJitInterface::yieldHelper(void* _interpreter, Box* val) {
ASTInterpreter* interpreter = (ASTInterpreter*)_interpreter;
return yield(interpreter->generator, val);
}
void ASTInterpreterJitInterface::setItemNameHelper(void* _interpreter, Box* str, Box* val) {
ASTInterpreter* interpreter = (ASTInterpreter*)_interpreter;
assert(interpreter->frame_info.boxedLocals != NULL);
setitem(interpreter->frame_info.boxedLocals, str, val);
}
void ASTInterpreterJitInterface::setLocalClosureHelper(void* _interpreter, InternedString id, Box* v) {
ASTInterpreter* interpreter = (ASTInterpreter*)_interpreter;
......
......@@ -35,19 +35,18 @@ struct LineInfo;
extern const void* interpreter_instr_addr;
struct ASTInterpreterJitInterface {
static int getBoxedLocalsOffset();
static int getCurrentBlockOffset();
static int getCurrentInstOffset();
static int getGeneratorOffset();
static int getGlobalsOffset();
static Box* derefHelper(void* interp, InternedString s);
static Box* doOSRHelper(void* interp, AST_Jump* node);
static Box* getBoxedLocalHelper(void* interp, BoxedString* s);
static Box* getBoxedLocalsHelper(void* interp);
static Box* getLocalHelper(void* interp, InternedString id);
static Box* landingpadHelper(void* interp);
static Box* setExcInfoHelper(void* interp, Box* type, Box* value, Box* traceback);
static Box* uncacheExcInfoHelper(void* interp);
static Box* yieldHelper(void* interp, Box* val);
static void setItemNameHelper(void* interp, Box* str, Box* val);
static void setLocalClosureHelper(void* interp, InternedString id, Box* v);
static void setLocalHelper(void* interp, InternedString id, Box* v);
};
......
......@@ -21,6 +21,7 @@
#include "codegen/memmgr.h"
#include "codegen/type_recording.h"
#include "core/cfg.h"
#include "runtime/generator.h"
#include "runtime/inline/list.h"
#include "runtime/objmodel.h"
#include "runtime/set.h"
......@@ -286,11 +287,13 @@ RewriterVar* JitFragmentWriter::emitGetBlockLocal(InternedString s) {
}
RewriterVar* JitFragmentWriter::emitGetBoxedLocal(BoxedString* s) {
return call(false, (void*)ASTInterpreterJitInterface::getBoxedLocalHelper, getInterp(), imm(s));
RewriterVar* boxed_locals = emitGetBoxedLocals();
RewriterVar* globals = getInterp()->getAttr(ASTInterpreterJitInterface::getGlobalsOffset());
return call(false, (void*)boxedLocalsGet, boxed_locals, imm(s), globals);
}
RewriterVar* JitFragmentWriter::emitGetBoxedLocals() {
return call(false, (void*)ASTInterpreterJitInterface::getBoxedLocalsHelper, getInterp());
return getInterp()->getAttr(ASTInterpreterJitInterface::getBoxedLocalsOffset());
}
RewriterVar* JitFragmentWriter::emitGetClsAttr(RewriterVar* obj, BoxedString* s) {
......@@ -396,7 +399,8 @@ RewriterVar* JitFragmentWriter::emitUnpackIntoArray(RewriterVar* v, uint64_t num
}
RewriterVar* JitFragmentWriter::emitYield(RewriterVar* v) {
return call(false, (void*)ASTInterpreterJitInterface::yieldHelper, getInterp(), v);
RewriterVar* generator = getInterp()->getAttr(ASTInterpreterJitInterface::getGeneratorOffset());
return call(false, (void*)yield, generator, v);
}
......@@ -464,7 +468,7 @@ void JitFragmentWriter::emitSetItem(RewriterVar* target, RewriterVar* slice, Rew
}
void JitFragmentWriter::emitSetItemName(BoxedString* s, RewriterVar* v) {
call(false, (void*)ASTInterpreterJitInterface::setItemNameHelper, getInterp(), imm(s), v);
emitSetItem(emitGetBoxedLocals(), imm(s), v);
}
void JitFragmentWriter::emitSetLocal(InternedString s, bool set_closure, RewriterVar* v) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment