Changeset 205324 in webkit


Ignore:
Timestamp:
Sep 1, 2016, 3:34:27 PM (8 years ago)
Author:
mark.lam@apple.com
Message:

Move some JSObject and JSArray inline functions to their respective Inlines.h files.
https://bugs.webkit.org/show_bug.cgi?id=161499

Reviewed by Saam Barati.

Source/JavaScriptCore:

This is just a refactoring patch to move some inline functions to their Inlines.h
files. This will be needed to enable https://bugs.webkit.org/show_bug.cgi?id=161498
later.

  • bindings/ScriptValue.cpp:
  • interpreter/Interpreter.cpp:
  • runtime/IntlDateTimeFormatPrototype.cpp:
  • runtime/IntlNumberFormatPrototype.cpp:
  • runtime/JSArray.cpp:
  • runtime/JSArray.h:

(JSC::getLength): Deleted.
(JSC::toLength): Deleted.

  • runtime/JSArrayInlines.h:

(JSC::JSArray::mergeIndexingTypeForCopying):
(JSC::JSArray::canFastCopy):
(JSC::getLength):
(JSC::toLength):

  • runtime/JSInternalPromise.cpp:
  • runtime/JSInternalPromiseDeferred.cpp:
  • runtime/JSJob.cpp:
  • runtime/JSModuleRecord.cpp:
  • runtime/JSObject.h:

(JSC::JSObject::getPropertySlot): Deleted.
(JSC::JSObject::getNonIndexPropertySlot): Deleted.

  • runtime/JSObjectInlines.h:

(JSC::JSObject::getPropertySlot):
(JSC::JSObject::getNonIndexPropertySlot):

  • runtime/JSPromiseDeferred.cpp:
  • runtime/JSTypedArrayViewPrototype.cpp:
  • runtime/MapConstructor.cpp:
  • runtime/SamplingProfiler.cpp:
  • runtime/SetConstructor.cpp:
  • runtime/WeakMapConstructor.cpp:
  • runtime/WeakSetConstructor.cpp:

Source/WebCore:

No new tests because there is no behavior change.

  • ForwardingHeaders/runtime/JSObjectInlines.h: Added.
  • bindings/js/JSDOMBinding.h:
  • bindings/js/JSSQLTransactionCustom.cpp:
  • bindings/js/JSWebGLRenderingContextBaseCustom.cpp:
  • contentextensions/ContentExtensionParser.cpp:
