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

Side by Side Diff: src/objects-inl.h

Issue 211333002: Replace HeapNumber as doublebox with an explicit MutableHeapNumber. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 } 170 }
171 171
172 172
173 bool Object::NonFailureIsHeapObject() { 173 bool Object::NonFailureIsHeapObject() {
174 ASSERT(!this->IsFailure()); 174 ASSERT(!this->IsFailure());
175 return (reinterpret_cast<intptr_t>(this) & kSmiTagMask) != 0; 175 return (reinterpret_cast<intptr_t>(this) & kSmiTagMask) != 0;
176 } 176 }
177 177
178 178
179 TYPE_CHECKER(HeapNumber, HEAP_NUMBER_TYPE) 179 TYPE_CHECKER(HeapNumber, HEAP_NUMBER_TYPE)
180 TYPE_CHECKER(MutableHeapNumber, MUTABLE_HEAP_NUMBER_TYPE)
180 TYPE_CHECKER(Symbol, SYMBOL_TYPE) 181 TYPE_CHECKER(Symbol, SYMBOL_TYPE)
181 182
182 183
183 bool Object::IsString() { 184 bool Object::IsString() {
184 return Object::IsHeapObject() 185 return Object::IsHeapObject()
185 && HeapObject::cast(this)->map()->instance_type() < FIRST_NONSTRING_TYPE; 186 && HeapObject::cast(this)->map()->instance_type() < FIRST_NONSTRING_TYPE;
186 } 187 }
187 188
188 189
189 bool Object::IsName() { 190 bool Object::IsName() {
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 IsFixedTypedArrayBase(); 276 IsFixedTypedArrayBase();
276 } 277 }
277 278
278 279
279 MaybeObject* Object::AllocateNewStorageFor(Heap* heap, 280 MaybeObject* Object::AllocateNewStorageFor(Heap* heap,
280 Representation representation) { 281 Representation representation) {
281 if (representation.IsSmi() && IsUninitialized()) { 282 if (representation.IsSmi() && IsUninitialized()) {
282 return Smi::FromInt(0); 283 return Smi::FromInt(0);
283 } 284 }
284 if (!representation.IsDouble()) return this; 285 if (!representation.IsDouble()) return this;
286 double value;
285 if (IsUninitialized()) { 287 if (IsUninitialized()) {
286 return heap->AllocateHeapNumber(0); 288 value = 0;
289 } else if (IsMutableHeapNumber()) {
Igor Sheludko 2014/03/27 11:30:16 If you extend IsNumber() to return true for mutabl
290 value = HeapNumber::cast(this)->value();
291 } else {
292 value = Number();
287 } 293 }
288 return heap->AllocateHeapNumber(Number()); 294 return heap->AllocateMutableHeapNumber(value);
289 } 295 }
290 296
291 297
298 MaybeObject* Object::WrapForRead(Heap* heap,
299 Representation representation) {
300 ASSERT(!IsUninitialized());
301 if (!representation.IsDouble()) {
302 ASSERT(FitsRepresentation(representation));
303 return this;
304 }
305 return heap->AllocateHeapNumber(HeapNumber::cast(this)->value());
Igor Sheludko 2014/03/27 11:30:16 Same here: use Number().
306 }
307
308
292 StringShape::StringShape(String* str) 309 StringShape::StringShape(String* str)
293 : type_(str->map()->instance_type()) { 310 : type_(str->map()->instance_type()) {
294 set_valid(); 311 set_valid();
295 ASSERT((type_ & kIsNotStringMask) == kStringTag); 312 ASSERT((type_ & kIsNotStringMask) == kStringTag);
296 } 313 }
297 314
298 315
299 StringShape::StringShape(Map* map) 316 StringShape::StringShape(Map* map)
300 : type_(map->instance_type()) { 317 : type_(map->instance_type()) {
301 set_valid(); 318 set_valid();
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 } 605 }
589 606
590 Vector<const char> string_; 607 Vector<const char> string_;
591 uint32_t hash_field_; 608 uint32_t hash_field_;
592 int chars_; // Caches the number of characters when computing the hash code. 609 int chars_; // Caches the number of characters when computing the hash code.
593 uint32_t seed_; 610 uint32_t seed_;
594 }; 611 };
595 612
596 613
597 bool Object::IsNumber() { 614 bool Object::IsNumber() {
598 return IsSmi() || IsHeapNumber(); 615 return IsSmi() || IsHeapNumber();
Igor Sheludko 2014/03/27 11:30:16 || IsMutableHeapNumber() ?
599 } 616 }
600 617
601 618
602 TYPE_CHECKER(ByteArray, BYTE_ARRAY_TYPE) 619 TYPE_CHECKER(ByteArray, BYTE_ARRAY_TYPE)
603 TYPE_CHECKER(FreeSpace, FREE_SPACE_TYPE) 620 TYPE_CHECKER(FreeSpace, FREE_SPACE_TYPE)
604 621
605 622
606 bool Object::IsFiller() { 623 bool Object::IsFiller() {
607 if (!Object::IsHeapObject()) return false; 624 if (!Object::IsHeapObject()) return false;
608 InstanceType instance_type = HeapObject::cast(this)->map()->instance_type(); 625 InstanceType instance_type = HeapObject::cast(this)->map()->instance_type();
(...skipping 1328 matching lines...) Expand 10 before | Expand all | Expand 10 after
1937 // properties are at the end of the object. Therefore there is no need 1954 // properties are at the end of the object. Therefore there is no need
1938 // to adjust the index here. 1955 // to adjust the index here.
1939 int offset = GetHeaderSize() + (kPointerSize * index); 1956 int offset = GetHeaderSize() + (kPointerSize * index);
1940 WRITE_FIELD(this, offset, value); 1957 WRITE_FIELD(this, offset, value);
1941 } 1958 }
1942 1959
1943 1960
1944 MaybeObject* JSObject::FastPropertyAt(Representation representation, 1961 MaybeObject* JSObject::FastPropertyAt(Representation representation,
1945 int index) { 1962 int index) {
1946 Object* raw_value = RawFastPropertyAt(index); 1963 Object* raw_value = RawFastPropertyAt(index);
1947 return raw_value->AllocateNewStorageFor(GetHeap(), representation); 1964 return raw_value->WrapForRead(GetHeap(), representation);
Igor Sheludko 2014/03/27 11:30:16 Shouldn't we also repack mutable heap number to im
1948 } 1965 }
1949 1966
1950 1967
1951 // Access fast-case object properties at index. The use of these routines 1968 // Access fast-case object properties at index. The use of these routines
1952 // is needed to correctly distinguish between properties stored in-object and 1969 // is needed to correctly distinguish between properties stored in-object and
1953 // properties stored in the properties array. 1970 // properties stored in the properties array.
1954 Object* JSObject::RawFastPropertyAt(int index) { 1971 Object* JSObject::RawFastPropertyAt(int index) {
1955 // Adjust for the number of properties stored in the object. 1972 // Adjust for the number of properties stored in the object.
1956 index -= map()->inobject_properties(); 1973 index -= map()->inobject_properties();
1957 if (index < 0) { 1974 if (index < 0) {
(...skipping 887 matching lines...) Expand 10 before | Expand all | Expand 10 after
2845 CAST_ACCESSOR(ConsString) 2862 CAST_ACCESSOR(ConsString)
2846 CAST_ACCESSOR(ExternalString) 2863 CAST_ACCESSOR(ExternalString)
2847 CAST_ACCESSOR(ExternalAsciiString) 2864 CAST_ACCESSOR(ExternalAsciiString)
2848 CAST_ACCESSOR(ExternalTwoByteString) 2865 CAST_ACCESSOR(ExternalTwoByteString)
2849 CAST_ACCESSOR(Symbol) 2866 CAST_ACCESSOR(Symbol)
2850 CAST_ACCESSOR(Name) 2867 CAST_ACCESSOR(Name)
2851 CAST_ACCESSOR(JSReceiver) 2868 CAST_ACCESSOR(JSReceiver)
2852 CAST_ACCESSOR(JSObject) 2869 CAST_ACCESSOR(JSObject)
2853 CAST_ACCESSOR(Smi) 2870 CAST_ACCESSOR(Smi)
2854 CAST_ACCESSOR(HeapObject) 2871 CAST_ACCESSOR(HeapObject)
2855 CAST_ACCESSOR(HeapNumber)
2856 CAST_ACCESSOR(Oddball) 2872 CAST_ACCESSOR(Oddball)
2857 CAST_ACCESSOR(Cell) 2873 CAST_ACCESSOR(Cell)
2858 CAST_ACCESSOR(PropertyCell) 2874 CAST_ACCESSOR(PropertyCell)
2859 CAST_ACCESSOR(SharedFunctionInfo) 2875 CAST_ACCESSOR(SharedFunctionInfo)
2860 CAST_ACCESSOR(Map) 2876 CAST_ACCESSOR(Map)
2861 CAST_ACCESSOR(JSFunction) 2877 CAST_ACCESSOR(JSFunction)
2862 CAST_ACCESSOR(GlobalObject) 2878 CAST_ACCESSOR(GlobalObject)
2863 CAST_ACCESSOR(JSGlobalProxy) 2879 CAST_ACCESSOR(JSGlobalProxy)
2864 CAST_ACCESSOR(JSGlobalObject) 2880 CAST_ACCESSOR(JSGlobalObject)
2865 CAST_ACCESSOR(JSBuiltinsObject) 2881 CAST_ACCESSOR(JSBuiltinsObject)
(...skipping 2800 matching lines...) Expand 10 before | Expand all | Expand 10 after
5666 ACCESSORS(JSValue, value, Object, kValueOffset) 5682 ACCESSORS(JSValue, value, Object, kValueOffset)
5667 5683
5668 5684
5669 JSValue* JSValue::cast(Object* obj) { 5685 JSValue* JSValue::cast(Object* obj) {
5670 ASSERT(obj->IsJSValue()); 5686 ASSERT(obj->IsJSValue());
5671 ASSERT(HeapObject::cast(obj)->Size() == JSValue::kSize); 5687 ASSERT(HeapObject::cast(obj)->Size() == JSValue::kSize);
5672 return reinterpret_cast<JSValue*>(obj); 5688 return reinterpret_cast<JSValue*>(obj);
5673 } 5689 }
5674 5690
5675 5691
5692 HeapNumber* HeapNumber::cast(Object* object) {
5693 SLOW_ASSERT(object->IsHeapNumber() || object->IsMutableHeapNumber());
5694 return reinterpret_cast<HeapNumber*>(object);
5695 }
5696
5697
5676 ACCESSORS(JSDate, value, Object, kValueOffset) 5698 ACCESSORS(JSDate, value, Object, kValueOffset)
5677 ACCESSORS(JSDate, cache_stamp, Object, kCacheStampOffset) 5699 ACCESSORS(JSDate, cache_stamp, Object, kCacheStampOffset)
5678 ACCESSORS(JSDate, year, Object, kYearOffset) 5700 ACCESSORS(JSDate, year, Object, kYearOffset)
5679 ACCESSORS(JSDate, month, Object, kMonthOffset) 5701 ACCESSORS(JSDate, month, Object, kMonthOffset)
5680 ACCESSORS(JSDate, day, Object, kDayOffset) 5702 ACCESSORS(JSDate, day, Object, kDayOffset)
5681 ACCESSORS(JSDate, weekday, Object, kWeekdayOffset) 5703 ACCESSORS(JSDate, weekday, Object, kWeekdayOffset)
5682 ACCESSORS(JSDate, hour, Object, kHourOffset) 5704 ACCESSORS(JSDate, hour, Object, kHourOffset)
5683 ACCESSORS(JSDate, min, Object, kMinOffset) 5705 ACCESSORS(JSDate, min, Object, kMinOffset)
5684 ACCESSORS(JSDate, sec, Object, kSecOffset) 5706 ACCESSORS(JSDate, sec, Object, kSecOffset)
5685 5707
(...skipping 1103 matching lines...) Expand 10 before | Expand all | Expand 10 after
6789 #undef READ_UINT32_FIELD 6811 #undef READ_UINT32_FIELD
6790 #undef WRITE_UINT32_FIELD 6812 #undef WRITE_UINT32_FIELD
6791 #undef READ_SHORT_FIELD 6813 #undef READ_SHORT_FIELD
6792 #undef WRITE_SHORT_FIELD 6814 #undef WRITE_SHORT_FIELD
6793 #undef READ_BYTE_FIELD 6815 #undef READ_BYTE_FIELD
6794 #undef WRITE_BYTE_FIELD 6816 #undef WRITE_BYTE_FIELD
6795 6817
6796 } } // namespace v8::internal 6818 } } // namespace v8::internal
6797 6819
6798 #endif // V8_OBJECTS_INL_H_ 6820 #endif // V8_OBJECTS_INL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698