Bug 1480524 - [Part 3] Move ICNewObject_Fallback out of SharedIC and remove non-CacheIR code generation r=jandem

--HG--
extra : rebase_source : 6324e6a5379b82e567e99b48657d8502b2360bc0
This commit is contained in:
Matthew Gaudet 2018-08-07 15:31:19 -04:00
Родитель 068e37e2c7
Коммит 7c9e88cb3a
4 изменённых файлов: 101 добавлений и 160 удалений

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

@ -5188,6 +5188,71 @@ ICNewArray_Fallback::Compiler::generateStubCode(MacroAssembler& masm)
return tailCallVM(DoNewArrayInfo, masm);
}
//
// NewObject_Fallback
//
static bool
DoNewObject(JSContext* cx, void* payload, ICNewObject_Fallback* stub, MutableHandleValue res)
{
SharedStubInfo info(cx, payload, stub->icEntry());
FallbackICSpew(cx, stub, "NewObject");
RootedObject obj(cx);
RootedObject templateObject(cx, stub->templateObject());
if (templateObject) {
MOZ_ASSERT(!templateObject->group()->maybePreliminaryObjectsDontCheckGeneration());
obj = NewObjectOperationWithTemplate(cx, templateObject);
} else {
HandleScript script = info.script();
jsbytecode* pc = info.pc();
obj = NewObjectOperation(cx, script, pc);
if (obj && !obj->isSingleton() &&
!obj->group()->maybePreliminaryObjectsDontCheckGeneration())
{
templateObject = NewObjectOperation(cx, script, pc, TenuredObject);
if (!templateObject)
return false;
if (!JitOptions.disableCacheIR) {
bool attached = false;
RootedScript script(cx, info.outerScript(cx));
NewObjectIRGenerator gen(cx, script, pc, stub->state().mode(), JSOp(*pc), templateObject);
if (gen.tryAttachStub()) {
ICStub* newStub = AttachBaselineCacheIRStub(cx, gen.writerRef(), gen.cacheKind(),
BaselineCacheIRStubKind::Regular,
ICStubEngine::Baseline , script, stub, &attached);
if (newStub)
JitSpew(JitSpew_BaselineIC, " NewObject Attached CacheIR stub");
}
}
stub->setTemplateObject(templateObject);
}
}
if (!obj)
return false;
res.setObject(*obj);
return true;
}
typedef bool(*DoNewObjectFn)(JSContext*, void*, ICNewObject_Fallback*, MutableHandleValue);
static const VMFunction DoNewObjectInfo =
FunctionInfo<DoNewObjectFn>(DoNewObject, "DoNewObject", TailCall);
bool
ICNewObject_Fallback::Compiler::generateStubCode(MacroAssembler& masm)
{
EmitRestoreTailCallReg(masm);
masm.push(ICStubReg); // stub.
pushStubPayload(masm, R0.scratchReg());
return tailCallVM(DoNewObjectInfo, masm);
}
} // namespace jit
} // namespace js

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

