OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 // | 4 // |
5 // Review notes: | 5 // Review notes: |
6 // | 6 // |
7 // - The use of macros in these inline functions may seem superfluous | 7 // - The use of macros in these inline functions may seem superfluous |
8 // but it is absolutely needed to make sure gcc generates optimal | 8 // but it is absolutely needed to make sure gcc generates optimal |
9 // code. gcc is not happy when attempting to inline too deep. | 9 // code. gcc is not happy when attempting to inline too deep. |
10 // | 10 // |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 return HAS_SMI_TAG(this); | 158 return HAS_SMI_TAG(this); |
159 } | 159 } |
160 | 160 |
161 | 161 |
162 bool Object::IsHeapObject() const { | 162 bool Object::IsHeapObject() const { |
163 return Internals::HasHeapObjectTag(this); | 163 return Internals::HasHeapObjectTag(this); |
164 } | 164 } |
165 | 165 |
166 | 166 |
167 TYPE_CHECKER(HeapNumber, HEAP_NUMBER_TYPE) | 167 TYPE_CHECKER(HeapNumber, HEAP_NUMBER_TYPE) |
| 168 TYPE_CHECKER(MutableHeapNumber, MUTABLE_HEAP_NUMBER_TYPE) |
168 TYPE_CHECKER(Symbol, SYMBOL_TYPE) | 169 TYPE_CHECKER(Symbol, SYMBOL_TYPE) |
169 | 170 |
170 | 171 |
171 bool Object::IsString() const { | 172 bool Object::IsString() const { |
172 return Object::IsHeapObject() | 173 return Object::IsHeapObject() |
173 && HeapObject::cast(this)->map()->instance_type() < FIRST_NONSTRING_TYPE; | 174 && HeapObject::cast(this)->map()->instance_type() < FIRST_NONSTRING_TYPE; |
174 } | 175 } |
175 | 176 |
176 | 177 |
177 bool Object::IsName() const { | 178 bool Object::IsName() const { |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 } | 271 } |
271 | 272 |
272 | 273 |
273 Handle<Object> Object::NewStorageFor(Isolate* isolate, | 274 Handle<Object> Object::NewStorageFor(Isolate* isolate, |
274 Handle<Object> object, | 275 Handle<Object> object, |
275 Representation representation) { | 276 Representation representation) { |
276 if (representation.IsSmi() && object->IsUninitialized()) { | 277 if (representation.IsSmi() && object->IsUninitialized()) { |
277 return handle(Smi::FromInt(0), isolate); | 278 return handle(Smi::FromInt(0), isolate); |
278 } | 279 } |
279 if (!representation.IsDouble()) return object; | 280 if (!representation.IsDouble()) return object; |
| 281 double value; |
280 if (object->IsUninitialized()) { | 282 if (object->IsUninitialized()) { |
281 return isolate->factory()->NewHeapNumber(0); | 283 value = 0; |
| 284 } else if (object->IsMutableHeapNumber()) { |
| 285 value = HeapNumber::cast(*object)->value(); |
| 286 } else { |
| 287 value = object->Number(); |
282 } | 288 } |
283 return isolate->factory()->NewHeapNumber(object->Number()); | 289 return isolate->factory()->NewHeapNumber(value, MUTABLE); |
284 } | 290 } |
285 | 291 |
286 | 292 |
| 293 Handle<Object> Object::WrapForRead(Isolate* isolate, |
| 294 Handle<Object> object, |
| 295 Representation representation) { |
| 296 ASSERT(!object->IsUninitialized()); |
| 297 if (!representation.IsDouble()) { |
| 298 ASSERT(object->FitsRepresentation(representation)); |
| 299 return object; |
| 300 } |
| 301 return isolate->factory()->NewHeapNumber(HeapNumber::cast(*object)->value()); |
| 302 } |
| 303 |
| 304 |
287 StringShape::StringShape(const String* str) | 305 StringShape::StringShape(const String* str) |
288 : type_(str->map()->instance_type()) { | 306 : type_(str->map()->instance_type()) { |
289 set_valid(); | 307 set_valid(); |
290 ASSERT((type_ & kIsNotStringMask) == kStringTag); | 308 ASSERT((type_ & kIsNotStringMask) == kStringTag); |
291 } | 309 } |
292 | 310 |
293 | 311 |
294 StringShape::StringShape(Map* map) | 312 StringShape::StringShape(Map* map) |
295 : type_(map->instance_type()) { | 313 : type_(map->instance_type()) { |
296 set_valid(); | 314 set_valid(); |
(...skipping 2775 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3072 CAST_ACCESSOR(ExternalUint32Array) | 3090 CAST_ACCESSOR(ExternalUint32Array) |
3073 CAST_ACCESSOR(ExternalUint8Array) | 3091 CAST_ACCESSOR(ExternalUint8Array) |
3074 CAST_ACCESSOR(ExternalUint8ClampedArray) | 3092 CAST_ACCESSOR(ExternalUint8ClampedArray) |
3075 CAST_ACCESSOR(FixedArray) | 3093 CAST_ACCESSOR(FixedArray) |
3076 CAST_ACCESSOR(FixedArrayBase) | 3094 CAST_ACCESSOR(FixedArrayBase) |
3077 CAST_ACCESSOR(FixedDoubleArray) | 3095 CAST_ACCESSOR(FixedDoubleArray) |
3078 CAST_ACCESSOR(FixedTypedArrayBase) | 3096 CAST_ACCESSOR(FixedTypedArrayBase) |
3079 CAST_ACCESSOR(Foreign) | 3097 CAST_ACCESSOR(Foreign) |
3080 CAST_ACCESSOR(FreeSpace) | 3098 CAST_ACCESSOR(FreeSpace) |
3081 CAST_ACCESSOR(GlobalObject) | 3099 CAST_ACCESSOR(GlobalObject) |
3082 CAST_ACCESSOR(HeapNumber) | |
3083 CAST_ACCESSOR(HeapObject) | 3100 CAST_ACCESSOR(HeapObject) |
3084 CAST_ACCESSOR(JSArray) | 3101 CAST_ACCESSOR(JSArray) |
3085 CAST_ACCESSOR(JSArrayBuffer) | 3102 CAST_ACCESSOR(JSArrayBuffer) |
3086 CAST_ACCESSOR(JSArrayBufferView) | 3103 CAST_ACCESSOR(JSArrayBufferView) |
3087 CAST_ACCESSOR(JSBuiltinsObject) | 3104 CAST_ACCESSOR(JSBuiltinsObject) |
3088 CAST_ACCESSOR(JSDataView) | 3105 CAST_ACCESSOR(JSDataView) |
3089 CAST_ACCESSOR(JSDate) | 3106 CAST_ACCESSOR(JSDate) |
3090 CAST_ACCESSOR(JSFunction) | 3107 CAST_ACCESSOR(JSFunction) |
3091 CAST_ACCESSOR(JSFunctionProxy) | 3108 CAST_ACCESSOR(JSFunctionProxy) |
3092 CAST_ACCESSOR(JSFunctionResultCache) | 3109 CAST_ACCESSOR(JSFunctionResultCache) |
(...skipping 2844 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5937 return continuation() == kGeneratorExecuting; | 5954 return continuation() == kGeneratorExecuting; |
5938 } | 5955 } |
5939 | 5956 |
5940 ACCESSORS(JSModule, context, Object, kContextOffset) | 5957 ACCESSORS(JSModule, context, Object, kContextOffset) |
5941 ACCESSORS(JSModule, scope_info, ScopeInfo, kScopeInfoOffset) | 5958 ACCESSORS(JSModule, scope_info, ScopeInfo, kScopeInfoOffset) |
5942 | 5959 |
5943 | 5960 |
5944 ACCESSORS(JSValue, value, Object, kValueOffset) | 5961 ACCESSORS(JSValue, value, Object, kValueOffset) |
5945 | 5962 |
5946 | 5963 |
| 5964 HeapNumber* HeapNumber::cast(Object* object) { |
| 5965 SLOW_ASSERT(object->IsHeapNumber() || object->IsMutableHeapNumber()); |
| 5966 return reinterpret_cast<HeapNumber*>(object); |
| 5967 } |
| 5968 |
| 5969 |
| 5970 const HeapNumber* HeapNumber::cast(const Object* object) { |
| 5971 SLOW_ASSERT(object->IsHeapNumber() || object->IsMutableHeapNumber()); |
| 5972 return reinterpret_cast<const HeapNumber*>(object); |
| 5973 } |
| 5974 |
| 5975 |
5947 ACCESSORS(JSDate, value, Object, kValueOffset) | 5976 ACCESSORS(JSDate, value, Object, kValueOffset) |
5948 ACCESSORS(JSDate, cache_stamp, Object, kCacheStampOffset) | 5977 ACCESSORS(JSDate, cache_stamp, Object, kCacheStampOffset) |
5949 ACCESSORS(JSDate, year, Object, kYearOffset) | 5978 ACCESSORS(JSDate, year, Object, kYearOffset) |
5950 ACCESSORS(JSDate, month, Object, kMonthOffset) | 5979 ACCESSORS(JSDate, month, Object, kMonthOffset) |
5951 ACCESSORS(JSDate, day, Object, kDayOffset) | 5980 ACCESSORS(JSDate, day, Object, kDayOffset) |
5952 ACCESSORS(JSDate, weekday, Object, kWeekdayOffset) | 5981 ACCESSORS(JSDate, weekday, Object, kWeekdayOffset) |
5953 ACCESSORS(JSDate, hour, Object, kHourOffset) | 5982 ACCESSORS(JSDate, hour, Object, kHourOffset) |
5954 ACCESSORS(JSDate, min, Object, kMinOffset) | 5983 ACCESSORS(JSDate, min, Object, kMinOffset) |
5955 ACCESSORS(JSDate, sec, Object, kSecOffset) | 5984 ACCESSORS(JSDate, sec, Object, kSecOffset) |
5956 | 5985 |
(...skipping 1065 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7022 #undef READ_SHORT_FIELD | 7051 #undef READ_SHORT_FIELD |
7023 #undef WRITE_SHORT_FIELD | 7052 #undef WRITE_SHORT_FIELD |
7024 #undef READ_BYTE_FIELD | 7053 #undef READ_BYTE_FIELD |
7025 #undef WRITE_BYTE_FIELD | 7054 #undef WRITE_BYTE_FIELD |
7026 #undef NOBARRIER_READ_BYTE_FIELD | 7055 #undef NOBARRIER_READ_BYTE_FIELD |
7027 #undef NOBARRIER_WRITE_BYTE_FIELD | 7056 #undef NOBARRIER_WRITE_BYTE_FIELD |
7028 | 7057 |
7029 } } // namespace v8::internal | 7058 } } // namespace v8::internal |
7030 | 7059 |
7031 #endif // V8_OBJECTS_INL_H_ | 7060 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |