Changeset 259835 in webkit


Ignore:
Timestamp:
Apr 9, 2020 3:49:01 PM (4 years ago)
Author:
ysuzuki@apple.com
Message:

[JSC] ModuleEnvironment do not have JSGlobalLexicalEnvironment as its upper scope
https://bugs.webkit.org/show_bug.cgi?id=193347

Reviewed by Tadeu Zagallo.

JSTests:

  • stress/global-lexical-environment-access-from-module.js: Added.

(shouldBe):
(import.string_appeared_here.then):

  • stress/resources/global-lexical-environment-access-from-module-child.js: Added.

(export.read):
(export.write):

LayoutTests/imported/w3c:

  • web-platform-tests/html/semantics/scripting-1/the-script-element/module/inline-async-execorder-expected.txt:

Source/JavaScriptCore:

The upper scope of module scope should be global lexical environment instead of global object.
This patch fixes it to allow modules to access global lexical environment's variables.

  • bytecode/CodeBlock.cpp:

(JSC::CodeBlock::notifyLexicalBindingUpdate):

  • dfg/DFGByteCodeParser.cpp:

(JSC::DFG::ByteCodeParser::parseBlock):

  • runtime/JSModuleEnvironment.h:
  • runtime/JSModuleRecord.cpp:

(JSC::JSModuleRecord::instantiateDeclarations):

