OLD | NEW |
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 Loading... |
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 Loading... |
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()) { |
| 290 value = HeapNumber::cast(this)->value(); |
| 291 } else { |
| 292 value = Number(); |
287 } | 293 } |
288 return heap->AllocateHeapNumber(Number()); | 294 return heap->AllocateHeapNumber(value, MUTABLE); |
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()); |
| 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 1645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1947 // properties are at the end of the object. Therefore there is no need | 1964 // properties are at the end of the object. Therefore there is no need |
1948 // to adjust the index here. | 1965 // to adjust the index here. |
1949 int offset = GetHeaderSize() + (kPointerSize * index); | 1966 int offset = GetHeaderSize() + (kPointerSize * index); |
1950 WRITE_FIELD(this, offset, value); | 1967 WRITE_FIELD(this, offset, value); |
1951 } | 1968 } |
1952 | 1969 |
1953 | 1970 |
1954 MaybeObject* JSObject::FastPropertyAt(Representation representation, | 1971 MaybeObject* JSObject::FastPropertyAt(Representation representation, |
1955 int index) { | 1972 int index) { |
1956 Object* raw_value = RawFastPropertyAt(index); | 1973 Object* raw_value = RawFastPropertyAt(index); |
1957 return raw_value->AllocateNewStorageFor(GetHeap(), representation); | 1974 return raw_value->WrapForRead(GetHeap(), representation); |
1958 } | 1975 } |
1959 | 1976 |
1960 | 1977 |
1961 // Access fast-case object properties at index. The use of these routines | 1978 // Access fast-case object properties at index. The use of these routines |
1962 // is needed to correctly distinguish between properties stored in-object and | 1979 // is needed to correctly distinguish between properties stored in-object and |
1963 // properties stored in the properties array. | 1980 // properties stored in the properties array. |
1964 Object* JSObject::RawFastPropertyAt(int index) { | 1981 Object* JSObject::RawFastPropertyAt(int index) { |
1965 // Adjust for the number of properties stored in the object. | 1982 // Adjust for the number of properties stored in the object. |
1966 index -= map()->inobject_properties(); | 1983 index -= map()->inobject_properties(); |
1967 if (index < 0) { | 1984 if (index < 0) { |
(...skipping 910 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2878 CAST_ACCESSOR(ConsString) | 2895 CAST_ACCESSOR(ConsString) |
2879 CAST_ACCESSOR(ExternalString) | 2896 CAST_ACCESSOR(ExternalString) |
2880 CAST_ACCESSOR(ExternalAsciiString) | 2897 CAST_ACCESSOR(ExternalAsciiString) |
2881 CAST_ACCESSOR(ExternalTwoByteString) | 2898 CAST_ACCESSOR(ExternalTwoByteString) |
2882 CAST_ACCESSOR(Symbol) | 2899 CAST_ACCESSOR(Symbol) |
2883 CAST_ACCESSOR(Name) | 2900 CAST_ACCESSOR(Name) |
2884 CAST_ACCESSOR(JSReceiver) | 2901 CAST_ACCESSOR(JSReceiver) |
2885 CAST_ACCESSOR(JSObject) | 2902 CAST_ACCESSOR(JSObject) |
2886 CAST_ACCESSOR(Smi) | 2903 CAST_ACCESSOR(Smi) |
2887 CAST_ACCESSOR(HeapObject) | 2904 CAST_ACCESSOR(HeapObject) |
2888 CAST_ACCESSOR(HeapNumber) | |
2889 CAST_ACCESSOR(Oddball) | 2905 CAST_ACCESSOR(Oddball) |
2890 CAST_ACCESSOR(Cell) | 2906 CAST_ACCESSOR(Cell) |
2891 CAST_ACCESSOR(PropertyCell) | 2907 CAST_ACCESSOR(PropertyCell) |
2892 CAST_ACCESSOR(SharedFunctionInfo) | 2908 CAST_ACCESSOR(SharedFunctionInfo) |
2893 CAST_ACCESSOR(Map) | 2909 CAST_ACCESSOR(Map) |
2894 CAST_ACCESSOR(JSFunction) | 2910 CAST_ACCESSOR(JSFunction) |
2895 CAST_ACCESSOR(GlobalObject) | 2911 CAST_ACCESSOR(GlobalObject) |
2896 CAST_ACCESSOR(JSGlobalProxy) | 2912 CAST_ACCESSOR(JSGlobalProxy) |
2897 CAST_ACCESSOR(JSGlobalObject) | 2913 CAST_ACCESSOR(JSGlobalObject) |
2898 CAST_ACCESSOR(JSBuiltinsObject) | 2914 CAST_ACCESSOR(JSBuiltinsObject) |
(...skipping 2870 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5769 ACCESSORS(JSValue, value, Object, kValueOffset) | 5785 ACCESSORS(JSValue, value, Object, kValueOffset) |
5770 | 5786 |
5771 | 5787 |
5772 JSValue* JSValue::cast(Object* obj) { | 5788 JSValue* JSValue::cast(Object* obj) { |
5773 ASSERT(obj->IsJSValue()); | 5789 ASSERT(obj->IsJSValue()); |
5774 ASSERT(HeapObject::cast(obj)->Size() == JSValue::kSize); | 5790 ASSERT(HeapObject::cast(obj)->Size() == JSValue::kSize); |
5775 return reinterpret_cast<JSValue*>(obj); | 5791 return reinterpret_cast<JSValue*>(obj); |
5776 } | 5792 } |
5777 | 5793 |
5778 | 5794 |
| 5795 HeapNumber* HeapNumber::cast(Object* object) { |
| 5796 SLOW_ASSERT(object->IsHeapNumber() || object->IsMutableHeapNumber()); |
| 5797 return reinterpret_cast<HeapNumber*>(object); |
| 5798 } |
| 5799 |
| 5800 |
5779 ACCESSORS(JSDate, value, Object, kValueOffset) | 5801 ACCESSORS(JSDate, value, Object, kValueOffset) |
5780 ACCESSORS(JSDate, cache_stamp, Object, kCacheStampOffset) | 5802 ACCESSORS(JSDate, cache_stamp, Object, kCacheStampOffset) |
5781 ACCESSORS(JSDate, year, Object, kYearOffset) | 5803 ACCESSORS(JSDate, year, Object, kYearOffset) |
5782 ACCESSORS(JSDate, month, Object, kMonthOffset) | 5804 ACCESSORS(JSDate, month, Object, kMonthOffset) |
5783 ACCESSORS(JSDate, day, Object, kDayOffset) | 5805 ACCESSORS(JSDate, day, Object, kDayOffset) |
5784 ACCESSORS(JSDate, weekday, Object, kWeekdayOffset) | 5806 ACCESSORS(JSDate, weekday, Object, kWeekdayOffset) |
5785 ACCESSORS(JSDate, hour, Object, kHourOffset) | 5807 ACCESSORS(JSDate, hour, Object, kHourOffset) |
5786 ACCESSORS(JSDate, min, Object, kMinOffset) | 5808 ACCESSORS(JSDate, min, Object, kMinOffset) |
5787 ACCESSORS(JSDate, sec, Object, kSecOffset) | 5809 ACCESSORS(JSDate, sec, Object, kSecOffset) |
5788 | 5810 |
(...skipping 1104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6893 #undef READ_UINT32_FIELD | 6915 #undef READ_UINT32_FIELD |
6894 #undef WRITE_UINT32_FIELD | 6916 #undef WRITE_UINT32_FIELD |
6895 #undef READ_SHORT_FIELD | 6917 #undef READ_SHORT_FIELD |
6896 #undef WRITE_SHORT_FIELD | 6918 #undef WRITE_SHORT_FIELD |
6897 #undef READ_BYTE_FIELD | 6919 #undef READ_BYTE_FIELD |
6898 #undef WRITE_BYTE_FIELD | 6920 #undef WRITE_BYTE_FIELD |
6899 | 6921 |
6900 } } // namespace v8::internal | 6922 } } // namespace v8::internal |
6901 | 6923 |
6902 #endif // V8_OBJECTS_INL_H_ | 6924 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |