Reviewers: Kevin Millikin,

Description:
Merge r10350 from the bleeding_edge to the 3.7 branch.

Adjust position recorded for call expressions.

For calls of the form ident(...) record position of the identifier as the
position of the call. For other calls record positions of the opening
parenthesis.

This guarantees that for expressions of the form function(){}() call position will not intersect with positions recorded for function literal which is used by
the debugger for scope chain resolution.

[email protected]
BUG=http://crbug.com/109195
TEST=test/mjsunit/regress/regress-109195.js

Review URL: http://codereview.chromium.org/9125001
------------------------------------------------------------------------

Please review this at http://codereview.chromium.org/9127002/

SVN Base: http://v8.googlecode.com/svn/branches/3.7/

Affected files:
  M     src/parser.cc
  M     src/scopes.cc
  M     src/version.cc
  A  +  test/mjsunit/regress/regress-109195.js


### BEGIN SVN COPY METADATA
#$ cp branches/bleeding_edge/test/mjsunit/regress/regress-109195.js test/mjsunit/regress/regress-109195.js
### END SVN COPY METADATA
Index: src/parser.cc
===================================================================
--- src/parser.cc       (revision 10163)
+++ src/parser.cc       (working copy)
@@ -2998,7 +2998,19 @@
       }

       case Token::LPAREN: {
-        int pos = scanner().location().beg_pos;
+        int pos;
+        if (scanner().current_token() == Token::IDENTIFIER) {
+          // For call of an identifier we want to report position of
+          // the identifier as position of the call in the stack trace.
+          pos = scanner().location().beg_pos;
+        } else {
+ // For other kinds of calls we record position of the parenthesis as + // position of the call. Note that this is extremely important for + // expressions of the form function(){...}() for which call position + // should not point to the closing brace otherwise it will intersect + // with positions recorded for function literal and confuse debugger.
+          pos = scanner().peek_location().beg_pos;
+        }
         ZoneList<Expression*>* args = ParseArguments(CHECK_OK);

         // Keep track of eval() calls since they disable all local variable
Index: src/scopes.cc
===================================================================
--- src/scopes.cc       (revision 10163)
+++ src/scopes.cc       (working copy)
@@ -767,7 +767,7 @@
     PrintF(")");
   }

-  PrintF(" {\n");
+  PrintF(" { // (%d, %d)\n", start_position(), end_position());

   // Function name, if any (named function literals, only).
   if (function_ != NULL) {
Index: src/version.cc
===================================================================
--- src/version.cc      (revision 10163)
+++ src/version.cc      (working copy)
@@ -35,7 +35,7 @@
 #define MAJOR_VERSION     3
 #define MINOR_VERSION     7
 #define BUILD_NUMBER      12
-#define PATCH_LEVEL       6
+#define PATCH_LEVEL       7
 // 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-109195.js


--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to