Skip to content

Commit

Permalink
Bug 1607670 part 3 - Split jit::CreateThis in CreateThisFromIC and Cr…
Browse files Browse the repository at this point in the history
…eateThisFromIon. r=tcampbell

The callers are very different and have different constraints, especially in
later patches in this stack.

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

--HG--
extra : moz-landing-system : lando
  • Loading branch information
jandem committed Jan 21, 2020
1 parent 817caff commit 3b4f46a
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 17 deletions.
4 changes: 2 additions & 2 deletions js/src/jit/BaselineCacheIRCompiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2669,10 +2669,10 @@ void BaselineCacheIRCompiler::createThis(Register argcReg, Register calleeReg,
loadStackObject(ArgumentKind::Callee, flags, depth, argcReg, scratch);
masm.push(scratch);

// Call CreateThis
// Call CreateThisFromIC.
using Fn =
bool (*)(JSContext*, HandleObject, HandleObject, MutableHandleValue);
callVM<Fn, CreateThis>(masm);
callVM<Fn, CreateThisFromIC>(masm);

#ifdef DEBUG
Label createdThisOK;
Expand Down
2 changes: 1 addition & 1 deletion js/src/jit/CodeGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6968,7 +6968,7 @@ void CodeGenerator::visitCreateThis(LCreateThis* lir) {

using Fn = bool (*)(JSContext * cx, HandleObject callee,
HandleObject newTarget, MutableHandleValue rval);
callVM<Fn, jit::CreateThis>(lir);
callVM<Fn, jit::CreateThisFromIon>(lir);
}

void CodeGenerator::visitCreateThisWithProto(LCreateThisWithProto* lir) {
Expand Down
3 changes: 2 additions & 1 deletion js/src/jit/VMFunctionList-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,9 @@ namespace jit {
_(CreateAsyncFromSyncIterator, js::CreateAsyncFromSyncIterator) \
_(CreateDerivedTypedObj, js::jit::CreateDerivedTypedObj) \
_(CreateGenerator, js::jit::CreateGenerator) \
_(CreateThis, js::jit::CreateThis) \
_(CreateThisForFunctionWithProto, js::CreateThisForFunctionWithProto) \
_(CreateThisFromIC, js::jit::CreateThisFromIC) \
_(CreateThisFromIon, js::jit::CreateThisFromIon) \
_(CreateThisWithTemplate, js::CreateThisWithTemplate) \
_(DebugAfterYield, js::jit::DebugAfterYield) \
_(DebugEpilogueOnBaselineReturn, js::jit::DebugEpilogueOnBaselineReturn) \
Expand Down
43 changes: 32 additions & 11 deletions js/src/jit/VMFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -681,21 +681,42 @@ bool GetIntrinsicValue(JSContext* cx, HandlePropertyName name,
return true;
}

bool CreateThis(JSContext* cx, HandleObject callee, HandleObject newTarget,
MutableHandleValue rval) {
bool CreateThisFromIC(JSContext* cx, HandleObject callee,
HandleObject newTarget, MutableHandleValue rval) {
HandleFunction fun = callee.as<JSFunction>();
MOZ_ASSERT(fun->isInterpreted());
MOZ_ASSERT(fun->isConstructor());

// CreateThis expects rval to be this magic value.
rval.set(MagicValue(JS_IS_CONSTRUCTING));

if (callee->is<JSFunction>()) {
RootedFunction fun(cx, &callee->as<JSFunction>());
if (fun->isInterpreted() && fun->isConstructor()) {
if (!js::CreateThis(cx, fun, newTarget, GenericObject, rval)) {
return false;
}
MOZ_ASSERT_IF(rval.isObject(),
fun->realm() == rval.toObject().nonCCWRealm());
}
if (!js::CreateThis(cx, fun, newTarget, GenericObject, rval)) {
return false;
}

MOZ_ASSERT_IF(rval.isObject(), fun->realm() == rval.toObject().nonCCWRealm());
return true;
}

bool CreateThisFromIon(JSContext* cx, HandleObject callee,
HandleObject newTarget, MutableHandleValue rval) {
// Return JS_IS_CONSTRUCTING for cases not supported by the inline call path.
rval.set(MagicValue(JS_IS_CONSTRUCTING));

if (!callee->is<JSFunction>()) {
return true;
}

HandleFunction fun = callee.as<JSFunction>();
if (!fun->isInterpreted() || !fun->isConstructor()) {
return true;
}

if (!js::CreateThis(cx, fun, newTarget, GenericObject, rval)) {
return false;
}

MOZ_ASSERT_IF(rval.isObject(), fun->realm() == rval.toObject().nonCCWRealm());
return true;
}

Expand Down
8 changes: 6 additions & 2 deletions js/src/jit/VMFunctions.h
Original file line number Diff line number Diff line change
Expand Up @@ -927,8 +927,12 @@ bool OperatorInI(JSContext* cx, uint32_t index, HandleObject obj, bool* out);
MOZ_MUST_USE bool GetIntrinsicValue(JSContext* cx, HandlePropertyName name,
MutableHandleValue rval);

MOZ_MUST_USE bool CreateThis(JSContext* cx, HandleObject callee,
HandleObject newTarget, MutableHandleValue rval);
MOZ_MUST_USE bool CreateThisFromIC(JSContext* cx, HandleObject callee,
HandleObject newTarget,
MutableHandleValue rval);
MOZ_MUST_USE bool CreateThisFromIon(JSContext* cx, HandleObject callee,
HandleObject newTarget,
MutableHandleValue rval);

bool GetDynamicNamePure(JSContext* cx, JSObject* scopeChain, JSString* str,
Value* vp);
Expand Down

0 comments on commit 3b4f46a

Please sign in to comment.