WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
patch
b-backup.diff (text/plain), 16.02 KB, created by
Saam Barati
on 2016-04-26 17:22:45 PDT
(
hide
)
Description:
patch
Filename:
MIME Type:
Creator:
Saam Barati
Created:
2016-04-26 17:22:45 PDT
Size:
16.02 KB
patch
obsolete
>Index: Source/JavaScriptCore/ChangeLog >=================================================================== >--- Source/JavaScriptCore/ChangeLog (revision 200113) >+++ Source/JavaScriptCore/ChangeLog (working copy) >@@ -1,3 +1,50 @@ >+2016-04-26 Saam barati <sbarati@apple.com> >+ >+ JSC should have an option to allow global const redeclarations >+ https://bugs.webkit.org/show_bug.cgi?id=157006 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ This patch implements an option that dictates whether >+ const redeclarations at the program level will throw. >+ This option defaults to true but allows users of JSC >+ to set it to false. This option is per VM. This is needed >+ for backwards compatibility with our old const implementation. >+ >+ * jsc.cpp: >+ (GlobalObject::finishCreation): >+ (functionShadowChickenFunctionsOnStack): >+ (functionSetGlobalConstRedeclarationShouldNotThrow): >+ (functionReadline): >+ * runtime/Executable.cpp: >+ (JSC::ProgramExecutable::initializeGlobalProperties): >+ * runtime/JSGlobalLexicalEnvironment.cpp: >+ (JSC::JSGlobalLexicalEnvironment::put): >+ (JSC::JSGlobalLexicalEnvironment::isConstVariable): >+ * runtime/JSGlobalLexicalEnvironment.h: >+ (JSC::JSGlobalLexicalEnvironment::isEmpty): >+ * runtime/VM.h: >+ (JSC::VM::setGlobalConstRedeclarationShouldThrow): >+ (JSC::VM::globalConstRedeclarationShouldThrow): >+ * tests/stress/global-const-redeclaration-setting: Added. >+ * tests/stress/global-const-redeclaration-setting-2.js: Added. >+ (assert): >+ * tests/stress/global-const-redeclaration-setting-3.js: Added. >+ (assert): >+ (catch): >+ * tests/stress/global-const-redeclaration-setting-4.js: Added. >+ (assert): >+ (catch): >+ * tests/stress/global-const-redeclaration-setting-5.js: Added. >+ (assert): >+ (catch): >+ * tests/stress/global-const-redeclaration-setting.js: Added. >+ (assert): >+ * tests/stress/global-const-redeclaration-setting/first.js: Added. >+ * tests/stress/global-const-redeclaration-setting/let.js: Added. >+ * tests/stress/global-const-redeclaration-setting/second.js: Added. >+ * tests/stress/global-const-redeclaration-setting/strict.js: Added. >+ > 2016-04-26 Benjamin Poulain <bpoulain@apple.com> > > [JSC] GetByVal on Undecided use its children before its OSR Exit >Index: Source/JavaScriptCore/jsc.cpp >=================================================================== >--- Source/JavaScriptCore/jsc.cpp (revision 200037) >+++ Source/JavaScriptCore/jsc.cpp (working copy) >@@ -634,6 +634,7 @@ static EncodedJSValue JSC_HOST_CALL func > #endif > > static EncodedJSValue JSC_HOST_CALL functionShadowChickenFunctionsOnStack(ExecState*); >+static EncodedJSValue JSC_HOST_CALL functionSetGlobalConstRedeclarationShouldNotThrow(ExecState*); > > struct Script { > bool isFile; >@@ -778,6 +779,7 @@ protected: > addFunction(vm, "clearSamplingFlags", functionClearSamplingFlags, 1); > #endif > addFunction(vm, "shadowChickenFunctionsOnStack", functionShadowChickenFunctionsOnStack, 0); >+ addFunction(vm, "setGlobalConstRedeclarationShouldNotThrow", functionSetGlobalConstRedeclarationShouldNotThrow, 0); > addConstructableFunction(vm, "Root", functionCreateRoot, 0); > addConstructableFunction(vm, "Element", functionCreateElement, 1); > addFunction(vm, "getElement", functionGetElement, 1); >@@ -1494,6 +1496,12 @@ EncodedJSValue JSC_HOST_CALL functionSha > return JSValue::encode(exec->vm().shadowChicken().functionsOnStack(exec)); > } > >+EncodedJSValue JSC_HOST_CALL functionSetGlobalConstRedeclarationShouldNotThrow(ExecState* exec) >+{ >+ exec->vm().setGlobalConstRedeclarationShouldThrow(false); >+ return JSValue::encode(jsUndefined()); >+} >+ > EncodedJSValue JSC_HOST_CALL functionReadline(ExecState* exec) > { > Vector<char, 256> line; >Index: Source/JavaScriptCore/runtime/Executable.cpp >=================================================================== >--- Source/JavaScriptCore/runtime/Executable.cpp (revision 200037) >+++ Source/JavaScriptCore/runtime/Executable.cpp (working copy) >@@ -606,8 +606,15 @@ JSObject* ProgramExecutable::initializeG > if (globalObject->hasProperty(exec, entry.key.get())) > return createSyntaxError(exec, makeString("Can't create duplicate variable that shadows a global property: '", String(entry.key.get()), "'")); > >- if (globalLexicalEnvironment->hasProperty(exec, entry.key.get())) >+ if (globalLexicalEnvironment->hasProperty(exec, entry.key.get())) { >+ if (UNLIKELY(entry.value.isConst() && !vm.globalConstRedeclarationShouldThrow() && !isStrictMode())) { >+ // We only allow "const" duplicate declarations under this setting. >+ // For example, we don't "let" variables to be overridden by "const" variables. >+ if (globalLexicalEnvironment->isConstVariable(entry.key.get())) >+ continue; >+ } > return createSyntaxError(exec, makeString("Can't create duplicate variable: '", String(entry.key.get()), "'")); >+ } > } > > // Check if any new "var"s will shadow any previous "let"/"const"/"class" names. >@@ -646,6 +653,10 @@ JSObject* ProgramExecutable::initializeG > SymbolTable* symbolTable = globalLexicalEnvironment->symbolTable(); > ConcurrentJITLocker locker(symbolTable->m_lock); > for (auto& entry : lexicalDeclarations) { >+ if (UNLIKELY(entry.value.isConst() && !vm.globalConstRedeclarationShouldThrow() && !isStrictMode())) { >+ if (symbolTable->contains(locker, entry.key.get())) >+ continue; >+ } > ScopeOffset offset = symbolTable->takeNextScopeOffset(locker); > SymbolTableEntry newEntry(VarOffset(offset), entry.value.isConst() ? ReadOnly : 0); > newEntry.prepareToWatch(); >Index: Source/JavaScriptCore/runtime/JSGlobalLexicalEnvironment.cpp >=================================================================== >--- Source/JavaScriptCore/runtime/JSGlobalLexicalEnvironment.cpp (revision 200037) >+++ Source/JavaScriptCore/runtime/JSGlobalLexicalEnvironment.cpp (working copy) >@@ -49,4 +49,11 @@ bool JSGlobalLexicalEnvironment::put(JSC > return putResult; > } > >+bool JSGlobalLexicalEnvironment::isConstVariable(UniquedStringImpl* impl) >+{ >+ SymbolTableEntry entry = symbolTable()->get(impl); >+ ASSERT(!entry.isNull()); >+ return entry.isReadOnly(); >+} >+ > } // namespace JSC >Index: Source/JavaScriptCore/runtime/JSGlobalLexicalEnvironment.h >=================================================================== >--- Source/JavaScriptCore/runtime/JSGlobalLexicalEnvironment.h (revision 200037) >+++ Source/JavaScriptCore/runtime/JSGlobalLexicalEnvironment.h (working copy) >@@ -50,6 +50,7 @@ public: > static bool put(JSCell*, ExecState*, PropertyName, JSValue, PutPropertySlot&); > > bool isEmpty() const { return !symbolTable()->size(); } >+ bool isConstVariable(UniquedStringImpl*); > > DECLARE_INFO; > >Index: Source/JavaScriptCore/runtime/VM.h >=================================================================== >--- Source/JavaScriptCore/runtime/VM.h (revision 200037) >+++ Source/JavaScriptCore/runtime/VM.h (working copy) >@@ -602,6 +602,8 @@ public: > > JS_EXPORT_PRIVATE void queueMicrotask(JSGlobalObject*, PassRefPtr<Microtask>); > JS_EXPORT_PRIVATE void drainMicrotasks(); >+ JS_EXPORT_PRIVATE void setGlobalConstRedeclarationShouldThrow(bool globalConstRedeclarationThrow) { m_globalConstRedeclarationShouldThrow = globalConstRedeclarationThrow; } >+ ALWAYS_INLINE bool globalConstRedeclarationShouldThrow() const { return m_globalConstRedeclarationShouldThrow; } > > inline bool shouldTriggerTermination(ExecState*); > >@@ -662,6 +664,7 @@ private: > Exception* m_lastException { nullptr }; > bool m_failNextNewCodeBlock { false }; > bool m_inDefineOwnProperty; >+ bool m_globalConstRedeclarationShouldThrow { true }; > bool m_shouldBuildPCToCodeOriginMapping { false }; > std::unique_ptr<CodeCache> m_codeCache; > LegacyProfiler* m_enabledProfiler; >Index: Source/JavaScriptCore/tests/stress/global-const-redeclaration-setting-2.js >=================================================================== >--- Source/JavaScriptCore/tests/stress/global-const-redeclaration-setting-2.js (revision 0) >+++ Source/JavaScriptCore/tests/stress/global-const-redeclaration-setting-2.js (working copy) >@@ -0,0 +1,13 @@ >+function assert(b) { >+ if (!b) >+ throw new Error("Bad assertion."); >+} >+ >+setGlobalConstRedeclarationShouldNotThrow(); // Allow duplicate const declarations at the global level. >+ >+for (let i = 0; i < 100; i++) { >+ load("./global-const-redeclaration-setting/first.js"); >+ assert(foo === 20); >+ load("./global-const-redeclaration-setting/second.js"); >+ assert(foo === 40); >+} >Index: Source/JavaScriptCore/tests/stress/global-const-redeclaration-setting-3.js >=================================================================== >--- Source/JavaScriptCore/tests/stress/global-const-redeclaration-setting-3.js (revision 0) >+++ Source/JavaScriptCore/tests/stress/global-const-redeclaration-setting-3.js (working copy) >@@ -0,0 +1,18 @@ >+function assert(b) { >+ if (!b) >+ throw new Error("Bad assertion."); >+} >+ >+setGlobalConstRedeclarationShouldNotThrow(); // Allow duplicate const declarations at the global level. >+ >+load("./global-const-redeclaration-setting/first.js"); >+assert(foo === 20); >+let threw = false; >+try { >+ load("./global-const-redeclaration-setting/strict.js"); // We ignore the setting and always throw an error when in strict mode! >+} catch(e) { >+ threw = true; >+} >+ >+assert(threw); >+assert(foo === 20); >Index: Source/JavaScriptCore/tests/stress/global-const-redeclaration-setting-4.js >=================================================================== >--- Source/JavaScriptCore/tests/stress/global-const-redeclaration-setting-4.js (revision 0) >+++ Source/JavaScriptCore/tests/stress/global-const-redeclaration-setting-4.js (working copy) >@@ -0,0 +1,18 @@ >+function assert(b) { >+ if (!b) >+ throw new Error("Bad assertion."); >+} >+ >+setGlobalConstRedeclarationShouldNotThrow(); // Allow duplicate const declarations at the global level. >+ >+load("./global-const-redeclaration-setting/first.js"); >+assert(foo === 20); >+let threw = false; >+try { >+ load("./global-const-redeclaration-setting/let.js"); // Redeclaration a 'let' variable should throw because this doesn't break backwards compat. >+} catch(e) { >+ threw = true; >+} >+ >+assert(threw); >+assert(foo === 20); >Index: Source/JavaScriptCore/tests/stress/global-const-redeclaration-setting-5.js >=================================================================== >--- Source/JavaScriptCore/tests/stress/global-const-redeclaration-setting-5.js (revision 0) >+++ Source/JavaScriptCore/tests/stress/global-const-redeclaration-setting-5.js (working copy) >@@ -0,0 +1,18 @@ >+function assert(b) { >+ if (!b) >+ throw new Error("Bad assertion."); >+} >+ >+setGlobalConstRedeclarationShouldNotThrow(); // Allow duplicate const declarations at the global level. >+ >+load("./global-const-redeclaration-setting/let.js"); >+assert(foo === 50); >+let threw = false; >+try { >+ load("./global-const-redeclaration-setting/first.js"); // Redeclaration of a 'let' to 'const' should always throw because it isn't breaking backwards compat. >+} catch(e) { >+ threw = true; >+} >+ >+assert(threw); >+assert(foo === 50); >Index: Source/JavaScriptCore/tests/stress/global-const-redeclaration-setting.js >=================================================================== >--- Source/JavaScriptCore/tests/stress/global-const-redeclaration-setting.js (revision 0) >+++ Source/JavaScriptCore/tests/stress/global-const-redeclaration-setting.js (working copy) >@@ -0,0 +1,11 @@ >+function assert(b) { >+ if (!b) >+ throw new Error("Bad assertion."); >+} >+ >+setGlobalConstRedeclarationShouldNotThrow(); // Allow duplicate const declarations at the global level. >+ >+load("./global-const-redeclaration-setting/first.js"); >+assert(foo === 20); >+load("./global-const-redeclaration-setting/second.js"); >+assert(foo === 40); >Index: Source/JavaScriptCore/tests/stress/global-const-redeclaration-setting/first.js >=================================================================== >--- Source/JavaScriptCore/tests/stress/global-const-redeclaration-setting/first.js (revision 0) >+++ Source/JavaScriptCore/tests/stress/global-const-redeclaration-setting/first.js (working copy) >@@ -0,0 +1 @@ >+const foo = 20; >Index: Source/JavaScriptCore/tests/stress/global-const-redeclaration-setting/let.js >=================================================================== >--- Source/JavaScriptCore/tests/stress/global-const-redeclaration-setting/let.js (revision 0) >+++ Source/JavaScriptCore/tests/stress/global-const-redeclaration-setting/let.js (working copy) >@@ -0,0 +1 @@ >+let foo = 50; >Index: Source/JavaScriptCore/tests/stress/global-const-redeclaration-setting/second.js >=================================================================== >--- Source/JavaScriptCore/tests/stress/global-const-redeclaration-setting/second.js (revision 0) >+++ Source/JavaScriptCore/tests/stress/global-const-redeclaration-setting/second.js (working copy) >@@ -0,0 +1 @@ >+const foo = 40; >Index: Source/JavaScriptCore/tests/stress/global-const-redeclaration-setting/strict.js >=================================================================== >--- Source/JavaScriptCore/tests/stress/global-const-redeclaration-setting/strict.js (revision 0) >+++ Source/JavaScriptCore/tests/stress/global-const-redeclaration-setting/strict.js (working copy) >@@ -0,0 +1,2 @@ >+"use strict"; >+const foo = 45; >Index: Source/WebCore/ChangeLog >=================================================================== >--- Source/WebCore/ChangeLog (revision 200037) >+++ Source/WebCore/ChangeLog (working copy) >@@ -1,3 +1,20 @@ >+2016-04-26 Saam barati <sbarati@apple.com> >+ >+ JSC should have an option to allow global const redeclarations >+ https://bugs.webkit.org/show_bug.cgi?id=157006 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ This patch makes the JS VM not throw global const redeclaration >+ errors when the application is iBooks. >+ >+ * bindings/js/JSDOMWindowBase.cpp: >+ (WebCore::JSDOMWindowBase::commonVM): >+ * page/Settings.h: >+ (WebCore::Settings::shouldUseHighResolutionTimers): >+ (WebCore::Settings::globalConstRedeclarationShouldThrow): >+ (WebCore::Settings::backgroundShouldExtendBeyondPage): >+ > 2016-04-25 Chris Dumez <cdumez@apple.com> > > [Web IDL] Specify default values for parameters of type 'unsigned short' >Index: Source/WebCore/bindings/js/JSDOMWindowBase.cpp >=================================================================== >--- Source/WebCore/bindings/js/JSDOMWindowBase.cpp (revision 200037) >+++ Source/WebCore/bindings/js/JSDOMWindowBase.cpp (working copy) >@@ -269,6 +269,8 @@ VM& JSDOMWindowBase::commonVM() > vm->heap.machineThreads().addCurrentThread(); > #endif > >+ vm->setGlobalConstRedeclarationShouldThrow(Settings::globalConstRedeclarationShouldThrow()); >+ > initNormalWorldClientData(vm); > } > >Index: Source/WebCore/page/Settings.h >=================================================================== >--- Source/WebCore/page/Settings.h (revision 200037) >+++ Source/WebCore/page/Settings.h (working copy) >@@ -30,6 +30,7 @@ > #include "ClipboardAccessPolicy.h" > #include "EditingBehaviorTypes.h" > #include "IntSize.h" >+#include "RuntimeApplicationChecks.h" > #include "SecurityOrigin.h" > #include "SettingsMacros.h" > #include "TextFlags.h" >@@ -183,6 +184,17 @@ public: > static bool shouldUseHighResolutionTimers() { return gShouldUseHighResolutionTimers; } > #endif > >+ static bool globalConstRedeclarationShouldThrow() >+ { >+#if PLATFORM(MAC) >+ return !MacApplication::isIBooks(); >+#elif PLATFORM(IOS) >+ return !IOSApplication::isIBooks(); >+#else >+ return true; >+#endif >+ } >+ > WEBCORE_EXPORT void setBackgroundShouldExtendBeyondPage(bool); > bool backgroundShouldExtendBeyondPage() const { return m_backgroundShouldExtendBeyondPage; } >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 157006
:
277297
|
277406
| 277426 |
277538