Changeset 207036 in webkit


Ignore:
Timestamp:
Oct 10, 2016 5:45:45 PM (8 years ago)
Author:
mark.lam@apple.com
Message:

Change ArrayPrototype.cpp's putLength() and setLength() to take a VM& so that we can use vm.propertyNames.
https://bugs.webkit.org/show_bug.cgi?id=163260

Reviewed by Saam Barati.

In all cases where we call these, we already have the VM& anyway.

  • runtime/ArrayPrototype.cpp:

(JSC::putLength):
(JSC::setLength):
(JSC::arrayProtoFuncPop):
(JSC::arrayProtoFuncPush):
(JSC::arrayProtoFuncShift):
(JSC::arrayProtoFuncSlice):
(JSC::arrayProtoFuncSplice):
(JSC::arrayProtoFuncUnShift):

Location:
trunk/Source/JavaScriptCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r207023 r207036  
     12016-10-10  Mark Lam  <mark.lam@apple.com>
     2
     3        Change ArrayPrototype.cpp's putLength() and setLength() to take a VM& so that we can use vm.propertyNames.
     4        https://bugs.webkit.org/show_bug.cgi?id=163260
     5
     6        Reviewed by Saam Barati.
     7
     8        In all cases where we call these, we already have the VM& anyway.
     9
     10        * runtime/ArrayPrototype.cpp:
     11        (JSC::putLength):
     12        (JSC::setLength):
     13        (JSC::arrayProtoFuncPop):
     14        (JSC::arrayProtoFuncPush):
     15        (JSC::arrayProtoFuncShift):
     16        (JSC::arrayProtoFuncSlice):
     17        (JSC::arrayProtoFuncSplice):
     18        (JSC::arrayProtoFuncUnShift):
     19
    1202016-10-10  Mark Lam  <mark.lam@apple.com>
    221
  • trunk/Source/JavaScriptCore/runtime/ArrayPrototype.cpp

    r206386 r207036  
    164164}
    165165
    166 static ALWAYS_INLINE void putLength(ExecState* exec, JSObject* obj, JSValue value)
     166static ALWAYS_INLINE void putLength(ExecState* exec, VM& vm, JSObject* obj, JSValue value)
    167167{
    168168    PutPropertySlot slot(obj);
    169     obj->methodTable()->put(obj, exec, exec->propertyNames().length, value, slot);
    170 }
    171 
    172 static ALWAYS_INLINE void setLength(ExecState* exec, JSObject* obj, unsigned value)
     169    obj->methodTable()->put(obj, exec, vm.propertyNames->length, value, slot);
     170}
     171
     172static ALWAYS_INLINE void setLength(ExecState* exec, VM& vm, JSObject* obj, unsigned value)
    173173{
    174174    if (isJSArray(obj))
    175175        jsCast<JSArray*>(obj)->setLength(exec, value);
    176     putLength(exec, obj, jsNumber(value));
     176    putLength(exec, vm, obj, jsNumber(value));
    177177}
    178178
     
    680680    JSValue result;
    681681    if (length == 0) {
    682         putLength(exec, thisObj, jsNumber(length));
     682        putLength(exec, vm, thisObj, jsNumber(length));
    683683        result = jsUndefined();
    684684    } else {
     
    689689            return JSValue::encode(jsUndefined());
    690690        }
    691         putLength(exec, thisObj, jsNumber(length - 1));
     691        putLength(exec, vm, thisObj, jsNumber(length - 1));
    692692    }
    693693    return JSValue::encode(result);
     
    725725   
    726726    JSValue newLength(static_cast<int64_t>(length) + static_cast<int64_t>(exec->argumentCount()));
    727     putLength(exec, thisObj, newLength);
     727    putLength(exec, vm, thisObj, newLength);
    728728    return JSValue::encode(newLength);
    729729}
     
    827827    JSValue result;
    828828    if (length == 0) {
    829         putLength(exec, thisObj, jsNumber(length));
     829        putLength(exec, vm, thisObj, jsNumber(length));
    830830        result = jsUndefined();
    831831    } else {
     
    833833        shift<JSArray::ShiftCountForShift>(exec, thisObj, 0, 1, 0, length);
    834834        RETURN_IF_EXCEPTION(scope, encodedJSValue());
    835         putLength(exec, thisObj, jsNumber(length - 1));
     835        putLength(exec, vm, thisObj, jsNumber(length - 1));
    836836    }
    837837    return JSValue::encode(result);
     
    877877            result->putDirectIndex(exec, n, v);
    878878    }
    879     setLength(exec, result, n);
     879    setLength(exec, vm, result, n);
    880880    return JSValue::encode(result);
    881881}
     
    907907        }
    908908
    909         setLength(exec, result, 0);
    910         setLength(exec, thisObj, length);
     909        setLength(exec, vm, result, 0);
     910        setLength(exec, vm, thisObj, length);
    911911        return JSValue::encode(result);
    912912    }
     
    973973    }
    974974   
    975     setLength(exec, thisObj, length - deleteCount + additionalArgs);
     975    setLength(exec, vm, thisObj, length - deleteCount + additionalArgs);
    976976    return JSValue::encode(result);
    977977}
     
    999999    }
    10001000    JSValue result = jsNumber(length + nrArgs);
    1001     putLength(exec, thisObj, result);
     1001    putLength(exec, vm, thisObj, result);
    10021002    return JSValue::encode(result);
    10031003}
Note: See TracChangeset for help on using the changeset viewer.