Location:
trunk/Source
Files:
1 added
26 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/Source/JavaScriptCore/ChangeLog

    r205321 r205324  
     12016-09-01  Mark Lam  <mark.lam@apple.com>
     2
     3        Move some JSObject and JSArray inline functions to their respective Inlines.h files.
     4        https://bugs.webkit.org/show_bug.cgi?id=161499
     5
     6        Reviewed by Saam Barati.
     7
     8        This is just a refactoring patch to move some inline functions to their Inlines.h
     9        files.  This will be needed to enable https://bugs.webkit.org/show_bug.cgi?id=161498
     10        later.
     11
     12        * bindings/ScriptValue.cpp:
     13        * interpreter/Interpreter.cpp:
     14        * runtime/IntlDateTimeFormatPrototype.cpp:
     15        * runtime/IntlNumberFormatPrototype.cpp:
     16        * runtime/JSArray.cpp:
     17        * runtime/JSArray.h:
     18        (JSC::getLength): Deleted.
     19        (JSC::toLength): Deleted.
     20        * runtime/JSArrayInlines.h:
     21        (JSC::JSArray::mergeIndexingTypeForCopying):
     22        (JSC::JSArray::canFastCopy):
     23        (JSC::getLength):
     24        (JSC::toLength):
     25        * runtime/JSInternalPromise.cpp:
     26        * runtime/JSInternalPromiseDeferred.cpp:
     27        * runtime/JSJob.cpp:
     28        * runtime/JSModuleRecord.cpp:
     29        * runtime/JSObject.h:
     30        (JSC::JSObject::getPropertySlot): Deleted.
     31        (JSC::JSObject::getNonIndexPropertySlot): Deleted.
     32        * runtime/JSObjectInlines.h:
     33        (JSC::JSObject::getPropertySlot):
     34        (JSC::JSObject::getNonIndexPropertySlot):
     35        * runtime/JSPromiseDeferred.cpp:
     36        * runtime/JSTypedArrayViewPrototype.cpp:
     37        * runtime/MapConstructor.cpp:
     38        * runtime/SamplingProfiler.cpp:
     39        * runtime/SetConstructor.cpp:
     40        * runtime/WeakMapConstructor.cpp:
     41        * runtime/WeakSetConstructor.cpp:
     42
    1432016-09-01  JF Bastien  <jfbastien@apple.com>
    244
  • TabularUnified trunk/Source/JavaScriptCore/bindings/ScriptValue.cpp

    r204912 r205324  
    3434#include "InspectorValues.h"
    3535#include "JSLock.h"
     36#include "JSObjectInlines.h"
    3637#include "StructureInlines.h"
    3738
  • TabularUnified trunk/Source/JavaScriptCore/interpreter/Interpreter.cpp

    r205198 r205324  
    4444#include "ExceptionHelpers.h"
    4545#include "GetterSetter.h"
    46 #include "JSArray.h"
     46#include "JSArrayInlines.h"
    4747#include "JSBoundFunction.h"
    4848#include "JSCInlines.h"
  • TabularUnified trunk/Source/JavaScriptCore/runtime/IntlDateTimeFormatPrototype.cpp

    r205198 r205324  
    3838#include "JSCJSValueInlines.h"
    3939#include "JSCellInlines.h"
    40 #include "JSObject.h"
     40#include "JSObjectInlines.h"
    4141#include "StructureInlines.h"
    4242
  • TabularUnified trunk/Source/JavaScriptCore/runtime/IntlNumberFormatPrototype.cpp

    r205198 r205324  
    3636#include "JSCJSValueInlines.h"
    3737#include "JSCellInlines.h"
    38 #include "JSObject.h"
     38#include "JSObjectInlines.h"
    3939#include "StructureInlines.h"
    4040
  • TabularUnified trunk/Source/JavaScriptCore/runtime/JSArray.cpp

    r205198 r205324  
    3232#include "GetterSetter.h"
    3333#include "IndexingHeaderInlines.h"
     34#include "JSArrayInlines.h"
    3435#include "JSCInlines.h"
    3536#include "PropertyNameArray.h"
  • TabularUnified trunk/Source/JavaScriptCore/runtime/JSArray.h

    r204912 r205324  
    342342}
    343343
    344 ALWAYS_INLINE unsigned getLength(ExecState* exec, JSObject* obj)
    345 {
    346     if (isJSArray(obj))
    347         return jsCast<JSArray*>(obj)->length();
    348 
    349     VM& vm = exec->vm();
    350     JSValue lengthValue = obj->get(exec, vm.propertyNames->length);
    351     if (UNLIKELY(vm.exception()))
    352         return UINT_MAX;
    353     return lengthValue.toUInt32(exec);
    354 }
    355 
    356 ALWAYS_INLINE double toLength(ExecState* exec, JSObject* obj)
    357 {
    358     if (isJSArray(obj))
    359         return jsCast<JSArray*>(obj)->length();
    360 
    361     VM& vm = exec->vm();
    362     JSValue lengthValue = obj->get(exec, vm.propertyNames->length);
    363     if (UNLIKELY(vm.exception()))
    364         return PNaN;
    365     return lengthValue.toLength(exec);
    366 }
    367 
    368344} // namespace JSC
    369345
  • TabularUnified trunk/Source/JavaScriptCore/runtime/JSArrayInlines.h

    r202125 r205324  
    2727namespace JSC {
    2828
    29 IndexingType JSArray::mergeIndexingTypeForCopying(IndexingType other)
     29inline IndexingType JSArray::mergeIndexingTypeForCopying(IndexingType other)
    3030{
    3131    IndexingType type = indexingType();
     
    5757}
    5858
    59 bool JSArray::canFastCopy(VM& vm, JSArray* otherArray)
     59inline bool JSArray::canFastCopy(VM& vm, JSArray* otherArray)
    6060{
    6161    if (hasAnyArrayStorage(indexingType()) || hasAnyArrayStorage(otherArray->indexingType()))
     
    6969}
    7070
     71ALWAYS_INLINE unsigned getLength(ExecState* exec, JSObject* obj)
     72{
     73    if (isJSArray(obj))
     74        return jsCast<JSArray*>(obj)->length();
     75
     76    VM& vm = exec->vm();
     77    JSValue lengthValue = obj->get(exec, vm.propertyNames->length);
     78    if (UNLIKELY(vm.exception()))
     79        return UINT_MAX;
     80    return lengthValue.toUInt32(exec);
     81}
     82
     83ALWAYS_INLINE double toLength(ExecState* exec, JSObject* obj)
     84{
     85    if (isJSArray(obj))
     86        return jsCast<JSArray*>(obj)->length();
     87
     88    VM& vm = exec->vm();
     89    JSValue lengthValue = obj->get(exec, vm.propertyNames->length);
     90    if (UNLIKELY(vm.exception()))
     91        return PNaN;
     92    return lengthValue.toLength(exec);
     93}
     94
    7195} // namespace JSC
    7296
  • TabularUnified trunk/Source/JavaScriptCore/runtime/JSInternalPromise.cpp

    r204912 r205324  
    3030#include "JSCJSValueInlines.h"
    3131#include "JSCellInlines.h"
     32#include "JSObjectInlines.h"
    3233#include "StructureInlines.h"
    3334
  • TabularUnified trunk/Source/JavaScriptCore/runtime/JSInternalPromiseDeferred.cpp

    r204912 r205324  
    3434#include "JSInternalPromise.h"
    3535#include "JSInternalPromiseConstructor.h"
     36#include "JSObjectInlines.h"
    3637#include "SlotVisitorInlines.h"
    3738#include "StructureInlines.h"
  • TabularUnified trunk/Source/JavaScriptCore/runtime/JSJob.cpp

    r204912 r205324  
    3232#include "JSCellInlines.h"
    3333#include "JSGlobalObject.h"
     34#include "JSObjectInlines.h"
    3435#include "Microtask.h"
    3536#include "SlotVisitorInlines.h"
  • TabularUnified trunk/Source/JavaScriptCore/runtime/JSModuleRecord.cpp

    r205198 r205324  
    3535#include "JSModuleEnvironment.h"
    3636#include "JSModuleNamespaceObject.h"
     37#include "JSObjectInlines.h"
    3738#include "SlotVisitorInlines.h"
    3839#include "StructureInlines.h"
  • TabularUnified trunk/Source/JavaScriptCore/runtime/JSObject.h

    r205198 r205324  
    12911291}
    12921292
    1293 ALWAYS_INLINE bool JSObject::getPropertySlot(ExecState* exec, unsigned propertyName, PropertySlot& slot)
    1294 {
    1295     VM& vm = exec->vm();
    1296     auto& structureIDTable = vm.heap.structureIDTable();
    1297     JSObject* object = this;
    1298     MethodTable::GetPrototypeFunctionPtr defaultGetPrototype = JSObject::getPrototype;
    1299     while (true) {
    1300         Structure& structure = *structureIDTable.get(object->structureID());
    1301         if (structure.classInfo()->methodTable.getOwnPropertySlotByIndex(object, exec, propertyName, slot))
    1302             return true;
    1303         if (UNLIKELY(vm.exception()))
    1304             return false;
    1305         JSValue prototype;
    1306         if (LIKELY(structure.classInfo()->methodTable.getPrototype == defaultGetPrototype || slot.internalMethodType() == PropertySlot::InternalMethodType::VMInquiry))
    1307             prototype = structure.storedPrototype();
    1308         else {
    1309             prototype = object->getPrototype(vm, exec);
    1310             if (vm.exception())
    1311                 return false;
    1312         }
    1313         if (!prototype.isObject())
    1314             return false;
    1315         object = asObject(prototype);
    1316     }
    1317 }
    1318 
    1319 ALWAYS_INLINE bool JSObject::getNonIndexPropertySlot(ExecState* exec, PropertyName propertyName, PropertySlot& slot)
    1320 {
    1321     // This method only supports non-index PropertyNames.
    1322     ASSERT(!parseIndex(propertyName));
    1323 
    1324     VM& vm = exec->vm();
    1325     auto& structureIDTable = vm.heap.structureIDTable();
    1326     JSObject* object = this;
    1327     MethodTable::GetPrototypeFunctionPtr defaultGetPrototype = JSObject::getPrototype;
    1328     while (true) {
    1329         Structure& structure = *structureIDTable.get(object->structureID());
    1330         if (LIKELY(!TypeInfo::overridesGetOwnPropertySlot(object->inlineTypeFlags()))) {
    1331             if (object->getOwnNonIndexPropertySlot(vm, structure, propertyName, slot))
    1332                 return true;
    1333         } else {
    1334             if (structure.classInfo()->methodTable.getOwnPropertySlot(object, exec, propertyName, slot))
    1335                 return true;
    1336             if (UNLIKELY(vm.exception()))
    1337                 return false;
    1338         }
    1339         JSValue prototype;
    1340         if (LIKELY(structure.classInfo()->methodTable.getPrototype == defaultGetPrototype || slot.internalMethodType() == PropertySlot::InternalMethodType::VMInquiry))
    1341             prototype = structure.storedPrototype();
    1342         else {
    1343             prototype = object->getPrototype(vm, exec);
    1344             if (vm.exception())
    1345                 return false;
    1346         }
    1347         if (!prototype.isObject())
    1348             return false;
    1349         object = asObject(prototype);
    1350     }
    1351 }
    1352 
    13531293inline JSValue JSObject::get(ExecState* exec, PropertyName propertyName) const
    13541294{
     
    13671307
    13681308    return jsUndefined();
    1369 }
    1370 
    1371 template<typename CallbackWhenNoException>
    1372 ALWAYS_INLINE typename std::result_of<CallbackWhenNoException(bool, PropertySlot&)>::type JSObject::getPropertySlot(ExecState* exec, PropertyName propertyName, CallbackWhenNoException callback) const
    1373 {
    1374     PropertySlot slot(this, PropertySlot::InternalMethodType::Get);
    1375     return getPropertySlot(exec, propertyName, slot, callback);
    1376 }
    1377 
    1378 template<typename CallbackWhenNoException>
    1379 ALWAYS_INLINE typename std::result_of<CallbackWhenNoException(bool, PropertySlot&)>::type JSObject::getPropertySlot(ExecState* exec, PropertyName propertyName, PropertySlot& slot, CallbackWhenNoException callback) const
    1380 {
    1381     bool found = const_cast<JSObject*>(this)->getPropertySlot(exec, propertyName, slot);
    1382     if (UNLIKELY(exec->hadException()))
    1383         return { };
    1384     return callback(found, slot);
    13851309}
    13861310
  • TabularUnified trunk/Source/JavaScriptCore/runtime/JSObjectInlines.h

    r205198 r205324  
    8686}
    8787
     88template<typename CallbackWhenNoException>
     89ALWAYS_INLINE typename std::result_of<CallbackWhenNoException(bool, PropertySlot&)>::type JSObject::getPropertySlot(ExecState* exec, PropertyName propertyName, CallbackWhenNoException callback) const
     90{
     91    PropertySlot slot(this, PropertySlot::InternalMethodType::Get);
     92    return getPropertySlot(exec, propertyName, slot, callback);
     93}
     94
     95template<typename CallbackWhenNoException>
     96ALWAYS_INLINE typename std::result_of<CallbackWhenNoException(bool, PropertySlot&)>::type JSObject::getPropertySlot(ExecState* exec, PropertyName propertyName, PropertySlot& slot, CallbackWhenNoException callback) const
     97{
     98    bool found = const_cast<JSObject*>(this)->getPropertySlot(exec, propertyName, slot);
     99    if (UNLIKELY(exec->hadException()))
     100        return { };
     101    return callback(found, slot);
     102}
     103
     104ALWAYS_INLINE bool JSObject::getPropertySlot(ExecState* exec, unsigned propertyName, PropertySlot& slot)
     105{
     106    VM& vm = exec->vm();
     107    auto& structureIDTable = vm.heap.structureIDTable();
     108    JSObject* object = this;
     109    MethodTable::GetPrototypeFunctionPtr defaultGetPrototype = JSObject::getPrototype;
     110    while (true) {
     111        Structure& structure = *structureIDTable.get(object->structureID());
     112        if (structure.classInfo()->methodTable.getOwnPropertySlotByIndex(object, exec, propertyName, slot))
     113            return true;
     114        if (UNLIKELY(vm.exception()))
     115            return false;
     116        JSValue prototype;
     117        if (LIKELY(structure.classInfo()->methodTable.getPrototype == defaultGetPrototype || slot.internalMethodType() == PropertySlot::InternalMethodType::VMInquiry))
     118            prototype = structure.storedPrototype();
     119        else {
     120            prototype = object->getPrototype(vm, exec);
     121            if (vm.exception())
     122                return false;
     123        }
     124        if (!prototype.isObject())
     125            return false;
     126        object = asObject(prototype);
     127    }
     128}
     129
     130ALWAYS_INLINE bool JSObject::getNonIndexPropertySlot(ExecState* exec, PropertyName propertyName, PropertySlot& slot)
     131{
     132    // This method only supports non-index PropertyNames.
     133    ASSERT(!parseIndex(propertyName));
     134
     135    VM& vm = exec->vm();
     136    auto& structureIDTable = vm.heap.structureIDTable();
     137    JSObject* object = this;
     138    MethodTable::GetPrototypeFunctionPtr defaultGetPrototype = JSObject::getPrototype;
     139    while (true) {
     140        Structure& structure = *structureIDTable.get(object->structureID());
     141        if (LIKELY(!TypeInfo::overridesGetOwnPropertySlot(object->inlineTypeFlags()))) {
     142            if (object->getOwnNonIndexPropertySlot(vm, structure, propertyName, slot))
     143                return true;
     144        } else {
     145            if (structure.classInfo()->methodTable.getOwnPropertySlot(object, exec, propertyName, slot))
     146                return true;
     147            if (UNLIKELY(vm.exception()))
     148                return false;
     149        }
     150        JSValue prototype;
     151        if (LIKELY(structure.classInfo()->methodTable.getPrototype == defaultGetPrototype || slot.internalMethodType() == PropertySlot::InternalMethodType::VMInquiry))
     152            prototype = structure.storedPrototype();
     153        else {
     154            prototype = object->getPrototype(vm, exec);
     155            if (vm.exception())
     156                return false;
     157        }
     158        if (!prototype.isObject())
     159            return false;
     160        object = asObject(prototype);
     161    }
     162}
     163
    88164// ECMA 8.6.2.2
    89165ALWAYS_INLINE bool JSObject::putInline(JSCell* cell, ExecState* exec, PropertyName propertyName, JSValue value, PutPropertySlot& slot)
  • TabularUnified trunk/Source/JavaScriptCore/runtime/JSPromiseDeferred.cpp

    r204912 r205324  
    3232#include "JSCJSValueInlines.h"
    3333#include "JSCellInlines.h"
     34#include "JSObjectInlines.h"
    3435#include "JSPromise.h"
    3536#include "JSPromiseConstructor.h"
  • TabularUnified trunk/Source/JavaScriptCore/runtime/JSTypedArrayViewPrototype.cpp

    r205198 r205324  
    3333#include "JSFunction.h"
    3434#include "JSGenericTypedArrayViewPrototypeFunctions.h"
     35#include "JSObjectInlines.h"
    3536#include "TypedArrayAdaptors.h"
    3637
  • TabularUnified trunk/Source/JavaScriptCore/runtime/MapConstructor.cpp

    r205198 r205324  
    3434#include "JSGlobalObject.h"
    3535#include "JSMap.h"
     36#include "JSObjectInlines.h"
    3637#include "MapPrototype.h"
    3738#include "StructureInlines.h"
  • TabularUnified trunk/Source/JavaScriptCore/runtime/SamplingProfiler.cpp

    r204912 r205324  
    3838#include "JSCJSValueInlines.h"
    3939#include "JSFunction.h"
     40#include "JSObjectInlines.h"
    4041#include "LLIntPCRanges.h"
    4142#include "MarkedBlock.h"
  • TabularUnified trunk/Source/JavaScriptCore/runtime/SetConstructor.cpp

    r205198 r205324  
    3333#include "JSCellInlines.h"
    3434#include "JSGlobalObject.h"
     35#include "JSObjectInlines.h"
    3536#include "JSSet.h"
    3637#include "MapData.h"
  • TabularUnified trunk/Source/JavaScriptCore/runtime/WeakMapConstructor.cpp

    r205198 r205324  
    3232#include "JSCellInlines.h"
    3333#include "JSGlobalObject.h"
     34#include "JSObjectInlines.h"
    3435#include "JSWeakMap.h"
    3536#include "StructureInlines.h"
  • TabularUnified trunk/Source/JavaScriptCore/runtime/WeakSetConstructor.cpp

    r205198 r205324  
    3232#include "JSCellInlines.h"
    3333#include "JSGlobalObject.h"
     34#include "JSObjectInlines.h"
    3435#include "JSWeakSet.h"
    3536#include "StructureInlines.h"
  • TabularUnified trunk/Source/WebCore/ChangeLog

    r205323 r205324  
     12016-09-01  Mark Lam  <mark.lam@apple.com>
     2
     3        Move some JSObject and JSArray inline functions to their respective Inlines.h files.
     4        https://bugs.webkit.org/show_bug.cgi?id=161499
     5
     6        Reviewed by Saam Barati.
     7
     8        No new tests because there is no behavior change.
     9
     10        * ForwardingHeaders/runtime/JSObjectInlines.h: Added.
     11        * bindings/js/JSDOMBinding.h:
     12        * bindings/js/JSSQLTransactionCustom.cpp:
     13        * bindings/js/JSWebGLRenderingContextBaseCustom.cpp:
     14        * contentextensions/ContentExtensionParser.cpp:
     15
    1162016-09-01  Michael Catanzaro  <mcatanzaro@igalia.com>
    217
  • TabularUnified trunk/Source/WebCore/bindings/js/JSDOMBinding.h

    r205198 r205324  
    4040#include <runtime/JSCJSValueInlines.h>
    4141#include <runtime/JSCellInlines.h>
     42#include <runtime/JSObjectInlines.h>
    4243#include <runtime/JSTypedArrays.h>
    4344#include <runtime/Lookup.h>
  • TabularUnified trunk/Source/WebCore/bindings/js/JSSQLTransactionCustom.cpp

    r200626 r205324  
    3737#include "SQLTransaction.h"
    3838#include "SQLValue.h"
     39#include <runtime/JSObjectInlines.h>
    3940
    4041using namespace JSC;
  • TabularUnified trunk/Source/WebCore/bindings/js/JSWebGLRenderingContextBaseCustom.cpp

    r205198 r205324  
    9797#include "WebGLVertexArrayObjectOES.h"
    9898#include <runtime/Error.h>
     99#include <runtime/JSObjectInlines.h>
    99100#include <runtime/JSTypedArrays.h>
    100101#include <runtime/TypedArrayInlines.h>
  • TabularUnified trunk/Source/WebCore/contentextensions/ContentExtensionParser.cpp

    r204912 r205324  
    4040#include <JavaScriptCore/JSGlobalObject.h>
    4141#include <JavaScriptCore/JSONObject.h>
     42#include <JavaScriptCore/JSObjectInlines.h>
    4243#include <JavaScriptCore/StructureInlines.h>
    4344#include <JavaScriptCore/VM.h>
Note: See TracChangeset for help on using the changeset viewer.