Revision: 18308
Author:   [email protected]
Date:     Thu Dec 12 15:19:57 2013 UTC
Log:      Fix off-by-one error in AstTyper, part 2.

[email protected]

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

Modified:
 /branches/bleeding_edge/src/typing.h
 /branches/bleeding_edge/test/mjsunit/regress/regress-param-local-type.js

=======================================
--- /branches/bleeding_edge/src/typing.h        Wed Dec 11 11:34:09 2013 UTC
+++ /branches/bleeding_edge/src/typing.h        Thu Dec 12 15:19:57 2013 UTC
@@ -83,8 +83,11 @@
   void ExitEffects() { store_ = store_.Pop(); }

   int variable_index(Variable* var) {
+    // Stack locals have the range [0 .. l]
+    // Parameters have the range [-1 .. p]
+    // We map this to [-p-2 .. -1, 0 .. l]
     return var->IsStackLocal() ? var->index() :
-           var->IsParameter() ? -var->index() - 1 : kNoVar;
+           var->IsParameter() ? -var->index() - 2 : kNoVar;
   }

   void VisitDeclarations(ZoneList<Declaration*>* declarations);
=======================================
--- /branches/bleeding_edge/test/mjsunit/regress/regress-param-local-type.js Wed Dec 11 11:34:09 2013 UTC +++ /branches/bleeding_edge/test/mjsunit/regress/regress-param-local-type.js Thu Dec 12 15:19:57 2013 UTC
@@ -42,3 +42,17 @@
 %OptimizeFunctionOnNextCall(f);
 f(1);
 assertOptimized(f);
+
+
+function g() {  // 0th parameter (receiver) is tagged.
+  var s = '';   // First local has string type.
+  var n = 0;
+  var i = 1;
+  n = i + this;
+}
+
+g.call(1);
+g.call(1);
+%OptimizeFunctionOnNextCall(g);
+g.call(1);
+assertOptimized(g);

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