Title: [191982] trunk/Source
Revision
191982
Author
sbar...@apple.com
Date
2015-11-03 15:23:23 -0800 (Tue, 03 Nov 2015)

Log Message

Rewrite "const" as "var" for iTunes/iBooks on the Mac
https://bugs.webkit.org/show_bug.cgi?id=150852

Reviewed by Geoffrey Garen.

Source/_javascript_Core:

VM now has a setting indicating if we should treat
"const" variables as "var" to more closely match
JSC's previous implementation of "const" before ES6.

* parser/Parser.h:
(JSC::Parser::next):
(JSC::Parser::nextExpectIdentifier):
* runtime/VM.h:
(JSC::VM::setShouldRewriteConstAsVar):
(JSC::VM::shouldRewriteConstAsVar):

Source/WebCore:

* bindings/js/JSDOMWindowBase.cpp:
(WebCore::JSDOMWindowBase::commonVM):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (191981 => 191982)


--- trunk/Source/_javascript_Core/ChangeLog	2015-11-03 22:51:52 UTC (rev 191981)
+++ trunk/Source/_javascript_Core/ChangeLog	2015-11-03 23:23:23 UTC (rev 191982)
@@ -1,3 +1,21 @@
+2015-11-03  Saam barati  <sbar...@apple.com>
+
+        Rewrite "const" as "var" for iTunes/iBooks on the Mac
+        https://bugs.webkit.org/show_bug.cgi?id=150852
+
+        Reviewed by Geoffrey Garen.
+
+        VM now has a setting indicating if we should treat
+        "const" variables as "var" to more closely match
+        JSC's previous implementation of "const" before ES6.
+
+        * parser/Parser.h:
+        (JSC::Parser::next):
+        (JSC::Parser::nextExpectIdentifier):
+        * runtime/VM.h:
+        (JSC::VM::setShouldRewriteConstAsVar):
+        (JSC::VM::shouldRewriteConstAsVar):
+
 2015-11-03  Mark Lam  <mark....@apple.com>
 
         Fix some inefficiencies in the baseline usage of JITAddGenerator.

Modified: trunk/Source/_javascript_Core/parser/Parser.h (191981 => 191982)


--- trunk/Source/_javascript_Core/parser/Parser.h	2015-11-03 22:51:52 UTC (rev 191981)
+++ trunk/Source/_javascript_Core/parser/Parser.h	2015-11-03 23:23:23 UTC (rev 191982)
@@ -908,6 +908,8 @@
         m_lastTokenEndPosition = JSTextPosition(lastLine, lastTokenEnd, lastTokenLineStart);
         m_lexer->setLastLineNumber(lastLine);
         m_token.m_type = m_lexer->lex(&m_token, lexerFlags, strictMode());
+        if (UNLIKELY(m_token.m_type == CONSTTOKEN && m_vm->shouldRewriteConstAsVar()))
+            m_token.m_type = VAR;
     }
 
     ALWAYS_INLINE void nextExpectIdentifier(unsigned lexerFlags = 0)

Modified: trunk/Source/_javascript_Core/runtime/VM.h (191981 => 191982)


--- trunk/Source/_javascript_Core/runtime/VM.h	2015-11-03 22:51:52 UTC (rev 191981)
+++ trunk/Source/_javascript_Core/runtime/VM.h	2015-11-03 23:23:23 UTC (rev 191982)
@@ -581,6 +581,8 @@
 
     JS_EXPORT_PRIVATE void queueMicrotask(JSGlobalObject*, PassRefPtr<Microtask>);
     JS_EXPORT_PRIVATE void drainMicrotasks();
+    JS_EXPORT_PRIVATE void setShouldRewriteConstAsVar(bool shouldRewrite) { m_shouldRewriteConstAsVar = shouldRewrite; }
+    ALWAYS_INLINE bool shouldRewriteConstAsVar() { return m_shouldRewriteConstAsVar; }
 
     inline bool shouldTriggerTermination(ExecState*);
 
@@ -634,6 +636,7 @@
     Exception* m_lastException { nullptr };
     bool m_failNextNewCodeBlock { false };
     bool m_inDefineOwnProperty;
+    bool m_shouldRewriteConstAsVar { false };
     std::unique_ptr<CodeCache> m_codeCache;
     LegacyProfiler* m_enabledProfiler;
     std::unique_ptr<BuiltinExecutables> m_builtinExecutables;

Modified: trunk/Source/WebCore/ChangeLog (191981 => 191982)


--- trunk/Source/WebCore/ChangeLog	2015-11-03 22:51:52 UTC (rev 191981)
+++ trunk/Source/WebCore/ChangeLog	2015-11-03 23:23:23 UTC (rev 191982)
@@ -1,3 +1,13 @@
+2015-11-03  Saam barati  <sbar...@apple.com>
+
+        Rewrite "const" as "var" for iTunes/iBooks on the Mac
+        https://bugs.webkit.org/show_bug.cgi?id=150852
+
+        Reviewed by Geoffrey Garen.
+
+        * bindings/js/JSDOMWindowBase.cpp:
+        (WebCore::JSDOMWindowBase::commonVM):
+
 2015-10-30  Jon Honeycutt  <jhoneyc...@apple.com>
 
         Implement support for the autocomplete attribute

Modified: trunk/Source/WebCore/bindings/js/JSDOMWindowBase.cpp (191981 => 191982)


--- trunk/Source/WebCore/bindings/js/JSDOMWindowBase.cpp	2015-11-03 22:51:52 UTC (rev 191981)
+++ trunk/Source/WebCore/bindings/js/JSDOMWindowBase.cpp	2015-11-03 23:23:23 UTC (rev 191982)
@@ -34,6 +34,7 @@
 #include "JSNode.h"
 #include "Logging.h"
 #include "Page.h"
+#include "RuntimeApplicationChecks.h"
 #include "ScriptController.h"
 #include "SecurityOrigin.h"
 #include "Settings.h"
@@ -261,6 +262,12 @@
         vm->heap.setIncrementalSweeper(std::make_unique<WebSafeIncrementalSweeper>(&vm->heap));
         vm->heap.machineThreads().addCurrentThread();
 #endif
+
+#if PLATFORM(MAC)
+        if (applicationIsITunes() || applicationIsIBooks())
+            vm->setShouldRewriteConstAsVar(true);
+#endif
+
         initNormalWorldClientData(vm);
     }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to