From: bmeurer@chromium.org Date: Wed, 29 Jan 2014 13:41:00 +0000 (+0000) Subject: Remove the HValueOf instruction. X-Git-Tag: upstream/4.7.83~10982 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=87a3951c11703372d831ea13607ea3a5d7f1516d;p=platform%2Fupstream%2Fv8.git Remove the HValueOf instruction. R=svenpanne@chromium.org Review URL: https://codereview.chromium.org/139233004 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@18905 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- diff --git a/src/arm/lithium-arm.cc b/src/arm/lithium-arm.cc index 3885b6b69..6c4ca2824 100644 --- a/src/arm/lithium-arm.cc +++ b/src/arm/lithium-arm.cc @@ -1711,13 +1711,6 @@ LInstruction* LChunkBuilder::DoElementsKind(HElementsKind* instr) { } -LInstruction* LChunkBuilder::DoValueOf(HValueOf* instr) { - LOperand* object = UseRegister(instr->value()); - LValueOf* result = new(zone()) LValueOf(object, TempRegister()); - return DefineAsRegister(result); -} - - LInstruction* LChunkBuilder::DoDateField(HDateField* instr) { LOperand* object = UseFixed(instr->value(), r0); LDateField* result = diff --git a/src/arm/lithium-arm.h b/src/arm/lithium-arm.h index f52e3f713..0e0792f05 100644 --- a/src/arm/lithium-arm.h +++ b/src/arm/lithium-arm.h @@ -177,7 +177,6 @@ class LCodeGen; V(Uint32ToDouble) \ V(Uint32ToSmi) \ V(UnknownOSRValue) \ - V(ValueOf) \ V(WrapReceiver) @@ -1308,21 +1307,6 @@ class LElementsKind V8_FINAL : public LTemplateInstruction<1, 1, 0> { }; -class LValueOf V8_FINAL : public LTemplateInstruction<1, 1, 1> { - public: - LValueOf(LOperand* value, LOperand* temp) { - inputs_[0] = value; - temps_[0] = temp; - } - - LOperand* value() { return inputs_[0]; } - LOperand* temp() { return temps_[0]; } - - DECLARE_CONCRETE_INSTRUCTION(ValueOf, "value-of") - DECLARE_HYDROGEN_ACCESSOR(ValueOf) -}; - - class LDateField V8_FINAL : public LTemplateInstruction<1, 1, 1> { public: LDateField(LOperand* date, LOperand* temp, Smi* index) : index_(index) { diff --git a/src/arm/lithium-codegen-arm.cc b/src/arm/lithium-codegen-arm.cc index 5ed93caba..c1ba19329 100644 --- a/src/arm/lithium-codegen-arm.cc +++ b/src/arm/lithium-codegen-arm.cc @@ -1878,28 +1878,6 @@ void LCodeGen::DoElementsKind(LElementsKind* instr) { } -void LCodeGen::DoValueOf(LValueOf* instr) { - Register input = ToRegister(instr->value()); - Register result = ToRegister(instr->result()); - Register map = ToRegister(instr->temp()); - Label done; - - if (!instr->hydrogen()->value()->IsHeapObject()) { - // If the object is a smi return the object. - __ SmiTst(input); - __ Move(result, input, eq); - __ b(eq, &done); - } - - // If the object is not a value type, return the object. - __ CompareObjectType(input, map, map, JS_VALUE_TYPE); - __ Move(result, input, ne); - __ ldr(result, FieldMemOperand(input, JSValue::kValueOffset), eq); - - __ bind(&done); -} - - void LCodeGen::DoDateField(LDateField* instr) { Register object = ToRegister(instr->date()); Register result = ToRegister(instr->result()); diff --git a/src/hydrogen-instructions.h b/src/hydrogen-instructions.h index 0e33c82cb..d599ab089 100644 --- a/src/hydrogen-instructions.h +++ b/src/hydrogen-instructions.h @@ -181,7 +181,6 @@ class LChunkBuilder; V(UnaryMathOperation) \ V(UnknownOSRValue) \ V(UseConst) \ - V(ValueOf) \ V(WrapReceiver) #define GVN_TRACKED_FLAG_LIST(V) \ @@ -7205,25 +7204,6 @@ class HToFastProperties V8_FINAL : public HUnaryOperation { }; -class HValueOf V8_FINAL : public HUnaryOperation { - public: - DECLARE_INSTRUCTION_FACTORY_P1(HValueOf, HValue*); - - virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE { - return Representation::Tagged(); - } - - DECLARE_CONCRETE_INSTRUCTION(ValueOf) - - private: - explicit HValueOf(HValue* value) : HUnaryOperation(value) { - set_representation(Representation::Tagged()); - } - - virtual bool IsDeletable() const V8_OVERRIDE { return true; } -}; - - class HDateField V8_FINAL : public HUnaryOperation { public: DECLARE_INSTRUCTION_FACTORY_P2(HDateField, HValue*, Smi*); diff --git a/src/hydrogen.cc b/src/hydrogen.cc index 54c3451fb..e38d9f3b9 100644 --- a/src/hydrogen.cc +++ b/src/hydrogen.cc @@ -10313,9 +10313,27 @@ void HOptimizedGraphBuilder::GenerateClassOf(CallRuntime* call) { void HOptimizedGraphBuilder::GenerateValueOf(CallRuntime* call) { ASSERT(call->arguments()->length() == 1); CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); - HValue* value = Pop(); - HValueOf* result = New(value); - return ast_context()->ReturnInstruction(result, call->id()); + HValue* object = Pop(); + + IfBuilder if_objectisvalue(this); + HValue* objectisvalue = if_objectisvalue.If( + object, JS_VALUE_TYPE); + if_objectisvalue.Then(); + { + // Return the actual value. + Push(Add( + object, objectisvalue, + HObjectAccess::ForJSObjectOffset(JSValue::kValueOffset))); + Add(call->id(), FIXED_SIMULATE); + } + if_objectisvalue.Else(); + { + // If the object is not a value return the object. + Push(object); + Add(call->id(), FIXED_SIMULATE); + } + if_objectisvalue.End(); + return ast_context()->ReturnValue(Pop()); } diff --git a/src/ia32/lithium-codegen-ia32.cc b/src/ia32/lithium-codegen-ia32.cc index bcb351c63..28ca344a4 100644 --- a/src/ia32/lithium-codegen-ia32.cc +++ b/src/ia32/lithium-codegen-ia32.cc @@ -1983,28 +1983,6 @@ void LCodeGen::DoElementsKind(LElementsKind* instr) { } -void LCodeGen::DoValueOf(LValueOf* instr) { - Register input = ToRegister(instr->value()); - Register result = ToRegister(instr->result()); - Register map = ToRegister(instr->temp()); - ASSERT(input.is(result)); - - Label done; - - if (!instr->hydrogen()->value()->IsHeapObject()) { - // If the object is a smi return the object. - __ JumpIfSmi(input, &done, Label::kNear); - } - - // If the object is not a value type, return the object. - __ CmpObjectType(input, JS_VALUE_TYPE, map); - __ j(not_equal, &done, Label::kNear); - __ mov(result, FieldOperand(input, JSValue::kValueOffset)); - - __ bind(&done); -} - - void LCodeGen::DoDateField(LDateField* instr) { Register object = ToRegister(instr->date()); Register result = ToRegister(instr->result()); diff --git a/src/ia32/lithium-ia32.cc b/src/ia32/lithium-ia32.cc index d50313f88..4f5c69f75 100644 --- a/src/ia32/lithium-ia32.cc +++ b/src/ia32/lithium-ia32.cc @@ -1703,13 +1703,6 @@ LInstruction* LChunkBuilder::DoElementsKind(HElementsKind* instr) { } -LInstruction* LChunkBuilder::DoValueOf(HValueOf* instr) { - LOperand* object = UseRegister(instr->value()); - LValueOf* result = new(zone()) LValueOf(object, TempRegister()); - return DefineSameAsFirst(result); -} - - LInstruction* LChunkBuilder::DoDateField(HDateField* instr) { LOperand* date = UseFixed(instr->value(), eax); LDateField* result = diff --git a/src/ia32/lithium-ia32.h b/src/ia32/lithium-ia32.h index a0b750f5c..73a31d78f 100644 --- a/src/ia32/lithium-ia32.h +++ b/src/ia32/lithium-ia32.h @@ -176,7 +176,6 @@ class LCodeGen; V(Uint32ToDouble) \ V(Uint32ToSmi) \ V(UnknownOSRValue) \ - V(ValueOf) \ V(WrapReceiver) @@ -1281,21 +1280,6 @@ class LElementsKind V8_FINAL : public LTemplateInstruction<1, 1, 0> { }; -class LValueOf V8_FINAL : public LTemplateInstruction<1, 1, 1> { - public: - LValueOf(LOperand* value, LOperand* temp) { - inputs_[0] = value; - temps_[0] = temp; - } - - LOperand* value() { return inputs_[0]; } - LOperand* temp() { return temps_[0]; } - - DECLARE_CONCRETE_INSTRUCTION(ValueOf, "value-of") - DECLARE_HYDROGEN_ACCESSOR(ValueOf) -}; - - class LDateField V8_FINAL : public LTemplateInstruction<1, 1, 1> { public: LDateField(LOperand* date, LOperand* temp, Smi* index) diff --git a/src/mips/lithium-mips.cc b/src/mips/lithium-mips.cc index ee64f8ee0..3be1313c0 100644 --- a/src/mips/lithium-mips.cc +++ b/src/mips/lithium-mips.cc @@ -1639,13 +1639,6 @@ LInstruction* LChunkBuilder::DoElementsKind(HElementsKind* instr) { } -LInstruction* LChunkBuilder::DoValueOf(HValueOf* instr) { - LOperand* object = UseRegister(instr->value()); - LValueOf* result = new(zone()) LValueOf(object, TempRegister()); - return DefineAsRegister(result); -} - - LInstruction* LChunkBuilder::DoDateField(HDateField* instr) { LOperand* object = UseFixed(instr->value(), a0); LDateField* result = diff --git a/src/mips/lithium-mips.h b/src/mips/lithium-mips.h index 5250c63c4..33d0def14 100644 --- a/src/mips/lithium-mips.h +++ b/src/mips/lithium-mips.h @@ -175,7 +175,6 @@ class LCodeGen; V(Uint32ToDouble) \ V(Uint32ToSmi) \ V(UnknownOSRValue) \ - V(ValueOf) \ V(WrapReceiver) #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \ @@ -1288,21 +1287,6 @@ class LElementsKind V8_FINAL : public LTemplateInstruction<1, 1, 0> { }; -class LValueOf V8_FINAL : public LTemplateInstruction<1, 1, 1> { - public: - LValueOf(LOperand* value, LOperand* temp) { - inputs_[0] = value; - temps_[0] = temp; - } - - LOperand* value() { return inputs_[0]; } - LOperand* temp() { return temps_[0]; } - - DECLARE_CONCRETE_INSTRUCTION(ValueOf, "value-of") - DECLARE_HYDROGEN_ACCESSOR(ValueOf) -}; - - class LDateField V8_FINAL : public LTemplateInstruction<1, 1, 1> { public: LDateField(LOperand* date, LOperand* temp, Smi* index) : index_(index) { diff --git a/src/x64/lithium-codegen-x64.cc b/src/x64/lithium-codegen-x64.cc index a06c3bb92..d86605930 100644 --- a/src/x64/lithium-codegen-x64.cc +++ b/src/x64/lithium-codegen-x64.cc @@ -1588,26 +1588,6 @@ void LCodeGen::DoElementsKind(LElementsKind* instr) { } -void LCodeGen::DoValueOf(LValueOf* instr) { - Register input = ToRegister(instr->value()); - Register result = ToRegister(instr->result()); - ASSERT(input.is(result)); - Label done; - - if (!instr->hydrogen()->value()->IsHeapObject()) { - // If the object is a smi return the object. - __ JumpIfSmi(input, &done, Label::kNear); - } - - // If the object is not a value type, return the object. - __ CmpObjectType(input, JS_VALUE_TYPE, kScratchRegister); - __ j(not_equal, &done, Label::kNear); - __ movp(result, FieldOperand(input, JSValue::kValueOffset)); - - __ bind(&done); -} - - void LCodeGen::DoDateField(LDateField* instr) { Register object = ToRegister(instr->date()); Register result = ToRegister(instr->result()); diff --git a/src/x64/lithium-x64.cc b/src/x64/lithium-x64.cc index 5c3fd7098..f07cb3ba5 100644 --- a/src/x64/lithium-x64.cc +++ b/src/x64/lithium-x64.cc @@ -1612,13 +1612,6 @@ LInstruction* LChunkBuilder::DoElementsKind(HElementsKind* instr) { } -LInstruction* LChunkBuilder::DoValueOf(HValueOf* instr) { - LOperand* object = UseRegister(instr->value()); - LValueOf* result = new(zone()) LValueOf(object); - return DefineSameAsFirst(result); -} - - LInstruction* LChunkBuilder::DoDateField(HDateField* instr) { LOperand* object = UseFixed(instr->value(), rax); LDateField* result = new(zone()) LDateField(object, instr->index()); diff --git a/src/x64/lithium-x64.h b/src/x64/lithium-x64.h index 5d85b398c..8b1c05571 100644 --- a/src/x64/lithium-x64.h +++ b/src/x64/lithium-x64.h @@ -174,7 +174,6 @@ class LCodeGen; V(Uint32ToDouble) \ V(Uint32ToSmi) \ V(UnknownOSRValue) \ - V(ValueOf) \ V(WrapReceiver) @@ -1249,19 +1248,6 @@ class LElementsKind V8_FINAL : public LTemplateInstruction<1, 1, 0> { }; -class LValueOf V8_FINAL : public LTemplateInstruction<1, 1, 0> { - public: - explicit LValueOf(LOperand* value) { - inputs_[0] = value; - } - - LOperand* value() { return inputs_[0]; } - - DECLARE_CONCRETE_INSTRUCTION(ValueOf, "value-of") - DECLARE_HYDROGEN_ACCESSOR(ValueOf) -}; - - class LDateField V8_FINAL : public LTemplateInstruction<1, 1, 0> { public: LDateField(LOperand* date, Smi* index) : index_(index) {