Ignore:
Timestamp:
Mar 15, 2017, 3:49:36 PM (8 years ago)
Author:
[email protected]
Message:

Fix exception scope verification failures in jsc.cpp.
https://bugs.webkit.org/show_bug.cgi?id=164968

Reviewed by Saam Barati.

  • jsc.cpp:

(WTF::CustomGetter::customGetter):

(GlobalObject::moduleLoaderResolve):
(GlobalObject::moduleLoaderFetch):

  • The only way modules would throw an exception is if we encounter an OutOfMemory error. This should be extremely rare. At this point, I don't think it's worth doing the dance to propagate the exception when this happens. Instead, we'll simply do a RELEASE_ASSERT that we don't see any exceptions here.

(functionRun):
(functionRunString):
(functionLoadModule):
(functionCheckModuleSyntax):
(box):
(dumpException):
(runWithScripts):

File:
1 edited

Legend:

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

    r213690 r214016  
    391391            return throwVMTypeError(exec, scope);
    392392        bool shouldThrow = thisObject->get(exec, PropertyName(Identifier::fromString(exec, "shouldThrow"))).toBoolean(exec);
     393        RETURN_IF_EXCEPTION(scope, encodedJSValue());
    393394        if (shouldThrow)
    394395            return throwVMTypeError(exec, scope);
     
    15951596
    15961597    JSInternalPromiseDeferred* deferred = JSInternalPromiseDeferred::create(exec, globalObject);
     1598    RELEASE_ASSERT(!scope.exception());
    15971599    const Identifier key = keyValue.toPropertyKey(exec);
    15981600    if (UNLIKELY(scope.exception())) {
     
    16301632    if (!directoryName)
    16311633        return deferred->reject(exec, createError(exec, makeString("Could not resolve the referrer name '", String(referrer.impl()), "'.")));
    1632     return deferred->resolve(exec, jsString(exec, resolvePath(directoryName.value(), ModuleName(key.impl()))));
     1634    auto result = deferred->resolve(exec, jsString(exec, resolvePath(directoryName.value(), ModuleName(key.impl()))));
     1635    RELEASE_ASSERT(!scope.exception());
     1636    return result;
    16331637}
    16341638
     
    17181722        return deferred->reject(exec, createError(exec, makeString("Could not open file '", moduleKey, "'.")));
    17191723
    1720     return deferred->resolve(exec, JSSourceCode::create(exec->vm(), makeSource(stringFromUTF(utf8), SourceOrigin { moduleKey }, moduleKey, TextPosition(), SourceProviderSourceType::Module)));
     1724    auto result = deferred->resolve(exec, JSSourceCode::create(exec->vm(), makeSource(stringFromUTF(utf8), SourceOrigin { moduleKey }, moduleKey, TextPosition(), SourceProviderSourceType::Module)));
     1725    RELEASE_ASSERT(!scope.exception());
     1726    return result;
    17211727}
    17221728
     
    20952101
    20962102    JSArray* array = constructEmptyArray(globalObject->globalExec(), 0);
    2097     for (unsigned i = 1; i < exec->argumentCount(); ++i)
     2103    RETURN_IF_EXCEPTION(scope, encodedJSValue());
     2104    for (unsigned i = 1; i < exec->argumentCount(); ++i) {
    20982105        array->putDirectIndex(globalObject->globalExec(), i - 1, exec->uncheckedArgument(i));
     2106        RETURN_IF_EXCEPTION(scope, encodedJSValue());
     2107    }
    20992108    globalObject->putDirect(
    21002109        vm, Identifier::fromString(globalObject->globalExec(), "arguments"), array);
     
    21252134
    21262135    JSArray* array = constructEmptyArray(globalObject->globalExec(), 0);
    2127     for (unsigned i = 1; i < exec->argumentCount(); ++i)
     2136    RETURN_IF_EXCEPTION(scope, encodedJSValue());
     2137    for (unsigned i = 1; i < exec->argumentCount(); ++i) {
    21282138        array->putDirectIndex(globalObject->globalExec(), i - 1, exec->uncheckedArgument(i));
     2139        RETURN_IF_EXCEPTION(scope, encodedJSValue());
     2140    }
    21292141    globalObject->putDirect(
    21302142        vm, Identifier::fromString(globalObject->globalExec(), "arguments"), array);
     
    29182930
    29192931    promise->then(exec, nullptr, errorHandler);
     2932    RETURN_IF_EXCEPTION(scope, encodedJSValue());
    29202933    vm.drainMicrotasks();
    29212934    if (error)
     
    29602973    ParserError error;
    29612974    bool validSyntax = checkModuleSyntax(exec, makeSource(source, { }, String(), TextPosition(), SourceProviderSourceType::Module), error);
     2975    RETURN_IF_EXCEPTION(scope, encodedJSValue());
    29622976    stopWatch.stop();
    29632977
     
    30523066static JSValue box(ExecState* exec, VM& vm, JSValue wasmValue)
    30533067{
     3068    auto scope = DECLARE_CATCH_SCOPE(vm);
    30543069
    30553070    JSString* type = asString(wasmValue.get(exec, makeIdentifier(vm, "type")));
     3071    ASSERT_UNUSED(scope, !scope.exception());
    30563072    JSValue value = wasmValue.get(exec, makeIdentifier(vm, "value"));
     3073    ASSERT(!scope.exception());
    30573074
    30583075    auto unboxString = [&] (const char* hexFormat, const char* decFormat, auto& result) {
     
    33093326
    33103327    Identifier nameID = Identifier::fromString(globalObject->globalExec(), "name");
     3328    CHECK_EXCEPTION();
    33113329    Identifier fileNameID = Identifier::fromString(globalObject->globalExec(), "sourceURL");
     3330    CHECK_EXCEPTION();
    33123331    Identifier lineNumberID = Identifier::fromString(globalObject->globalExec(), "line");
     3332    CHECK_EXCEPTION();
    33133333    Identifier stackID = Identifier::fromString(globalObject->globalExec(), "stack");
    3314    
     3334    CHECK_EXCEPTION();
     3335
    33153336    JSValue nameValue = exception.get(globalObject->globalExec(), nameID);
    33163337    CHECK_EXCEPTION();
     
    34053426                scriptBuffer.append("\"use strict\";\n", strlen("\"use strict\";\n"));
    34063427
    3407             if (isModule)
     3428            if (isModule) {
    34083429                promise = loadAndEvaluateModule(globalObject->globalExec(), fileName);
    3409             else {
     3430                RELEASE_ASSERT(!scope.exception());
     3431            } else {
    34103432                if (!fetchScriptFromLocalFileSystem(fileName, scriptBuffer))
    34113433                    return false; // fail early so we can catch missing files
     
    34353457
    34363458            promise->then(globalObject->globalExec(), fulfillHandler, rejectHandler);
     3459            RELEASE_ASSERT(!scope.exception());
    34373460            vm.drainMicrotasks();
    34383461        } else {
Note: See TracChangeset for help on using the changeset viewer.