| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 2042 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2053 return ptr[index]; | 2053 return ptr[index]; |
| 2054 } | 2054 } |
| 2055 | 2055 |
| 2056 | 2056 |
| 2057 void ExternalFloatArray::set(int index, float value) { | 2057 void ExternalFloatArray::set(int index, float value) { |
| 2058 ASSERT((index >= 0) && (index < this->length())); | 2058 ASSERT((index >= 0) && (index < this->length())); |
| 2059 float* ptr = static_cast<float*>(external_pointer()); | 2059 float* ptr = static_cast<float*>(external_pointer()); |
| 2060 ptr[index] = value; | 2060 ptr[index] = value; |
| 2061 } | 2061 } |
| 2062 | 2062 |
| 2063 inline Scavenger Map::scavenger() { | |
| 2064 Scavenger callback = reinterpret_cast<Scavenger>( | |
| 2065 READ_INTPTR_FIELD(this, kScavengerCallbackOffset)); | |
| 2066 | 2063 |
| 2067 ASSERT(callback == Heap::GetScavenger(instance_type(), | 2064 INT_ACCESSORS(Map, visitor_id, kScavengerCallbackOffset) |
| 2068 instance_size())); | |
| 2069 | |
| 2070 return callback; | |
| 2071 } | |
| 2072 | |
| 2073 inline void Map::set_scavenger(Scavenger callback) { | |
| 2074 WRITE_INTPTR_FIELD(this, | |
| 2075 kScavengerCallbackOffset, | |
| 2076 reinterpret_cast<intptr_t>(callback)); | |
| 2077 } | |
| 2078 | 2065 |
| 2079 int Map::instance_size() { | 2066 int Map::instance_size() { |
| 2080 return READ_BYTE_FIELD(this, kInstanceSizeOffset) << kPointerSizeLog2; | 2067 return READ_BYTE_FIELD(this, kInstanceSizeOffset) << kPointerSizeLog2; |
| 2081 } | 2068 } |
| 2082 | 2069 |
| 2083 | 2070 |
| 2084 int Map::inobject_properties() { | 2071 int Map::inobject_properties() { |
| 2085 return READ_BYTE_FIELD(this, kInObjectPropertiesOffset); | 2072 return READ_BYTE_FIELD(this, kInObjectPropertiesOffset); |
| 2086 } | 2073 } |
| 2087 | 2074 |
| 2088 | 2075 |
| 2089 int Map::pre_allocated_property_fields() { | 2076 int Map::pre_allocated_property_fields() { |
| 2090 return READ_BYTE_FIELD(this, kPreAllocatedPropertyFieldsOffset); | 2077 return READ_BYTE_FIELD(this, kPreAllocatedPropertyFieldsOffset); |
| 2091 } | 2078 } |
| 2092 | 2079 |
| 2093 | 2080 |
| 2094 int HeapObject::SizeFromMap(Map* map) { | 2081 int HeapObject::SizeFromMap(Map* map) { |
| 2095 InstanceType instance_type = map->instance_type(); | 2082 InstanceType instance_type = map->instance_type(); |
| 2096 // Only inline the most frequent cases. | 2083 // Only inline the most frequent cases. |
| 2097 if (instance_type == JS_OBJECT_TYPE || | 2084 if (instance_type == JS_OBJECT_TYPE || |
| 2098 (instance_type & (kIsNotStringMask | kStringRepresentationMask)) == | 2085 (instance_type & (kIsNotStringMask | kStringRepresentationMask)) == |
| 2099 (kStringTag | kConsStringTag) || | 2086 (kStringTag | kConsStringTag) || |
| 2100 instance_type == JS_ARRAY_TYPE) return map->instance_size(); | 2087 instance_type == JS_ARRAY_TYPE) return map->instance_size(); |
| 2101 if (instance_type == FIXED_ARRAY_TYPE) { | 2088 if (instance_type == FIXED_ARRAY_TYPE) { |
| 2102 return reinterpret_cast<FixedArray*>(this)->FixedArraySize(); | 2089 return FixedArray::BodyDescriptor::SizeOf(map, this); |
| 2103 } | 2090 } |
| 2104 if (instance_type == BYTE_ARRAY_TYPE) { | 2091 if (instance_type == BYTE_ARRAY_TYPE) { |
| 2105 return reinterpret_cast<ByteArray*>(this)->ByteArraySize(); | 2092 return reinterpret_cast<ByteArray*>(this)->ByteArraySize(); |
| 2106 } | 2093 } |
| 2107 // Otherwise do the general size computation. | 2094 // Otherwise do the general size computation. |
| 2108 return SlowSizeFromMap(map); | 2095 return SlowSizeFromMap(map); |
| 2109 } | 2096 } |
| 2110 | 2097 |
| 2111 | 2098 |
| 2112 void Map::set_instance_size(int value) { | 2099 void Map::set_instance_size(int value) { |
| (...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2811 Address Proxy::proxy() { | 2798 Address Proxy::proxy() { |
| 2812 return AddressFrom<Address>(READ_INTPTR_FIELD(this, kProxyOffset)); | 2799 return AddressFrom<Address>(READ_INTPTR_FIELD(this, kProxyOffset)); |
| 2813 } | 2800 } |
| 2814 | 2801 |
| 2815 | 2802 |
| 2816 void Proxy::set_proxy(Address value) { | 2803 void Proxy::set_proxy(Address value) { |
| 2817 WRITE_INTPTR_FIELD(this, kProxyOffset, OffsetFrom(value)); | 2804 WRITE_INTPTR_FIELD(this, kProxyOffset, OffsetFrom(value)); |
| 2818 } | 2805 } |
| 2819 | 2806 |
| 2820 | 2807 |
| 2821 void Proxy::ProxyIterateBody(ObjectVisitor* visitor) { | |
| 2822 visitor->VisitExternalReference( | |
| 2823 reinterpret_cast<Address *>(FIELD_ADDR(this, kProxyOffset))); | |
| 2824 } | |
| 2825 | |
| 2826 | |
| 2827 ACCESSORS(JSValue, value, Object, kValueOffset) | 2808 ACCESSORS(JSValue, value, Object, kValueOffset) |
| 2828 | 2809 |
| 2829 | 2810 |
| 2830 JSValue* JSValue::cast(Object* obj) { | 2811 JSValue* JSValue::cast(Object* obj) { |
| 2831 ASSERT(obj->IsJSValue()); | 2812 ASSERT(obj->IsJSValue()); |
| 2832 ASSERT(HeapObject::cast(obj)->Size() == JSValue::kSize); | 2813 ASSERT(HeapObject::cast(obj)->Size() == JSValue::kSize); |
| 2833 return reinterpret_cast<JSValue*>(obj); | 2814 return reinterpret_cast<JSValue*>(obj); |
| 2834 } | 2815 } |
| 2835 | 2816 |
| 2836 | 2817 |
| (...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3300 set_elements(storage); | 3281 set_elements(storage); |
| 3301 } | 3282 } |
| 3302 | 3283 |
| 3303 | 3284 |
| 3304 Object* FixedArray::Copy() { | 3285 Object* FixedArray::Copy() { |
| 3305 if (length() == 0) return this; | 3286 if (length() == 0) return this; |
| 3306 return Heap::CopyFixedArray(this); | 3287 return Heap::CopyFixedArray(this); |
| 3307 } | 3288 } |
| 3308 | 3289 |
| 3309 | 3290 |
| 3291 int JSObject::BodyDescriptor::SizeOf(Map* map, HeapObject* object) { |
| 3292 return map->instance_size(); |
| 3293 } |
| 3294 |
| 3295 |
| 3296 void Proxy::ProxyIterateBody(ObjectVisitor* v) { |
| 3297 v->VisitExternalReference( |
| 3298 reinterpret_cast<Address *>(FIELD_ADDR(this, kProxyOffset))); |
| 3299 } |
| 3300 |
| 3301 |
| 3302 template<typename StaticVisitor> |
| 3303 void Proxy::ProxyIterateBody() { |
| 3304 StaticVisitor::VisitExternalReference( |
| 3305 reinterpret_cast<Address *>(FIELD_ADDR(this, kProxyOffset))); |
| 3306 } |
| 3307 |
| 3308 |
| 3309 void ExternalAsciiString::ExternalAsciiStringIterateBody(ObjectVisitor* v) { |
| 3310 typedef v8::String::ExternalAsciiStringResource Resource; |
| 3311 v->VisitExternalAsciiString( |
| 3312 reinterpret_cast<Resource**>(FIELD_ADDR(this, kResourceOffset))); |
| 3313 } |
| 3314 |
| 3315 |
| 3316 template<typename StaticVisitor> |
| 3317 void ExternalAsciiString::ExternalAsciiStringIterateBody() { |
| 3318 typedef v8::String::ExternalAsciiStringResource Resource; |
| 3319 StaticVisitor::VisitExternalAsciiString( |
| 3320 reinterpret_cast<Resource**>(FIELD_ADDR(this, kResourceOffset))); |
| 3321 } |
| 3322 |
| 3323 |
| 3324 void ExternalTwoByteString::ExternalTwoByteStringIterateBody(ObjectVisitor* v) { |
| 3325 typedef v8::String::ExternalStringResource Resource; |
| 3326 v->VisitExternalTwoByteString( |
| 3327 reinterpret_cast<Resource**>(FIELD_ADDR(this, kResourceOffset))); |
| 3328 } |
| 3329 |
| 3330 |
| 3331 template<typename StaticVisitor> |
| 3332 void ExternalTwoByteString::ExternalTwoByteStringIterateBody() { |
| 3333 typedef v8::String::ExternalStringResource Resource; |
| 3334 StaticVisitor::VisitExternalTwoByteString( |
| 3335 reinterpret_cast<Resource**>(FIELD_ADDR(this, kResourceOffset))); |
| 3336 } |
| 3337 |
| 3338 #define SLOT_ADDR(obj, offset) \ |
| 3339 reinterpret_cast<Object**>((obj)->address() + offset) |
| 3340 |
| 3341 template<int start_offset, int end_offset, int size> |
| 3342 void FixedBodyDescriptor<start_offset, end_offset, size>::IterateBody( |
| 3343 HeapObject* obj, |
| 3344 ObjectVisitor* v) { |
| 3345 v->VisitPointers(SLOT_ADDR(obj, start_offset), SLOT_ADDR(obj, end_offset)); |
| 3346 } |
| 3347 |
| 3348 |
| 3349 template<int start_offset> |
| 3350 void FlexibleBodyDescriptor<start_offset>::IterateBody(HeapObject* obj, |
| 3351 int object_size, |
| 3352 ObjectVisitor* v) { |
| 3353 v->VisitPointers(SLOT_ADDR(obj, start_offset), SLOT_ADDR(obj, object_size)); |
| 3354 } |
| 3355 |
| 3356 #undef SLOT_ADDR |
| 3357 |
| 3358 |
| 3310 #undef CAST_ACCESSOR | 3359 #undef CAST_ACCESSOR |
| 3311 #undef INT_ACCESSORS | 3360 #undef INT_ACCESSORS |
| 3312 #undef SMI_ACCESSORS | 3361 #undef SMI_ACCESSORS |
| 3313 #undef ACCESSORS | 3362 #undef ACCESSORS |
| 3314 #undef FIELD_ADDR | 3363 #undef FIELD_ADDR |
| 3315 #undef READ_FIELD | 3364 #undef READ_FIELD |
| 3316 #undef WRITE_FIELD | 3365 #undef WRITE_FIELD |
| 3317 #undef WRITE_BARRIER | 3366 #undef WRITE_BARRIER |
| 3318 #undef CONDITIONAL_WRITE_BARRIER | 3367 #undef CONDITIONAL_WRITE_BARRIER |
| 3319 #undef READ_MEMADDR_FIELD | 3368 #undef READ_MEMADDR_FIELD |
| 3320 #undef WRITE_MEMADDR_FIELD | 3369 #undef WRITE_MEMADDR_FIELD |
| 3321 #undef READ_DOUBLE_FIELD | 3370 #undef READ_DOUBLE_FIELD |
| 3322 #undef WRITE_DOUBLE_FIELD | 3371 #undef WRITE_DOUBLE_FIELD |
| 3323 #undef READ_INT_FIELD | 3372 #undef READ_INT_FIELD |
| 3324 #undef WRITE_INT_FIELD | 3373 #undef WRITE_INT_FIELD |
| 3325 #undef READ_SHORT_FIELD | 3374 #undef READ_SHORT_FIELD |
| 3326 #undef WRITE_SHORT_FIELD | 3375 #undef WRITE_SHORT_FIELD |
| 3327 #undef READ_BYTE_FIELD | 3376 #undef READ_BYTE_FIELD |
| 3328 #undef WRITE_BYTE_FIELD | 3377 #undef WRITE_BYTE_FIELD |
| 3329 | 3378 |
| 3330 | 3379 |
| 3331 } } // namespace v8::internal | 3380 } } // namespace v8::internal |
| 3332 | 3381 |
| 3333 #endif // V8_OBJECTS_INL_H_ | 3382 #endif // V8_OBJECTS_INL_H_ |
| OLD | NEW |