Title: [242482] releases/WebKitGTK/webkit-2.24
Revision
242482
Author
carlo...@webkit.org
Date
2019-03-05 09:22:15 -0800 (Tue, 05 Mar 2019)

Log Message

Merge r242193 - The parser is failing to record the token location of new in new.target.
https://bugs.webkit.org/show_bug.cgi?id=195127
<rdar://problem/39645578>

Reviewed by Yusuke Suzuki.

JSTests:

* stress/parser-should-record-token-location-of-new-dot-target.js: Added.

Source/_javascript_Core:

Also adjust the token location for the following to be as shown:

    new.target
    ^
    super
    ^
    import.meta
    ^

* parser/Parser.cpp:
(JSC::Parser<LexerType>::parseMemberExpression):

Modified Paths

Added Paths

Diff

Modified: releases/WebKitGTK/webkit-2.24/JSTests/ChangeLog (242481 => 242482)


--- releases/WebKitGTK/webkit-2.24/JSTests/ChangeLog	2019-03-05 17:22:11 UTC (rev 242481)
+++ releases/WebKitGTK/webkit-2.24/JSTests/ChangeLog	2019-03-05 17:22:15 UTC (rev 242482)
@@ -1,3 +1,13 @@
+2019-02-27  Mark Lam  <mark....@apple.com>
+
+        The parser is failing to record the token location of new in new.target.
+        https://bugs.webkit.org/show_bug.cgi?id=195127
+        <rdar://problem/39645578>
+
+        Reviewed by Yusuke Suzuki.
+
+        * stress/parser-should-record-token-location-of-new-dot-target.js: Added.
+
 2019-02-27  Yusuke Suzuki  <ysuz...@apple.com>
 
         [JSC] mustHandleValues for dead bytecode locals should be ignored in DFG phases

Added: releases/WebKitGTK/webkit-2.24/JSTests/stress/parser-should-record-token-location-of-new-dot-target.js (0 => 242482)


--- releases/WebKitGTK/webkit-2.24/JSTests/stress/parser-should-record-token-location-of-new-dot-target.js	                        (rev 0)
+++ releases/WebKitGTK/webkit-2.24/JSTests/stress/parser-should-record-token-location-of-new-dot-target.js	2019-03-05 17:22:15 UTC (rev 242482)
@@ -0,0 +1,8 @@
+//@ runDefault("--forceDebuggerBytecodeGeneration=true")
+
+// This test should not crash.
+
+function foo() {
+    if (new.target) {}
+}
++foo();

Modified: releases/WebKitGTK/webkit-2.24/Source/_javascript_Core/ChangeLog (242481 => 242482)


--- releases/WebKitGTK/webkit-2.24/Source/_javascript_Core/ChangeLog	2019-03-05 17:22:11 UTC (rev 242481)
+++ releases/WebKitGTK/webkit-2.24/Source/_javascript_Core/ChangeLog	2019-03-05 17:22:15 UTC (rev 242482)
@@ -1,3 +1,23 @@
+2019-02-27  Mark Lam  <mark....@apple.com>
+
+        The parser is failing to record the token location of new in new.target.
+        https://bugs.webkit.org/show_bug.cgi?id=195127
+        <rdar://problem/39645578>
+
+        Reviewed by Yusuke Suzuki.
+
+        Also adjust the token location for the following to be as shown:
+
+            new.target
+            ^
+            super
+            ^
+            import.meta
+            ^
+
+        * parser/Parser.cpp:
+        (JSC::Parser<LexerType>::parseMemberExpression):
+
 2019-02-27  Yusuke Suzuki  <ysuz...@apple.com>
 
         [JSC] mustHandleValues for dead bytecode locals should be ignored in DFG phases

Modified: releases/WebKitGTK/webkit-2.24/Source/_javascript_Core/parser/Parser.cpp (242481 => 242482)


--- releases/WebKitGTK/webkit-2.24/Source/_javascript_Core/parser/Parser.cpp	2019-03-05 17:22:11 UTC (rev 242481)
+++ releases/WebKitGTK/webkit-2.24/Source/_javascript_Core/parser/Parser.cpp	2019-03-05 17:22:15 UTC (rev 242482)
@@ -1,7 +1,7 @@
 /*
  *  Copyright (C) 1999-2001 Harri Porten (por...@kde.org)
  *  Copyright (C) 2001 Peter Kelly (p...@post.com)
- *  Copyright (C) 2003, 2006-2010, 2013, 2016 Apple Inc. All rights reserved.
+ *  Copyright (C) 2003-2019 Apple Inc. All rights reserved.
  *
  *  This library is free software; you can redistribute it and/or
  *  modify it under the terms of the GNU Library General Public
@@ -4674,11 +4674,13 @@
     JSTextPosition expressionStart = tokenStartPosition();
     int newCount = 0;
     JSTokenLocation startLocation = tokenLocation();
-    JSTokenLocation location;
+    JSTokenLocation lastNewTokenLocation;
     while (match(NEW)) {
+        lastNewTokenLocation = tokenLocation();
         next();
         newCount++;
     }
+    JSTokenLocation location = tokenLocation();
 
     bool baseIsSuper = match(SUPER);
     bool previousBaseWasSuper = false;
@@ -4696,7 +4698,8 @@
                 semanticFailIfFalse(!closestOrdinaryFunctionScope->isGlobalCodeScope() || closestOrdinaryFunctionScope->evalContextType() == EvalContextType::FunctionEvalContext, "new.target is not valid inside arrow functions in global code");
                 currentScope()->setInnerArrowFunctionUsesNewTarget();
             }
-            base = context.createNewTargetExpr(location);
+            ASSERT(lastNewTokenLocation.line);
+            base = context.createNewTargetExpr(lastNewTokenLocation);
             newCount--;
             next();
         } else {
@@ -4730,8 +4733,6 @@
         if (consume(DOT)) {
             if (matchContextualKeyword(m_vm->propertyNames->builtinNames().metaPublicName())) {
                 semanticFailIfFalse(m_scriptMode == JSParserScriptMode::Module, "import.meta is only valid inside modules");
-
-                JSTokenLocation location(tokenLocation());
                 base = context.createImportMetaExpr(location, createResolveAndUseVariable(context, &m_vm->propertyNames->metaPrivateName, false, expressionStart, location));
                 next();
             } else {
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to