Ignore:
Timestamp:
Apr 18, 2018, 2:47:19 AM (7 years ago)
Author:
Yusuke Suzuki
Message:

Unreviewed, reland r230697, r230720, and r230724.
https://bugs.webkit.org/show_bug.cgi?id=184600

JSTests:

  • wasm.yaml:
  • wasm/modules/constant.wasm: Added.
  • wasm/modules/constant.wat: Added.
  • wasm/modules/default-import-star-error.js: Added.

(then):

  • wasm/modules/default-import-star-error/entry.wasm: Added.
  • wasm/modules/default-import-star-error/entry.wat: Added.
  • wasm/modules/default-import-star-error/t0.js: Added.
  • wasm/modules/default-import-star-error/t1.js: Added.
  • wasm/modules/default-import-star-error/t2.js: Added.

(export.default.Cocoa):

  • wasm/modules/js-wasm-cycle.js: Added.
  • wasm/modules/js-wasm-cycle/entry.js: Added.

(from.string_appeared_here.export.return42):

  • wasm/modules/js-wasm-cycle/sum.wasm: Added.
  • wasm/modules/js-wasm-cycle/sum.wat: Added.
  • wasm/modules/js-wasm-function-namespace.js: Added.

(assert.throws):

  • wasm/modules/js-wasm-function.js: Added.

(assert.throws):

  • wasm/modules/js-wasm-global-namespace.js: Added.

(assert.throws):

  • wasm/modules/js-wasm-global.js: Added.

(assert.throws):

  • wasm/modules/js-wasm-memory-namespace.js: Added.

(assert.throws):

  • wasm/modules/js-wasm-memory.js: Added.

(assert.throws):

  • wasm/modules/js-wasm-start.js: Added.

(then):

  • wasm/modules/js-wasm-table-namespace.js: Added.

(assert.throws):

  • wasm/modules/js-wasm-table.js: Added.

(assert.throws):

  • wasm/modules/memory.wasm: Added.
  • wasm/modules/memory.wat: Added.
  • wasm/modules/run-from-wasm.wasm: Added.
  • wasm/modules/run-from-wasm.wat: Added.
  • wasm/modules/run-from-wasm/check.js: Added.

(export.check):

  • wasm/modules/start.wasm: Added.
  • wasm/modules/start.wat: Added.
  • wasm/modules/sum.wasm: Added.
  • wasm/modules/sum.wat: Added.
  • wasm/modules/table.wasm: Added.
  • wasm/modules/table.wat: Added.
  • wasm/modules/wasm-imports-js-exports.js: Added.
  • wasm/modules/wasm-imports-js-exports/imports.wasm: Added.
  • wasm/modules/wasm-imports-js-exports/imports.wat: Added.
  • wasm/modules/wasm-imports-js-exports/sum.js: Added.

(export.sum):

  • wasm/modules/wasm-imports-js-re-exports-wasm-exports.js: Added.
  • wasm/modules/wasm-imports-js-re-exports-wasm-exports/imports.wasm: Added.
  • wasm/modules/wasm-imports-js-re-exports-wasm-exports/imports.wat: Added.
  • wasm/modules/wasm-imports-js-re-exports-wasm-exports/re-export.js: Added.
  • wasm/modules/wasm-imports-js-re-exports-wasm-exports/sum.wasm: Added.
  • wasm/modules/wasm-imports-js-re-exports-wasm-exports/sum.wat: Added.
  • wasm/modules/wasm-imports-wasm-exports.js: Added.
  • wasm/modules/wasm-imports-wasm-exports/imports.wasm: Added.
  • wasm/modules/wasm-imports-wasm-exports/imports.wat: Added.
  • wasm/modules/wasm-imports-wasm-exports/sum.wasm: Added.
  • wasm/modules/wasm-imports-wasm-exports/sum.wat: Added.
  • wasm/modules/wasm-js-cycle.js: Added.
  • wasm/modules/wasm-js-cycle/entry.wasm: Added.
  • wasm/modules/wasm-js-cycle/entry.wat: Added.
  • wasm/modules/wasm-js-cycle/sum.js: Added.

(from.string_appeared_here.export.sum):

  • wasm/modules/wasm-wasm-cycle.js: Added.
  • wasm/modules/wasm-wasm-cycle/entry.wasm: Added.
  • wasm/modules/wasm-wasm-cycle/entry.wat: Added.
  • wasm/modules/wasm-wasm-cycle/sum.wasm: Added.
  • wasm/modules/wasm-wasm-cycle/sum.wat: Added.

Source/JavaScriptCore:

