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.h20
1 files changed, 16 insertions, 4 deletions
diff --git a/Source/JavaScriptCore/runtime/JSCell.h b/Source/JavaScriptCore/runtime/JSCell.h
index 2ef359b76..431e67145 100644
--- a/Source/JavaScriptCore/runtime/JSCell.h
+++ b/Source/JavaScriptCore/runtime/JSCell.h
@@ -178,7 +178,7 @@ namespace JSC {
{
#if ENABLE(GC_VALIDATION)
ASSERT(globalData.isInitializingObject());
- globalData.setInitializingObject(false);
+ globalData.setInitializingObjectClass(0);
#else
UNUSED_PARAM(globalData);
#endif
@@ -328,9 +328,8 @@ namespace JSC {
void* allocateCell(Heap& heap)
{
#if ENABLE(GC_VALIDATION)
- ASSERT(sizeof(T) == T::s_info.cellSize);
ASSERT(!heap.globalData()->isInitializingObject());
- heap.globalData()->setInitializingObject(true);
+ heap.globalData()->setInitializingObjectClass(&T::s_info);
#endif
JSCell* result = 0;
if (NeedsDestructor<T>::value)
@@ -351,16 +350,29 @@ namespace JSC {
template<typename To, typename From>
inline To jsCast(From* from)
{
- ASSERT(from->inherits(&WTF::RemovePointer<To>::Type::s_info));
+ ASSERT(!from || from->JSCell::inherits(&WTF::RemovePointer<To>::Type::s_info));
return static_cast<To>(from);
}
+ template<typename To>
+ inline To jsCast(JSValue from)
+ {
+ ASSERT(from.isCell() && from.asCell()->JSCell::inherits(&WTF::RemovePointer<To>::Type::s_info));
+ return static_cast<To>(from.asCell());
+ }
+
template<typename To, typename From>
inline To jsDynamicCast(From* from)
{
return from->inherits(&WTF::RemovePointer<To>::Type::s_info) ? static_cast<To>(from) : 0;
}
+ template<typename To>
+ inline To jsDynamicCast(JSValue from)
+ {
+ return from.isCell() && from.asCell()->inherits(&WTF::RemovePointer<To>::Type::s_info) ? static_cast<To>(from.asCell()) : 0;
+ }
+
} // namespace JSC
#endif // JSCell_h