Reviewers: Jakob,
Description:
Fix off-by-one error in AstTyper.
This causes the first parameter to be confused with the first
stack local when we collect type information.
[email protected]
Please review this at https://codereview.chromium.org/105943007/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files (+12, -7 lines):
M src/typing.h
A + test/mjsunit/regress/regress-param-local-type.js
Index: src/typing.h
diff --git a/src/typing.h b/src/typing.h
index
c942b0063278708d4c4828652ebd7d9365943717..6298e5a41b3d6824f45cc6879e408f48014ce9b0
100644
--- a/src/typing.h
+++ b/src/typing.h
@@ -84,7 +84,7 @@ class AstTyper: public AstVisitor {
int variable_index(Variable* var) {
return var->IsStackLocal() ? var->index() :
- var->IsParameter() ? -var->index() : kNoVar;
+ var->IsParameter() ? -var->index() - 1 : kNoVar;
}
void VisitDeclarations(ZoneList<Declaration*>* declarations);
Index: test/mjsunit/regress/regress-param-local-type.js
diff --git a/test/mjsunit/compiler/increment-typefeedback.js
b/test/mjsunit/regress/regress-param-local-type.js
similarity index 86%
copy from test/mjsunit/compiler/increment-typefeedback.js
copy to test/mjsunit/regress/regress-param-local-type.js
index
798959296c43014f252d65ae5dd11e00563bfd04..e339a06d03b8657a8ab95a6b36e49e97d3752beb
100644
--- a/test/mjsunit/compiler/increment-typefeedback.js
+++ b/test/mjsunit/regress/regress-param-local-type.js
@@ -27,13 +27,18 @@
// Flags: --allow-natives-syntax
-function f(x) {
- x++;
- return x;
+// Test that we do not confuse the first local and the first parameter
+// when gathering type information.
+
+function f(a) { // First parameter has smi type.
+ var s = ''; // First local has string type.
+ var n = 0;
+ var i = 1;
+ n = i + a;
}
-f(0.5);
-f(0.5);
+f(1);
+f(1);
%OptimizeFunctionOnNextCall(f);
-f(0.5);
+f(1);
assertOptimized(f);
--
--
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.