diff --git a/src/arm/lithium-arm.h b/src/arm/lithium-arm.h index f4df669179..80e07a12f4 100644 --- a/src/arm/lithium-arm.h +++ b/src/arm/lithium-arm.h @@ -1276,7 +1276,9 @@ class LPushArgument: public LTemplateInstruction<0, 1, 0> { class LThisFunction: public LTemplateInstruction<1, 0, 0> { + public: DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function") + DECLARE_HYDROGEN_ACCESSOR(ThisFunction) }; diff --git a/src/arm/lithium-codegen-arm.cc b/src/arm/lithium-codegen-arm.cc index 683853faa1..e1b71f4d5d 100644 --- a/src/arm/lithium-codegen-arm.cc +++ b/src/arm/lithium-codegen-arm.cc @@ -2786,7 +2786,7 @@ void LCodeGen::DoPushArgument(LPushArgument* instr) { void LCodeGen::DoThisFunction(LThisFunction* instr) { Register result = ToRegister(instr->result()); - __ ldr(result, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); + LoadHeapObject(result, instr->hydrogen()->closure()); } diff --git a/src/ast.cc b/src/ast.cc index 21173b4bf9..9e34bc0e81 100644 --- a/src/ast.cc +++ b/src/ast.cc @@ -465,7 +465,7 @@ bool FunctionLiteral::IsInlineable() const { bool ThisFunction::IsInlineable() const { - return false; + return true; } diff --git a/src/hydrogen-instructions.h b/src/hydrogen-instructions.h index a18a64c9ab..6bce2d1694 100644 --- a/src/hydrogen-instructions.h +++ b/src/hydrogen-instructions.h @@ -1347,7 +1347,7 @@ class HPushArgument: public HUnaryOperation { class HThisFunction: public HTemplateInstruction<0> { public: - HThisFunction() { + explicit HThisFunction(Handle closure) : closure_(closure) { set_representation(Representation::Tagged()); SetFlag(kUseGVN); } @@ -1356,10 +1356,18 @@ class HThisFunction: public HTemplateInstruction<0> { return Representation::None(); } + Handle closure() const { return closure_; } + DECLARE_CONCRETE_INSTRUCTION(ThisFunction) protected: - virtual bool DataEquals(HValue* other) { return true; } + virtual bool DataEquals(HValue* other) { + HThisFunction* b = HThisFunction::cast(other); + return *closure() == *b->closure(); + } + + private: + Handle closure_; }; diff --git a/src/hydrogen.cc b/src/hydrogen.cc index 692bcd38b3..4fcef23bda 100644 --- a/src/hydrogen.cc +++ b/src/hydrogen.cc @@ -6001,7 +6001,8 @@ void HGraphBuilder::VisitThisFunction(ThisFunction* expr) { ASSERT(!HasStackOverflow()); ASSERT(current_block() != NULL); ASSERT(current_block()->HasPredecessor()); - HThisFunction* self = new(zone()) HThisFunction; + HThisFunction* self = new(zone()) HThisFunction( + function_state()->compilation_info()->closure()); return ast_context()->ReturnInstruction(self, expr->id()); } diff --git a/src/ia32/lithium-codegen-ia32.cc b/src/ia32/lithium-codegen-ia32.cc index e648b6cec8..68602e0baa 100644 --- a/src/ia32/lithium-codegen-ia32.cc +++ b/src/ia32/lithium-codegen-ia32.cc @@ -2626,7 +2626,7 @@ void LCodeGen::DoPushArgument(LPushArgument* instr) { void LCodeGen::DoThisFunction(LThisFunction* instr) { Register result = ToRegister(instr->result()); - __ mov(result, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); + LoadHeapObject(result, instr->hydrogen()->closure()); } diff --git a/src/ia32/lithium-ia32.h b/src/ia32/lithium-ia32.h index dc92b09b27..d23563532c 100644 --- a/src/ia32/lithium-ia32.h +++ b/src/ia32/lithium-ia32.h @@ -1311,7 +1311,9 @@ class LPushArgument: public LTemplateInstruction<0, 1, 0> { class LThisFunction: public LTemplateInstruction<1, 0, 0> { + public: DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function") + DECLARE_HYDROGEN_ACCESSOR(ThisFunction) }; diff --git a/src/x64/lithium-codegen-x64.cc b/src/x64/lithium-codegen-x64.cc index 391affe604..f17b70db64 100644 --- a/src/x64/lithium-codegen-x64.cc +++ b/src/x64/lithium-codegen-x64.cc @@ -2572,7 +2572,7 @@ void LCodeGen::DoPushArgument(LPushArgument* instr) { void LCodeGen::DoThisFunction(LThisFunction* instr) { Register result = ToRegister(instr->result()); - __ movq(result, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); + LoadHeapObject(result, instr->hydrogen()->closure()); } diff --git a/src/x64/lithium-x64.h b/src/x64/lithium-x64.h index 32292b6259..515a3082b5 100644 --- a/src/x64/lithium-x64.h +++ b/src/x64/lithium-x64.h @@ -1276,7 +1276,9 @@ class LPushArgument: public LTemplateInstruction<0, 1, 0> { class LThisFunction: public LTemplateInstruction<1, 0, 0> { + public: DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function") + DECLARE_HYDROGEN_ACCESSOR(ThisFunction) };