Reviewers: Hannes Payer,

Description:
Version 3.25.28.18 (merged r20967)

Don't adopt the AST id from previous if id is none, since previous may have
mismatching expected stack height. Additionally, harden merging of simulates
after instructions with side effects and ensure there's a simulate before
HEnterInlined.

[email protected]

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

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

Affected files (+30, -19 lines):
  M src/hydrogen-instructions.cc
  M src/hydrogen-removable-simulates.cc
  M src/version.cc
  A + test/mjsunit/regress/regress-lazy-deopt-inlining2.js


Index: src/hydrogen-instructions.cc
diff --git a/src/hydrogen-instructions.cc b/src/hydrogen-instructions.cc
index 8333193db0ca99d46036567cb41e95d58dc98602..59b23114bb7c7ab9f0549f6c19e24941847e226b 100644
--- a/src/hydrogen-instructions.cc
+++ b/src/hydrogen-instructions.cc
@@ -2569,9 +2569,6 @@ void HPhi::AddIndirectUsesTo(int* dest) {


 void HSimulate::MergeWith(ZoneList<HSimulate*>* list) {
-  if (!list->is_empty() && !HasAstId()) {
-    set_ast_id(list->last()->ast_id());
-  }
   while (!list->is_empty()) {
     HSimulate* from = list->RemoveLast();
     ZoneList<HValue*>* from_values = &from->values_;
Index: src/hydrogen-removable-simulates.cc
diff --git a/src/hydrogen-removable-simulates.cc b/src/hydrogen-removable-simulates.cc index f952832431c124dcda6079a941947ad9cd7ed389..bd8de0b4f4f6755eb546a41ddc99e27736409212 100644
--- a/src/hydrogen-removable-simulates.cc
+++ b/src/hydrogen-removable-simulates.cc
@@ -41,14 +41,17 @@ void HMergeRemovableSimulatesPhase::Run() {
     bool first = true;
     for (HInstructionIterator it(block); !it.Done(); it.Advance()) {
       HInstruction* current = it.Current();
+      if (current->IsEnterInlined()) {
+ // Ensure there's a non-foldable HSimulate before an HEnterInlined to
+        // avoid folding across HEnterInlined.
+        ASSERT(!HSimulate::cast(current->previous())->
+                   is_candidate_for_removal());
+      }
       if (current->IsLeaveInlined()) {
-        // Never fold simulates from inlined environments into simulates
-        // in the outer environment.
-        // (Before each HEnterInlined, there is a non-foldable HSimulate
-        // anyway, so we get the barrier in the other direction for free.)
-        // Simply remove all accumulated simulates without merging.  This
-        // is safe because simulates after instructions with side effects
-        // are never added to the merge list.
+ // Never fold simulates from inlined environments into simulates in the + // outer environment. Simply remove all accumulated simulates without + // merging. This is safe because simulates after instructions with side
+        // effects are never added to the merge list.
         while (!mergelist.is_empty()) {
           mergelist.RemoveLast()->DeleteAndReplaceWith(NULL);
         }
@@ -70,13 +73,24 @@ void HMergeRemovableSimulatesPhase::Run() {
         continue;
       }
       HSimulate* current_simulate = HSimulate::cast(current);
-      if ((current_simulate->previous()->HasObservableSideEffects() &&
-           !current_simulate->next()->IsSimulate()) ||
-          !current_simulate->is_candidate_for_removal()) {
-        // This simulate is not suitable for folding.
-        // Fold the ones accumulated so far.
+      if (!current_simulate->is_candidate_for_removal()) {
+        current_simulate->MergeWith(&mergelist);
+      } else if (current_simulate->ast_id().IsNone()) {
+        ASSERT(current_simulate->next()->IsEnterInlined());
+        if (!mergelist.is_empty()) {
+          HSimulate* last = mergelist.RemoveLast();
+          last->MergeWith(&mergelist);
+        }
+ } else if (current_simulate->previous()->HasObservableSideEffects()) {
+        while (current_simulate->next()->IsSimulate()) {
+          it.Advance();
+          HSimulate* next_simulate = HSimulate::cast(it.Current());
+          if (next_simulate->ast_id().IsNone()) break;
+          mergelist.Add(current_simulate, zone());
+          current_simulate = next_simulate;
+          if (!current_simulate->is_candidate_for_removal()) break;
+        }
         current_simulate->MergeWith(&mergelist);
-        continue;
       } else {
         // Accumulate this simulate for folding later on.
         mergelist.Add(current_simulate, zone());
Index: src/version.cc
diff --git a/src/version.cc b/src/version.cc
index 6cb1b22b4197a3444d5e2b0069bb15eea7293456..d574eed6374d030c57c98ed94c8314b2d801552b 100644
--- a/src/version.cc
+++ b/src/version.cc
@@ -35,7 +35,7 @@
 #define MAJOR_VERSION     3
 #define MINOR_VERSION     25
 #define BUILD_NUMBER      28
-#define PATCH_LEVEL       17
+#define PATCH_LEVEL       18
 // Use 1 for candidates and 0 otherwise.
 // (Boolean macro values are not supported by all preprocessors.)
 #define IS_CANDIDATE_VERSION 0
Index: test/mjsunit/regress/regress-lazy-deopt-inlining2.js
diff --git a/test/mjsunit/regress/regress-lazy-deopt-inlining.js b/test/mjsunit/regress/regress-lazy-deopt-inlining2.js
similarity index 85%
copy from test/mjsunit/regress/regress-lazy-deopt-inlining.js
copy to test/mjsunit/regress/regress-lazy-deopt-inlining2.js
index 6cda168dff5c948727d854c93d192c4fcac88a03..7b73b142322aeb4efb46768585437e8036c481e2 100644
--- a/test/mjsunit/regress/regress-lazy-deopt-inlining.js
+++ b/test/mjsunit/regress/regress-lazy-deopt-inlining2.js
@@ -6,10 +6,10 @@

 "use strict";
 function f1(d) {
-  return 1 + f2(f3(d));
+  return 1 + f2(1, f3(d), d);
 }

-function f2(v) { return v; }
+function f2(v0, v1, v2) { return v1; }

 function f3(d) {
   if (d) %DeoptimizeFunction(f1);


--
--
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