@ -1607,6 +1607,42 @@ class ICNewArray_Fallback : public ICFallbackStub
}
};
// JSOP_NEWOBJECT
class ICNewObject_Fallback : public ICFallbackStub
{
friend class ICStubSpace;
GCPtrObject templateObject_;
explicit ICNewObject_Fallback(JitCode* stubCode)
: ICFallbackStub(ICStub::NewObject_Fallback, stubCode), templateObject_(nullptr)
{}
public:
class Compiler : public ICStubCompiler {
MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm) override;
public:
explicit Compiler(JSContext* cx, Engine engine)
: ICStubCompiler(cx, ICStub::NewObject_Fallback, engine)
{}
ICStub* getStub(ICStubSpace* space) override {
return newStub<ICNewObject_Fallback>(space, getStubCode());
}
};
GCPtrObject& templateObject() {
return templateObject_;
}
void setTemplateObject(JSObject* obj) {
templateObject_ = obj;
}
};
inline bool
IsCacheableDOMProxy(JSObject* obj)
{

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

@ -1185,121 +1185,5 @@ ICUpdatedStub::addUpdateStubForValue(JSContext* cx, HandleScript outerScript, Ha
return true;
}
//
// NewObject_Fallback
//
// Unlike typical baseline IC stubs, the code for NewObject_WithTemplate is
// specialized for the template object being allocated.
static JitCode*
GenerateNewObjectWithTemplateCode(JSContext* cx, JSObject* templateObject)
{
JitContext jctx(cx, nullptr);
StackMacroAssembler masm;
#ifdef JS_CODEGEN_ARM
masm.setSecondScratchReg(BaselineSecondScratchReg);
#endif
Label failure;
Register objReg = R0.scratchReg();
Register tempReg = R1.scratchReg();
masm.branchIfPretenuredGroup(templateObject->group(), tempReg, &failure);
masm.branchPtr(Assembler::NotEqual, AbsoluteAddress(cx->realm()->addressOfMetadataBuilder()),
ImmWord(0), &failure);
TemplateObject templateObj(templateObject);
masm.createGCObject(objReg, tempReg, templateObj, gc::DefaultHeap, &failure);
masm.tagValue(JSVAL_TYPE_OBJECT, objReg, R0);
EmitReturnFromIC(masm);
masm.bind(&failure);
EmitStubGuardFailure(masm);
Linker linker(masm);
AutoFlushICache afc("GenerateNewObjectWithTemplateCode");
return linker.newCode(cx, CodeKind::Baseline);
}
static bool
DoNewObject(JSContext* cx, void* payload, ICNewObject_Fallback* stub, MutableHandleValue res)
{
SharedStubInfo info(cx, payload, stub->icEntry());
FallbackICSpew(cx, stub, "NewObject");
RootedObject obj(cx);
RootedObject templateObject(cx, stub->templateObject());
if (templateObject) {
MOZ_ASSERT(!templateObject->group()->maybePreliminaryObjectsDontCheckGeneration());
obj = NewObjectOperationWithTemplate(cx, templateObject);
} else {
HandleScript script = info.script();
jsbytecode* pc = info.pc();
obj = NewObjectOperation(cx, script, pc);
if (obj && !obj->isSingleton() &&
!obj->group()->maybePreliminaryObjectsDontCheckGeneration())
{
templateObject = NewObjectOperation(cx, script, pc, TenuredObject);
if (!templateObject)
return false;
ICStubCompiler::Engine engine = info.engine();
if (engine == ICStubEngine::Baseline && !JitOptions.disableCacheIR) {
bool attached = false;
RootedScript script(cx, info.outerScript(cx));
NewObjectIRGenerator gen(cx, script, pc, stub->state().mode(), JSOp(*pc), templateObject);
if (gen.tryAttachStub()) {
ICStub* newStub = AttachBaselineCacheIRStub(cx, gen.writerRef(), gen.cacheKind(),
BaselineCacheIRStubKind::Regular,
ICStubEngine::Baseline , script, stub, &attached);
if (newStub)
JitSpew(JitSpew_BaselineIC, " NewObject Attached CacheIR stub");
}
} else {
if (!stub->invalid() &&
(templateObject->is<UnboxedPlainObject>() ||
!templateObject->as<PlainObject>().hasDynamicSlots()))
{
JitCode* code = GenerateNewObjectWithTemplateCode(cx, templateObject);
if (!code)
return false;
ICStubSpace* space =
ICStubCompiler::StubSpaceForStub(/* makesGCCalls = */ false, script,
ICStubCompiler::Engine::Baseline);
ICStub* templateStub = ICStub::New<ICNewObject_WithTemplate>(cx, space, code);
if (!templateStub)
return false;
stub->addNewStub(templateStub);
}
}
stub->setTemplateObject(templateObject);
}
}
if (!obj)
return false;
res.setObject(*obj);
return true;
}
typedef bool(*DoNewObjectFn)(JSContext*, void*, ICNewObject_Fallback*, MutableHandleValue);
static const VMFunction DoNewObjectInfo =
FunctionInfo<DoNewObjectFn>(DoNewObject, "DoNewObject", TailCall);
bool
ICNewObject_Fallback::Compiler::generateStubCode(MacroAssembler& masm)
{
EmitRestoreTailCallReg(masm);
masm.push(ICStubReg); // stub.
pushStubPayload(masm, R0.scratchReg());
return tailCallVM(DoNewObjectInfo, masm);
}
} // namespace jit
} // namespace js

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

@ -1779,50 +1779,6 @@ ReferenceTypeFromSimpleTypeDescrKey(uint32_t key)
return ReferenceType(key >> 1);
}
// JSOP_NEWOBJECT
class ICNewObject_Fallback : public ICFallbackStub
{
friend class ICStubSpace;
GCPtrObject templateObject_;
explicit ICNewObject_Fallback(JitCode* stubCode)
: ICFallbackStub(ICStub::NewObject_Fallback, stubCode), templateObject_(nullptr)
{}
public:
class Compiler : public ICStubCompiler {
MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm) override;
public:
explicit Compiler(JSContext* cx, Engine engine)
: ICStubCompiler(cx, ICStub::NewObject_Fallback, engine)
{}
ICStub* getStub(ICStubSpace* space) override {
return newStub<ICNewObject_Fallback>(space, getStubCode());
}
};
GCPtrObject& templateObject() {
return templateObject_;
}
void setTemplateObject(JSObject* obj) {
templateObject_ = obj;
}
};
class ICNewObject_WithTemplate : public ICStub
{
friend class ICStubSpace;
explicit ICNewObject_WithTemplate(JitCode* stubCode)
: ICStub(ICStub::NewObject_WithTemplate, stubCode)
{}
};
} // namespace jit
} // namespace js