Changeset 209036 in webkit


Ignore:
Timestamp:
Nov 28, 2016 3:50:16 PM (7 years ago)
Author:
mark.lam@apple.com
Message:

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

Reviewed by Saam Barati.

  • runtime/JSArray.cpp:

(JSC::JSArray::defineOwnProperty):
(JSC::JSArray::put):
(JSC::JSArray::setLength):
(JSC::JSArray::pop):
(JSC::JSArray::push):
(JSC::JSArray::unshiftCountWithAnyIndexingType):

  • runtime/JSArrayBuffer.cpp:

(JSC::JSArrayBuffer::put):
(JSC::JSArrayBuffer::defineOwnProperty):

  • runtime/JSArrayInlines.h:

(JSC::getLength):
(JSC::toLength):

Location:
trunk/Source/JavaScriptCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r209034 r209036  
     12016-11-28  Mark Lam  <mark.lam@apple.com>
     2
     3        Fix exception scope verification failures in JSArray* files.
     4        https://bugs.webkit.org/show_bug.cgi?id=165016
     5
     6        Reviewed by Saam Barati.
     7
     8        * runtime/JSArray.cpp:
     9        (JSC::JSArray::defineOwnProperty):
     10        (JSC::JSArray::put):
     11        (JSC::JSArray::setLength):
     12        (JSC::JSArray::pop):
     13        (JSC::JSArray::push):
     14        (JSC::JSArray::unshiftCountWithAnyIndexingType):
     15        * runtime/JSArrayBuffer.cpp:
     16        (JSC::JSArrayBuffer::put):
     17        (JSC::JSArrayBuffer::defineOwnProperty):
     18        * runtime/JSArrayInlines.h:
     19        (JSC::getLength):
     20        (JSC::toLength):
     21
    1222016-11-28  Mark Lam  <mark.lam@apple.com>
    223
  • trunk/Source/JavaScriptCore/runtime/JSArray.cpp

    r208985 r209036  
    187187        // l.ii. Let deleteSucceeded be the result of calling the [[Delete]] internal method of A passing ToString(oldLen) and false as arguments.
    188188        // l.iii. If deleteSucceeded is false, then
    189         if (!array->setLength(exec, newLen, throwException)) {
     189        bool success = array->setLength(exec, newLen, throwException);
     190        ASSERT(!scope.exception() || !success);
     191        if (!success) {
    190192            // 1. Set newLenDesc.[[Value] to oldLen+1.
    191193            // 2. If newWritable is false, set newLenDesc.[[Writable] to false.
     
    221223        // e.ii. Call the default [[DefineOwnProperty]] internal method (8.12.9) on A passing "length", oldLenDesc, and false as arguments. This call will always return true.
    222224        // f. Return true.
     225        scope.release();
    223226        return array->defineOwnIndexedProperty(exec, index, descriptor, throwException);
    224227    }
    225228
     229    scope.release();
    226230    return array->JSObject::defineOwnNonIndexProperty(exec, propertyName, descriptor, throwException);
    227231}
     
    247251    JSArray* thisObject = jsCast<JSArray*>(cell);
    248252
    249     if (UNLIKELY(isThisValueAltered(slot, thisObject)))
     253    if (UNLIKELY(isThisValueAltered(slot, thisObject))) {
     254        scope.release();
    250255        return ordinarySetSlow(exec, thisObject, propertyName, value, slot.thisValue(), slot.isStrictMode());
     256    }
    251257
    252258    if (propertyName == exec->propertyNames().length) {
    253259        unsigned newLength = value.toUInt32(exec);
     260        RETURN_IF_EXCEPTION(scope, false);
    254261        if (value.toNumber(exec) != static_cast<double>(newLength)) {
    255262            throwException(exec, scope, createRangeError(exec, ASCIILiteral("Invalid array length")));
    256263            return false;
    257264        }
     265        scope.release();
    258266        return thisObject->setLength(exec, newLength, slot.isStrictMode());
    259267    }
    260268
     269    scope.release();
    261270    return JSObject::put(thisObject, exec, propertyName, value, slot);
    262271}
     
    518527            return true;
    519528        if (newLength >= MIN_SPARSE_ARRAY_INDEX) {
     529            scope.release();
    520530            return setLengthWithArrayStorage(
    521531                exec, newLength, throwException,
     
    534544            || (newLength >= MIN_SPARSE_ARRAY_INDEX
    535545                && !isDenseEnoughForVector(newLength, countElements()))) {
     546            scope.release();
    536547            return setLengthWithArrayStorage(
    537548                exec, newLength, throwException,
     
    566577    case ArrayWithArrayStorage:
    567578    case ArrayWithSlowPutArrayStorage:
     579        scope.release();
    568580        return setLengthWithArrayStorage(exec, newLength, throwException, arrayStorage());
    569581       
     
    660672    RETURN_IF_EXCEPTION(scope, JSValue());
    661673    // Call the [[Delete]] internal method of O with arguments indx and true.
    662     if (!deletePropertyByIndex(this, exec, index)) {
     674    bool success = deletePropertyByIndex(this, exec, index);
     675    RETURN_IF_EXCEPTION(scope, JSValue());
     676    if (!success) {
    663677        throwTypeError(exec, scope, ASCIILiteral(UnableToDeletePropertyError));
    664678        return jsUndefined();
    665679    }
    666680    // Call the [[Put]] internal method of O with arguments "length", indx, and true.
     681    scope.release();
    667682    setLength(exec, index, true);
    668683    // Return element.
     
    688703    case ArrayWithUndecided: {
    689704        convertUndecidedForValue(vm, value);
     705        scope.release();
    690706        push(exec, value);
    691707        return;
     
    695711        if (!value.isInt32()) {
    696712            convertInt32ForValue(vm, value);
     713            scope.release();
    697714            push(exec, value);
    698715            return;
     
    707724        }
    708725       
    709         if (length > MAX_ARRAY_INDEX) {
     726        if (UNLIKELY(length > MAX_ARRAY_INDEX)) {
    710727            methodTable(vm)->putByIndex(this, exec, length, value, true);
    711728            if (!scope.exception())
     
    713730            return;
    714731        }
    715        
     732
     733        scope.release();
    716734        putByIndexBeyondVectorLengthWithoutAttributes<Int32Shape>(exec, length, value);
    717735        return;
     
    727745        }
    728746       
    729         if (length > MAX_ARRAY_INDEX) {
     747        if (UNLIKELY(length > MAX_ARRAY_INDEX)) {
    730748            methodTable(vm)->putByIndex(this, exec, length, value, true);
    731749            if (!scope.exception())
     
    733751            return;
    734752        }
    735        
     753
     754        scope.release();
    736755        putByIndexBeyondVectorLengthWithoutAttributes<ContiguousShape>(exec, length, value);
    737756        return;
     
    741760        if (!value.isNumber()) {
    742761            convertDoubleToContiguous(vm);
     762            scope.release();
    743763            push(exec, value);
    744764            return;
     
    747767        if (valueAsDouble != valueAsDouble) {
    748768            convertDoubleToContiguous(vm);
     769            scope.release();
    749770            push(exec, value);
    750771            return;
     
    759780        }
    760781       
    761         if (length > MAX_ARRAY_INDEX) {
     782        if (UNLIKELY(length > MAX_ARRAY_INDEX)) {
    762783            methodTable(vm)->putByIndex(this, exec, length, value, true);
    763784            if (!scope.exception())
     
    765786            return;
    766787        }
    767        
     788
     789        scope.release();
    768790        putByIndexBeyondVectorLengthWithoutAttributes<DoubleShape>(exec, length, value);
    769         break;
     791        return;
    770792    }
    771793       
     
    774796        bool putResult = false;
    775797        if (attemptToInterceptPutByIndexOnHole(exec, oldLength, value, true, putResult)) {
    776             if (!scope.exception() && oldLength < 0xFFFFFFFFu)
     798            if (!scope.exception() && oldLength < 0xFFFFFFFFu) {
     799                scope.release();
    777800                setLength(exec, oldLength + 1, true);
     801            }
    778802            return;
    779803        }
     
    794818
    795819        // Pushing to an array of invalid length (2^31-1) stores the property, but throws a range error.
    796         if (storage->length() > MAX_ARRAY_INDEX) {
     820        if (UNLIKELY(storage->length() > MAX_ARRAY_INDEX)) {
    797821            methodTable(vm)->putByIndex(this, exec, storage->length(), value, true);
    798822            // Per ES5.1 15.4.4.7 step 6 & 15.4.5.1 step 3.d.
     
    803827
    804828        // Handled the same as putIndex.
     829        scope.release();
    805830        putByIndexBeyondVectorLengthWithArrayStorage(exec, storage->length(), value, true, storage);
    806         break;
     831        return;
    807832    }
    808833       
     
    11181143        // We may have to walk the entire array to do the unshift. We're willing to do so
    11191144        // only if it's not horribly slow.
    1120         if (oldLength - startIndex >= MIN_SPARSE_ARRAY_INDEX)
     1145        if (oldLength - startIndex >= MIN_SPARSE_ARRAY_INDEX) {
     1146            scope.release();
    11211147            return unshiftCountWithArrayStorage(exec, startIndex, count, ensureArrayStorage(vm));
     1148        }
    11221149       
    11231150        if (!ensureLength(vm, oldLength + count)) {
     
    11311158        for (unsigned i = oldLength; i-- > startIndex;) {
    11321159            JSValue v = butterfly->contiguous()[i].get();
    1133             if (UNLIKELY(!v))
     1160            if (UNLIKELY(!v)) {
     1161                scope.release();
    11341162                return unshiftCountWithArrayStorage(exec, startIndex, count, ensureArrayStorage(vm));
     1163            }
    11351164        }
    11361165
     
    11541183        // We may have to walk the entire array to do the unshift. We're willing to do so
    11551184        // only if it's not horribly slow.
    1156         if (oldLength - startIndex >= MIN_SPARSE_ARRAY_INDEX)
     1185        if (oldLength - startIndex >= MIN_SPARSE_ARRAY_INDEX) {
     1186            scope.release();
    11571187            return unshiftCountWithArrayStorage(exec, startIndex, count, ensureArrayStorage(vm));
     1188        }
    11581189       
    11591190        if (!ensureLength(vm, oldLength + count)) {
     
    11671198        for (unsigned i = oldLength; i-- > startIndex;) {
    11681199            double v = butterfly->contiguousDouble()[i];
    1169             if (UNLIKELY(v != v))
     1200            if (UNLIKELY(v != v)) {
     1201                scope.release();
    11701202                return unshiftCountWithArrayStorage(exec, startIndex, count, ensureArrayStorage(vm));
     1203            }
    11711204        }
    11721205
     
    11871220    case ArrayWithArrayStorage:
    11881221    case ArrayWithSlowPutArrayStorage:
     1222        scope.release();
    11891223        return unshiftCountWithArrayStorage(exec, startIndex, count, arrayStorage());
    11901224       
  • trunk/Source/JavaScriptCore/runtime/JSArrayBuffer.cpp

    r208209 r209036  
    107107    JSArrayBuffer* thisObject = jsCast<JSArrayBuffer*>(cell);
    108108
    109     if (UNLIKELY(isThisValueAltered(slot, thisObject)))
     109    if (UNLIKELY(isThisValueAltered(slot, thisObject))) {
     110        scope.release();
    110111        return ordinarySetSlow(exec, thisObject, propertyName, value, slot.thisValue(), slot.isStrictMode());
     112    }
    111113   
    112114    if (propertyName == vm.propertyNames->byteLength)
    113115        return typeError(exec, scope, slot.isStrictMode(), ASCIILiteral("Attempting to write to a read-only array buffer property."));
    114    
     116
     117    scope.release();
    115118    return Base::put(thisObject, exec, propertyName, value, slot);
    116119}
     
    126129    if (propertyName == vm.propertyNames->byteLength)
    127130        return typeError(exec, scope, shouldThrow, ASCIILiteral("Attempting to define read-only array buffer property."));
    128    
     131
     132    scope.release();
    129133    return Base::defineOwnProperty(thisObject, exec, propertyName, descriptor, shouldThrow);
    130134}
  • trunk/Source/JavaScriptCore/runtime/JSArrayInlines.h

    r206525 r209036  
    7777    JSValue lengthValue = obj->get(exec, vm.propertyNames->length);
    7878    RETURN_IF_EXCEPTION(scope, UINT_MAX);
     79    scope.release();
    7980    return lengthValue.toUInt32(exec);
    8081}
     
    8990    JSValue lengthValue = obj->get(exec, vm.propertyNames->length);
    9091    RETURN_IF_EXCEPTION(scope, PNaN);
     92    scope.release();
    9193    return lengthValue.toLength(exec);
    9294}
Note: See TracChangeset for help on using the changeset viewer.