| 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 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 } | 287 } |
| 288 | 288 |
| 289 | 289 |
| 290 bool Object::HasValidElements() { | 290 bool Object::HasValidElements() { |
| 291 // Dictionary is covered under FixedArray. | 291 // Dictionary is covered under FixedArray. |
| 292 return IsFixedArray() || IsFixedDoubleArray() || IsExternalArray() || | 292 return IsFixedArray() || IsFixedDoubleArray() || IsExternalArray() || |
| 293 IsFixedTypedArrayBase(); | 293 IsFixedTypedArrayBase(); |
| 294 } | 294 } |
| 295 | 295 |
| 296 | 296 |
| 297 MaybeObject* Object::AllocateNewStorageFor(Heap* heap, | 297 Handle<Object> Object::NewStorageFor(Isolate* isolate, |
| 298 Representation representation) { | 298 Handle<Object> object, |
| 299 if (representation.IsSmi() && IsUninitialized()) { | 299 Representation representation) { |
| 300 return Smi::FromInt(0); | 300 if (representation.IsSmi() && object->IsUninitialized()) { |
| 301 return handle(Smi::FromInt(0), isolate); |
| 301 } | 302 } |
| 302 if (!representation.IsDouble()) return this; | 303 if (!representation.IsDouble()) return object; |
| 303 if (IsUninitialized()) { | 304 if (object->IsUninitialized()) { |
| 304 return heap->AllocateHeapNumber(0); | 305 return isolate->factory()->NewHeapNumber(0); |
| 305 } | 306 } |
| 306 return heap->AllocateHeapNumber(Number()); | 307 return isolate->factory()->NewHeapNumber(object->Number()); |
| 307 } | 308 } |
| 308 | 309 |
| 309 | 310 |
| 310 StringShape::StringShape(String* str) | 311 StringShape::StringShape(String* str) |
| 311 : type_(str->map()->instance_type()) { | 312 : type_(str->map()->instance_type()) { |
| 312 set_valid(); | 313 set_valid(); |
| 313 ASSERT((type_ & kIsNotStringMask) == kStringTag); | 314 ASSERT((type_ & kIsNotStringMask) == kStringTag); |
| 314 } | 315 } |
| 315 | 316 |
| 316 | 317 |
| (...skipping 1664 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1981 void JSObject::SetInternalField(int index, Smi* value) { | 1982 void JSObject::SetInternalField(int index, Smi* value) { |
| 1982 ASSERT(index < GetInternalFieldCount() && index >= 0); | 1983 ASSERT(index < GetInternalFieldCount() && index >= 0); |
| 1983 // Internal objects do follow immediately after the header, whereas in-object | 1984 // Internal objects do follow immediately after the header, whereas in-object |
| 1984 // properties are at the end of the object. Therefore there is no need | 1985 // properties are at the end of the object. Therefore there is no need |
| 1985 // to adjust the index here. | 1986 // to adjust the index here. |
| 1986 int offset = GetHeaderSize() + (kPointerSize * index); | 1987 int offset = GetHeaderSize() + (kPointerSize * index); |
| 1987 WRITE_FIELD(this, offset, value); | 1988 WRITE_FIELD(this, offset, value); |
| 1988 } | 1989 } |
| 1989 | 1990 |
| 1990 | 1991 |
| 1991 MaybeObject* JSObject::FastPropertyAt(Representation representation, | |
| 1992 int index) { | |
| 1993 Object* raw_value = RawFastPropertyAt(index); | |
| 1994 return raw_value->AllocateNewStorageFor(GetHeap(), representation); | |
| 1995 } | |
| 1996 | |
| 1997 | |
| 1998 // Access fast-case object properties at index. The use of these routines | 1992 // Access fast-case object properties at index. The use of these routines |
| 1999 // is needed to correctly distinguish between properties stored in-object and | 1993 // is needed to correctly distinguish between properties stored in-object and |
| 2000 // properties stored in the properties array. | 1994 // properties stored in the properties array. |
| 2001 Object* JSObject::RawFastPropertyAt(int index) { | 1995 Object* JSObject::RawFastPropertyAt(int index) { |
| 2002 // Adjust for the number of properties stored in the object. | 1996 // Adjust for the number of properties stored in the object. |
| 2003 index -= map()->inobject_properties(); | 1997 index -= map()->inobject_properties(); |
| 2004 if (index < 0) { | 1998 if (index < 0) { |
| 2005 int offset = map()->instance_size() + (index * kPointerSize); | 1999 int offset = map()->instance_size() + (index * kPointerSize); |
| 2006 return READ_FIELD(this, offset); | 2000 return READ_FIELD(this, offset); |
| 2007 } else { | 2001 } else { |
| (...skipping 5091 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7099 #undef READ_SHORT_FIELD | 7093 #undef READ_SHORT_FIELD |
| 7100 #undef WRITE_SHORT_FIELD | 7094 #undef WRITE_SHORT_FIELD |
| 7101 #undef READ_BYTE_FIELD | 7095 #undef READ_BYTE_FIELD |
| 7102 #undef WRITE_BYTE_FIELD | 7096 #undef WRITE_BYTE_FIELD |
| 7103 #undef NOBARRIER_READ_BYTE_FIELD | 7097 #undef NOBARRIER_READ_BYTE_FIELD |
| 7104 #undef NOBARRIER_WRITE_BYTE_FIELD | 7098 #undef NOBARRIER_WRITE_BYTE_FIELD |
| 7105 | 7099 |
| 7106 } } // namespace v8::internal | 7100 } } // namespace v8::internal |
| 7107 | 7101 |
| 7108 #endif // V8_OBJECTS_INL_H_ | 7102 #endif // V8_OBJECTS_INL_H_ |
| OLD | NEW |