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 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 bool Object::IsLayoutDescriptor() const { | 371 bool Object::IsLayoutDescriptor() const { |
372 return IsSmi() || IsFixedTypedArrayBase(); | 372 return IsSmi() || IsFixedTypedArrayBase(); |
373 } | 373 } |
374 | 374 |
375 bool HeapObject::IsTypeFeedbackVector() const { | 375 bool HeapObject::IsTypeFeedbackVector() const { |
376 return map() == GetHeap()->type_feedback_vector_map(); | 376 return map() == GetHeap()->type_feedback_vector_map(); |
377 } | 377 } |
378 | 378 |
379 bool HeapObject::IsTypeFeedbackMetadata() const { return IsFixedArray(); } | 379 bool HeapObject::IsTypeFeedbackMetadata() const { return IsFixedArray(); } |
380 | 380 |
381 bool HeapObject::IsLiteralsArray() const { return IsFixedArray(); } | |
382 | |
383 bool HeapObject::IsDeoptimizationInputData() const { | 381 bool HeapObject::IsDeoptimizationInputData() const { |
384 // Must be a fixed array. | 382 // Must be a fixed array. |
385 if (!IsFixedArray()) return false; | 383 if (!IsFixedArray()) return false; |
386 | 384 |
387 // There's no sure way to detect the difference between a fixed array and | 385 // There's no sure way to detect the difference between a fixed array and |
388 // a deoptimization data array. Since this is used for asserts we can | 386 // a deoptimization data array. Since this is used for asserts we can |
389 // check that the length is zero or else the fixed size plus a multiple of | 387 // check that the length is zero or else the fixed size plus a multiple of |
390 // the entry size. | 388 // the entry size. |
391 int length = FixedArray::cast(this)->length(); | 389 int length = FixedArray::cast(this)->length(); |
392 if (length == 0) return true; | 390 if (length == 0) return true; |
(...skipping 3062 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3455 | 3453 |
3456 Smi* DeoptimizationOutputData::PcAndState(int index) { | 3454 Smi* DeoptimizationOutputData::PcAndState(int index) { |
3457 return Smi::cast(get(1 + index * 2)); | 3455 return Smi::cast(get(1 + index * 2)); |
3458 } | 3456 } |
3459 | 3457 |
3460 | 3458 |
3461 void DeoptimizationOutputData::SetPcAndState(int index, Smi* offset) { | 3459 void DeoptimizationOutputData::SetPcAndState(int index, Smi* offset) { |
3462 set(1 + index * 2, offset); | 3460 set(1 + index * 2, offset); |
3463 } | 3461 } |
3464 | 3462 |
3465 | |
3466 Object* LiteralsArray::get(int index) const { return FixedArray::get(index); } | |
3467 | |
3468 | |
3469 void LiteralsArray::set(int index, Object* value) { | |
3470 FixedArray::set(index, value); | |
3471 } | |
3472 | |
3473 | |
3474 void LiteralsArray::set(int index, Smi* value) { | |
3475 FixedArray::set(index, value); | |
3476 } | |
3477 | |
3478 | |
3479 void LiteralsArray::set(int index, Object* value, WriteBarrierMode mode) { | |
3480 FixedArray::set(index, value, mode); | |
3481 } | |
3482 | |
3483 | |
3484 LiteralsArray* LiteralsArray::cast(Object* object) { | |
3485 SLOW_DCHECK(object->IsLiteralsArray()); | |
3486 return reinterpret_cast<LiteralsArray*>(object); | |
3487 } | |
3488 | |
3489 | |
3490 TypeFeedbackVector* LiteralsArray::feedback_vector() const { | |
3491 if (length() == 0) { | |
3492 return TypeFeedbackVector::cast( | |
3493 const_cast<FixedArray*>(FixedArray::cast(this))); | |
3494 } | |
3495 return TypeFeedbackVector::cast(get(kVectorIndex)); | |
3496 } | |
3497 | |
3498 | |
3499 void LiteralsArray::set_feedback_vector(TypeFeedbackVector* vector) { | |
3500 if (length() <= kVectorIndex) { | |
3501 DCHECK(vector->length() == 0); | |
3502 return; | |
3503 } | |
3504 set(kVectorIndex, vector); | |
3505 } | |
3506 | |
3507 | |
3508 Object* LiteralsArray::literal(int literal_index) const { | |
3509 return get(kFirstLiteralIndex + literal_index); | |
3510 } | |
3511 | |
3512 | |
3513 void LiteralsArray::set_literal(int literal_index, Object* literal) { | |
3514 set(kFirstLiteralIndex + literal_index, literal); | |
3515 } | |
3516 | |
3517 void LiteralsArray::set_literal_undefined(int literal_index) { | |
3518 set_undefined(kFirstLiteralIndex + literal_index); | |
3519 } | |
3520 | |
3521 int LiteralsArray::literals_count() const { | |
3522 return length() - kFirstLiteralIndex; | |
3523 } | |
3524 | |
3525 int HandlerTable::GetRangeStart(int index) const { | 3463 int HandlerTable::GetRangeStart(int index) const { |
3526 return Smi::cast(get(index * kRangeEntrySize + kRangeStartIndex))->value(); | 3464 return Smi::cast(get(index * kRangeEntrySize + kRangeStartIndex))->value(); |
3527 } | 3465 } |
3528 | 3466 |
3529 int HandlerTable::GetRangeEnd(int index) const { | 3467 int HandlerTable::GetRangeEnd(int index) const { |
3530 return Smi::cast(get(index * kRangeEntrySize + kRangeEndIndex))->value(); | 3468 return Smi::cast(get(index * kRangeEntrySize + kRangeEndIndex))->value(); |
3531 } | 3469 } |
3532 | 3470 |
3533 int HandlerTable::GetRangeHandler(int index) const { | 3471 int HandlerTable::GetRangeHandler(int index) const { |
3534 return HandlerOffsetField::decode( | 3472 return HandlerOffsetField::decode( |
(...skipping 2175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5710 map->unused_property_fields()); | 5648 map->unused_property_fields()); |
5711 } | 5649 } |
5712 | 5650 |
5713 | 5651 |
5714 ACCESSORS(JSBoundFunction, bound_target_function, JSReceiver, | 5652 ACCESSORS(JSBoundFunction, bound_target_function, JSReceiver, |
5715 kBoundTargetFunctionOffset) | 5653 kBoundTargetFunctionOffset) |
5716 ACCESSORS(JSBoundFunction, bound_this, Object, kBoundThisOffset) | 5654 ACCESSORS(JSBoundFunction, bound_this, Object, kBoundThisOffset) |
5717 ACCESSORS(JSBoundFunction, bound_arguments, FixedArray, kBoundArgumentsOffset) | 5655 ACCESSORS(JSBoundFunction, bound_arguments, FixedArray, kBoundArgumentsOffset) |
5718 | 5656 |
5719 ACCESSORS(JSFunction, shared, SharedFunctionInfo, kSharedFunctionInfoOffset) | 5657 ACCESSORS(JSFunction, shared, SharedFunctionInfo, kSharedFunctionInfoOffset) |
5720 ACCESSORS(JSFunction, literals, LiteralsArray, kLiteralsOffset) | 5658 ACCESSORS(JSFunction, feedback_vector, TypeFeedbackVector, |
| 5659 kFeedbackVectorOffset) |
5721 ACCESSORS(JSFunction, next_function_link, Object, kNextFunctionLinkOffset) | 5660 ACCESSORS(JSFunction, next_function_link, Object, kNextFunctionLinkOffset) |
5722 | 5661 |
5723 ACCESSORS(JSGlobalObject, native_context, Context, kNativeContextOffset) | 5662 ACCESSORS(JSGlobalObject, native_context, Context, kNativeContextOffset) |
5724 ACCESSORS(JSGlobalObject, global_proxy, JSObject, kGlobalProxyOffset) | 5663 ACCESSORS(JSGlobalObject, global_proxy, JSObject, kGlobalProxyOffset) |
5725 | 5664 |
5726 ACCESSORS(JSGlobalProxy, native_context, Object, kNativeContextOffset) | 5665 ACCESSORS(JSGlobalProxy, native_context, Object, kNativeContextOffset) |
5727 ACCESSORS(JSGlobalProxy, hash, Object, kHashOffset) | 5666 ACCESSORS(JSGlobalProxy, hash, Object, kHashOffset) |
5728 | 5667 |
5729 ACCESSORS(AccessorInfo, name, Object, kNameOffset) | 5668 ACCESSORS(AccessorInfo, name, Object, kNameOffset) |
5730 SMI_ACCESSORS(AccessorInfo, flag, kFlagOffset) | 5669 SMI_ACCESSORS(AccessorInfo, flag, kFlagOffset) |
(...skipping 987 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6718 | 6657 |
6719 | 6658 |
6720 bool JSFunction::is_compiled() { | 6659 bool JSFunction::is_compiled() { |
6721 Builtins* builtins = GetIsolate()->builtins(); | 6660 Builtins* builtins = GetIsolate()->builtins(); |
6722 return code() != builtins->builtin(Builtins::kCompileLazy) && | 6661 return code() != builtins->builtin(Builtins::kCompileLazy) && |
6723 code() != builtins->builtin(Builtins::kCompileBaseline) && | 6662 code() != builtins->builtin(Builtins::kCompileBaseline) && |
6724 code() != builtins->builtin(Builtins::kCompileOptimized) && | 6663 code() != builtins->builtin(Builtins::kCompileOptimized) && |
6725 code() != builtins->builtin(Builtins::kCompileOptimizedConcurrent); | 6664 code() != builtins->builtin(Builtins::kCompileOptimizedConcurrent); |
6726 } | 6665 } |
6727 | 6666 |
6728 TypeFeedbackVector* JSFunction::feedback_vector() { | |
6729 LiteralsArray* array = literals(); | |
6730 return array->feedback_vector(); | |
6731 } | |
6732 | |
6733 ACCESSORS(JSProxy, target, JSReceiver, kTargetOffset) | 6667 ACCESSORS(JSProxy, target, JSReceiver, kTargetOffset) |
6734 ACCESSORS(JSProxy, handler, Object, kHandlerOffset) | 6668 ACCESSORS(JSProxy, handler, Object, kHandlerOffset) |
6735 ACCESSORS(JSProxy, hash, Object, kHashOffset) | 6669 ACCESSORS(JSProxy, hash, Object, kHashOffset) |
6736 | 6670 |
6737 bool JSProxy::IsRevoked() const { return !handler()->IsJSReceiver(); } | 6671 bool JSProxy::IsRevoked() const { return !handler()->IsJSReceiver(); } |
6738 | 6672 |
6739 ACCESSORS(JSCollection, table, Object, kTableOffset) | 6673 ACCESSORS(JSCollection, table, Object, kTableOffset) |
6740 | 6674 |
6741 | 6675 |
6742 #define ORDERED_HASH_TABLE_ITERATOR_ACCESSORS(name, type, offset) \ | 6676 #define ORDERED_HASH_TABLE_ITERATOR_ACCESSORS(name, type, offset) \ |
(...skipping 1702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8445 #undef WRITE_INT64_FIELD | 8379 #undef WRITE_INT64_FIELD |
8446 #undef READ_BYTE_FIELD | 8380 #undef READ_BYTE_FIELD |
8447 #undef WRITE_BYTE_FIELD | 8381 #undef WRITE_BYTE_FIELD |
8448 #undef NOBARRIER_READ_BYTE_FIELD | 8382 #undef NOBARRIER_READ_BYTE_FIELD |
8449 #undef NOBARRIER_WRITE_BYTE_FIELD | 8383 #undef NOBARRIER_WRITE_BYTE_FIELD |
8450 | 8384 |
8451 } // namespace internal | 8385 } // namespace internal |
8452 } // namespace v8 | 8386 } // namespace v8 |
8453 | 8387 |
8454 #endif // V8_OBJECTS_INL_H_ | 8388 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |