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 2299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2310 Object* FixedArray::get(int index) const { | 2310 Object* FixedArray::get(int index) const { |
2311 SLOW_DCHECK(index >= 0 && index < this->length()); | 2311 SLOW_DCHECK(index >= 0 && index < this->length()); |
2312 return READ_FIELD(this, kHeaderSize + index * kPointerSize); | 2312 return READ_FIELD(this, kHeaderSize + index * kPointerSize); |
2313 } | 2313 } |
2314 | 2314 |
2315 Handle<Object> FixedArray::get(FixedArray* array, int index, Isolate* isolate) { | 2315 Handle<Object> FixedArray::get(FixedArray* array, int index, Isolate* isolate) { |
2316 return handle(array->get(index), isolate); | 2316 return handle(array->get(index), isolate); |
2317 } | 2317 } |
2318 | 2318 |
2319 template <class T> | 2319 template <class T> |
2320 MaybeHandle<T> FixedArray::GetValue(int index) const { | 2320 MaybeHandle<T> FixedArray::GetValue(Isolate* isolate, int index) const { |
2321 Object* obj = get(index); | 2321 Object* obj = get(index); |
2322 if (obj->IsUndefined(GetIsolate())) return MaybeHandle<T>(); | 2322 if (obj->IsUndefined(isolate)) return MaybeHandle<T>(); |
2323 return Handle<T>(T::cast(obj)); | 2323 return Handle<T>(T::cast(obj), isolate); |
2324 } | 2324 } |
2325 | 2325 |
2326 template <class T> | 2326 template <class T> |
2327 Handle<T> FixedArray::GetValueChecked(int index) const { | 2327 Handle<T> FixedArray::GetValueChecked(Isolate* isolate, int index) const { |
2328 Object* obj = get(index); | 2328 Object* obj = get(index); |
2329 CHECK(!obj->IsUndefined(GetIsolate())); | 2329 CHECK(!obj->IsUndefined(isolate)); |
2330 return Handle<T>(T::cast(obj)); | 2330 return Handle<T>(T::cast(obj), isolate); |
2331 } | 2331 } |
2332 | 2332 |
2333 bool FixedArray::is_the_hole(int index) { | 2333 bool FixedArray::is_the_hole(int index) { |
2334 return get(index) == GetHeap()->the_hole_value(); | 2334 return get(index) == GetHeap()->the_hole_value(); |
2335 } | 2335 } |
2336 | 2336 |
2337 void FixedArray::set(int index, Smi* value) { | 2337 void FixedArray::set(int index, Smi* value) { |
2338 DCHECK(map() != GetHeap()->fixed_cow_array_map()); | 2338 DCHECK(map() != GetHeap()->fixed_cow_array_map()); |
2339 DCHECK(index >= 0 && index < this->length()); | 2339 DCHECK(index >= 0 && index < this->length()); |
2340 DCHECK(reinterpret_cast<Object*>(value)->IsSmi()); | 2340 DCHECK(reinterpret_cast<Object*>(value)->IsSmi()); |
(...skipping 3253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5594 | 5594 |
5595 bool PrototypeInfo::HasObjectCreateMap() { | 5595 bool PrototypeInfo::HasObjectCreateMap() { |
5596 Object* cache = object_create_map(); | 5596 Object* cache = object_create_map(); |
5597 return cache->IsWeakCell() && !WeakCell::cast(cache)->cleared(); | 5597 return cache->IsWeakCell() && !WeakCell::cast(cache)->cleared(); |
5598 } | 5598 } |
5599 | 5599 |
5600 bool FunctionTemplateInfo::instantiated() { | 5600 bool FunctionTemplateInfo::instantiated() { |
5601 return shared_function_info()->IsSharedFunctionInfo(); | 5601 return shared_function_info()->IsSharedFunctionInfo(); |
5602 } | 5602 } |
5603 | 5603 |
| 5604 FunctionTemplateInfo* FunctionTemplateInfo::GetParent(Isolate* isolate) { |
| 5605 Object* parent = parent_template(); |
| 5606 return parent->IsUndefined(isolate) ? nullptr |
| 5607 : FunctionTemplateInfo::cast(parent); |
| 5608 } |
| 5609 |
| 5610 ObjectTemplateInfo* ObjectTemplateInfo::GetParent(Isolate* isolate) { |
| 5611 Object* maybe_ctor = constructor(); |
| 5612 if (maybe_ctor->IsUndefined(isolate)) return nullptr; |
| 5613 FunctionTemplateInfo* constructor = FunctionTemplateInfo::cast(maybe_ctor); |
| 5614 while (true) { |
| 5615 constructor = constructor->GetParent(isolate); |
| 5616 if (constructor == nullptr) return nullptr; |
| 5617 Object* maybe_obj = constructor->instance_template(); |
| 5618 if (!maybe_obj->IsUndefined(isolate)) { |
| 5619 return ObjectTemplateInfo::cast(maybe_obj); |
| 5620 } |
| 5621 } |
| 5622 return nullptr; |
| 5623 } |
| 5624 |
5604 ACCESSORS(PrototypeInfo, prototype_users, Object, kPrototypeUsersOffset) | 5625 ACCESSORS(PrototypeInfo, prototype_users, Object, kPrototypeUsersOffset) |
5605 ACCESSORS(PrototypeInfo, object_create_map, Object, kObjectCreateMap) | 5626 ACCESSORS(PrototypeInfo, object_create_map, Object, kObjectCreateMap) |
5606 SMI_ACCESSORS(PrototypeInfo, registry_slot, kRegistrySlotOffset) | 5627 SMI_ACCESSORS(PrototypeInfo, registry_slot, kRegistrySlotOffset) |
5607 ACCESSORS(PrototypeInfo, validity_cell, Object, kValidityCellOffset) | 5628 ACCESSORS(PrototypeInfo, validity_cell, Object, kValidityCellOffset) |
5608 SMI_ACCESSORS(PrototypeInfo, bit_field, kBitFieldOffset) | 5629 SMI_ACCESSORS(PrototypeInfo, bit_field, kBitFieldOffset) |
5609 BOOL_ACCESSORS(PrototypeInfo, bit_field, should_be_fast_map, kShouldBeFastBit) | 5630 BOOL_ACCESSORS(PrototypeInfo, bit_field, should_be_fast_map, kShouldBeFastBit) |
5610 | 5631 |
5611 ACCESSORS(SloppyBlockWithEvalContextExtension, scope_info, ScopeInfo, | 5632 ACCESSORS(SloppyBlockWithEvalContextExtension, scope_info, ScopeInfo, |
5612 kScopeInfoOffset) | 5633 kScopeInfoOffset) |
5613 ACCESSORS(SloppyBlockWithEvalContextExtension, extension, JSObject, | 5634 ACCESSORS(SloppyBlockWithEvalContextExtension, extension, JSObject, |
(...skipping 2511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8125 #undef WRITE_INT64_FIELD | 8146 #undef WRITE_INT64_FIELD |
8126 #undef READ_BYTE_FIELD | 8147 #undef READ_BYTE_FIELD |
8127 #undef WRITE_BYTE_FIELD | 8148 #undef WRITE_BYTE_FIELD |
8128 #undef NOBARRIER_READ_BYTE_FIELD | 8149 #undef NOBARRIER_READ_BYTE_FIELD |
8129 #undef NOBARRIER_WRITE_BYTE_FIELD | 8150 #undef NOBARRIER_WRITE_BYTE_FIELD |
8130 | 8151 |
8131 } // namespace internal | 8152 } // namespace internal |
8132 } // namespace v8 | 8153 } // namespace v8 |
8133 | 8154 |
8134 #endif // V8_OBJECTS_INL_H_ | 8155 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |