Reviewers: Yury Semikhatsky,

Description:
Add support for //# sourceURL similar to deprecated //@ sourceURL one.

BUG=v8:2702

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

SVN Base: git://github.com/v8/v8.git@master

Affected files:
  M include/v8.h
  M src/messages.js
  M test/cctest/test-api.cc
  M test/mjsunit/debug-compile-event.js
  M test/mjsunit/debug-set-script-source.js
  M test/mjsunit/debug-setbreakpoint.js
  M test/mjsunit/regress/regress-1853.js
  M test/mjsunit/stack-traces.js


Index: include/v8.h
diff --git a/include/v8.h b/include/v8.h
index 51040fe1a70f57d992f08d6107e8f0316de42955..96b13655e5ae995db32a548f590cc9fe731dcbdb 100644
--- a/include/v8.h
+++ b/include/v8.h
@@ -1219,7 +1219,8 @@ class V8EXPORT StackFrame {
   /**
    * Returns the name of the resource that contains the script for the
    * function for this StackFrame or sourceURL value if the script name
-   * is undefined and its source ends with //@ sourceURL=... string.
+   * is undefined and its source ends with //# sourceURL=... string or
+   * deprecated //@ sourceURL=... string.
    */
   Local<String> GetScriptNameOrSourceURL() const;

Index: src/messages.js
diff --git a/src/messages.js b/src/messages.js
index 2ad68cbb032a8de3ffde75ab9938e40c2d600c55..ce075ce5e5f685d776c2292d03521223fad261c6 100644
--- a/src/messages.js
+++ b/src/messages.js
@@ -543,11 +543,11 @@ function ScriptLineCount() {
* If sourceURL comment is available and script starts at zero returns sourceURL
  * comment contents. Otherwise, script name is returned. See
* http://fbug.googlecode.com/svn/branches/firebug1.1/docs/ReleaseNotes_1.1.txt - * for details on using //@ sourceURL comment to identify scritps that don't
- * have name.
+ * and Source Map Revision 3 proposal for details on using //# sourceURL and + * deprecated //@ sourceURL comment to identify scripts that don't have name.
  *
- * @return {?string} script name if present, value for //@ sourceURL comment
- * otherwise.
+ * @return {?string} script name if present, value for //# sourceURL or
+ * deprecated //@ sourceURL comment otherwise.
  */
 function ScriptNameOrSourceURL() {
   if (this.line_offset > 0 || this.column_offset > 0) {
@@ -572,7 +572,7 @@ function ScriptNameOrSourceURL() {
   this.cachedNameOrSourceURL = this.name;
   if (sourceUrlPos > 4) {
     var sourceUrlPattern =
-        /\/\/@[\040\t]sourceURL=[\040\t]*([^\s\'\"]*)[\040\t]*$/gm;
+        /\/\/[#@][\040\t]sourceURL=[\040\t]*([^\s\'\"]*)[\040\t]*$/gm;
     // Don't reuse lastMatchInfo here, so we create a new array with room
     // for four captures (array with length one longer than the index
     // of the fourth capture, where the numbering is zero-based).
Index: test/cctest/test-api.cc
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
index e52dde37c994fea3d04b3444bb5cc8a6cf8d0836..ba03523c8f55cba7e6baca7298db0d86c0db389a 100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -16017,8 +16017,13 @@ TEST(SourceURLInStackTrace) {
     "}\n"
     "foo();\n"
     "}\n"
-    "eval('(' + outer +')()//@ sourceURL=eval_url');";
-  CHECK(CompileRun(source)->IsUndefined());
+    "eval('(' + outer +')()%s');";
+
+  i::ScopedVector<char> code(1024);
+  i::OS::SNPrintF(code, source, "//# sourceURL=eval_url");
+  CHECK(CompileRun(code.start())->IsUndefined());
+  i::OS::SNPrintF(code, source, "//@ sourceURL=eval_url");
+  CHECK(CompileRun(code.start())->IsUndefined());
 }


@@ -16058,9 +16063,13 @@ TEST(InlineScriptWithSourceURLInStackTrace) {
     "}\n"
     "foo();\n"
     "}\n"
-    "outer()\n"
-    "//@ sourceURL=source_url";
-  CHECK(CompileRunWithOrigin(source, "url", 0, 1)->IsUndefined());
+    "outer()\n%s";
+
+  i::ScopedVector<char> code(1024);
+  i::OS::SNPrintF(code, source, "//# sourceURL=source_url");
+  CHECK(CompileRunWithOrigin(code.start(), "url", 0, 1)->IsUndefined());
+  i::OS::SNPrintF(code, source, "//@ sourceURL=source_url");
+  CHECK(CompileRunWithOrigin(code.start(), "url", 0, 1)->IsUndefined());
 }


@@ -16100,9 +16109,13 @@ TEST(DynamicWithSourceURLInStackTrace) {
     "}\n"
     "foo();\n"
     "}\n"
-    "outer()\n"
-    "//@ sourceURL=source_url";
-  CHECK(CompileRunWithOrigin(source, "url", 0, 0)->IsUndefined());
+    "outer()\n%s";
+
+  i::ScopedVector<char> code(1024);
+  i::OS::SNPrintF(code, source, "//# sourceURL=source_url");
+  CHECK(CompileRunWithOrigin(code.start(), "url", 0, 0)->IsUndefined());
+  i::OS::SNPrintF(code, source, "//@ sourceURL=source_url");
+  CHECK(CompileRunWithOrigin(code.start(), "url", 0, 0)->IsUndefined());
 }

 static void CreateGarbageInOldSpace() {
Index: test/mjsunit/debug-compile-event.js
diff --git a/test/mjsunit/debug-compile-event.js b/test/mjsunit/debug-compile-event.js index 94dddfa1049f8ec9a5415aa55701364eb8eaf673..89a71ddb598197f4586c9cf99b3ac76f2a9b5019 100644
--- a/test/mjsunit/debug-compile-event.js
+++ b/test/mjsunit/debug-compile-event.js
@@ -80,7 +80,7 @@ function listener(event, exec_state, event_data, data) {
       var msg = eval('(' + json + ')');
       assertTrue('context' in msg.body.script);

-      // Check that we pick script name from //@ sourceURL, iff present
+      // Check that we pick script name from //# sourceURL, iff present
       assertEquals(current_source.indexOf('sourceURL') >= 0 ?
                      'myscript.js' : undefined,
                    event_data.script().name());
@@ -103,7 +103,7 @@ compileSource('eval("eval(\'(function(){return a;})\')")');
 source_count += 2;  // Using eval causes additional compilation event.
 compileSource('JSON.parse(\'{"a":1,"b":2}\')');
 // Using JSON.parse does not causes additional compilation events.
-compileSource('x=1; //@ sourceURL=myscript.js');
+compileSource('x=1; //# sourceURL=myscript.js');

 // Make sure that the debug event listener was invoked.
 assertFalse(exception, "exception in listener")
Index: test/mjsunit/debug-set-script-source.js
diff --git a/test/mjsunit/debug-set-script-source.js b/test/mjsunit/debug-set-script-source.js index 34ae8488a4de608543c543555e11236e1c65726e..10ab43cd63d4b3388f293e53e6b502bd952f5464 100644
--- a/test/mjsunit/debug-set-script-source.js
+++ b/test/mjsunit/debug-set-script-source.js
@@ -36,10 +36,10 @@ var exception = null;
 function listener(event, exec_state, event_data, data) {
   if (event == Debug.DebugEvent.BeforeCompile) {
     event_data.script().setSource(event_data.script().source() +
-        " //@ sourceURL=proper_location_" + (++script_number));
+        " //# sourceURL=proper_location_" + (++script_number));
   } else if (event == Debug.DebugEvent.AfterCompile) {
     try {
-      event_data.script().setSource("a=1 //@ sourceURL=wrong_location");
+      event_data.script().setSource("a=1 //# sourceURL=wrong_location");
     } catch(e) {
       exception = e;
     }
Index: test/mjsunit/debug-setbreakpoint.js
diff --git a/test/mjsunit/debug-setbreakpoint.js b/test/mjsunit/debug-setbreakpoint.js index 90dfcd136bd38b437cd22b5fe9f1be0c47d35fa4..8531c4e9358f407b46e184108eb6e7a363d2c0b9 100644
--- a/test/mjsunit/debug-setbreakpoint.js
+++ b/test/mjsunit/debug-setbreakpoint.js
@@ -146,7 +146,7 @@ function g() {
 };

 eval('function h(){}');
-eval('function sourceUrlFunc() { a = 2; }\n//@ sourceURL=sourceUrlScript');
+eval('function sourceUrlFunc() { a = 2; }\n//# sourceURL=sourceUrlScript');

 o = {a:function(){},b:function(){}}

Index: test/mjsunit/regress/regress-1853.js
diff --git a/test/mjsunit/regress/regress-1853.js b/test/mjsunit/regress/regress-1853.js index f80badecb6ab94171583e3e133701634dab5cfbb..cfafe82fa35a55c978a3cdbdc24ef6e3567ffc43 100644
--- a/test/mjsunit/regress/regress-1853.js
+++ b/test/mjsunit/regress/regress-1853.js
@@ -102,13 +102,13 @@ eval('function test1() {                \n' +
      '  assertFalse(test_break_1);      \n' +
      '  assertTrue(test_break_1);       \n' +
      '}                                 \n' +
-     '//@ sourceURL=testScriptOne');
+     '//# sourceURL=testScriptOne');

 eval('function test2() {                \n' +
      '  assertFalse(test_break_2);      \n' +
      '  assertTrue(test_break_2);       \n' +
      '}                                 \n' +
-     '//@ sourceURL=testScriptTwo');
+     '//# sourceURL=testScriptTwo');

 test1();
 test2();
Index: test/mjsunit/stack-traces.js
diff --git a/test/mjsunit/stack-traces.js b/test/mjsunit/stack-traces.js
index b5d58fa0759f3086bce84d139824114d0b80d505..4a37ee6fa4f9ead6629c351af03cc72111a173b7 100644
--- a/test/mjsunit/stack-traces.js
+++ b/test/mjsunit/stack-traces.js
@@ -64,13 +64,13 @@ function testNestedEval() {
 }

 function testEvalWithSourceURL() {
-  eval("function Doo() { FAIL; }; Doo();\n//@ sourceURL=res://name");
+  eval("function Doo() { FAIL; }; Doo();\n//# sourceURL=res://name");
 }

 function testNestedEvalWithSourceURL() {
   var x = "FAIL";
var innerEval = 'function Inner() { eval(x); }\n//@ sourceURL=res://inner-eval'; - eval("function Outer() { eval(innerEval); Inner(); }; Outer();\n//@ sourceURL=res://outer-eval"); + eval("function Outer() { eval(innerEval); Inner(); }; Outer();\n//# sourceURL=res://outer-eval");
 }

 function testValue() {


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