diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2016-05-24 08:28:08 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2016-05-24 08:28:08 +0000 |
commit | a4e969f4965059196ca948db781e52f7cfebf19e (patch) | |
tree | 6ca352808c8fdc52006a0f33f6ae3c593b23867d /Source/JavaScriptCore/runtime/JSCell.cpp | |
parent | 41386e9cb918eed93b3f13648cbef387e371e451 (diff) | |
download | WebKitGtk-tarball-a4e969f4965059196ca948db781e52f7cfebf19e.tar.gz |
webkitgtk-2.12.3webkitgtk-2.12.3
Diffstat (limited to 'Source/JavaScriptCore/runtime/JSCell.cpp')
-rw-r--r-- | Source/JavaScriptCore/runtime/JSCell.cpp | 61 |
1 files changed, 53 insertions, 8 deletions
diff --git a/Source/JavaScriptCore/runtime/JSCell.cpp b/Source/JavaScriptCore/runtime/JSCell.cpp index f472a9679..09af32bf9 100644 --- a/Source/JavaScriptCore/runtime/JSCell.cpp +++ b/Source/JavaScriptCore/runtime/JSCell.cpp @@ -28,11 +28,12 @@ #include "JSString.h" #include "JSObject.h" #include "NumberObject.h" -#include "Operations.h" +#include "JSCInlines.h" #include <wtf/MathExtras.h> namespace JSC { +COMPILE_ASSERT(sizeof(JSCell) == sizeof(uint64_t), jscell_is_eight_bytes); STATIC_ASSERT_IS_TRIVIALLY_DESTRUCTIBLE(JSCell); void JSCell::destroy(JSCell* cell) @@ -40,6 +41,26 @@ void JSCell::destroy(JSCell* cell) cell->JSCell::~JSCell(); } +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()); +} + +size_t JSCell::estimatedSizeInBytes() const +{ + return methodTable()->estimatedSize(const_cast<JSCell*>(this)); +} + +size_t JSCell::estimatedSize(JSCell* cell) +{ + return MarkedBlock::blockFor(cell)->cellSize(); +} + void JSCell::copyBackingStore(JSCell*, CopyVisitor&, CopyToken) { } @@ -85,35 +106,35 @@ ConstructType JSCell::getConstructData(JSCell*, ConstructData& constructData) void JSCell::put(JSCell* cell, ExecState* exec, PropertyName identifier, JSValue value, PutPropertySlot& slot) { - if (cell->isString()) { + if (cell->isString() || cell->isSymbol()) { 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()) { + if (cell->isString() || cell->isSymbol()) { 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, 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); } JSValue JSCell::toThis(JSCell* cell, ExecState* exec, ECMAMode ecmaMode) @@ -127,6 +148,8 @@ JSValue JSCell::toPrimitive(ExecState* exec, PreferredPrimitiveType preferredTyp { if (isString()) return static_cast<const JSString*>(this)->toPrimitive(exec, preferredType); + if (isSymbol()) + return static_cast<const Symbol*>(this)->toPrimitive(exec, preferredType); return static_cast<const JSObject*>(this)->toPrimitive(exec, preferredType); } @@ -134,6 +157,8 @@ bool JSCell::getPrimitiveNumber(ExecState* exec, double& number, JSValue& value) { if (isString()) return static_cast<const JSString*>(this)->getPrimitiveNumber(exec, number, value); + if (isSymbol()) + return static_cast<const Symbol*>(this)->getPrimitiveNumber(exec, number, value); return static_cast<const JSObject*>(this)->getPrimitiveNumber(exec, number, value); } @@ -141,6 +166,8 @@ double JSCell::toNumber(ExecState* exec) const { if (isString()) return static_cast<const JSString*>(this)->toNumber(exec); + if (isSymbol()) + return static_cast<const Symbol*>(this)->toNumber(exec); return static_cast<const JSObject*>(this)->toNumber(exec); } @@ -148,6 +175,8 @@ JSObject* JSCell::toObject(ExecState* exec, JSGlobalObject* globalObject) const { if (isString()) return static_cast<const JSString*>(this)->toObject(exec, globalObject); + if (isSymbol()) + return static_cast<const Symbol*>(this)->toObject(exec, globalObject); ASSERT(isObject()); return jsCast<JSObject*>(const_cast<JSCell*>(this)); } @@ -191,7 +220,7 @@ String JSCell::className(const JSObject*) return String(); } -const char* JSCell::className() +const char* JSCell::className() const { return classInfo()->className; } @@ -225,4 +254,20 @@ PassRefPtr<ArrayBufferView> JSCell::getTypedArrayImpl(JSArrayBufferView*) return 0; } +uint32_t JSCell::getEnumerableLength(ExecState*, JSObject*) +{ + RELEASE_ASSERT_NOT_REACHED(); + return 0; +} + +void JSCell::getStructurePropertyNames(JSObject*, ExecState*, PropertyNameArray&, EnumerationMode) +{ + RELEASE_ASSERT_NOT_REACHED(); +} + +void JSCell::getGenericPropertyNames(JSObject*, ExecState*, PropertyNameArray&, EnumerationMode) +{ + RELEASE_ASSERT_NOT_REACHED(); +} + } // namespace JSC |