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 3496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3507 void LiteralsArray::set(int index, Object* value, WriteBarrierMode mode) { | 3507 void LiteralsArray::set(int index, Object* value, WriteBarrierMode mode) { |
3508 FixedArray::set(index, value, mode); | 3508 FixedArray::set(index, value, mode); |
3509 } | 3509 } |
3510 | 3510 |
3511 | 3511 |
3512 LiteralsArray* LiteralsArray::cast(Object* object) { | 3512 LiteralsArray* LiteralsArray::cast(Object* object) { |
3513 SLOW_DCHECK(object->IsLiteralsArray()); | 3513 SLOW_DCHECK(object->IsLiteralsArray()); |
3514 return reinterpret_cast<LiteralsArray*>(object); | 3514 return reinterpret_cast<LiteralsArray*>(object); |
3515 } | 3515 } |
3516 | 3516 |
| 3517 bool LiteralsArray::has_feedback_vector() const { |
| 3518 return !get(kVectorIndex)->IsUndefined(this->GetIsolate()); |
| 3519 } |
3517 | 3520 |
3518 TypeFeedbackVector* LiteralsArray::feedback_vector() const { | 3521 TypeFeedbackVector* LiteralsArray::feedback_vector() const { |
3519 if (length() == 0) { | 3522 if (length() == 0 || !has_feedback_vector()) { |
3520 return TypeFeedbackVector::cast( | 3523 return TypeFeedbackVector::cast( |
3521 const_cast<FixedArray*>(FixedArray::cast(this))); | 3524 this->GetIsolate()->heap()->empty_type_feedback_vector()); |
3522 } | 3525 } |
| 3526 |
3523 return TypeFeedbackVector::cast(get(kVectorIndex)); | 3527 return TypeFeedbackVector::cast(get(kVectorIndex)); |
3524 } | 3528 } |
3525 | 3529 |
3526 | 3530 |
3527 void LiteralsArray::set_feedback_vector(TypeFeedbackVector* vector) { | 3531 void LiteralsArray::set_feedback_vector(TypeFeedbackVector* vector) { |
3528 if (length() <= kVectorIndex) { | 3532 if (length() <= kVectorIndex) { |
3529 DCHECK(vector->length() == 0); | 3533 DCHECK(vector->length() == 0); |
3530 return; | 3534 return; |
3531 } | 3535 } |
3532 set(kVectorIndex, vector); | 3536 set(kVectorIndex, vector); |
(...skipping 3107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6640 // context based on the state change. | 6644 // context based on the state change. |
6641 if (!was_optimized && is_optimized) { | 6645 if (!was_optimized && is_optimized) { |
6642 context()->native_context()->AddOptimizedFunction(this); | 6646 context()->native_context()->AddOptimizedFunction(this); |
6643 } | 6647 } |
6644 if (was_optimized && !is_optimized) { | 6648 if (was_optimized && !is_optimized) { |
6645 // TODO(titzer): linear in the number of optimized functions; fix! | 6649 // TODO(titzer): linear in the number of optimized functions; fix! |
6646 context()->native_context()->RemoveOptimizedFunction(this); | 6650 context()->native_context()->RemoveOptimizedFunction(this); |
6647 } | 6651 } |
6648 } | 6652 } |
6649 | 6653 |
| 6654 bool JSFunction::has_literals_array() const { |
| 6655 SharedFunctionInfo* shared = this->shared(); |
| 6656 |
| 6657 return (literals() != shared->GetIsolate()->heap()->empty_literals_array() || |
| 6658 (shared->feedback_metadata()->slot_count() == 0 && |
| 6659 shared->num_literals() == 0)); |
| 6660 } |
6650 | 6661 |
6651 Context* JSFunction::context() { | 6662 Context* JSFunction::context() { |
6652 return Context::cast(READ_FIELD(this, kContextOffset)); | 6663 return Context::cast(READ_FIELD(this, kContextOffset)); |
6653 } | 6664 } |
6654 | 6665 |
6655 | 6666 |
6656 JSObject* JSFunction::global_proxy() { | 6667 JSObject* JSFunction::global_proxy() { |
6657 return context()->global_proxy(); | 6668 return context()->global_proxy(); |
6658 } | 6669 } |
6659 | 6670 |
(...skipping 1812 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8472 #undef WRITE_INT64_FIELD | 8483 #undef WRITE_INT64_FIELD |
8473 #undef READ_BYTE_FIELD | 8484 #undef READ_BYTE_FIELD |
8474 #undef WRITE_BYTE_FIELD | 8485 #undef WRITE_BYTE_FIELD |
8475 #undef NOBARRIER_READ_BYTE_FIELD | 8486 #undef NOBARRIER_READ_BYTE_FIELD |
8476 #undef NOBARRIER_WRITE_BYTE_FIELD | 8487 #undef NOBARRIER_WRITE_BYTE_FIELD |
8477 | 8488 |
8478 } // namespace internal | 8489 } // namespace internal |
8479 } // namespace v8 | 8490 } // namespace v8 |
8480 | 8491 |
8481 #endif // V8_OBJECTS_INL_H_ | 8492 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |