From 94a0a95b7a0dc729889fff5e3b5590e5adbc46a1 Mon Sep 17 00:00:00 2001 From: "titzer@chromium.org" Date: Fri, 20 Sep 2013 12:32:31 +0000 Subject: [PATCH] Use Unique and Unique in LoadGlobalCell and StoreGlobalCell. BUG= R=verwaest@chromium.org Review URL: https://codereview.chromium.org/24072016 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@16865 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/arm/lithium-codegen-arm.cc | 4 ++-- src/hydrogen-instructions.cc | 4 ++-- src/hydrogen-instructions.h | 24 +++++++++++++----------- src/ia32/lithium-codegen-ia32.cc | 4 ++-- src/mips/lithium-codegen-mips.cc | 4 ++-- src/unique.h | 12 ++++++------ src/x64/lithium-codegen-x64.cc | 4 ++-- 7 files changed, 29 insertions(+), 27 deletions(-) diff --git a/src/arm/lithium-codegen-arm.cc b/src/arm/lithium-codegen-arm.cc index f62e3fff51..2680c348d6 100644 --- a/src/arm/lithium-codegen-arm.cc +++ b/src/arm/lithium-codegen-arm.cc @@ -2954,7 +2954,7 @@ void LCodeGen::DoReturn(LReturn* instr) { void LCodeGen::DoLoadGlobalCell(LLoadGlobalCell* instr) { Register result = ToRegister(instr->result()); - __ mov(ip, Operand(Handle(instr->hydrogen()->cell()))); + __ mov(ip, Operand(Handle(instr->hydrogen()->cell().handle()))); __ ldr(result, FieldMemOperand(ip, Cell::kValueOffset)); if (instr->hydrogen()->RequiresHoleCheck()) { __ LoadRoot(ip, Heap::kTheHoleValueRootIndex); @@ -2981,7 +2981,7 @@ void LCodeGen::DoStoreGlobalCell(LStoreGlobalCell* instr) { Register cell = scratch0(); // Load the cell. - __ mov(cell, Operand(instr->hydrogen()->cell())); + __ mov(cell, Operand(instr->hydrogen()->cell().handle())); // If the cell we are storing to contains the hole it could have // been deleted from the property dictionary. In that case, we need diff --git a/src/hydrogen-instructions.cc b/src/hydrogen-instructions.cc index 2bd2360cf4..a685198ba6 100644 --- a/src/hydrogen-instructions.cc +++ b/src/hydrogen-instructions.cc @@ -3145,7 +3145,7 @@ void HTransitionElementsKind::PrintDataTo(StringStream* stream) { void HLoadGlobalCell::PrintDataTo(StringStream* stream) { - stream->Add("[%p]", *cell()); + stream->Add("[%p]", *cell().handle()); if (!details_.IsDontDelete()) stream->Add(" (deleteable)"); if (details_.IsReadOnly()) stream->Add(" (read-only)"); } @@ -3173,7 +3173,7 @@ void HInnerAllocatedObject::PrintDataTo(StringStream* stream) { void HStoreGlobalCell::PrintDataTo(StringStream* stream) { - stream->Add("[%p] = ", *cell()); + stream->Add("[%p] = ", *cell().handle()); value()->PrintNameTo(stream); if (!details_.IsDontDelete()) stream->Add(" (deleteable)"); if (details_.IsReadOnly()) stream->Add(" (read-only)"); diff --git a/src/hydrogen-instructions.h b/src/hydrogen-instructions.h index 505bc80d09..8cb2f59174 100644 --- a/src/hydrogen-instructions.h +++ b/src/hydrogen-instructions.h @@ -5122,23 +5122,23 @@ class HUnknownOSRValue V8_FINAL : public HTemplateInstruction<0> { class HLoadGlobalCell V8_FINAL : public HTemplateInstruction<0> { public: HLoadGlobalCell(Handle cell, PropertyDetails details) - : cell_(cell), details_(details), unique_id_() { + : cell_(Unique::CreateUninitialized(cell)), details_(details) { set_representation(Representation::Tagged()); SetFlag(kUseGVN); SetGVNFlag(kDependsOnGlobalVars); } - Handle cell() const { return cell_; } + Unique cell() const { return cell_; } bool RequiresHoleCheck() const; virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE; virtual intptr_t Hashcode() V8_OVERRIDE { - return unique_id_.Hashcode(); + return cell_.Hashcode(); } virtual void FinalizeUniqueValueId() V8_OVERRIDE { - unique_id_ = UniqueValueId(cell_); + cell_ = Unique(cell_.handle()); } virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE { @@ -5149,16 +5149,14 @@ class HLoadGlobalCell V8_FINAL : public HTemplateInstruction<0> { protected: virtual bool DataEquals(HValue* other) V8_OVERRIDE { - HLoadGlobalCell* b = HLoadGlobalCell::cast(other); - return unique_id_ == b->unique_id_; + return cell_ == HLoadGlobalCell::cast(other)->cell_; } private: virtual bool IsDeletable() const V8_OVERRIDE { return !RequiresHoleCheck(); } - Handle cell_; + Unique cell_; PropertyDetails details_; - UniqueValueId unique_id_; }; @@ -5429,7 +5427,7 @@ class HStoreGlobalCell V8_FINAL : public HUnaryOperation { DECLARE_INSTRUCTION_FACTORY_P3(HStoreGlobalCell, HValue*, Handle, PropertyDetails); - Handle cell() const { return cell_; } + Unique cell() const { return cell_; } bool RequiresHoleCheck() { return !details_.IsDontDelete() || details_.IsReadOnly(); } @@ -5437,6 +5435,10 @@ class HStoreGlobalCell V8_FINAL : public HUnaryOperation { return StoringValueNeedsWriteBarrier(value()); } + virtual void FinalizeUniqueValueId() V8_OVERRIDE { + cell_ = Unique(cell_.handle()); + } + virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE { return Representation::Tagged(); } @@ -5449,12 +5451,12 @@ class HStoreGlobalCell V8_FINAL : public HUnaryOperation { Handle cell, PropertyDetails details) : HUnaryOperation(value), - cell_(cell), + cell_(Unique::CreateUninitialized(cell)), details_(details) { SetGVNFlag(kChangesGlobalVars); } - Handle cell_; + Unique cell_; PropertyDetails details_; }; diff --git a/src/ia32/lithium-codegen-ia32.cc b/src/ia32/lithium-codegen-ia32.cc index 0f6ef999ad..98a049b64a 100644 --- a/src/ia32/lithium-codegen-ia32.cc +++ b/src/ia32/lithium-codegen-ia32.cc @@ -3151,7 +3151,7 @@ void LCodeGen::DoReturn(LReturn* instr) { void LCodeGen::DoLoadGlobalCell(LLoadGlobalCell* instr) { Register result = ToRegister(instr->result()); - __ mov(result, Operand::ForCell(instr->hydrogen()->cell())); + __ mov(result, Operand::ForCell(instr->hydrogen()->cell().handle())); if (instr->hydrogen()->RequiresHoleCheck()) { __ cmp(result, factory()->the_hole_value()); DeoptimizeIf(equal, instr->environment()); @@ -3174,7 +3174,7 @@ void LCodeGen::DoLoadGlobalGeneric(LLoadGlobalGeneric* instr) { void LCodeGen::DoStoreGlobalCell(LStoreGlobalCell* instr) { Register value = ToRegister(instr->value()); - Handle cell_handle = instr->hydrogen()->cell(); + Handle cell_handle = instr->hydrogen()->cell().handle(); // If the cell we are storing to contains the hole it could have // been deleted from the property dictionary. In that case, we need diff --git a/src/mips/lithium-codegen-mips.cc b/src/mips/lithium-codegen-mips.cc index 6f82e1bd75..a9c4a4ca10 100644 --- a/src/mips/lithium-codegen-mips.cc +++ b/src/mips/lithium-codegen-mips.cc @@ -2805,7 +2805,7 @@ void LCodeGen::DoReturn(LReturn* instr) { void LCodeGen::DoLoadGlobalCell(LLoadGlobalCell* instr) { Register result = ToRegister(instr->result()); - __ li(at, Operand(Handle(instr->hydrogen()->cell()))); + __ li(at, Operand(Handle(instr->hydrogen()->cell().handle()))); __ lw(result, FieldMemOperand(at, Cell::kValueOffset)); if (instr->hydrogen()->RequiresHoleCheck()) { __ LoadRoot(at, Heap::kTheHoleValueRootIndex); @@ -2831,7 +2831,7 @@ void LCodeGen::DoStoreGlobalCell(LStoreGlobalCell* instr) { Register cell = scratch0(); // Load the cell. - __ li(cell, Operand(instr->hydrogen()->cell())); + __ li(cell, Operand(instr->hydrogen()->cell().handle())); // If the cell we are storing to contains the hole it could have // been deleted from the property dictionary. In that case, we need diff --git a/src/unique.h b/src/unique.h index 206fd4e7c6..68166541bc 100644 --- a/src/unique.h +++ b/src/unique.h @@ -90,34 +90,34 @@ class Unique V8_FINAL { } template - bool operator==(const Unique& other) const { + inline bool operator==(const Unique& other) const { ASSERT(IsInitialized() && other.IsInitialized()); return raw_address_ == other.raw_address_; } template - bool operator!=(const Unique& other) const { + inline bool operator!=(const Unique& other) const { ASSERT(IsInitialized() && other.IsInitialized()); return raw_address_ != other.raw_address_; } - intptr_t Hashcode() const { + inline intptr_t Hashcode() const { ASSERT(IsInitialized()); return reinterpret_cast(raw_address_); } - bool IsNull() const { + inline bool IsNull() const { ASSERT(IsInitialized()); return raw_address_ == NULL; } // Extract the handle from this Unique in order to dereference it. // WARNING: Only do this if you have access to the heap. - Handle handle() const { + inline Handle handle() const { return handle_; } - bool IsInitialized() const { + inline bool IsInitialized() const { return raw_address_ != NULL || handle_.is_null(); } diff --git a/src/x64/lithium-codegen-x64.cc b/src/x64/lithium-codegen-x64.cc index 04ae391060..83a8cb2498 100644 --- a/src/x64/lithium-codegen-x64.cc +++ b/src/x64/lithium-codegen-x64.cc @@ -2668,7 +2668,7 @@ void LCodeGen::DoReturn(LReturn* instr) { void LCodeGen::DoLoadGlobalCell(LLoadGlobalCell* instr) { Register result = ToRegister(instr->result()); - __ LoadGlobalCell(result, instr->hydrogen()->cell()); + __ LoadGlobalCell(result, instr->hydrogen()->cell().handle()); if (instr->hydrogen()->RequiresHoleCheck()) { __ CompareRoot(result, Heap::kTheHoleValueRootIndex); DeoptimizeIf(equal, instr->environment()); @@ -2690,7 +2690,7 @@ void LCodeGen::DoLoadGlobalGeneric(LLoadGlobalGeneric* instr) { void LCodeGen::DoStoreGlobalCell(LStoreGlobalCell* instr) { Register value = ToRegister(instr->value()); - Handle cell_handle = instr->hydrogen()->cell(); + Handle cell_handle = instr->hydrogen()->cell().handle(); // If the cell we are storing to contains the hole it could have // been deleted from the property dictionary. In that case, we need