|
| 1 | +2015-08-20 Yusuke Suzuki <utatane.tea@gmail.com> |
| 2 | + |
| 3 | + [ES6] prototyping module loader in JSC shell |
| 4 | + https://bugs.webkit.org/show_bug.cgi?id=147876 |
| 5 | + |
| 6 | + Reviewed by Saam Barati. |
| 7 | + |
| 8 | + This patch implements ES6 Module Loader part. The implementation is based on |
| 9 | + the latest draft[1, 2]. The naive implementation poses several problems. |
| 10 | + This patch attempts to solve the spec issues and proposes the fix[3, 4, 5]. |
| 11 | + |
| 12 | + We construct the JSC internal module loader based on the ES6 Promises. |
| 13 | + The chain of the promises represents the dependency graph of the modules and |
| 14 | + it automatically enables asynchronous module fetching. |
| 15 | + To leverage the Promises internally, we use the InternalPromise landed in r188681. |
| 16 | + |
| 17 | + The loader has several platform-dependent hooks. The platform can implement |
| 18 | + these hooks to provide the functionality missing in the module loaders, like |
| 19 | + "how to fetch the resources". The method table of the JSGlobalObject is extended |
| 20 | + to accept these hooks from the platform. |
| 21 | + |
| 22 | + This patch focus on the loading part. So we don't create the module environment |
| 23 | + and don't link the modules yet. |
| 24 | + |
| 25 | + To test the current module progress easily, we add the `-m` option to the JSC shell. |
| 26 | + When this option is specified, we load the given script as the module. And to use |
| 27 | + the module loading inside the JSC shell, we added the simple loader hook for fetching. |
| 28 | + It fetches the module content from the file system. |
| 29 | + |
| 30 | + And to use the ES6 Map in the Loader implementation, we added @get and @set methods to the Map. |
| 31 | + But it conflicts with the existing `getPrivateName` method. Rename it to `lookUpPrivateName`. |
| 32 | + |
| 33 | + [1]: https://whatwg.github.io/loader/ |
| 34 | + [2]: https://github.com/whatwg/loader/commit/214c7a6625b445bdf411c39984f36f01139a24be |
| 35 | + [3]: https://github.com/whatwg/loader/pull/66 |
| 36 | + [4]: https://github.com/whatwg/loader/pull/67 |
| 37 | + [5]: https://github.com/whatwg/loader/issues/68 |
| 38 | + [6]: https://bugs.webkit.org/show_bug.cgi?id=148136 |
| 39 | + |
| 40 | + * CMakeLists.txt: |
| 41 | + * DerivedSources.make: |
| 42 | + * JavaScriptCore.vcxproj/JavaScriptCore.vcxproj: |
| 43 | + * JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters: |
| 44 | + * JavaScriptCore.xcodeproj/project.pbxproj: |
| 45 | + * builtins/BuiltinNames.h: |
| 46 | + (JSC::BuiltinNames::lookUpPrivateName): |
| 47 | + (JSC::BuiltinNames::lookUpPublicName): |
| 48 | + (JSC::BuiltinNames::getPrivateName): Deleted. |
| 49 | + (JSC::BuiltinNames::getPublicName): Deleted. |
| 50 | + * builtins/ModuleLoaderObject.js: Added. |
| 51 | + (setStateToMax): |
| 52 | + (newRegistryEntry): |
| 53 | + (forceFulfillPromise): |
| 54 | + (fulfillFetch): |
| 55 | + (fulfillTranslate): |
| 56 | + (fulfillInstantiate): |
| 57 | + (instantiation): |
| 58 | + (requestFetch): |
| 59 | + (requestTranslate): |
| 60 | + (requestInstantiate): |
| 61 | + (requestResolveDependencies.resolveDependenciesPromise.this.requestInstantiate.then.): |
| 62 | + (requestResolveDependencies.resolveDependenciesPromise.this.requestInstantiate.then): |
| 63 | + (requestResolveDependencies): |
| 64 | + (requestInstantiateAll): |
| 65 | + (provide): |
| 66 | + * jsc.cpp: |
| 67 | + (stringFromUTF): |
| 68 | + (jscSource): |
| 69 | + (GlobalObject::moduleLoaderFetch): |
| 70 | + (functionCheckModuleSyntax): |
| 71 | + (dumpException): |
| 72 | + (runWithScripts): |
| 73 | + (printUsageStatement): |
| 74 | + (CommandLine::parseArguments): |
| 75 | + (jscmain): |
| 76 | + (CommandLine::CommandLine): Deleted. |
| 77 | + * parser/Lexer.cpp: |
| 78 | + (JSC::Lexer<LChar>::parseIdentifier): |
| 79 | + (JSC::Lexer<UChar>::parseIdentifier): |
| 80 | + * parser/ModuleAnalyzer.cpp: |
| 81 | + (JSC::ModuleAnalyzer::ModuleAnalyzer): |
| 82 | + (JSC::ModuleAnalyzer::exportVariable): |
| 83 | + (JSC::ModuleAnalyzer::analyze): |
| 84 | + * parser/ModuleAnalyzer.h: |
| 85 | + (JSC::ModuleAnalyzer::moduleRecord): |
| 86 | + * parser/ModuleRecord.cpp: |
| 87 | + (JSC::printableName): Deleted. |
| 88 | + (JSC::ModuleRecord::dump): Deleted. |
| 89 | + * parser/ModuleRecord.h: |
| 90 | + (JSC::ModuleRecord::ImportEntry::isNamespace): Deleted. |
| 91 | + (JSC::ModuleRecord::create): Deleted. |
| 92 | + (JSC::ModuleRecord::appendRequestedModule): Deleted. |
| 93 | + (JSC::ModuleRecord::addImportEntry): Deleted. |
| 94 | + (JSC::ModuleRecord::addExportEntry): Deleted. |
| 95 | + (JSC::ModuleRecord::addStarExportEntry): Deleted. |
| 96 | + * parser/Nodes.h: |
| 97 | + * parser/NodesAnalyzeModule.cpp: |
| 98 | + (JSC::ImportDeclarationNode::analyzeModule): |
| 99 | + (JSC::ExportAllDeclarationNode::analyzeModule): |
| 100 | + (JSC::ExportNamedDeclarationNode::analyzeModule): |
| 101 | + * runtime/CommonIdentifiers.cpp: |
| 102 | + (JSC::CommonIdentifiers::lookUpPrivateName): |
| 103 | + (JSC::CommonIdentifiers::lookUpPublicName): |
| 104 | + (JSC::CommonIdentifiers::getPrivateName): Deleted. |
| 105 | + (JSC::CommonIdentifiers::getPublicName): Deleted. |
| 106 | + * runtime/CommonIdentifiers.h: |
| 107 | + * runtime/Completion.cpp: |
| 108 | + (JSC::checkModuleSyntax): |
| 109 | + (JSC::evaluateModule): |
| 110 | + * runtime/Completion.h: |
| 111 | + * runtime/ExceptionHelpers.cpp: |
| 112 | + (JSC::createUndefinedVariableError): |
| 113 | + * runtime/Identifier.h: |
| 114 | + * runtime/JSGlobalObject.cpp: |
| 115 | + (JSC::JSGlobalObject::init): |
| 116 | + (JSC::JSGlobalObject::visitChildren): |
| 117 | + * runtime/JSGlobalObject.h: |
| 118 | + (JSC::JSGlobalObject::moduleLoader): |
| 119 | + (JSC::JSGlobalObject::moduleRecordStructure): |
| 120 | + * runtime/JSModuleRecord.cpp: Renamed from Source/JavaScriptCore/parser/ModuleRecord.cpp. |
| 121 | + (JSC::JSModuleRecord::destroy): |
| 122 | + (JSC::JSModuleRecord::finishCreation): |
| 123 | + (JSC::printableName): |
| 124 | + (JSC::JSModuleRecord::dump): |
| 125 | + * runtime/JSModuleRecord.h: Renamed from Source/JavaScriptCore/parser/ModuleRecord.h. |
| 126 | + (JSC::JSModuleRecord::ImportEntry::isNamespace): |
| 127 | + (JSC::JSModuleRecord::createStructure): |
| 128 | + (JSC::JSModuleRecord::create): |
| 129 | + (JSC::JSModuleRecord::requestedModules): |
| 130 | + (JSC::JSModuleRecord::JSModuleRecord): |
| 131 | + (JSC::JSModuleRecord::appendRequestedModule): |
| 132 | + (JSC::JSModuleRecord::addImportEntry): |
| 133 | + (JSC::JSModuleRecord::addExportEntry): |
| 134 | + (JSC::JSModuleRecord::addStarExportEntry): |
| 135 | + * runtime/MapPrototype.cpp: |
| 136 | + (JSC::MapPrototype::finishCreation): |
| 137 | + * runtime/ModuleLoaderObject.cpp: Added. |
| 138 | + (JSC::ModuleLoaderObject::ModuleLoaderObject): |
| 139 | + (JSC::ModuleLoaderObject::finishCreation): |
| 140 | + (JSC::ModuleLoaderObject::getOwnPropertySlot): |
| 141 | + (JSC::printableModuleKey): |
| 142 | + (JSC::ModuleLoaderObject::provide): |
| 143 | + (JSC::ModuleLoaderObject::requestInstantiateAll): |
| 144 | + (JSC::ModuleLoaderObject::resolve): |
| 145 | + (JSC::ModuleLoaderObject::fetch): |
| 146 | + (JSC::ModuleLoaderObject::translate): |
| 147 | + (JSC::ModuleLoaderObject::instantiate): |
| 148 | + (JSC::moduleLoaderObjectParseModule): |
| 149 | + (JSC::moduleLoaderObjectRequestedModules): |
| 150 | + (JSC::moduleLoaderObjectResolve): |
| 151 | + (JSC::moduleLoaderObjectFetch): |
| 152 | + (JSC::moduleLoaderObjectTranslate): |
| 153 | + (JSC::moduleLoaderObjectInstantiate): |
| 154 | + * runtime/ModuleLoaderObject.h: Added. |
| 155 | + (JSC::ModuleLoaderObject::create): |
| 156 | + (JSC::ModuleLoaderObject::createStructure): |
| 157 | + * runtime/Options.h: |
| 158 | + |
1 | 159 | 2015-08-20 Filip Pizlo <fpizlo@apple.com>
|
2 | 160 |
|
3 | 161 | DFG should have a KnownBooleanUse for cases where we are required to know that the child is a boolean and it's not OK to speculate
|
|
0 commit comments