Revision: 20870
Author:   [email protected]
Date:     Tue Apr 22 07:24:05 2014 UTC
Log:      Fix field type handling in load elimination.

Drive-by-fix: map_set() must return a pointer to the UniqueSet
instead of a copy.

[email protected]

Review URL: https://codereview.chromium.org/244383002
http://code.google.com/p/v8/source/detail?r=20870

Modified:
 /branches/bleeding_edge/src/arm/lithium-codegen-arm.cc
 /branches/bleeding_edge/src/arm64/lithium-codegen-arm64.cc
 /branches/bleeding_edge/src/hydrogen-check-elimination.cc
 /branches/bleeding_edge/src/hydrogen-instructions.h
 /branches/bleeding_edge/src/hydrogen-load-elimination.cc
 /branches/bleeding_edge/src/ia32/lithium-codegen-ia32.cc
 /branches/bleeding_edge/src/mips/lithium-codegen-mips.cc
 /branches/bleeding_edge/src/unique.h
 /branches/bleeding_edge/src/x64/lithium-codegen-x64.cc

=======================================
--- /branches/bleeding_edge/src/arm/lithium-codegen-arm.cc Tue Apr 15 07:36:47 2014 UTC +++ /branches/bleeding_edge/src/arm/lithium-codegen-arm.cc Tue Apr 22 07:24:05 2014 UTC
@@ -5190,15 +5190,15 @@
     __ bind(deferred->check_maps());
   }

-  UniqueSet<Map> map_set = instr->hydrogen()->map_set();
+  const UniqueSet<Map>* map_set = instr->hydrogen()->map_set();
   Label success;
