X-Git-Url: https://git.saurik.com/apple/javascriptcore.git/blobdiff_plain/93a3786624b2768d89bfa27e46598dc64e2fb70a..refs/heads/master:/runtime/SparseArrayValueMap.cpp diff --git a/runtime/SparseArrayValueMap.cpp b/runtime/SparseArrayValueMap.cpp index 1997c5b..62d34ba 100644 --- a/runtime/SparseArrayValueMap.cpp +++ b/runtime/SparseArrayValueMap.cpp @@ -29,7 +29,7 @@ #include "ClassInfo.h" #include "GetterSetter.h" #include "JSObject.h" -#include "Operations.h" +#include "JSCInlines.h" #include "PropertySlot.h" #include "Reject.h" #include "SlotVisitor.h" @@ -37,7 +37,7 @@ namespace JSC { -const ClassInfo SparseArrayValueMap::s_info = { "SparseArrayValueMap", 0, 0, 0, CREATE_METHOD_TABLE(SparseArrayValueMap) }; +const ClassInfo SparseArrayValueMap::s_info = { "SparseArrayValueMap", 0, 0, CREATE_METHOD_TABLE(SparseArrayValueMap) }; SparseArrayValueMap::SparseArrayValueMap(VM& vm) : Base(vm, vm.sparseArrayValueMapStructure.get()) @@ -69,7 +69,7 @@ void SparseArrayValueMap::destroy(JSCell* cell) Structure* SparseArrayValueMap::createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype) { - return Structure::create(vm, globalObject, prototype, TypeInfo(CompoundType, StructureFlags), &s_info); + return Structure::create(vm, globalObject, prototype, TypeInfo(CellType, StructureFlags), info()); } SparseArrayValueMap::AddResult SparseArrayValueMap::add(JSObject* array, unsigned i) @@ -80,7 +80,9 @@ SparseArrayValueMap::AddResult SparseArrayValueMap::add(JSObject* array, unsigne AddResult result = m_map.add(i, entry); size_t capacity = m_map.capacity(); if (capacity != m_reportedCapacity) { - Heap::heap(array)->reportExtraMemoryCost((capacity - m_reportedCapacity) * (sizeof(unsigned) + sizeof(WriteBarrier))); + // FIXME: Adopt reportExtraMemoryVisited, and switch to reportExtraMemoryAllocated. + // https://bugs.webkit.org/show_bug.cgi?id=142595 + Heap::heap(array)->deprecatedReportExtraMemory((capacity - m_reportedCapacity) * (sizeof(unsigned) + sizeof(WriteBarrier))); m_reportedCapacity = capacity; } return result; @@ -122,23 +124,17 @@ bool SparseArrayValueMap::putDirect(ExecState* exec, JSObject* array, unsigned i return true; } -void SparseArrayEntry::get(PropertySlot& slot) const +void SparseArrayEntry::get(JSObject* thisObject, PropertySlot& slot) const { JSValue value = Base::get(); ASSERT(value); if (LIKELY(!value.isGetterSetter())) { - slot.setValue(value); + slot.setValue(thisObject, attributes, value); return; } - JSObject* getter = asGetterSetter(value)->getter(); - if (!getter) { - slot.setUndefined(); - return; - } - - slot.setGetterSlot(getter); + slot.setGetterSlot(thisObject, attributes, jsCast(value)); } void SparseArrayEntry::get(PropertyDescriptor& descriptor) const @@ -148,19 +144,13 @@ void SparseArrayEntry::get(PropertyDescriptor& descriptor) const JSValue SparseArrayEntry::get(ExecState* exec, JSObject* array) const { - JSValue result = Base::get(); - ASSERT(result); - - if (LIKELY(!result.isGetterSetter())) - return result; + JSValue value = Base::get(); + ASSERT(value); - JSObject* getter = asGetterSetter(result)->getter(); - if (!getter) - return jsUndefined(); + if (LIKELY(!value.isGetterSetter())) + return value; - CallData callData; - CallType callType = getter->methodTable()->getCallData(getter, callData); - return call(exec, getter, callType, callData, array->methodTable()->toThisObject(array, exec), exec->emptyList()); + return callGetter(exec, array, jsCast(value)); } void SparseArrayEntry::put(ExecState* exec, JSValue thisValue, SparseArrayValueMap* map, JSValue value, bool shouldThrow) @@ -176,23 +166,7 @@ void SparseArrayEntry::put(ExecState* exec, JSValue thisValue, SparseArrayValueM return; } - JSValue accessor = Base::get(); - ASSERT(accessor.isGetterSetter()); - JSObject* setter = asGetterSetter(accessor)->setter(); - - if (!setter) { - if (shouldThrow) - throwTypeError(exec, StrictModeReadonlyPropertyWriteError); - return; - } - - CallData callData; - CallType callType = setter->methodTable()->getCallData(setter, callData); - MarkedArgumentBuffer args; - args.append(value); - if (thisValue.isObject()) - thisValue = asObject(thisValue)->methodTable()->toThisObject(asObject(thisValue), exec); - call(exec, setter, callType, callData, thisValue, args); + callSetter(exec, thisValue, Base::get(), value, shouldThrow ? StrictMode : NotStrictMode); } JSValue SparseArrayEntry::getNonSparseMode() const