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), 17.90 KB, created by
Saam Barati
on 2016-04-25 17:54:38 PDT
(
hide
)
Description:
patch
Filename:
MIME Type:
Creator:
Saam Barati
Created:
2016-04-25 17:54:38 PDT
Size:
17.90 KB
patch
obsolete
>Index: Source/JavaScriptCore/ChangeLog >=================================================================== >--- Source/JavaScriptCore/ChangeLog (revision 200063) >+++ Source/JavaScriptCore/ChangeLog (working copy) >@@ -1,3 +1,38 @@ >+2016-04-25 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/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.js: Added. >+ (assert): >+ * tests/stress/global-const-redeclaration-setting/first.js: Added. >+ * tests/stress/global-const-redeclaration-setting/second.js: Added. >+ * tests/stress/global-const-redeclaration-setting/strict.js: Added. >+ > 2016-04-25 Michael Saboff <msaboff@apple.com> > > Crash using @tryGetById in DFG >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,6 +606,8 @@ 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 (UNLIKELY(entry.value.isConst() && !vm.globalConstRedeclarationShouldThrow() && !isStrictMode())) >+ continue; > if (globalLexicalEnvironment->hasProperty(exec, entry.key.get())) > return createSyntaxError(exec, makeString("Can't create duplicate variable: '", String(entry.key.get()), "'")); > } >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.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,23 @@ >+2016-04-25 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.cpp: >+ * page/Settings.h: >+ (WebCore::Settings::shouldUseHighResolutionTimers): >+ (WebCore::Settings::globalConstRedeclarationShouldThrow): >+ (WebCore::Settings::setGlobalConstRedeclarationShouldThrow): >+ (WebCore::Settings::backgroundShouldExtendBeyondPage): >+ * platform/RuntimeApplicationChecks.h: >+ > 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,16 @@ VM& JSDOMWindowBase::commonVM() > vm->heap.machineThreads().addCurrentThread(); > #endif > >+#if PLATFORM(MAC) >+ namespace ApplicationChecker = MacApplication; >+#elif PLATFORM(IOS) >+ namespace ApplicationChecker = IOSApplication; >+#endif >+#if PLATFORM(MAC) || PLATFORM(IOS) >+ if (ApplicationChecker::isIBooks() || !Settings::globalConstRedeclarationShouldThrow()) >+ vm->setGlobalConstRedeclarationShouldThrow(false); >+#endif >+ > initNormalWorldClientData(vm); > } > >Index: Source/WebCore/page/Settings.cpp >=================================================================== >--- Source/WebCore/page/Settings.cpp (revision 200037) >+++ Source/WebCore/page/Settings.cpp (working copy) >@@ -97,6 +97,7 @@ bool Settings::gMockCaptureDevicesEnable > bool Settings::gShouldUseHighResolutionTimers = true; > #endif > >+bool Settings::gGlobalConstRedeclarationShouldThrow = true; > bool Settings::gShouldRespectPriorityInCSSAttributeSetters = false; > bool Settings::gLowPowerVideoAudioBufferSizeEnabled = false; > bool Settings::gResourceLoadStatisticsEnabledEnabled = false; >Index: Source/WebCore/page/Settings.h >=================================================================== >--- Source/WebCore/page/Settings.h (revision 200037) >+++ Source/WebCore/page/Settings.h (working copy) >@@ -183,6 +183,9 @@ public: > static bool shouldUseHighResolutionTimers() { return gShouldUseHighResolutionTimers; } > #endif > >+ static bool globalConstRedeclarationShouldThrow() { return gGlobalConstRedeclarationShouldThrow; } >+ static void setGlobalConstRedeclarationShouldThrow(bool globalConstRedeclarationShouldThrow) { gGlobalConstRedeclarationShouldThrow = globalConstRedeclarationShouldThrow; } >+ > WEBCORE_EXPORT void setBackgroundShouldExtendBeyondPage(bool); > bool backgroundShouldExtendBeyondPage() const { return m_backgroundShouldExtendBeyondPage; } > >@@ -363,6 +366,7 @@ private: > #if PLATFORM(WIN) > static bool gShouldUseHighResolutionTimers; > #endif >+ WEBCORE_EXPORT static bool gGlobalConstRedeclarationShouldThrow; > static bool gShouldRespectPriorityInCSSAttributeSetters; > #if PLATFORM(IOS) > static bool gNetworkDataUsageTrackingEnabled; >Index: Source/WebCore/platform/RuntimeApplicationChecks.h >=================================================================== >--- Source/WebCore/platform/RuntimeApplicationChecks.h (revision 200037) >+++ Source/WebCore/platform/RuntimeApplicationChecks.h (working copy) >@@ -72,7 +72,7 @@ WEBCORE_EXPORT bool isDaijisenDictionary > bool isNASAHD(); > WEBCORE_EXPORT bool isTheEconomistOnIphone(); > WEBCORE_EXPORT bool isWebProcess(); >-bool isIBooks(); >+WEBCORE_EXPORT bool isIBooks(); > > } // IOSApplication > >Index: Source/WebKit2/ChangeLog >=================================================================== >--- Source/WebKit2/ChangeLog (revision 200037) >+++ Source/WebKit2/ChangeLog (working copy) >@@ -1,3 +1,19 @@ >+2016-04-25 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!). >+ >+ * Shared/WebProcessCreationParameters.cpp: >+ (WebKit::WebProcessCreationParameters::encode): >+ (WebKit::WebProcessCreationParameters::decode): >+ * Shared/WebProcessCreationParameters.h: >+ * UIProcess/Cocoa/WebProcessPoolCocoa.mm: >+ (WebKit::WebProcessPool::platformInitializeWebProcess): >+ * WebProcess/WebProcess.cpp: >+ (WebKit::WebProcess::initializeWebProcess): >+ > 2016-04-25 Dan Bernstein <mitz@apple.com> > > Fix a couple of mistakes from r199700. >Index: Source/WebKit2/Shared/WebProcessCreationParameters.cpp >=================================================================== >--- Source/WebKit2/Shared/WebProcessCreationParameters.cpp (revision 200037) >+++ Source/WebKit2/Shared/WebProcessCreationParameters.cpp (working copy) >@@ -102,6 +102,7 @@ void WebProcessCreationParameters::encod > encoder << resourceLoadStatisticsEnabled; > encoder << fontWhitelist; > encoder << iconDatabaseEnabled; >+ encoder << globalConstRedeclarationShouldThrow; > encoder << terminationTimeout; > encoder << languages; > encoder << textCheckerState; >@@ -229,6 +230,8 @@ bool WebProcessCreationParameters::decod > return false; > if (!decoder.decode(parameters.iconDatabaseEnabled)) > return false; >+ if (!decoder.decode(parameters.globalConstRedeclarationShouldThrow)) >+ return false; > if (!decoder.decode(parameters.terminationTimeout)) > return false; > if (!decoder.decode(parameters.languages)) >Index: Source/WebKit2/Shared/WebProcessCreationParameters.h >=================================================================== >--- Source/WebKit2/Shared/WebProcessCreationParameters.h (revision 200037) >+++ Source/WebKit2/Shared/WebProcessCreationParameters.h (working copy) >@@ -115,6 +115,7 @@ struct WebProcessCreationParameters { > Vector<String> fontWhitelist; > > bool iconDatabaseEnabled; >+ bool globalConstRedeclarationShouldThrow { true }; > > double terminationTimeout; > >Index: Source/WebKit2/UIProcess/Cocoa/WebProcessPoolCocoa.mm >=================================================================== >--- Source/WebKit2/UIProcess/Cocoa/WebProcessPoolCocoa.mm (revision 200037) >+++ Source/WebKit2/UIProcess/Cocoa/WebProcessPoolCocoa.mm (working copy) >@@ -173,6 +173,12 @@ void WebProcessPool::platformInitializeW > parameters.shouldEnableMemoryPressureReliefLogging = [defaults boolForKey:@"LogMemoryJetsamDetails"]; > parameters.shouldSuppressMemoryPressureHandler = [defaults boolForKey:WebKitSuppressMemoryPressureHandlerDefaultsKey]; > >+#if PLATFORM(MAC) >+ parameters.globalConstRedeclarationShouldThrow = !MacApplication::isIBooks(); >+#elif PLATFORM(IOS) >+ parameters.globalConstRedeclarationShouldThrow = !IOSApplication::isIBooks(); >+#endif >+ > #if HAVE(HOSTED_CORE_ANIMATION) > #if !PLATFORM(IOS) > parameters.acceleratedCompositingPort = MachSendRight::create([CARemoteLayerServer sharedServer].serverPort); >Index: Source/WebKit2/WebProcess/WebProcess.cpp >=================================================================== >--- Source/WebKit2/WebProcess/WebProcess.cpp (revision 200037) >+++ Source/WebKit2/WebProcess/WebProcess.cpp (working copy) >@@ -336,6 +336,8 @@ void WebProcess::initializeWebProcess(We > for (auto& scheme : parameters.urlSchemesRegisteredAsAlwaysRevalidated) > registerURLSchemeAsAlwaysRevalidated(scheme); > >+ WebCore::Settings::setGlobalConstRedeclarationShouldThrow(parameters.globalConstRedeclarationShouldThrow); >+ > #if ENABLE(CACHE_PARTITIONING) > for (auto& scheme : parameters.urlSchemesRegisteredAsCachePartitioned) > registerURLSchemeAsCachePartitioned(scheme);
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
Flags:
ggaren
:
review+
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 157006
:
277297
|
277406
|
277426
|
277538