Changeset 208950 in webkit


Ignore:
Timestamp:
Nov 21, 2016 9:19:30 AM (7 years ago)
Author:
mark.lam@apple.com
Message:

Fix exception scope verification failures in *Executable.cpp files.
https://bugs.webkit.org/show_bug.cgi?id=164996

Reviewed by Darin Adler.

  • runtime/DirectEvalExecutable.cpp:

(JSC::DirectEvalExecutable::create):

  • runtime/IndirectEvalExecutable.cpp:

(JSC::IndirectEvalExecutable::create):

  • runtime/ProgramExecutable.cpp:

(JSC::ProgramExecutable::initializeGlobalProperties):

  • runtime/ScriptExecutable.cpp:

(JSC::ScriptExecutable::prepareForExecutionImpl):

Location:
trunk/Source/JavaScriptCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r208939 r208950  
     12016-11-21  Mark Lam  <mark.lam@apple.com>
     2
     3        Fix exception scope verification failures in *Executable.cpp files.
     4        https://bugs.webkit.org/show_bug.cgi?id=164996
     5
     6        Reviewed by Darin Adler.
     7
     8        * runtime/DirectEvalExecutable.cpp:
     9        (JSC::DirectEvalExecutable::create):
     10        * runtime/IndirectEvalExecutable.cpp:
     11        (JSC::IndirectEvalExecutable::create):
     12        * runtime/ProgramExecutable.cpp:
     13        (JSC::ProgramExecutable::initializeGlobalProperties):
     14        * runtime/ScriptExecutable.cpp:
     15        (JSC::ScriptExecutable::prepareForExecutionImpl):
     16
    1172016-11-20  Zan Dobersek  <zdobersek@igalia.com>
    218
  • trunk/Source/JavaScriptCore/runtime/DirectEvalExecutable.cpp

    r208712 r208950  
    4848
    4949    UnlinkedEvalCodeBlock* unlinkedEvalCode = globalObject->createLocalEvalCodeBlock(exec, executable, variablesUnderTDZ);
     50    ASSERT(!!scope.exception() == !unlinkedEvalCode);
    5051    if (!unlinkedEvalCode)
    5152        return 0;
  • trunk/Source/JavaScriptCore/runtime/IndirectEvalExecutable.cpp

    r208712 r208950  
    4848
    4949    UnlinkedEvalCodeBlock* unlinkedEvalCode = globalObject->createGlobalEvalCodeBlock(exec, executable);
     50    ASSERT(!!scope.exception() == !unlinkedEvalCode);
    5051    if (!unlinkedEvalCode)
    5152        return 0;
  • trunk/Source/JavaScriptCore/runtime/ProgramExecutable.cpp

    r208761 r208950  
    2929#include "CodeBlock.h"
    3030#include "Debugger.h"
     31#include "Exception.h"
    3132#include "JIT.h"
    3233#include "JSCInlines.h"
     
    7374JSObject* ProgramExecutable::initializeGlobalProperties(VM& vm, CallFrame* callFrame, JSScope* scope)
    7475{
     76    auto throwScope = DECLARE_THROW_SCOPE(vm);
    7577    RELEASE_ASSERT(scope);
    7678    JSGlobalObject* globalObject = scope->globalObject();
     
    7880    ASSERT(&globalObject->vm() == &vm);
    7981
    80     JSObject* exception = 0;
     82    JSObject* exception = nullptr;
    8183    UnlinkedProgramCodeBlock* unlinkedCodeBlock = globalObject->createProgramCodeBlock(callFrame, this, &exception);
    82     if (exception)
     84    if (UNLIKELY(exception))
    8385        return exception;
    8486
     
    99101        // It's an error to introduce a shadow.
    100102        for (auto& entry : lexicalDeclarations) {
    101             if (globalObject->hasProperty(exec, entry.key.get())) {
     103            bool hasProperty = globalObject->hasProperty(exec, entry.key.get());
     104            RETURN_IF_EXCEPTION(throwScope, throwScope.exception());
     105            if (hasProperty) {
    102106                // The ES6 spec says that just RestrictedGlobalProperty can't be shadowed
    103107                // This carried out section 8.1.1.4.14 of the ES6 spec: http://www.ecma-international.org/ecma-262/6.0/index.html#sec-hasrestrictedglobalproperty
     
    108112                    return createSyntaxError(exec, makeString("Can't create duplicate variable that shadows a global property: '", String(entry.key.get()), "'"));
    109113            }
    110                
    111             if (globalLexicalEnvironment->hasProperty(exec, entry.key.get())) {
     114
     115            hasProperty = globalLexicalEnvironment->hasProperty(exec, entry.key.get());
     116            RETURN_IF_EXCEPTION(throwScope, throwScope.exception());
     117            if (hasProperty) {
    112118                if (UNLIKELY(entry.value.isConst() && !vm.globalConstRedeclarationShouldThrow() && !isStrictMode())) {
    113119                    // We only allow "const" duplicate declarations under this setting.
     
    124130        if (!globalLexicalEnvironment->isEmpty()) {
    125131            for (auto& entry : variableDeclarations) {
    126                 if (globalLexicalEnvironment->hasProperty(exec, entry.key.get()))
     132                bool hasProperty = globalLexicalEnvironment->hasProperty(exec, entry.key.get());
     133                RETURN_IF_EXCEPTION(throwScope, throwScope.exception());
     134                if (hasProperty)
    127135                    return createSyntaxError(exec, makeString("Can't create duplicate variable: '", String(entry.key.get()), "'"));
    128136            }
     
    149157        ASSERT(entry.value.isVar());
    150158        globalObject->addVar(callFrame, Identifier::fromUid(&vm, entry.key.get()));
     159        ASSERT(!throwScope.exception());
    151160    }
    152161
  • trunk/Source/JavaScriptCore/runtime/ScriptExecutable.cpp

    r208309 r208950  
    308308    VM& vm, JSFunction* function, JSScope* scope, CodeSpecializationKind kind, CodeBlock*& resultCodeBlock)
    309309{
     310    auto throwScope = DECLARE_THROW_SCOPE(vm);
    310311    DeferGCForAWhile deferGC(vm.heap);
    311312
    312     if (vm.getAndClearFailNextNewCodeBlock())
    313         return createError(scope->globalObject()->globalExec(), ASCIILiteral("Forced Failure"));
    314 
    315     JSObject* exception = 0;
     313    if (vm.getAndClearFailNextNewCodeBlock()) {
     314        auto& state = *scope->globalObject()->globalExec();
     315        return throwException(&state, throwScope, createError(&state, ASCIILiteral("Forced Failure")));
     316    }
     317
     318    JSObject* exception = nullptr;
    316319    CodeBlock* codeBlock = newCodeBlockFor(kind, function, scope, exception);
    317320    resultCodeBlock = codeBlock;
    318     if (!codeBlock) {
    319         RELEASE_ASSERT(exception);
     321    ASSERT(!!throwScope.exception() == !codeBlock);
     322    if (UNLIKELY(!codeBlock))
    320323        return exception;
    321     }
    322324   
    323325    if (Options::validateBytecode())
Note: See TracChangeset for help on using the changeset viewer.