Changeset 208913 in webkit


Ignore:
Timestamp:
Nov 18, 2016, 5:46:01 PM (9 years ago)
Author:
mark.lam@apple.com
Message:

Fix missing exception checks in DFGOperations.cpp.
https://bugs.webkit.org/show_bug.cgi?id=164958

Reviewed by Geoffrey Garen.

  • dfg/DFGOperations.cpp:
Location:
trunk/Source/JavaScriptCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r208912 r208913  
     12016-11-18  Mark Lam  <mark.lam@apple.com>
     2
     3        Fix missing exception checks in DFGOperations.cpp.
     4        https://bugs.webkit.org/show_bug.cgi?id=164958
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        * dfg/DFGOperations.cpp:
     9
    1102016-11-18  Mark Lam  <mark.lam@apple.com>
    211
  • trunk/Source/JavaScriptCore/dfg/DFGOperations.cpp

    r208720 r208913  
    111111        // Despite its name, JSValue::isUInt32 will return true only for positive boxed int32_t; all those values are valid array indices.
    112112        ASSERT(isIndex(property.asUInt32()));
     113        scope.release();
    113114        putByVal<strict, direct>(exec, baseValue, property.asUInt32(), value);
    114115        return;
     
    119120        uint32_t propertyAsUInt32 = static_cast<uint32_t>(propertyAsDouble);
    120121        if (propertyAsDouble == propertyAsUInt32 && isIndex(propertyAsUInt32)) {
     122            scope.release();
    121123            putByVal<strict, direct>(exec, baseValue, propertyAsUInt32, value);
    122124            return;
     
    131133    if (direct) {
    132134        RELEASE_ASSERT(baseValue.isObject());
    133         if (Optional<uint32_t> index = parseIndex(propertyName))
     135        if (Optional<uint32_t> index = parseIndex(propertyName)) {
     136            scope.release();
    134137            asObject(baseValue)->putDirectIndex(exec, index.value(), value, 0, strict ? PutDirectIndexShouldThrow : PutDirectIndexShouldNotThrow);
    135         else
    136             asObject(baseValue)->putDirect(*vm, propertyName, value, slot);
    137     } else
    138         baseValue.put(exec, propertyName, value, slot);
     138            return;
     139        }
     140        asObject(baseValue)->putDirect(*vm, propertyName, value, slot);
     141        return;
     142    }
     143    scope.release();
     144    baseValue.put(exec, propertyName, value, slot);
    139145}
    140146
     
    153159    if (vector)
    154160        return bitwise_cast<char*>(ViewClass::createWithFastVector(exec, structure, size, vector));
    155    
     161
     162    scope.release();
    156163    return bitwise_cast<char*>(ViewClass::create(exec, structure, size));
    157164}
     
    190197    NativeCallFrameTracer tracer(&vm, exec);
    191198    auto scope = DECLARE_THROW_SCOPE(vm);
    192     if (constructor->type() == JSFunctionType)
    193         return constructEmptyObject(exec, jsCast<JSFunction*>(constructor)->rareData(exec, inlineCapacity)->objectAllocationProfile()->structure());
     199    if (constructor->type() == JSFunctionType) {
     200        auto rareData = jsCast<JSFunction*>(constructor)->rareData(exec, inlineCapacity);
     201        RETURN_IF_EXCEPTION(scope, nullptr);
     202        return constructEmptyObject(exec, rareData->objectAllocationProfile()->structure());
     203    }
    194204
    195205    JSValue proto = constructor->get(exec, exec->propertyNames().prototype);
     
    224234    int32_t a = op1.toInt32(exec);
    225235    RETURN_IF_EXCEPTION(scope, encodedJSValue());
     236    scope.release();
    226237    int32_t b = op2.toInt32(exec);
    227238    return JSValue::encode(jsNumber(a & b));
     
    239250    int32_t a = op1.toInt32(exec);
    240251    RETURN_IF_EXCEPTION(scope, encodedJSValue());
     252    scope.release();
    241253    int32_t b = op2.toInt32(exec);
    242254    return JSValue::encode(jsNumber(a | b));
     
    254266    int32_t a = op1.toInt32(exec);
    255267    RETURN_IF_EXCEPTION(scope, encodedJSValue());
     268    scope.release();
    256269    int32_t b = op2.toInt32(exec);
    257270    return JSValue::encode(jsNumber(a ^ b));
     
    269282    int32_t a = op1.toInt32(exec);
    270283    RETURN_IF_EXCEPTION(scope, encodedJSValue());
     284    scope.release();
    271285    uint32_t b = op2.toUInt32(exec);
    272286    return JSValue::encode(jsNumber(a << (b & 0x1f)));
     
    284298    int32_t a = op1.toInt32(exec);
    285299    RETURN_IF_EXCEPTION(scope, encodedJSValue());
     300    scope.release();
    286301    uint32_t b = op2.toUInt32(exec);
    287302    return JSValue::encode(jsNumber(a >> (b & 0x1f)));
     
    299314    uint32_t a = op1.toUInt32(exec);
    300315    RETURN_IF_EXCEPTION(scope, encodedJSValue());
     316    scope.release();
    301317    uint32_t b = op2.toUInt32(exec);
    302318    return JSValue::encode(jsNumber(static_cast<int32_t>(a >> (b & 0x1f))));
     
    330346    double a = op1.toNumber(exec);
    331347    RETURN_IF_EXCEPTION(scope, encodedJSValue());
     348    scope.release();
    332349    double b = op2.toNumber(exec);
    333350    return JSValue::encode(jsNumber(a / b));
     
    507524        JSCell* base = baseValue.asCell();
    508525
    509         if (property.isUInt32())
     526        if (property.isUInt32()) {
     527            scope.release();
    510528            return getByVal(exec, base, property.asUInt32());
    511         else if (property.isDouble()) {
     529        }
     530        if (property.isDouble()) {
    512531            double propertyAsDouble = property.asDouble();
    513532            uint32_t propertyAsUInt32 = static_cast<uint32_t>(propertyAsDouble);
    514             if (propertyAsUInt32 == propertyAsDouble && isIndex(propertyAsUInt32))
     533            if (propertyAsUInt32 == propertyAsDouble && isIndex(propertyAsUInt32)) {
     534                scope.release();
    515535                return getByVal(exec, base, propertyAsUInt32);
     536            }
    516537        } else if (property.isString()) {
    517538            Structure& structure = *base->structure(vm);
     
    529550    auto propertyName = property.toPropertyKey(exec);
    530551    RETURN_IF_EXCEPTION(scope, encodedJSValue());
     552    scope.release();
    531553    return JSValue::encode(baseValue.get(exec, propertyName));
    532554}
     
    955977            return JSValue::encode(asString(baseValue)->getIndex(exec, i));
    956978       
     979        scope.release();
    957980        return JSValue::encode(baseValue.get(exec, i, slot));
    958981    }
     
    963986    auto property = subscript.toPropertyKey(exec);
    964987    RETURN_IF_EXCEPTION(scope, encodedJSValue());
     988    scope.release();
    965989    return JSValue::encode(baseValue.get(exec, property, slot));
    966990}
     
    9901014    Identifier property = JSValue::decode(encodedSubscript).toPropertyKey(exec);
    9911015    RETURN_IF_EXCEPTION(scope, void());
     1016    scope.release();
    9921017    putWithThis<true>(exec, encodedBase, encodedThis, encodedValue, property);
    9931018}
     
    10011026    Identifier property = JSValue::decode(encodedSubscript).toPropertyKey(exec);
    10021027    RETURN_IF_EXCEPTION(scope, void());
     1028    scope.release();
    10031029    putWithThis<false>(exec, encodedBase, encodedThis, encodedValue, property);
    10041030}
     
    10221048    Identifier propertyName = JSValue::decode(encodedProperty).toPropertyKey(exec);
    10231049    RETURN_IF_EXCEPTION(scope, void());
     1050    scope.release();
    10241051    defineDataProperty(exec, vm, base, propertyName, JSValue::decode(encodedValue), attributes);
    10251052}
     
    10331060    Identifier propertyName = property->toIdentifier(exec);
    10341061    RETURN_IF_EXCEPTION(scope, void());
     1062    scope.release();
    10351063    defineDataProperty(exec, vm, base, propertyName, JSValue::decode(encodedValue), attributes);
    10361064}
     
    19441972    if (isJSArray(iterable) && globalObject->isArrayIteratorProtocolFastAndNonObservable()) {
    19451973        JSArray* array = jsCast<JSArray*>(iterable);
     1974        throwScope.release();
    19461975        return JSFixedArray::createFromArray(exec, vm, array);
    19471976    }
     
    19641993    }
    19651994
     1995    throwScope.release();
    19661996    return JSFixedArray::createFromArray(exec, vm, array);
    19671997}
     
    20412071
    20422072    Identifier ident = Identifier::fromUid(exec, impl);
     2073    throwScope.release();
    20432074    return JSValue::encode(scope->getPropertySlot(exec, ident, [&] (bool found, PropertySlot& slot) -> JSValue {
    20442075        if (!found) {
     
    20722103    GetPutInfo getPutInfo(getPutInfoBits);
    20732104    bool hasProperty = scope->hasProperty(exec, ident);
     2105    RETURN_IF_EXCEPTION(throwScope, void());
    20742106    if (hasProperty
    20752107        && scope->isGlobalLexicalEnvironment()
     
    20962128        strictMode = exec->codeBlock()->isStrictMode();
    20972129    PutPropertySlot slot(scope, strictMode, PutPropertySlot::UnknownContext, isInitialization(getPutInfo.initializationMode()));
     2130    throwScope.release();
    20982131    scope->methodTable()->put(scope, exec, ident, JSValue::decode(value), slot);
    20992132}
Note: See TracChangeset for help on using the changeset viewer.