With CatchScope check.

  • JavaScriptCore.xcodeproj/project.pbxproj:
  • builtins/ModuleLoaderPrototype.js:

(globalPrivate.newRegistryEntry):
(requestInstantiate):
(link):

  • jsc.cpp:

(convertShebangToJSComment):
(fillBufferWithContentsOfFile):
(fetchModuleFromLocalFileSystem):
(GlobalObject::moduleLoaderFetch):
(functionDollarAgentStart):
(checkException):
(runWithOptions):

  • parser/NodesAnalyzeModule.cpp:

(JSC::ImportDeclarationNode::analyzeModule):

  • parser/SourceProvider.h:

(JSC::WebAssemblySourceProvider::create):
(JSC::WebAssemblySourceProvider::WebAssemblySourceProvider):

  • runtime/AbstractModuleRecord.cpp:

(JSC::AbstractModuleRecord::hostResolveImportedModule):
(JSC::AbstractModuleRecord::resolveImport):
(JSC::AbstractModuleRecord::link):
(JSC::AbstractModuleRecord::evaluate):
(JSC::identifierToJSValue): Deleted.

  • runtime/AbstractModuleRecord.h:

(JSC::AbstractModuleRecord::moduleEnvironmentMayBeNull):
(JSC::AbstractModuleRecord::ImportEntry::isNamespace const): Deleted.

  • runtime/JSModuleEnvironment.cpp:

(JSC::JSModuleEnvironment::getOwnNonIndexPropertyNames):

  • runtime/JSModuleLoader.cpp:

(JSC::JSModuleLoader::evaluate):

  • runtime/JSModuleRecord.cpp:

(JSC::JSModuleRecord::link):
(JSC::JSModuleRecord::instantiateDeclarations):

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

(JSC::moduleLoaderPrototypeParseModule):
(JSC::moduleLoaderPrototypeRequestedModules):
(JSC::moduleLoaderPrototypeModuleDeclarationInstantiation):

  • wasm/WasmCreationMode.h: Copied from Source/JavaScriptCore/wasm/js/WebAssemblyPrototype.h.
  • wasm/js/JSWebAssemblyHelpers.h:

(JSC::getWasmBufferFromValue):
(JSC::createSourceBufferFromValue):

  • wasm/js/JSWebAssemblyInstance.cpp:

(JSC::JSWebAssemblyInstance::finalizeCreation):
(JSC::JSWebAssemblyInstance::createPrivateModuleKey):
(JSC::JSWebAssemblyInstance::create):

  • wasm/js/JSWebAssemblyInstance.h:
  • wasm/js/WebAssemblyInstanceConstructor.cpp:

(JSC::constructJSWebAssemblyInstance):

  • wasm/js/WebAssemblyModuleRecord.cpp:

(JSC::WebAssemblyModuleRecord::prepareLink):
(JSC::WebAssemblyModuleRecord::link):

  • wasm/js/WebAssemblyModuleRecord.h:
  • wasm/js/WebAssemblyPrototype.cpp:

(JSC::resolve):
(JSC::instantiate):
(JSC::compileAndInstantiate):
(JSC::WebAssemblyPrototype::instantiate):
(JSC::webAssemblyInstantiateFunc):
(JSC::webAssemblyValidateFunc):

  • wasm/js/WebAssemblyPrototype.h:

Tools:

  • Scripts/run-jsc-stress-tests:
File:
1 edited

