summaryrefslogtreecommitdiff
path: root/Source/JavaScriptCore/runtime/JSCell.h
diff options
context:
space:
mode:
Diffstat (limited to 'Source/JavaScriptCore/runtime/JSCell.h')
-rw-r--r--Source/JavaScriptCore/runtime/JSCell.h59
1 files changed, 18 insertions, 41 deletions
diff --git a/Source/JavaScriptCore/runtime/JSCell.h b/Source/JavaScriptCore/runtime/JSCell.h
index cf6f4ec45..a39af1283 100644
--- a/Source/JavaScriptCore/runtime/JSCell.h
+++ b/Source/JavaScriptCore/runtime/JSCell.h
@@ -31,12 +31,15 @@
#include "JSValueInlineMethods.h"
#include "SlotVisitor.h"
#include "SlotVisitorInlineMethods.h"
+#include "TypedArrayDescriptor.h"
#include "WriteBarrier.h"
#include <wtf/Noncopyable.h>
#include <wtf/TypeTraits.h>
namespace JSC {
+ class CopyVisitor;
+ class JSDestructibleObject;
class JSGlobalObject;
class LLIntOffsetsExtractor;
class PropertyDescriptor;
@@ -48,19 +51,6 @@ namespace JSC {
IncludeDontEnumProperties
};
- enum TypedArrayType {
- TypedArrayNone,
- TypedArrayInt8,
- TypedArrayInt16,
- TypedArrayInt32,
- TypedArrayUint8,
- TypedArrayUint8Clamped,
- TypedArrayUint16,
- TypedArrayUint32,
- TypedArrayFloat32,
- TypedArrayFloat64
- };
-
class JSCell {
friend class JSValue;
friend class MarkedBlock;
@@ -70,6 +60,9 @@ namespace JSC {
public:
static const unsigned StructureFlags = 0;
+ static const bool needsDestruction = false;
+ static const bool hasImmortalStructure = false;
+
enum CreatingEarlyCellTag { CreatingEarlyCell };
JSCell(CreatingEarlyCellTag);
@@ -108,6 +101,7 @@ namespace JSC {
JS_EXPORT_PRIVATE JSObject* toObject(ExecState*, JSGlobalObject*) const;
static void visitChildren(JSCell*, SlotVisitor&);
+ JS_EXPORT_PRIVATE static void copyBackingStore(JSCell*, CopyVisitor&);
// Object operations, with the toObject operation included.
const ClassInfo* classInfo() const;
@@ -309,46 +303,29 @@ namespace JSC {
return isCell() ? asCell()->toObject(exec, globalObject) : toObjectSlowCase(exec, globalObject);
}
- template<class T>
- struct NeedsDestructor {
- static const bool value = !WTF::HasTrivialDestructor<T>::value;
- };
-
template<typename T>
- void* allocateCell(Heap& heap)
+ void* allocateCell(Heap& heap, size_t size)
{
+ ASSERT(size >= sizeof(T));
#if ENABLE(GC_VALIDATION)
ASSERT(!heap.globalData()->isInitializingObject());
heap.globalData()->setInitializingObjectClass(&T::s_info);
#endif
JSCell* result = 0;
- if (NeedsDestructor<T>::value)
- result = static_cast<JSCell*>(heap.allocateWithDestructor(sizeof(T)));
- else {
- ASSERT(T::s_info.methodTable.destroy == JSCell::destroy);
- result = static_cast<JSCell*>(heap.allocateWithoutDestructor(sizeof(T)));
- }
+ if (T::needsDestruction && T::hasImmortalStructure)
+ result = static_cast<JSCell*>(heap.allocateWithImmortalStructureDestructor(size));
+ else if (T::needsDestruction && !T::hasImmortalStructure)
+ result = static_cast<JSCell*>(heap.allocateWithNormalDestructor(size));
+ else
+ result = static_cast<JSCell*>(heap.allocateWithoutDestructor(size));
result->clearStructure();
return result;
}
template<typename T>
- void* allocateCell(Heap& heap, size_t size)
+ void* allocateCell(Heap& heap)
{
- ASSERT(size >= sizeof(T));
-#if ENABLE(GC_VALIDATION)
- ASSERT(!heap.globalData()->isInitializingObject());
- heap.globalData()->setInitializingObjectClass(&T::s_info);
-#endif
- JSCell* result = 0;
- if (NeedsDestructor<T>::value)
- result = static_cast<JSCell*>(heap.allocateWithDestructor(size));
- else {
- ASSERT(T::s_info.methodTable.destroy == JSCell::destroy);
- result = static_cast<JSCell*>(heap.allocateWithoutDestructor(size));
- }
- result->clearStructure();
- return result;
+ return allocateCell<T>(heap, sizeof(T));
}
inline bool isZapped(const JSCell* cell)
@@ -362,7 +339,7 @@ namespace JSC {
ASSERT(!from || from->JSCell::inherits(&WTF::RemovePointer<To>::Type::s_info));
return static_cast<To>(from);
}
-
+
template<typename To>
inline To jsCast(JSValue from)
{