Ignore:
Timestamp:
Apr 27, 2016, 12:12:06 AM (9 years ago)
Author:
[email protected]
Message:

JSC should have an option to allow global const redeclarations
https://bugs.webkit.org/show_bug.cgi?id=157006

Reviewed by Geoffrey Garen.

Source/JavaScriptCore:

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.

Source/WebCore:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/jsc.cpp

    r200101 r200121  
    635635
    636636static EncodedJSValue JSC_HOST_CALL functionShadowChickenFunctionsOnStack(ExecState*);
     637static EncodedJSValue JSC_HOST_CALL functionSetGlobalConstRedeclarationShouldNotThrow(ExecState*);
    637638
    638639struct Script {
     
    779780#endif
    780781        addFunction(vm, "shadowChickenFunctionsOnStack", functionShadowChickenFunctionsOnStack, 0);
     782        addFunction(vm, "setGlobalConstRedeclarationShouldNotThrow", functionSetGlobalConstRedeclarationShouldNotThrow, 0);
    781783        addConstructableFunction(vm, "Root", functionCreateRoot, 0);
    782784        addConstructableFunction(vm, "Element", functionCreateElement, 1);
     
    14951497}
    14961498
     1499EncodedJSValue JSC_HOST_CALL functionSetGlobalConstRedeclarationShouldNotThrow(ExecState* exec)
     1500{
     1501    exec->vm().setGlobalConstRedeclarationShouldThrow(false);
     1502    return JSValue::encode(jsUndefined());
     1503}
     1504
    14971505EncodedJSValue JSC_HOST_CALL functionReadline(ExecState* exec)
    14981506{
Note: See TracChangeset for help on using the changeset viewer.