Legend:

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

    r230741 r230759  
    187187}
    188188
    189 static bool fillBufferWithContentsOfFile(const String& fileName, Vector<char>& buffer);
     189template<typename Vector>
     190static bool fillBufferWithContentsOfFile(const String& fileName, Vector& buffer);
    190191static RefPtr<Uint8Array> fillBufferWithContentsOfFile(const String& fileName);
    191192
     
    196197template<typename Func>
    197198int runJSC(CommandLine, bool isWorker, const Func&);
    198 static void checkException(GlobalObject*, bool isLastFile, bool hasException, JSValue, CommandLine&, bool& success);
     199static void checkException(ExecState*, GlobalObject*, bool isLastFile, bool hasException, JSValue, CommandLine&, bool& success);
    199200
    200201class Message : public ThreadSafeRefCounted<Message> {
     
    845846}
    846847
    847 static void convertShebangToJSComment(Vector<char>& buffer)
     848template<typename Vector>
     849static void convertShebangToJSComment(Vector& buffer)
    848850{
    849851    if (buffer.size() >= 2) {
     
    883885}
    884886
    885 static bool fillBufferWithContentsOfFile(FILE* file, Vector<char>& buffer)
     887template<typename Vector>
     888static bool fillBufferWithContentsOfFile(FILE* file, Vector& buffer)
    886889{
    887890    // We might have injected "use strict"; at the top.
     
    921924}
    922925
    923 static bool fetchModuleFromLocalFileSystem(const String& fileName, Vector<char>& buffer)
     926template<typename Vector>
     927static bool fetchModuleFromLocalFileSystem(const String& fileName, Vector& buffer)
    924928{
    925929    // We assume that fileName is always an absolute path.
     
    972976
    973977    // Here, now we consider moduleKey as the fileName.
    974     Vector<char> utf8;
    975     if (!fetchModuleFromLocalFileSystem(moduleKey, utf8)) {
     978    Vector<uint8_t> buffer;
     979    if (!fetchModuleFromLocalFileSystem(moduleKey, buffer)) {
    976980        auto result = deferred->reject(exec, createError(exec, makeString("Could not open file '", moduleKey, "'.")));
    977981        scope.releaseAssertNoException();
     
    979983    }
    980984
    981     auto result = deferred->resolve(exec, JSSourceCode::create(vm, makeSource(stringFromUTF(utf8), SourceOrigin { moduleKey }, moduleKey, TextPosition(), SourceProviderSourceType::Module)));
     985#if ENABLE(WEBASSEMBLY)
     986    // FileSystem does not have mime-type header. The JSC shell recognizes WebAssembly's magic header.
     987    if (buffer.size() >= 4) {
     988        if (buffer[0] == '\0' && buffer[1] == 'a' && buffer[2] == 's' && buffer[3] == 'm') {
     989            auto result = deferred->resolve(exec, JSSourceCode::create(vm, SourceCode(WebAssemblySourceProvider::create(WTFMove(buffer), SourceOrigin { moduleKey }, moduleKey))));
     990            scope.releaseAssertNoException();
     991            return result;
     992        }
     993    }
     994#endif
     995
     996    auto result = deferred->resolve(exec, JSSourceCode::create(vm, makeSource(stringFromUTF(buffer), SourceOrigin { moduleKey }, moduleKey, TextPosition(), SourceProviderSourceType::Module)));
    982997    scope.releaseAssertNoException();
    983998    return result;
     
    16181633                    if (evaluationException)
    16191634                        result = evaluationException->value();
    1620                     checkException(globalObject, true, evaluationException, result, commandLine, success);
     1635                    checkException(globalObject->globalExec(), globalObject, true, evaluationException, result, commandLine, success);
    16211636                    if (!success)
    16221637                        exit(1);
     
    22452260}
    22462261
    2247 static void checkException(GlobalObject* globalObject, bool isLastFile, bool hasException, JSValue value, CommandLine& options, bool& success)
     2262static void checkException(ExecState* exec, GlobalObject* globalObject, bool isLastFile, bool hasException, JSValue value, CommandLine& options, bool& success)
    22482263{
    22492264    VM& vm = globalObject->vm();
     
    22572272        success = success && !hasException;
    22582273        if (options.m_dump && !hasException)
    2259             printf("End: %s\n", value.toWTFString(globalObject->globalExec()).utf8().data());
     2274            printf("End: %s\n", value.toWTFString(exec).utf8().data());
    22602275        if (hasException)
    22612276            dumpException(globalObject, value);
     
    23102325
    23112326            JSFunction* fulfillHandler = JSNativeStdFunction::create(vm, globalObject, 1, String(), [&, isLastFile](ExecState* exec) {
    2312                 checkException(globalObject, isLastFile, false, exec->argument(0), options, success);
     2327                checkException(exec, globalObject, isLastFile, false, exec->argument(0), options, success);
    23132328                return JSValue::encode(jsUndefined());
    23142329            });
    23152330
    23162331            JSFunction* rejectHandler = JSNativeStdFunction::create(vm, globalObject, 1, String(), [&, isLastFile](ExecState* exec) {
    2317                 checkException(globalObject, isLastFile, true, exec->argument(0), options, success);
     2332                checkException(exec, globalObject, isLastFile, true, exec->argument(0), options, success);
    23182333                return JSValue::encode(jsUndefined());
    23192334            });
     
    23282343            if (evaluationException)
    23292344                returnValue = evaluationException->value();
    2330             checkException(globalObject, isLastFile, evaluationException, returnValue, options, success);
     2345            checkException(globalObject->globalExec(), globalObject, isLastFile, evaluationException, returnValue, options, success);
    23312346        }
    23322347
Note: See TracChangeset for help on using the changeset viewer.