summaryrefslogtreecommitdiff
path: root/Source/JavaScriptCore/runtime/JSCell.cpp
diff options
context:
space:
mode:
authorKonstantin Tokarev <annulen@yandex.ru>2016-08-25 19:20:41 +0300
committerKonstantin Tokarev <annulen@yandex.ru>2017-02-02 12:30:55 +0000
commit6882a04fb36642862b11efe514251d32070c3d65 (patch)
treeb7959826000b061fd5ccc7512035c7478742f7b0 /Source/JavaScriptCore/runtime/JSCell.cpp
parentab6df191029eeeb0b0f16f127d553265659f739e (diff)
downloadqtwebkit-6882a04fb36642862b11efe514251d32070c3d65.tar.gz
Imported QtWebKit TP3 (git b57bc6801f1876c3220d5a4bfea33d620d477443)
Change-Id: I3b1d8a2808782c9f34d50240000e20cb38d3680f Reviewed-by: Konstantin Tokarev <annulen@yandex.ru>
Diffstat (limited to 'Source/JavaScriptCore/runtime/JSCell.cpp')
-rw-r--r--Source/JavaScriptCore/runtime/JSCell.cpp119
1 files changed, 78 insertions, 41 deletions
diff --git a/Source/JavaScriptCore/runtime/JSCell.cpp b/Source/JavaScriptCore/runtime/JSCell.cpp
index 07b333193..09af32bf9 100644
--- a/Source/JavaScriptCore/runtime/JSCell.cpp
+++ b/Source/JavaScriptCore/runtime/JSCell.cpp
@@ -23,23 +23,45 @@
#include "config.h"
#include "JSCell.h"
+#include "ArrayBufferView.h"
#include "JSFunction.h"
#include "JSString.h"
#include "JSObject.h"
#include "NumberObject.h"
-#include "Operations.h"
+#include "JSCInlines.h"
#include <wtf/MathExtras.h>
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();
}
-void JSCell::copyBackingStore(JSCell*, CopyVisitor&)
+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)
{
}
@@ -82,65 +104,43 @@ ConstructType JSCell::getConstructData(JSCell*, ConstructData& constructData)
return ConstructTypeNone;
}
-bool JSCell::getOwnPropertySlot(JSCell* cell, ExecState* exec, PropertyName 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, 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()) {
- PutPropertySlot slot(shouldThrow);
+ 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);
}
-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());
}
@@ -148,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);
}
@@ -155,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);
}
@@ -162,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);
}
@@ -169,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));
}
@@ -184,6 +192,18 @@ JSValue JSCell::defaultValue(const JSObject*, ExecState*, PreferredPrimitiveType
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)
{
RELEASE_ASSERT_NOT_REACHED();
@@ -200,7 +220,7 @@ String JSCell::className(const JSObject*)
return String();
}
-const char* JSCell::className()
+const char* JSCell::className() const
{
return classInfo()->className;
}
@@ -216,21 +236,38 @@ bool JSCell::customHasInstance(JSObject*, ExecState*, JSValue)
return false;
}
-void JSCell::putDirectVirtual(JSObject*, ExecState*, PropertyName, JSValue, unsigned)
+bool JSCell::defineOwnProperty(JSObject*, ExecState*, PropertyName, const PropertyDescriptor&, bool)
{
RELEASE_ASSERT_NOT_REACHED();
+ return false;
}
-bool JSCell::defineOwnProperty(JSObject*, ExecState*, PropertyName, PropertyDescriptor&, bool)
+ArrayBuffer* JSCell::slowDownAndWasteMemory(JSArrayBufferView*)
{
RELEASE_ASSERT_NOT_REACHED();
- return false;
+ return 0;
}
-bool JSCell::getOwnPropertyDescriptor(JSObject*, ExecState*, PropertyName, PropertyDescriptor&)
+PassRefPtr<ArrayBufferView> JSCell::getTypedArrayImpl(JSArrayBufferView*)
+{
+ RELEASE_ASSERT_NOT_REACHED();
+ 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();
- return false;
}
} // namespace JSC