-  for (int i = 0; i < map_set.size() - 1; i++) {
-    Handle<Map> map = map_set.at(i).handle();
+  for (int i = 0; i < map_set->size() - 1; i++) {
+    Handle<Map> map = map_set->at(i).handle();
     __ CompareMap(map_reg, map, &success);
     __ b(eq, &success);
   }

-  Handle<Map> map = map_set.at(map_set.size() - 1).handle();
+  Handle<Map> map = map_set->at(map_set->size() - 1).handle();
   __ CompareMap(map_reg, map, &success);
   if (instr->hydrogen()->has_migration_target()) {
     __ b(ne, deferred->entry());
=======================================
--- /branches/bleeding_edge/src/arm64/lithium-codegen-arm64.cc Tue Apr 15 07:36:47 2014 UTC +++ /branches/bleeding_edge/src/arm64/lithium-codegen-arm64.cc Tue Apr 22 07:24:05 2014 UTC
@@ -2135,14 +2135,14 @@
     __ Bind(deferred->check_maps());
   }

-  UniqueSet<Map> map_set = instr->hydrogen()->map_set();
+  const UniqueSet<Map>* map_set = instr->hydrogen()->map_set();
   Label success;
-  for (int i = 0; i < map_set.size() - 1; i++) {
-    Handle<Map> map = map_set.at(i).handle();
+  for (int i = 0; i < map_set->size() - 1; i++) {
+    Handle<Map> map = map_set->at(i).handle();
     __ CompareMap(map_reg, map);
     __ B(eq, &success);
   }
-  Handle<Map> map = map_set.at(map_set.size() - 1).handle();
+  Handle<Map> map = map_set->at(map_set->size() - 1).handle();
   __ CompareMap(map_reg, map);

   // We didn't match a map.
=======================================
--- /branches/bleeding_edge/src/hydrogen-check-elimination.cc Wed Apr 16 11:41:09 2014 UTC +++ /branches/bleeding_edge/src/hydrogen-check-elimination.cc Tue Apr 22 07:24:05 2014 UTC
@@ -305,7 +305,7 @@
     if (entry != NULL) {
       // entry found;
       MapSet a = entry->maps_;
-      MapSet i = instr->map_set().Copy(phase_->zone());
+      MapSet i = instr->map_set()->Copy(phase_->zone());
       if (a->IsSubset(i)) {
         // The first check is more strict; the second is redundant.
         if (entry->check_ != NULL) {
@@ -364,7 +364,7 @@
       }
     } else {
       // No entry; insert a new one.
-      Insert(object, instr, instr->map_set().Copy(phase_->zone()));
+      Insert(object, instr, instr->map_set()->Copy(phase_->zone()));
     }
   }

@@ -384,8 +384,8 @@
     // Reduce a load of the map field when it is known to be a constant.
     if (!IsMapAccess(instr->access())) {
       // Check if we introduce field maps here.
-      if (instr->map_set().size() != 0) {
-        Insert(instr, instr, instr->map_set().Copy(phase_->zone()));
+      if (instr->map_set()->size() != 0) {
+        Insert(instr, instr, instr->map_set()->Copy(phase_->zone()));
       }
       return;
     }
=======================================
--- /branches/bleeding_edge/src/hydrogen-instructions.h Wed Apr 16 11:41:09 2014 UTC +++ /branches/bleeding_edge/src/hydrogen-instructions.h Tue Apr 22 07:24:05 2014 UTC
@@ -2770,7 +2770,7 @@
   HValue* typecheck() { return OperandAt(1); }

   Unique<Map> first_map() const { return map_set_.at(0); }
-  UniqueSet<Map> map_set() const { return map_set_; }
+  const UniqueSet<Map>* map_set() const { return &map_set_; }

   void set_map_set(UniqueSet<Map>* maps, Zone *zone) {
     map_set_.Clear();
@@ -6172,7 +6172,7 @@
       return access_.representation();
   }

-  UniqueSet<Map> map_set() const { return map_set_; }
+  const UniqueSet<Map>* map_set() const { return &map_set_; }

virtual bool HasEscapingOperandAt(int index) V8_OVERRIDE { return false; }
   virtual bool HasOutOfBoundsAccess(int size) V8_OVERRIDE {
=======================================
--- /branches/bleeding_edge/src/hydrogen-load-elimination.cc Tue Feb 25 09:55:50 2014 UTC +++ /branches/bleeding_edge/src/hydrogen-load-elimination.cc Tue Apr 22 07:24:05 2014 UTC
@@ -78,7 +78,10 @@
         HValue* result = load(l);
         if (result != instr &&
             result->type().Equals(instr->type()) &&
-            result->representation().Equals(instr->representation())) {
+            result->representation().Equals(instr->representation()) &&
+            (!result->IsLoadNamedField() ||
+             HLoadNamedField::cast(instr)->map_set()->IsSubset(
+                 HLoadNamedField::cast(result)->map_set()))) {
           // The load can be replaced with a previous load or a value.
           TRACE(("  replace L%d -> v%d\n", instr->id(), result->id()));
           instr->DeleteAndReplaceWith(result);
=======================================
--- /branches/bleeding_edge/src/ia32/lithium-codegen-ia32.cc Tue Apr 15 07:36:47 2014 UTC +++ /branches/bleeding_edge/src/ia32/lithium-codegen-ia32.cc Tue Apr 22 07:24:05 2014 UTC
@@ -5638,15 +5638,15 @@
     __ bind(deferred->check_maps());
   }

-  UniqueSet<Map> map_set = instr->hydrogen()->map_set();
+  const UniqueSet<Map>* map_set = instr->hydrogen()->map_set();
   Label success;
-  for (int i = 0; i < map_set.size() - 1; i++) {
-    Handle<Map> map = map_set.at(i).handle();
+  for (int i = 0; i < map_set->size() - 1; i++) {
+    Handle<Map> map = map_set->at(i).handle();
     __ CompareMap(reg, map);
     __ j(equal, &success, Label::kNear);
   }

-  Handle<Map> map = map_set.at(map_set.size() - 1).handle();
+  Handle<Map> map = map_set->at(map_set->size() - 1).handle();
   __ CompareMap(reg, map);
   if (instr->hydrogen()->has_migration_target()) {
     __ j(not_equal, deferred->entry());
=======================================
--- /branches/bleeding_edge/src/mips/lithium-codegen-mips.cc Tue Apr 15 16:39:21 2014 UTC +++ /branches/bleeding_edge/src/mips/lithium-codegen-mips.cc Tue Apr 22 07:24:05 2014 UTC
@@ -5197,13 +5197,13 @@
     __ bind(deferred->check_maps());
   }

-  UniqueSet<Map> map_set = instr->hydrogen()->map_set();
+  const UniqueSet<Map>* map_set = instr->hydrogen()->map_set();
   Label success;
-  for (int i = 0; i < map_set.size() - 1; i++) {
-    Handle<Map> map = map_set.at(i).handle();
+  for (int i = 0; i < map_set->size() - 1; i++) {
+    Handle<Map> map = map_set->at(i).handle();
     __ CompareMapAndBranch(map_reg, map, &success, eq, &success);
   }
-  Handle<Map> map = map_set.at(map_set.size() - 1).handle();
+  Handle<Map> map = map_set->at(map_set->size() - 1).handle();
   // Do the CompareMap() directly within the Branch() and DeoptimizeIf().
   if (instr->hydrogen()->has_migration_target()) {
     __ Branch(deferred->entry(), ne, map_reg, Operand(map));
=======================================
--- /branches/bleeding_edge/src/unique.h        Fri Mar  7 10:14:03 2014 UTC
+++ /branches/bleeding_edge/src/unique.h        Tue Apr 22 07:24:05 2014 UTC
@@ -189,7 +189,7 @@
   }

   // Compare this set against another set. O(|this|).
-  bool Equals(UniqueSet<T>* that) const {
+  bool Equals(const UniqueSet<T>* that) const {
     if (that->size_ != this->size_) return false;
     for (int i = 0; i < this->size_; i++) {
       if (this->array_[i] != that->array_[i]) return false;
@@ -200,7 +200,7 @@
   // Check whether this set contains the given element. O(|this|)
// TODO(titzer): use binary search for large sets to make this O(log| this|)
   template <typename U>
-  bool Contains(Unique<U> elem) const {
+  bool Contains(const Unique<U> elem) const {
     for (int i = 0; i < size_; i++) {
       if (this->array_[i] == elem) return true;
     }
@@ -208,7 +208,7 @@
   }

   // Check if this set is a subset of the given set. O(|this| + |that|).
-  bool IsSubset(UniqueSet<T>* that) const {
+  bool IsSubset(const UniqueSet<T>* that) const {
     if (that->size_ < this->size_) return false;
     int j = 0;
     for (int i = 0; i < this->size_; i++) {
=======================================
--- /branches/bleeding_edge/src/x64/lithium-codegen-x64.cc Tue Apr 15 07:36:47 2014 UTC +++ /branches/bleeding_edge/src/x64/lithium-codegen-x64.cc Tue Apr 22 07:24:05 2014 UTC
@@ -5052,15 +5052,15 @@
     __ bind(deferred->check_maps());
   }

-  UniqueSet<Map> map_set = instr->hydrogen()->map_set();
+  const UniqueSet<Map>* map_set = instr->hydrogen()->map_set();
   Label success;
-  for (int i = 0; i < map_set.size() - 1; i++) {
-    Handle<Map> map = map_set.at(i).handle();
+  for (int i = 0; i < map_set->size() - 1; i++) {
+    Handle<Map> map = map_set->at(i).handle();
     __ CompareMap(reg, map);
     __ j(equal, &success, Label::kNear);
   }

-  Handle<Map> map = map_set.at(map_set.size() - 1).handle();
+  Handle<Map> map = map_set->at(map_set->size() - 1).handle();
   __ CompareMap(reg, map);
   if (instr->hydrogen()->has_migration_target()) {
     __ j(not_equal, deferred->entry());

--
--
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/d/optout.

Reply via email to