X-Git-Url: https://git.saurik.com/apple/javascriptcore.git/blobdiff_plain/6fe7ccc865dc7d7541b93c5bcaf6368d2c98a174..81345200c95645a1b0d2635520f96ad55dfde63f:/runtime/JSCell.cpp diff --git a/runtime/JSCell.cpp b/runtime/JSCell.cpp index 7f9ba88..84349fe 100644 --- a/runtime/JSCell.cpp +++ b/runtime/JSCell.cpp @@ -23,22 +23,39 @@ #include "config.h" #include "JSCell.h" +#include "ArrayBufferView.h" #include "JSFunction.h" #include "JSString.h" #include "JSObject.h" #include "NumberObject.h" +#include "JSCInlines.h" #include namespace JSC { -ASSERT_HAS_TRIVIAL_DESTRUCTOR(JSCell); +COMPILE_ASSERT(sizeof(JSCell) == sizeof(uint64_t), jscell_is_eight_bytes); +STATIC_ASSERT_IS_TRIVIALLY_DESTRUCTIBLE(JSCell); void JSCell::destroy(JSCell* cell) { cell->JSCell::~JSCell(); } -bool JSCell::getString(ExecState* exec, UString&stringValue) const +void JSCell::dump(PrintStream& out) const +{ + methodTable()->dumpToStream(this, out); +} + +void JSCell::dumpToStream(const JSCell* cell, PrintStream& out) +{ + out.printf("<%p, %s>", cell, cell->className()); +} + +void JSCell::copyBackingStore(JSCell*, CopyVisitor&, CopyToken) +{ +} + +bool JSCell::getString(ExecState* exec, String& stringValue) const { if (!isString()) return false; @@ -46,9 +63,9 @@ bool JSCell::getString(ExecState* exec, UString&stringValue) const return true; } -UString JSCell::getString(ExecState* exec) const +String JSCell::getString(ExecState* exec) const { - return isString() ? static_cast(this)->value(exec) : UString(); + return isString() ? static_cast(this)->value(exec) : String(); } JSObject* JSCell::getObject() @@ -61,75 +78,59 @@ const JSObject* JSCell::getObject() const return isObject() ? static_cast(this) : 0; } -CallType JSCell::getCallData(JSCell*, CallData&) +CallType JSCell::getCallData(JSCell*, CallData& callData) { + callData.js.functionExecutable = 0; + callData.js.scope = 0; + callData.native.function = 0; return CallTypeNone; } -ConstructType JSCell::getConstructData(JSCell*, ConstructData&) +ConstructType JSCell::getConstructData(JSCell*, ConstructData& constructData) { + constructData.js.functionExecutable = 0; + constructData.js.scope = 0; + constructData.native.function = 0; return ConstructTypeNone; } -bool JSCell::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& identifier, PropertySlot& slot) -{ - // This is not a general purpose implementation of getOwnPropertySlot. - // It should only be called by JSValue::get. - // It calls getPropertySlot, not getOwnPropertySlot. - JSObject* object = cell->toObject(exec, exec->lexicalGlobalObject()); - slot.setBase(object); - if (!object->getPropertySlot(exec, identifier, slot)) - slot.setUndefined(); - return true; -} - -bool JSCell::getOwnPropertySlotByIndex(JSCell* cell, ExecState* exec, unsigned identifier, PropertySlot& slot) -{ - // This is not a general purpose implementation of getOwnPropertySlot. - // It should only be called by JSValue::get. - // It calls getPropertySlot, not getOwnPropertySlot. - JSObject* object = cell->toObject(exec, exec->lexicalGlobalObject()); - slot.setBase(object); - if (!object->getPropertySlot(exec, identifier, slot)) - slot.setUndefined(); - return true; -} - -void JSCell::put(JSCell* cell, ExecState* exec, const Identifier& identifier, JSValue value, PutPropertySlot& slot) +void JSCell::put(JSCell* cell, ExecState* exec, PropertyName identifier, JSValue value, PutPropertySlot& slot) { if (cell->isString()) { JSValue(cell).putToPrimitive(exec, identifier, value, slot); return; } JSObject* thisObject = cell->toObject(exec, exec->lexicalGlobalObject()); - thisObject->methodTable()->put(thisObject, exec, identifier, value, slot); + thisObject->methodTable(exec->vm())->put(thisObject, exec, identifier, value, slot); } void JSCell::putByIndex(JSCell* cell, ExecState* exec, unsigned identifier, JSValue value, bool shouldThrow) { if (cell->isString()) { - PutPropertySlot slot(shouldThrow); + PutPropertySlot slot(cell, shouldThrow); JSValue(cell).putToPrimitive(exec, Identifier::from(exec, identifier), value, slot); return; } JSObject* thisObject = cell->toObject(exec, exec->lexicalGlobalObject()); - thisObject->methodTable()->putByIndex(thisObject, exec, identifier, value, shouldThrow); + thisObject->methodTable(exec->vm())->putByIndex(thisObject, exec, identifier, value, shouldThrow); } -bool JSCell::deleteProperty(JSCell* cell, ExecState* exec, const Identifier& identifier) +bool JSCell::deleteProperty(JSCell* cell, ExecState* exec, PropertyName identifier) { JSObject* thisObject = cell->toObject(exec, exec->lexicalGlobalObject()); - return thisObject->methodTable()->deleteProperty(thisObject, exec, identifier); + return thisObject->methodTable(exec->vm())->deleteProperty(thisObject, exec, identifier); } bool JSCell::deletePropertyByIndex(JSCell* cell, ExecState* exec, unsigned identifier) { JSObject* thisObject = cell->toObject(exec, exec->lexicalGlobalObject()); - return thisObject->methodTable()->deletePropertyByIndex(thisObject, exec, identifier); + return thisObject->methodTable(exec->vm())->deletePropertyByIndex(thisObject, exec, identifier); } -JSObject* JSCell::toThisObject(JSCell* cell, ExecState* exec) +JSValue JSCell::toThis(JSCell* cell, ExecState* exec, ECMAMode ecmaMode) { + if (ecmaMode == StrictMode) + return cell; return cell->toObject(exec, exec->lexicalGlobalObject()); } @@ -169,47 +170,70 @@ void slowValidateCell(JSCell* cell) JSValue JSCell::defaultValue(const JSObject*, ExecState*, PreferredPrimitiveType) { - ASSERT_NOT_REACHED(); + RELEASE_ASSERT_NOT_REACHED(); return jsUndefined(); } +bool JSCell::getOwnPropertySlot(JSObject*, ExecState*, PropertyName, PropertySlot&) +{ + RELEASE_ASSERT_NOT_REACHED(); + return false; +} + +bool JSCell::getOwnPropertySlotByIndex(JSObject*, ExecState*, unsigned, PropertySlot&) +{ + RELEASE_ASSERT_NOT_REACHED(); + return false; +} + void JSCell::getOwnPropertyNames(JSObject*, ExecState*, PropertyNameArray&, EnumerationMode) { - ASSERT_NOT_REACHED(); + RELEASE_ASSERT_NOT_REACHED(); } -UString JSCell::className(const JSObject*) +void JSCell::getOwnNonIndexPropertyNames(JSObject*, ExecState*, PropertyNameArray&, EnumerationMode) { - ASSERT_NOT_REACHED(); - return UString(); + RELEASE_ASSERT_NOT_REACHED(); } -void JSCell::getPropertyNames(JSObject*, ExecState*, PropertyNameArray&, EnumerationMode) +String JSCell::className(const JSObject*) { - ASSERT_NOT_REACHED(); + RELEASE_ASSERT_NOT_REACHED(); + return String(); } -bool JSCell::hasInstance(JSObject*, ExecState*, JSValue, JSValue) +const char* JSCell::className() const { - ASSERT_NOT_REACHED(); - return false; + return classInfo()->className; } -void JSCell::putDirectVirtual(JSObject*, ExecState*, const Identifier&, JSValue, unsigned) +void JSCell::getPropertyNames(JSObject*, ExecState*, PropertyNameArray&, EnumerationMode) { - ASSERT_NOT_REACHED(); + RELEASE_ASSERT_NOT_REACHED(); } -bool JSCell::defineOwnProperty(JSObject*, ExecState*, const Identifier&, PropertyDescriptor&, bool) +bool JSCell::customHasInstance(JSObject*, ExecState*, JSValue) { - ASSERT_NOT_REACHED(); + RELEASE_ASSERT_NOT_REACHED(); return false; } -bool JSCell::getOwnPropertyDescriptor(JSObject*, ExecState*, const Identifier&, PropertyDescriptor&) +bool JSCell::defineOwnProperty(JSObject*, ExecState*, PropertyName, const PropertyDescriptor&, bool) { - ASSERT_NOT_REACHED(); + RELEASE_ASSERT_NOT_REACHED(); return false; } +ArrayBuffer* JSCell::slowDownAndWasteMemory(JSArrayBufferView*) +{ + RELEASE_ASSERT_NOT_REACHED(); + return 0; +} + +PassRefPtr JSCell::getTypedArrayImpl(JSArrayBufferView*) +{ + RELEASE_ASSERT_NOT_REACHED(); + return 0; +} + } // namespace JSC