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