Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: src/objects-inl.h

Issue 2504153002: [TypeFeedbackVector] Root literal arrays in function literals slots (Closed)
Patch Set: REBASE. Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 3494 matching lines...) Expand 10 before | Expand all | Expand 10 after
3505 void LiteralsArray::set(int index, Object* value, WriteBarrierMode mode) { 3505 void LiteralsArray::set(int index, Object* value, WriteBarrierMode mode) {
3506 FixedArray::set(index, value, mode); 3506 FixedArray::set(index, value, mode);
3507 } 3507 }
3508 3508
3509 3509
3510 LiteralsArray* LiteralsArray::cast(Object* object) { 3510 LiteralsArray* LiteralsArray::cast(Object* object) {
3511 SLOW_DCHECK(object->IsLiteralsArray()); 3511 SLOW_DCHECK(object->IsLiteralsArray());
3512 return reinterpret_cast<LiteralsArray*>(object); 3512 return reinterpret_cast<LiteralsArray*>(object);
3513 } 3513 }
3514 3514
3515 bool LiteralsArray::needs_feedback_vector() const {
3516 return get(kVectorIndex)->IsUndefined(this->GetIsolate());
3517 }
3515 3518
3516 TypeFeedbackVector* LiteralsArray::feedback_vector() const { 3519 TypeFeedbackVector* LiteralsArray::feedback_vector() const {
3517 if (length() == 0) { 3520 if (length() == 0 || needs_feedback_vector()) {
3518 return TypeFeedbackVector::cast( 3521 return TypeFeedbackVector::cast(
3519 const_cast<FixedArray*>(FixedArray::cast(this))); 3522 this->GetIsolate()->heap()->empty_type_feedback_vector());
3520 } 3523 }
3524
3521 return TypeFeedbackVector::cast(get(kVectorIndex)); 3525 return TypeFeedbackVector::cast(get(kVectorIndex));
3522 } 3526 }
3523 3527
3524 3528
3525 void LiteralsArray::set_feedback_vector(TypeFeedbackVector* vector) { 3529 void LiteralsArray::set_feedback_vector(TypeFeedbackVector* vector) {
3526 if (length() <= kVectorIndex) { 3530 if (length() <= kVectorIndex) {
3527 DCHECK(vector->length() == 0); 3531 DCHECK(vector->length() == 0);
3528 return; 3532 return;
3529 } 3533 }
3530 set(kVectorIndex, vector); 3534 set(kVectorIndex, vector);
(...skipping 3095 matching lines...) Expand 10 before | Expand all | Expand 10 after
6626 // context based on the state change. 6630 // context based on the state change.
6627 if (!was_optimized && is_optimized) { 6631 if (!was_optimized && is_optimized) {
6628 context()->native_context()->AddOptimizedFunction(this); 6632 context()->native_context()->AddOptimizedFunction(this);
6629 } 6633 }
6630 if (was_optimized && !is_optimized) { 6634 if (was_optimized && !is_optimized) {
6631 // TODO(titzer): linear in the number of optimized functions; fix! 6635 // TODO(titzer): linear in the number of optimized functions; fix!
6632 context()->native_context()->RemoveOptimizedFunction(this); 6636 context()->native_context()->RemoveOptimizedFunction(this);
6633 } 6637 }
6634 } 6638 }
6635 6639
6640 bool JSFunction::needs_literals_array() const {
6641 SharedFunctionInfo* shared = this->shared();
6642
6643 return literals() == shared->GetIsolate()->heap()->empty_literals_array() &&
6644 (shared->feedback_metadata()->slot_count() > 0 ||
6645 shared->num_literals() > 0);
6646 }
6636 6647
6637 Context* JSFunction::context() { 6648 Context* JSFunction::context() {
6638 return Context::cast(READ_FIELD(this, kContextOffset)); 6649 return Context::cast(READ_FIELD(this, kContextOffset));
6639 } 6650 }
6640 6651
6641 6652
6642 JSObject* JSFunction::global_proxy() { 6653 JSObject* JSFunction::global_proxy() {
6643 return context()->global_proxy(); 6654 return context()->global_proxy();
6644 } 6655 }
6645 6656
(...skipping 1824 matching lines...) Expand 10 before | Expand all | Expand 10 after
8470 #undef WRITE_INT64_FIELD 8481 #undef WRITE_INT64_FIELD
8471 #undef READ_BYTE_FIELD 8482 #undef READ_BYTE_FIELD
8472 #undef WRITE_BYTE_FIELD 8483 #undef WRITE_BYTE_FIELD
8473 #undef NOBARRIER_READ_BYTE_FIELD 8484 #undef NOBARRIER_READ_BYTE_FIELD
8474 #undef NOBARRIER_WRITE_BYTE_FIELD 8485 #undef NOBARRIER_WRITE_BYTE_FIELD
8475 8486
8476 } // namespace internal 8487 } // namespace internal
8477 } // namespace v8 8488 } // namespace v8
8478 8489
8479 #endif // V8_OBJECTS_INL_H_ 8490 #endif // V8_OBJECTS_INL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698