Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(514)

Unified Diff: src/objects-inl.h

Issue 355793003: Replace HeapNumber as doublebox with an explicit MutableHeapNumber. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/objects-debug.cc ('k') | src/objects-printer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects-inl.h
diff --git a/src/objects-inl.h b/src/objects-inl.h
index 16d0acd6e3caf045cb3bc470b71f7b3b841b18fa..d600b4ec25103c250d527f6914fc91895f380543 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)
« no previous file with comments | « src/objects-debug.cc ('k') | src/objects-printer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698