Index: src/objects-inl.h |
diff --git a/src/objects-inl.h b/src/objects-inl.h |
index 3a2fe939a22da26b3618b51dad9f5f8195917d61..d69d71f17125e8c9b320fbe48c3e5bdf66492833 100644 |
--- a/src/objects-inl.h |
+++ b/src/objects-inl.h |
@@ -165,6 +165,7 @@ bool Object::IsHeapObject() const { |
TYPE_CHECKER(HeapNumber, HEAP_NUMBER_TYPE) |
+TYPE_CHECKER(MutableHeapNumber, MUTABLE_HEAP_NUMBER_TYPE) |
TYPE_CHECKER(Symbol, SYMBOL_TYPE) |
@@ -277,10 +278,27 @@ Handle<Object> Object::NewStorageFor(Isolate* isolate, |
return handle(Smi::FromInt(0), isolate); |
} |
if (!representation.IsDouble()) return object; |
+ double value; |
if (object->IsUninitialized()) { |
- return isolate->factory()->NewHeapNumber(0); |
+ value = 0; |
+ } else if (object->IsMutableHeapNumber()) { |
+ value = HeapNumber::cast(*object)->value(); |
+ } else { |
+ value = object->Number(); |
+ } |
+ return isolate->factory()->NewHeapNumber(value, MUTABLE); |
+} |
+ |
+ |
+Handle<Object> Object::WrapForRead(Isolate* isolate, |
+ Handle<Object> object, |
+ Representation representation) { |
+ ASSERT(!object->IsUninitialized()); |
+ if (!representation.IsDouble()) { |
+ ASSERT(object->FitsRepresentation(representation)); |
+ return object; |
} |
- return isolate->factory()->NewHeapNumber(object->Number()); |
+ return isolate->factory()->NewHeapNumber(HeapNumber::cast(*object)->value()); |
} |
@@ -3079,7 +3097,6 @@ CAST_ACCESSOR(FixedTypedArrayBase) |
CAST_ACCESSOR(Foreign) |
CAST_ACCESSOR(FreeSpace) |
CAST_ACCESSOR(GlobalObject) |
-CAST_ACCESSOR(HeapNumber) |
CAST_ACCESSOR(HeapObject) |
CAST_ACCESSOR(JSArray) |
CAST_ACCESSOR(JSArrayBuffer) |
@@ -5944,6 +5961,18 @@ ACCESSORS(JSModule, scope_info, ScopeInfo, kScopeInfoOffset) |
ACCESSORS(JSValue, value, Object, kValueOffset) |
+HeapNumber* HeapNumber::cast(Object* object) { |
+ SLOW_ASSERT(object->IsHeapNumber() || object->IsMutableHeapNumber()); |
+ return reinterpret_cast<HeapNumber*>(object); |
+} |
+ |
+ |
+const HeapNumber* HeapNumber::cast(const Object* object) { |
+ SLOW_ASSERT(object->IsHeapNumber() || object->IsMutableHeapNumber()); |
+ return reinterpret_cast<const HeapNumber*>(object); |
+} |
+ |
+ |
ACCESSORS(JSDate, value, Object, kValueOffset) |
ACCESSORS(JSDate, cache_stamp, Object, kCacheStampOffset) |
ACCESSORS(JSDate, year, Object, kYearOffset) |