From 5f0b9ead288983da682266a099d711c5d21cea46 Mon Sep 17 00:00:00 2001 From: Hannes Verschore Date: Mon, 10 Dec 2012 00:48:59 +0100 Subject: [PATCH] Backed out changeset f1a9592618ec due to orange --- js/src/ion/CodeGenerator.cpp | 22 +++---------- js/src/ion/CodeGenerator.h | 2 +- js/src/ion/IonBuilder.cpp | 7 +++-- js/src/ion/IonMacroAssembler.h | 10 ------ js/src/ion/LIR-Common.h | 32 +++++++++---------- js/src/ion/LOpcodes.h | 2 +- js/src/ion/Lowering.cpp | 21 +++++-------- js/src/ion/Lowering.h | 1 - js/src/ion/MIR.h | 56 ++++++++-------------------------- js/src/ion/MOpcodes.h | 1 - 10 files changed, 46 insertions(+), 108 deletions(-) diff --git a/js/src/ion/CodeGenerator.cpp b/js/src/ion/CodeGenerator.cpp index ca6a34006674..4b2276a996be 100644 --- a/js/src/ion/CodeGenerator.cpp +++ b/js/src/ion/CodeGenerator.cpp @@ -1842,8 +1842,10 @@ static const VMFunction NewGCThingInfo = FunctionInfo(js::ion::NewGCThing); bool -CodeGenerator::visitCreateThisWithTemplate(LCreateThisWithTemplate *lir) +CodeGenerator::visitCreateThis(LCreateThis *lir) { + JS_ASSERT(lir->mir()->hasTemplateObject()); + JSObject *templateObject = lir->mir()->getTemplateObject(); gc::AllocKind allocKind = templateObject->getAllocKind(); int thingSize = (int)gc::Arena::thingSize(allocKind); @@ -1870,24 +1872,11 @@ static const VMFunction CreateThisInfo = FunctionInfo(js_CreateThisForFunctionWithProto); bool -CodeGenerator::visitCreateThis(LCreateThis *lir) +CodeGenerator::visitCreateThisVM(LCreateThisVM *lir) { - Label done, vm; - const LAllocation *proto = lir->getPrototype(); const LAllocation *callee = lir->getCallee(); - // When callee could be a native, put MagicValue in return operand. - // Use the VMCall when callee turns out to not be a native. - if (lir->mir()->needNativeCheck()) { - JS_ASSERT(lir->mir()->type() == MIRType_Value); - masm.branchIfInterpreted(ToRegister(callee), &vm); - masm.moveValue(MagicValue(JS_IS_CONSTRUCTING), GetValueOutput(lir)); - masm.jump(&done); - } - - masm.bind(&vm); - // Push arguments. if (proto->isConstant()) pushArg(ImmGCPtr(&proto->toConstant()->toObject())); @@ -1901,9 +1890,6 @@ CodeGenerator::visitCreateThis(LCreateThis *lir) if (!callVM(CreateThisInfo, lir)) return false; - - masm.bind(&done); - return true; } diff --git a/js/src/ion/CodeGenerator.h b/js/src/ion/CodeGenerator.h index 426ca1db9b36..67c6527d1585 100644 --- a/js/src/ion/CodeGenerator.h +++ b/js/src/ion/CodeGenerator.h @@ -97,7 +97,7 @@ class CodeGenerator : public CodeGeneratorSpecific bool visitNewStringObject(LNewStringObject *lir); bool visitInitProp(LInitProp *lir); bool visitCreateThis(LCreateThis *lir); - bool visitCreateThisWithTemplate(LCreateThisWithTemplate *lir); + bool visitCreateThisVM(LCreateThisVM *lir); bool visitReturnFromCtor(LReturnFromCtor *lir); bool visitArrayLength(LArrayLength *lir); bool visitTypedArrayLength(LTypedArrayLength *lir); diff --git a/js/src/ion/IonBuilder.cpp b/js/src/ion/IonBuilder.cpp index ccad252aa2c2..202eba3789ae 100644 --- a/js/src/ion/IonBuilder.cpp +++ b/js/src/ion/IonBuilder.cpp @@ -3864,7 +3864,7 @@ IonBuilder::createThisScripted(MDefinition *callee) current->add(getProto); // Create this from prototype - MCreateThis *createThis = MCreateThis::New(callee, getProto); + MCreateThis *createThis = MCreateThis::New(callee, getProto, NULL); current->add(createThis); return createThis; @@ -3905,7 +3905,10 @@ IonBuilder::createThisScriptedSingleton(HandleFunction target, HandleObject prot if (templateObject->type()->newScript) types::HeapTypeSet::WatchObjectStateChange(cx, templateObject->type()); - MCreateThisWithTemplate *createThis = MCreateThisWithTemplate::New(templateObject); + MConstant *protoDef = MConstant::New(ObjectValue(*proto)); + current->add(protoDef); + + MCreateThis *createThis = MCreateThis::New(callee, protoDef, templateObject); current->add(createThis); return createThis; diff --git a/js/src/ion/IonMacroAssembler.h b/js/src/ion/IonMacroAssembler.h index ae453ee7db65..9de5028e31b2 100644 --- a/js/src/ion/IonMacroAssembler.h +++ b/js/src/ion/IonMacroAssembler.h @@ -284,16 +284,6 @@ class MacroAssembler : public MacroAssemblerSpecific uint32_t bit = JSFunction::INTERPRETED << 16; branchTest32(Assembler::Zero, address, Imm32(bit), label); } - void branchIfInterpreted(Register fun, Label *label) { - // 16-bit loads are slow and unaligned 32-bit loads may be too so - // perform an aligned 32-bit load and adjust the bitmask accordingly. - JS_STATIC_ASSERT(offsetof(JSFunction, nargs) % sizeof(uint32_t) == 0); - JS_STATIC_ASSERT(offsetof(JSFunction, flags) == offsetof(JSFunction, nargs) + 2); - JS_STATIC_ASSERT(IS_LITTLE_ENDIAN); - Address address(fun, offsetof(JSFunction, nargs)); - uint32_t bit = JSFunction::INTERPRETED << 16; - branchTest32(Assembler::NonZero, address, Imm32(bit), label); - } using MacroAssemblerSpecific::Push; diff --git a/js/src/ion/LIR-Common.h b/js/src/ion/LIR-Common.h index d43ad5863e4e..7224eb574230 100644 --- a/js/src/ion/LIR-Common.h +++ b/js/src/ion/LIR-Common.h @@ -420,26 +420,26 @@ class LToIdV : public LCallInstructionHelper // Allocate an object for |new| on the caller-side. // Always performs object initialization with a fast path. -class LCreateThisWithTemplate : public LInstructionHelper<1, 0, 0> -{ - public: - LIR_HEADER(CreateThisWithTemplate) - - LCreateThisWithTemplate() - { } - - MCreateThisWithTemplate *mir() const { - return mir_->toCreateThisWithTemplate(); - } -}; - -// Allocate an object for |new| on the caller-side, when there is no templateObject. -class LCreateThis : public LCallInstructionHelper<1, 2, 0> +class LCreateThis : public LInstructionHelper<1, 0, 0> { public: LIR_HEADER(CreateThis) - LCreateThis(const LAllocation &callee, const LAllocation &prototype) + LCreateThis() + { } + + MCreateThis *mir() const { + return mir_->toCreateThis(); + } +}; + +// Allocate an object for |new| on the caller-side, when there is no templateObject. +class LCreateThisVM : public LCallInstructionHelper<1, 2, 0> +{ + public: + LIR_HEADER(CreateThisVM) + + LCreateThisVM(const LAllocation &callee, const LAllocation &prototype) { setOperand(0, callee); setOperand(1, prototype); diff --git a/js/src/ion/LOpcodes.h b/js/src/ion/LOpcodes.h index 38158f3675a5..e4250e8dcf6d 100644 --- a/js/src/ion/LOpcodes.h +++ b/js/src/ion/LOpcodes.h @@ -40,7 +40,7 @@ _(StackArgT) \ _(StackArgV) \ _(CreateThis) \ - _(CreateThisWithTemplate) \ + _(CreateThisVM) \ _(ReturnFromCtor) \ _(BitNotI) \ _(BitNotV) \ diff --git a/js/src/ion/Lowering.cpp b/js/src/ion/Lowering.cpp index 7713bda333a9..67852f2c87f5 100644 --- a/js/src/ion/Lowering.cpp +++ b/js/src/ion/Lowering.cpp @@ -235,24 +235,17 @@ LIRGenerator::visitPassArg(MPassArg *arg) return add(stack); } -bool -LIRGenerator::visitCreateThisWithTemplate(MCreateThisWithTemplate *ins) -{ - LCreateThisWithTemplate *lir = new LCreateThisWithTemplate(); - return define(lir, ins) && assignSafepoint(lir, ins); -} - bool LIRGenerator::visitCreateThis(MCreateThis *ins) { - LAllocation callee = useRegisterOrConstantAtStart(ins->getCallee()); - LAllocation prototype = useRegisterOrConstantAtStart(ins->getPrototype()); + // Template objects permit fast initialization. + if (ins->hasTemplateObject()) { + LCreateThis *lir = new LCreateThis(); + return define(lir, ins) && assignSafepoint(lir, ins); + } - // For the native check we need the callee in a register. - if (ins->needNativeCheck()) - callee = useRegisterAtStart(ins->getCallee()); - - LCreateThis *lir = new LCreateThis(callee, prototype); + LCreateThisVM *lir = new LCreateThisVM(useRegisterOrConstantAtStart(ins->getCallee()), + useRegisterOrConstantAtStart(ins->getPrototype())); return defineReturn(lir, ins) && assignSafepoint(lir, ins); } diff --git a/js/src/ion/Lowering.h b/js/src/ion/Lowering.h index 922aa8452b15..fc077ce6e4be 100644 --- a/js/src/ion/Lowering.h +++ b/js/src/ion/Lowering.h @@ -89,7 +89,6 @@ class LIRGenerator : public LIRGeneratorSpecific bool visitDefVar(MDefVar *ins); bool visitPrepareCall(MPrepareCall *ins); bool visitPassArg(MPassArg *arg); - bool visitCreateThisWithTemplate(MCreateThisWithTemplate *ins); bool visitCreateThis(MCreateThis *ins); bool visitReturnFromCtor(MReturnFromCtor *ins); bool visitCall(MCall *call); diff --git a/js/src/ion/MIR.h b/js/src/ion/MIR.h index 6d168ff6281d..8676a30018cb 100644 --- a/js/src/ion/MIR.h +++ b/js/src/ion/MIR.h @@ -1569,36 +1569,6 @@ class MGuardString } }; -// Caller-side allocation of |this| for |new|: -// Given a templateobject, construct |this| for JSOP_NEW -class MCreateThisWithTemplate - : public MNullaryInstruction -{ - // Template for |this|, provided by TI - CompilerRootObject templateObject_; - - MCreateThisWithTemplate(JSObject *templateObject) - : templateObject_(templateObject) - { - setResultType(MIRType_Object); - } - - public: - INSTRUCTION_HEADER(CreateThisWithTemplate); - static MCreateThisWithTemplate *New(JSObject *templateObject) - { - return new MCreateThisWithTemplate(templateObject); - } - JSObject *getTemplateObject() const { - return templateObject_; - } - - // Although creation of |this| modifies global state, it is safely repeatable. - AliasSet getAliasSet() const { - return AliasSet::None(); - } -}; - // Caller-side allocation of |this| for |new|: // Given a prototype operand, construct |this| for JSOP_NEW. // For native constructors, returns MagicValue(JS_IS_CONSTRUCTING). @@ -1606,24 +1576,22 @@ class MCreateThis : public MAryInstruction<2>, public MixPolicy, ObjectPolicy<1> > { - bool needNativeCheck_; + // Template for |this|, provided by TI, or NULL. + CompilerRootObject templateObject_; - MCreateThis(MDefinition *callee, MDefinition *prototype) - : needNativeCheck_(true) + MCreateThis(MDefinition *callee, MDefinition *prototype, JSObject *templateObject) + : templateObject_(templateObject) { initOperand(0, callee); initOperand(1, prototype); - - // Type is mostly object, except for native constructors - // therefore the need of Value type. - setResultType(MIRType_Value); + setResultType(MIRType_Object); } public: INSTRUCTION_HEADER(CreateThis) - static MCreateThis *New(MDefinition *callee, MDefinition *prototype) + static MCreateThis *New(MDefinition *callee, MDefinition *prototype, JSObject *templateObject) { - return new MCreateThis(callee, prototype); + return new MCreateThis(callee, prototype, templateObject); } MDefinition *getCallee() const { @@ -1632,12 +1600,12 @@ class MCreateThis MDefinition *getPrototype() const { return getOperand(1); } - void removeNativeCheck() { - needNativeCheck_ = false; - setResultType(MIRType_Object); + bool hasTemplateObject() const { + return !!templateObject_; } - bool needNativeCheck() const { - return needNativeCheck_; + JSObject *getTemplateObject() const { + JS_ASSERT(hasTemplateObject()); + return templateObject_; } // Although creation of |this| modifies global state, it is safely repeatable. diff --git a/js/src/ion/MOpcodes.h b/js/src/ion/MOpcodes.h index 05fb87864eee..ae948185d464 100644 --- a/js/src/ion/MOpcodes.h +++ b/js/src/ion/MOpcodes.h @@ -30,7 +30,6 @@ namespace ion { _(RecompileCheck) \ _(DefVar) \ _(CreateThis) \ - _(CreateThisWithTemplate) \ _(PrepareCall) \ _(PassArg) \ _(Call) \