| 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 3476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3487 void LiteralsArray::set(int index, Object* value, WriteBarrierMode mode) { | 3487 void LiteralsArray::set(int index, Object* value, WriteBarrierMode mode) { |
| 3488 FixedArray::set(index, value, mode); | 3488 FixedArray::set(index, value, mode); |
| 3489 } | 3489 } |
| 3490 | 3490 |
| 3491 | 3491 |
| 3492 LiteralsArray* LiteralsArray::cast(Object* object) { | 3492 LiteralsArray* LiteralsArray::cast(Object* object) { |
| 3493 SLOW_DCHECK(object->IsLiteralsArray()); | 3493 SLOW_DCHECK(object->IsLiteralsArray()); |
| 3494 return reinterpret_cast<LiteralsArray*>(object); | 3494 return reinterpret_cast<LiteralsArray*>(object); |
| 3495 } | 3495 } |
| 3496 | 3496 |
| 3497 bool LiteralsArray::needs_feedback_vector() const { |
| 3498 return get(kVectorIndex)->IsUndefined(this->GetIsolate()); |
| 3499 } |
| 3497 | 3500 |
| 3498 TypeFeedbackVector* LiteralsArray::feedback_vector() const { | 3501 TypeFeedbackVector* LiteralsArray::feedback_vector() const { |
| 3499 if (length() == 0) { | 3502 if (length() == 0 || needs_feedback_vector()) { |
| 3500 return TypeFeedbackVector::cast( | 3503 return TypeFeedbackVector::cast( |
| 3501 const_cast<FixedArray*>(FixedArray::cast(this))); | 3504 this->GetIsolate()->heap()->empty_type_feedback_vector()); |
| 3502 } | 3505 } |
| 3506 |
| 3503 return TypeFeedbackVector::cast(get(kVectorIndex)); | 3507 return TypeFeedbackVector::cast(get(kVectorIndex)); |
| 3504 } | 3508 } |
| 3505 | 3509 |
| 3506 | 3510 |
| 3507 void LiteralsArray::set_feedback_vector(TypeFeedbackVector* vector) { | 3511 void LiteralsArray::set_feedback_vector(TypeFeedbackVector* vector) { |
| 3508 if (length() <= kVectorIndex) { | 3512 if (length() <= kVectorIndex) { |
| 3509 DCHECK(vector->length() == 0); | 3513 DCHECK(vector->length() == 0); |
| 3510 return; | 3514 return; |
| 3511 } | 3515 } |
| 3512 set(kVectorIndex, vector); | 3516 set(kVectorIndex, vector); |
| (...skipping 3106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6619 // context based on the state change. | 6623 // context based on the state change. |
| 6620 if (!was_optimized && is_optimized) { | 6624 if (!was_optimized && is_optimized) { |
| 6621 context()->native_context()->AddOptimizedFunction(this); | 6625 context()->native_context()->AddOptimizedFunction(this); |
| 6622 } | 6626 } |
| 6623 if (was_optimized && !is_optimized) { | 6627 if (was_optimized && !is_optimized) { |
| 6624 // TODO(titzer): linear in the number of optimized functions; fix! | 6628 // TODO(titzer): linear in the number of optimized functions; fix! |
| 6625 context()->native_context()->RemoveOptimizedFunction(this); | 6629 context()->native_context()->RemoveOptimizedFunction(this); |
| 6626 } | 6630 } |
| 6627 } | 6631 } |
| 6628 | 6632 |
| 6633 bool JSFunction::needs_literals_array() const { |
| 6634 SharedFunctionInfo* shared = this->shared(); |
| 6635 |
| 6636 return literals() == shared->GetIsolate()->heap()->empty_literals_array() && |
| 6637 (shared->feedback_metadata()->slot_count() > 0 || |
| 6638 shared->num_literals() > 0); |
| 6639 } |
| 6629 | 6640 |
| 6630 Context* JSFunction::context() { | 6641 Context* JSFunction::context() { |
| 6631 return Context::cast(READ_FIELD(this, kContextOffset)); | 6642 return Context::cast(READ_FIELD(this, kContextOffset)); |
| 6632 } | 6643 } |
| 6633 | 6644 |
| 6634 | 6645 |
| 6635 JSObject* JSFunction::global_proxy() { | 6646 JSObject* JSFunction::global_proxy() { |
| 6636 return context()->global_proxy(); | 6647 return context()->global_proxy(); |
| 6637 } | 6648 } |
| 6638 | 6649 |
| (...skipping 1797 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8436 #undef WRITE_INT64_FIELD | 8447 #undef WRITE_INT64_FIELD |
| 8437 #undef READ_BYTE_FIELD | 8448 #undef READ_BYTE_FIELD |
| 8438 #undef WRITE_BYTE_FIELD | 8449 #undef WRITE_BYTE_FIELD |
| 8439 #undef NOBARRIER_READ_BYTE_FIELD | 8450 #undef NOBARRIER_READ_BYTE_FIELD |
| 8440 #undef NOBARRIER_WRITE_BYTE_FIELD | 8451 #undef NOBARRIER_WRITE_BYTE_FIELD |
| 8441 | 8452 |
| 8442 } // namespace internal | 8453 } // namespace internal |
| 8443 } // namespace v8 | 8454 } // namespace v8 |
| 8444 | 8455 |
| 8445 #endif // V8_OBJECTS_INL_H_ | 8456 #endif // V8_OBJECTS_INL_H_ |
| OLD | NEW |