Reviewers: Toon Verwaest,

Message:
Because.

Description:
Use Unique<Cell> and Unique<PropertyCell> in LoadGlobalCell and StoreGlobalCell.

BUG=

Please review this at https://codereview.chromium.org/24072016/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files (+29, -27 lines):
  M src/arm/lithium-codegen-arm.cc
  M src/hydrogen-instructions.h
  M src/hydrogen-instructions.cc
  M src/ia32/lithium-codegen-ia32.cc
  M src/mips/lithium-codegen-mips.cc
  M src/unique.h
  M src/x64/lithium-codegen-x64.cc


Index: src/arm/lithium-codegen-arm.cc
diff --git a/src/arm/lithium-codegen-arm.cc b/src/arm/lithium-codegen-arm.cc
index f62e3fff5135914ced225de11f7962e9c2e53c63..2680c348d6255177386fdc7cd11611a4a3fff1d8 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<Object>(instr->hydrogen()->cell())));
+  __ mov(ip, Operand(Handle<Object>(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
Index: src/hydrogen-instructions.cc
diff --git a/src/hydrogen-instructions.cc b/src/hydrogen-instructions.cc
index d8a438054d5f0a53227992a29ef9f9970ecca4ee..caa9d6c79f0c51bb9171412ac74eff6e24f20ab7 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)");
Index: src/hydrogen-instructions.h
diff --git a/src/hydrogen-instructions.h b/src/hydrogen-instructions.h
index 6783694f79467f50c950330f8bed8fa3347610a3..9f3e9ba04545b1ae7e4613299dce74bab1507442 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> cell, PropertyDetails details)
-      : cell_(cell), details_(details), unique_id_() {
+    : cell_(Unique<Cell>::CreateUninitialized(cell)), details_(details) {
     set_representation(Representation::Tagged());
     SetFlag(kUseGVN);
     SetGVNFlag(kDependsOnGlobalVars);
   }

-  Handle<Cell> cell() const { return cell_; }
+  Unique<Cell> 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>(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> cell_;
+  Unique<Cell> cell_;
   PropertyDetails details_;
-  UniqueValueId unique_id_;
 };


@@ -5429,7 +5427,7 @@ class HStoreGlobalCell V8_FINAL : public HUnaryOperation {
   DECLARE_INSTRUCTION_FACTORY_P3(HStoreGlobalCell, HValue*,
                                  Handle<PropertyCell>, PropertyDetails);

-  Handle<PropertyCell> cell() const { return cell_; }
+  Unique<PropertyCell> 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<PropertyCell>(cell_.handle());
+  }
+
virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE {
     return Representation::Tagged();
   }
@@ -5449,12 +5451,12 @@ class HStoreGlobalCell V8_FINAL : public HUnaryOperation {
                    Handle<PropertyCell> cell,
                    PropertyDetails details)
       : HUnaryOperation(value),
-        cell_(cell),
+        cell_(Unique<PropertyCell>::CreateUninitialized(cell)),
         details_(details) {
     SetGVNFlag(kChangesGlobalVars);
   }

-  Handle<PropertyCell> cell_;
+  Unique<PropertyCell> cell_;
   PropertyDetails details_;
 };

Index: src/ia32/lithium-codegen-ia32.cc
diff --git a/src/ia32/lithium-codegen-ia32.cc b/src/ia32/lithium-codegen-ia32.cc index 92b1250458acda624dbdf0facddff1728159bc28..dc0ffb689def2a56edd77b5bd0c7607363509340 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<PropertyCell> cell_handle = instr->hydrogen()->cell();
+  Handle<PropertyCell> 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
Index: src/mips/lithium-codegen-mips.cc
diff --git a/src/mips/lithium-codegen-mips.cc b/src/mips/lithium-codegen-mips.cc index 6f82e1bd75d77d9362318cec51cb23be206f7cd1..a9c4a4ca10826e244e33ef279607cc68221e7178 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<Object>(instr->hydrogen()->cell())));
+  __ li(at, Operand(Handle<Object>(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
Index: src/unique.h
diff --git a/src/unique.h b/src/unique.h
index 206fd4e7c678b231f073bc58d0e7664659e4452b..68166541bce4ff796eb49eb788614def857c4457 100644
--- a/src/unique.h
+++ b/src/unique.h
@@ -90,34 +90,34 @@ class Unique V8_FINAL {
   }

   template <typename U>
-  bool operator==(const Unique<U>& other) const {
+  inline bool operator==(const Unique<U>& other) const {
     ASSERT(IsInitialized() && other.IsInitialized());
     return raw_address_ == other.raw_address_;
   }

   template <typename U>
-  bool operator!=(const Unique<U>& other) const {
+  inline bool operator!=(const Unique<U>& 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<intptr_t>(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<T> handle() const {
+  inline Handle<T> handle() const {
     return handle_;
   }

-  bool IsInitialized() const {
+  inline bool IsInitialized() const {
     return raw_address_ != NULL || handle_.is_null();
   }

Index: src/x64/lithium-codegen-x64.cc
diff --git a/src/x64/lithium-codegen-x64.cc b/src/x64/lithium-codegen-x64.cc
index 04ae3910609840a761db19435374e2431244958b..83a8cb249841051b0a1ac62d50d59be5085823f6 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> cell_handle = instr->hydrogen()->cell();
+  Handle<Cell> 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


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to