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 3435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3446 void LiteralsArray::set(int index, Object* value, WriteBarrierMode mode) { | 3446 void LiteralsArray::set(int index, Object* value, WriteBarrierMode mode) { |
3447 FixedArray::set(index, value, mode); | 3447 FixedArray::set(index, value, mode); |
3448 } | 3448 } |
3449 | 3449 |
3450 | 3450 |
3451 LiteralsArray* LiteralsArray::cast(Object* object) { | 3451 LiteralsArray* LiteralsArray::cast(Object* object) { |
3452 SLOW_DCHECK(object->IsLiteralsArray()); | 3452 SLOW_DCHECK(object->IsLiteralsArray()); |
3453 return reinterpret_cast<LiteralsArray*>(object); | 3453 return reinterpret_cast<LiteralsArray*>(object); |
3454 } | 3454 } |
3455 | 3455 |
3456 bool LiteralsArray::has_feedback_vector() const { | |
3457 return !get(kVectorIndex)->IsUndefined(this->GetIsolate()); | |
3458 } | |
3459 | 3456 |
3460 TypeFeedbackVector* LiteralsArray::feedback_vector() const { | 3457 TypeFeedbackVector* LiteralsArray::feedback_vector() const { |
3461 if (length() == 0 || !has_feedback_vector()) { | 3458 if (length() == 0) { |
3462 return TypeFeedbackVector::cast( | 3459 return TypeFeedbackVector::cast( |
3463 this->GetIsolate()->heap()->empty_type_feedback_vector()); | 3460 const_cast<FixedArray*>(FixedArray::cast(this))); |
3464 } | 3461 } |
3465 | |
3466 return TypeFeedbackVector::cast(get(kVectorIndex)); | 3462 return TypeFeedbackVector::cast(get(kVectorIndex)); |
3467 } | 3463 } |
3468 | 3464 |
3469 | 3465 |
3470 void LiteralsArray::set_feedback_vector(TypeFeedbackVector* vector) { | 3466 void LiteralsArray::set_feedback_vector(TypeFeedbackVector* vector) { |
3471 if (length() <= kVectorIndex) { | 3467 if (length() <= kVectorIndex) { |
3472 DCHECK(vector->length() == 0); | 3468 DCHECK(vector->length() == 0); |
3473 return; | 3469 return; |
3474 } | 3470 } |
3475 set(kVectorIndex, vector); | 3471 set(kVectorIndex, vector); |
(...skipping 3115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6591 // context based on the state change. | 6587 // context based on the state change. |
6592 if (!was_optimized && is_optimized) { | 6588 if (!was_optimized && is_optimized) { |
6593 context()->native_context()->AddOptimizedFunction(this); | 6589 context()->native_context()->AddOptimizedFunction(this); |
6594 } | 6590 } |
6595 if (was_optimized && !is_optimized) { | 6591 if (was_optimized && !is_optimized) { |
6596 // TODO(titzer): linear in the number of optimized functions; fix! | 6592 // TODO(titzer): linear in the number of optimized functions; fix! |
6597 context()->native_context()->RemoveOptimizedFunction(this); | 6593 context()->native_context()->RemoveOptimizedFunction(this); |
6598 } | 6594 } |
6599 } | 6595 } |
6600 | 6596 |
6601 bool JSFunction::has_literals_array() const { | |
6602 SharedFunctionInfo* shared = this->shared(); | |
6603 | |
6604 return (literals() != shared->GetIsolate()->heap()->empty_literals_array() || | |
6605 (shared->feedback_metadata()->slot_count() == 0 && | |
6606 shared->num_literals() == 0)); | |
6607 } | |
6608 | 6597 |
6609 Context* JSFunction::context() { | 6598 Context* JSFunction::context() { |
6610 return Context::cast(READ_FIELD(this, kContextOffset)); | 6599 return Context::cast(READ_FIELD(this, kContextOffset)); |
6611 } | 6600 } |
6612 | 6601 |
6613 | 6602 |
6614 JSObject* JSFunction::global_proxy() { | 6603 JSObject* JSFunction::global_proxy() { |
6615 return context()->global_proxy(); | 6604 return context()->global_proxy(); |
6616 } | 6605 } |
6617 | 6606 |
(...skipping 1783 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8401 #undef WRITE_INT64_FIELD | 8390 #undef WRITE_INT64_FIELD |
8402 #undef READ_BYTE_FIELD | 8391 #undef READ_BYTE_FIELD |
8403 #undef WRITE_BYTE_FIELD | 8392 #undef WRITE_BYTE_FIELD |
8404 #undef NOBARRIER_READ_BYTE_FIELD | 8393 #undef NOBARRIER_READ_BYTE_FIELD |
8405 #undef NOBARRIER_WRITE_BYTE_FIELD | 8394 #undef NOBARRIER_WRITE_BYTE_FIELD |
8406 | 8395 |
8407 } // namespace internal | 8396 } // namespace internal |
8408 } // namespace v8 | 8397 } // namespace v8 |
8409 | 8398 |
8410 #endif // V8_OBJECTS_INL_H_ | 8399 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |