summaryrefslogtreecommitdiff
path: root/Source/JavaScriptCore/runtime/JSCell.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/JavaScriptCore/runtime/JSCell.cpp')
-rw-r--r--Source/JavaScriptCore/runtime/JSCell.cpp131
1 files changed, 106 insertions, 25 deletions
diff --git a/Source/JavaScriptCore/runtime/JSCell.cpp b/Source/JavaScriptCore/runtime/JSCell.cpp
index f472a9679..acdd4e88c 100644
--- a/Source/JavaScriptCore/runtime/JSCell.cpp
+++ b/Source/JavaScriptCore/runtime/JSCell.cpp
@@ -24,15 +24,18 @@
#include "JSCell.h"
#include "ArrayBufferView.h"
+#include "JSCInlines.h"
#include "JSFunction.h"
#include "JSString.h"
#include "JSObject.h"
+#include "JSWebAssemblyCallee.h"
#include "NumberObject.h"
-#include "Operations.h"
+#include "WebAssemblyToJSCallee.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,7 +43,27 @@ void JSCell::destroy(JSCell* cell)
cell->JSCell::~JSCell();
}
-void JSCell::copyBackingStore(JSCell*, CopyVisitor&, CopyToken)
+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(*cell->vm()));
+}
+
+size_t JSCell::estimatedSizeInBytes() const
+{
+ return methodTable()->estimatedSize(const_cast<JSCell*>(this));
+}
+
+size_t JSCell::estimatedSize(JSCell* cell)
+{
+ return cell->cellSize();
+}
+
+void JSCell::heapSnapshot(JSCell*, HeapSnapshotBuilder&)
{
}
@@ -72,7 +95,7 @@ CallType JSCell::getCallData(JSCell*, CallData& callData)
callData.js.functionExecutable = 0;
callData.js.scope = 0;
callData.native.function = 0;
- return CallTypeNone;
+ return CallType::None;
}
ConstructType JSCell::getConstructData(JSCell*, ConstructData& constructData)
@@ -80,40 +103,38 @@ ConstructType JSCell::getConstructData(JSCell*, ConstructData& constructData)
constructData.js.functionExecutable = 0;
constructData.js.scope = 0;
constructData.native.function = 0;
- return ConstructTypeNone;
+ return ConstructType::None;
}
-void JSCell::put(JSCell* cell, ExecState* exec, PropertyName identifier, JSValue value, PutPropertySlot& slot)
+bool JSCell::put(JSCell* cell, ExecState* exec, PropertyName identifier, JSValue value, PutPropertySlot& slot)
{
- if (cell->isString()) {
- JSValue(cell).putToPrimitive(exec, identifier, value, slot);
- return;
- }
+ if (cell->isString() || cell->isSymbol())
+ return JSValue(cell).putToPrimitive(exec, identifier, value, slot);
+
JSObject* thisObject = cell->toObject(exec, exec->lexicalGlobalObject());
- thisObject->methodTable()->put(thisObject, exec, identifier, value, slot);
+ return thisObject->methodTable(exec->vm())->put(thisObject, exec, identifier, value, slot);
}
-void JSCell::putByIndex(JSCell* cell, ExecState* exec, unsigned identifier, JSValue value, bool shouldThrow)
+bool 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;
+ return JSValue(cell).putToPrimitive(exec, Identifier::from(exec, identifier), value, slot);
}
JSObject* thisObject = cell->toObject(exec, exec->lexicalGlobalObject());
- thisObject->methodTable()->putByIndex(thisObject, exec, identifier, value, shouldThrow);
+ return 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,22 +157,27 @@ 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);
}
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);
}
-JSObject* JSCell::toObject(ExecState* exec, JSGlobalObject* globalObject) const
+JSObject* JSCell::toObjectSlow(ExecState* exec, JSGlobalObject* globalObject) const
{
+ ASSERT(!isObject());
if (isString())
return static_cast<const JSString*>(this)->toObject(exec, globalObject);
- ASSERT(isObject());
- return jsCast<JSObject*>(const_cast<JSCell*>(this));
+ ASSERT(isSymbol());
+ return static_cast<const Symbol*>(this)->toObject(exec, globalObject);
}
void slowValidateCell(JSCell* cell)
@@ -191,9 +219,15 @@ String JSCell::className(const JSObject*)
return String();
}
-const char* JSCell::className()
+String JSCell::toStringName(const JSObject*, ExecState*)
{
- return classInfo()->className;
+ RELEASE_ASSERT_NOT_REACHED();
+ return String();
+}
+
+const char* JSCell::className(VM& vm) const
+{
+ return classInfo(vm)->className;
}
void JSCell::getPropertyNames(JSObject*, ExecState*, PropertyNameArray&, EnumerationMode)
@@ -216,13 +250,60 @@ bool JSCell::defineOwnProperty(JSObject*, ExecState*, PropertyName, const Proper
ArrayBuffer* JSCell::slowDownAndWasteMemory(JSArrayBufferView*)
{
RELEASE_ASSERT_NOT_REACHED();
- return 0;
+ return nullptr;
}
-PassRefPtr<ArrayBufferView> JSCell::getTypedArrayImpl(JSArrayBufferView*)
+RefPtr<ArrayBufferView> JSCell::getTypedArrayImpl(JSArrayBufferView*)
+{
+ RELEASE_ASSERT_NOT_REACHED();
+ return nullptr;
+}
+
+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();
+}
+
+bool JSCell::preventExtensions(JSObject*, ExecState*)
+{
+ RELEASE_ASSERT_NOT_REACHED();
+}
+
+bool JSCell::isExtensible(JSObject*, ExecState*)
+{
+ RELEASE_ASSERT_NOT_REACHED();
+}
+
+bool JSCell::setPrototype(JSObject*, ExecState*, JSValue, bool)
+{
+ RELEASE_ASSERT_NOT_REACHED();
+}
+
+JSValue JSCell::getPrototype(JSObject*, ExecState*)
+{
+ RELEASE_ASSERT_NOT_REACHED();
+}
+
+bool JSCell::isAnyWasmCallee(VM& vm) const
+{
+#if ENABLE(WEBASSEMBLY)
+ return inherits(vm, JSWebAssemblyCallee::info()) || inherits(vm, WebAssemblyToJSCallee::info());
+#else
+ UNUSED_PARAM(vm);
+ return false;
+#endif
+
+}
+
} // namespace JSC