Bug 1522837 part 8 - Implement JSOP_GETIMPORT in BaselineInterpreterCodeGen. r=tcampbell

Eventually this op could use an IC or some frontend/bytecode refactoring to make
it faster in the interpreter. For now following the C++ interpreter is the
simplest solution though.

Differential Revision: https://phabricator.services.mozilla.com/D17939

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Jan de Mooij 2019-01-31 18:13:25 +00:00
Родитель bd4243cae1
Коммит 0c7e884af5
3 изменённых файлов: 39 добавлений и 7 удалений

Просмотреть файл

@ -3312,9 +3312,35 @@ bool BaselineCompilerCodeGen::emit_JSOP_GETIMPORT() {
return true;
}
typedef bool (*GetImportOperationFn)(JSContext*, HandleObject, HandleScript,
jsbytecode*, MutableHandleValue);
static const VMFunction GetImportOperationInfo =
FunctionInfo<GetImportOperationFn>(GetImportOperation,
"GetImportOperation");
template <>
bool BaselineInterpreterCodeGen::emit_JSOP_GETIMPORT() {
MOZ_CRASH("NYI: interpreter JSOP_GETIMPORT");
frame.syncStack(0);
masm.loadPtr(frame.addressOfEnvironmentChain(), R0.scratchReg());
prepareVMCall();
pushBytecodePCArg();
pushScriptArg(R2.scratchReg());
pushArg(R0.scratchReg());
if (!callVM(GetImportOperationInfo)) {
return false;
}
// Enter the type monitor IC.
if (!emitNextIC()) {
return false;
}
frame.push(R0);
return true;
}
template <typename Handler>

Просмотреть файл

@ -243,13 +243,14 @@ static inline bool GetNameOperation(JSContext* cx, InterpreterFrame* fp,
return GetEnvironmentName<GetNameMode::Normal>(cx, envChain, name, vp);
}
static inline bool GetImportOperation(JSContext* cx, InterpreterFrame* fp,
jsbytecode* pc, MutableHandleValue vp) {
RootedObject obj(cx, fp->environmentChain()), env(cx), pobj(cx);
RootedPropertyName name(cx, fp->script()->getName(pc));
bool js::GetImportOperation(JSContext* cx, HandleObject envChain,
HandleScript script, jsbytecode* pc,
MutableHandleValue vp) {
RootedObject env(cx), pobj(cx);
RootedPropertyName name(cx, script->getName(pc));
Rooted<PropertyResult> prop(cx);
MOZ_ALWAYS_TRUE(LookupName(cx, name, obj, &env, &pobj, &prop));
MOZ_ALWAYS_TRUE(LookupName(cx, name, envChain, &env, &pobj, &prop));
MOZ_ASSERT(env && env->is<ModuleEnvironmentObject>());
MOZ_ASSERT(env->as<ModuleEnvironmentObject>().hasImportBinding(name));
return FetchName<GetNameMode::Normal>(cx, env, pobj, name, prop, vp);
@ -3229,7 +3230,8 @@ static MOZ_NEVER_INLINE JS_HAZ_JSNATIVE_CALLER bool Interpret(JSContext* cx,
CASE(JSOP_GETIMPORT) {
PUSH_NULL();
MutableHandleValue rval = REGS.stackHandleAt(-1);
if (!GetImportOperation(cx, REGS.fp(), REGS.pc, rval)) {
HandleObject envChain = REGS.fp()->environmentChain();
if (!GetImportOperation(cx, envChain, script, REGS.pc, rval)) {
goto error;
}

Просмотреть файл

@ -551,6 +551,10 @@ JSObject* NewArrayOperationWithTemplate(JSContext* cx,
ArrayObject* NewArrayCopyOnWriteOperation(JSContext* cx, HandleScript script,
jsbytecode* pc);
MOZ_MUST_USE bool GetImportOperation(JSContext* cx, HandleObject envChain,
HandleScript script, jsbytecode* pc,
MutableHandleValue vp);
void ReportRuntimeLexicalError(JSContext* cx, unsigned errorNumber,
HandleId id);