Location:
trunk
Files:
2 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r259828 r259835  
     12020-04-09  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        [JSC] ModuleEnvironment do not have JSGlobalLexicalEnvironment as its upper scope
     4        https://bugs.webkit.org/show_bug.cgi?id=193347
     5
     6        Reviewed by Tadeu Zagallo.
     7
     8        * stress/global-lexical-environment-access-from-module.js: Added.
     9        (shouldBe):
     10        (import.string_appeared_here.then):
     11        * stress/resources/global-lexical-environment-access-from-module-child.js: Added.
     12        (export.read):
     13        (export.write):
     14
    1152020-04-09  Yusuke Suzuki  <ysuzuki@apple.com>
    216
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r259773 r259835  
     12020-04-09  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        [JSC] ModuleEnvironment do not have JSGlobalLexicalEnvironment as its upper scope
     4        https://bugs.webkit.org/show_bug.cgi?id=193347
     5
     6        Reviewed by Tadeu Zagallo.
     7
     8        * web-platform-tests/html/semantics/scripting-1/the-script-element/module/inline-async-execorder-expected.txt:
     9
    1102020-04-08  Chris Dumez  <cdumez@apple.com>
    211
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/module/inline-async-execorder-expected.txt

    r249886 r259835  
    1 CONSOLE MESSAGE: line 1: ReferenceError: Can't find variable: loaded
    2 CONSOLE MESSAGE: line 1: ReferenceError: Can't find variable: loaded
    3 CONSOLE MESSAGE: line 3: ReferenceError: Can't find variable: loaded
    4 CONSOLE MESSAGE: line 3: ReferenceError: Can't find variable: loaded
    51
    6 Harness Error (FAIL), message = ReferenceError: Can't find variable: loaded
     2PASS Inline async module script execution order
    73
    8 FAIL Inline async module script execution order assert_array_equals: lengths differ, expected 6 got 0
    9 
  • trunk/Source/JavaScriptCore/ChangeLog

    r259822 r259835  
     12020-04-09  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        [JSC] ModuleEnvironment do not have JSGlobalLexicalEnvironment as its upper scope
     4        https://bugs.webkit.org/show_bug.cgi?id=193347
     5
     6        Reviewed by Tadeu Zagallo.
     7
     8        The upper scope of module scope should be global lexical environment instead of global object.
     9        This patch fixes it to allow modules to access global lexical environment's variables.
     10
     11        * bytecode/CodeBlock.cpp:
     12        (JSC::CodeBlock::notifyLexicalBindingUpdate):
     13        * dfg/DFGByteCodeParser.cpp:
     14        (JSC::DFG::ByteCodeParser::parseBlock):
     15        * runtime/JSModuleEnvironment.h:
     16        * runtime/JSModuleRecord.cpp:
     17        (JSC::JSModuleRecord::instantiateDeclarations):
     18
    1192020-04-09  Alexey Shvayka  <shvaikalesh@gmail.com>
    220
  • trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp

    r259676 r259835  
    28852885void CodeBlock::notifyLexicalBindingUpdate()
    28862886{
    2887     // FIXME: Currently, module code do not query to JSGlobalLexicalEnvironment. So this case should be removed once it is fixed.
    2888     // https://bugs.webkit.org/show_bug.cgi?id=193347
    2889     if (scriptMode() == JSParserScriptMode::Module)
    2890         return;
    28912887    JSGlobalObject* globalObject = m_globalObject.get();
    28922888    JSGlobalLexicalEnvironment* globalLexicalEnvironment = jsCast<JSGlobalLexicalEnvironment*>(globalObject->globalScope());
  • trunk/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp

    r259676 r259835  
    66786678                m_graph.watchpoints().addLazily(m_inlineStackTop->m_codeBlock->globalObject()->varInjectionWatchpoint());
    66796679
    6680             // FIXME: Currently, module code do not query to JSGlobalLexicalEnvironment. So this case should be removed once it is fixed.
    6681             // https://bugs.webkit.org/show_bug.cgi?id=193347
    6682             if (m_inlineStackTop->m_codeBlock->scriptMode() != JSParserScriptMode::Module) {
    6683                 if (resolveType == GlobalProperty || resolveType == GlobalPropertyWithVarInjectionChecks) {
    6684                     JSGlobalObject* globalObject = m_inlineStackTop->m_codeBlock->globalObject();
    6685                     unsigned identifierNumber = m_inlineStackTop->m_identifierRemap[bytecode.m_var];
    6686                     if (!m_graph.watchGlobalProperty(globalObject, identifierNumber))
    6687                         addToGraph(ForceOSRExit);
    6688                 }
     6680            if (resolveType == GlobalProperty || resolveType == GlobalPropertyWithVarInjectionChecks) {
     6681                JSGlobalObject* globalObject = m_inlineStackTop->m_codeBlock->globalObject();
     6682                unsigned identifierNumber = m_inlineStackTop->m_identifierRemap[bytecode.m_var];
     6683                if (!m_graph.watchGlobalProperty(globalObject, identifierNumber))
     6684                    addToGraph(ForceOSRExit);
    66896685            }
    66906686
     
    67946790            case GlobalProperty:
    67956791            case GlobalPropertyWithVarInjectionChecks: {
    6796                 // FIXME: Currently, module code do not query to JSGlobalLexicalEnvironment. So this case should be removed once it is fixed.
    6797                 // https://bugs.webkit.org/show_bug.cgi?id=193347
    6798                 if (m_inlineStackTop->m_codeBlock->scriptMode() != JSParserScriptMode::Module) {
    6799                     if (!m_graph.watchGlobalProperty(globalObject, identifierNumber))
    6800                         addToGraph(ForceOSRExit);
    6801                 }
     6792                if (!m_graph.watchGlobalProperty(globalObject, identifierNumber))
     6793                    addToGraph(ForceOSRExit);
    68026794
    68036795                SpeculatedType prediction = getPrediction();
     
    69716963            case GlobalProperty:
    69726964            case GlobalPropertyWithVarInjectionChecks: {
    6973                 // FIXME: Currently, module code do not query to JSGlobalLexicalEnvironment. So this case should be removed once it is fixed.
    6974                 // https://bugs.webkit.org/show_bug.cgi?id=193347
    6975                 if (m_inlineStackTop->m_codeBlock->scriptMode() != JSParserScriptMode::Module) {
    6976                     if (!m_graph.watchGlobalProperty(globalObject, identifierNumber))
    6977                         addToGraph(ForceOSRExit);
    6978                 }
     6965                if (!m_graph.watchGlobalProperty(globalObject, identifierNumber))
     6966                    addToGraph(ForceOSRExit);
    69796967
    69806968                PutByIdStatus status;
  • trunk/Source/JavaScriptCore/runtime/JSModuleEnvironment.h

    r257399 r259835  
    4343    static constexpr unsigned StructureFlags = Base::StructureFlags | OverridesGetOwnPropertySlot | OverridesGetPropertyNames;
    4444
    45     static JSModuleEnvironment* create(VM&, Structure*, JSScope*, SymbolTable*, JSValue initialValue, AbstractModuleRecord*);
    46 
    4745    static JSModuleEnvironment* create(VM& vm, JSGlobalObject* globalObject, JSScope* currentScope, SymbolTable* symbolTable, JSValue initialValue, AbstractModuleRecord* moduleRecord)
    4846    {
     
    8381    JSModuleEnvironment(VM&, Structure*, JSScope*, SymbolTable*);
    8482
     83    static JSModuleEnvironment* create(VM&, Structure*, JSScope*, SymbolTable*, JSValue initialValue, AbstractModuleRecord*);
     84
    8585    void finishCreation(VM&, JSValue initialValue, AbstractModuleRecord*);
    8686
  • trunk/Source/JavaScriptCore/runtime/JSModuleRecord.cpp

    r251425 r259835  
    104104
    105105    SymbolTable* symbolTable = moduleProgramExecutable->moduleEnvironmentSymbolTable();
    106     JSModuleEnvironment* moduleEnvironment = JSModuleEnvironment::create(vm, globalObject, globalObject, symbolTable, jsTDZValue(), this);
     106    JSModuleEnvironment* moduleEnvironment = JSModuleEnvironment::create(vm, globalObject, globalObject->globalLexicalEnvironment(), symbolTable, jsTDZValue(), this);
    107107
    108108    // http://www.ecma-international.org/ecma-262/6.0/#sec-moduledeclarationinstantiation
Note: See TracChangeset for help on using the changeset viewer.