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

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

Issue 1369293003: Wrap JSFunction bindings in a helper object (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: comments. Created 5 years, 2 months 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
« no previous file with comments | « src/objects.cc ('k') | src/profiler/heap-snapshot-generator.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 713 matching lines...) Expand 10 before | Expand all | Expand 10 after
724 724
725 bool Object::IsTransitionArray() const { 725 bool Object::IsTransitionArray() const {
726 return IsFixedArray(); 726 return IsFixedArray();
727 } 727 }
728 728
729 729
730 bool Object::IsTypeFeedbackVector() const { return IsFixedArray(); } 730 bool Object::IsTypeFeedbackVector() const { return IsFixedArray(); }
731 731
732 732
733 bool Object::IsLiteralsArray() const { return IsFixedArray(); } 733 bool Object::IsLiteralsArray() const { return IsFixedArray(); }
734 bool Object::IsBindingsArray() const { return IsFixedArray(); }
734 735
735 736
736 bool Object::IsDeoptimizationInputData() const { 737 bool Object::IsDeoptimizationInputData() const {
737 // Must be a fixed array. 738 // Must be a fixed array.
738 if (!IsFixedArray()) return false; 739 if (!IsFixedArray()) return false;
739 740
740 // There's no sure way to detect the difference between a fixed array and 741 // There's no sure way to detect the difference between a fixed array and
741 // a deoptimization data array. Since this is used for asserts we can 742 // a deoptimization data array. Since this is used for asserts we can
742 // check that the length is zero or else the fixed size plus a multiple of 743 // check that the length is zero or else the fixed size plus a multiple of
743 // the entry size. 744 // the entry size.
(...skipping 2755 matching lines...) Expand 10 before | Expand all | Expand 10 after
3499 void LiteralsArray::set_literal(int literal_index, Object* literal) { 3500 void LiteralsArray::set_literal(int literal_index, Object* literal) {
3500 set(kFirstLiteralIndex + literal_index, literal); 3501 set(kFirstLiteralIndex + literal_index, literal);
3501 } 3502 }
3502 3503
3503 3504
3504 int LiteralsArray::literals_count() const { 3505 int LiteralsArray::literals_count() const {
3505 return length() - kFirstLiteralIndex; 3506 return length() - kFirstLiteralIndex;
3506 } 3507 }
3507 3508
3508 3509
3510 Object* BindingsArray::get(int index) const { return FixedArray::get(index); }
3511
3512
3513 void BindingsArray::set(int index, Object* value) {
3514 FixedArray::set(index, value);
3515 }
3516
3517
3518 void BindingsArray::set(int index, Smi* value) {
3519 FixedArray::set(index, value);
3520 }
3521
3522
3523 void BindingsArray::set(int index, Object* value, WriteBarrierMode mode) {
3524 FixedArray::set(index, value, mode);
3525 }
3526
3527
3528 int BindingsArray::length() const { return FixedArray::length(); }
3529
3530
3531 BindingsArray* BindingsArray::cast(Object* object) {
3532 SLOW_DCHECK(object->IsBindingsArray());
3533 return reinterpret_cast<BindingsArray*>(object);
3534 }
3535
3536 void BindingsArray::set_feedback_vector(TypeFeedbackVector* vector) {
3537 set(kVectorIndex, vector);
3538 }
3539
3540
3541 TypeFeedbackVector* BindingsArray::feedback_vector() const {
3542 return TypeFeedbackVector::cast(get(kVectorIndex));
3543 }
3544
3545
3546 JSReceiver* BindingsArray::bound_function() const {
3547 return JSReceiver::cast(get(kBoundFunctionIndex));
3548 }
3549
3550
3551 void BindingsArray::set_bound_function(JSReceiver* function) {
3552 set(kBoundFunctionIndex, function);
3553 }
3554
3555
3556 Object* BindingsArray::bound_this() const { return get(kBoundThisIndex); }
3557
3558
3559 void BindingsArray::set_bound_this(Object* bound_this) {
3560 set(kBoundThisIndex, bound_this);
3561 }
3562
3563
3564 Object* BindingsArray::binding(int binding_index) const {
3565 return get(kFirstBindingIndex + binding_index);
3566 }
3567
3568
3569 void BindingsArray::set_binding(int binding_index, Object* binding) {
3570 set(kFirstBindingIndex + binding_index, binding);
3571 }
3572
3573
3574 int BindingsArray::bindings_count() const {
3575 return length() - kFirstBindingIndex;
3576 }
3577
3578
3509 void HandlerTable::SetRangeStart(int index, int value) { 3579 void HandlerTable::SetRangeStart(int index, int value) {
3510 set(index * kRangeEntrySize + kRangeStartIndex, Smi::FromInt(value)); 3580 set(index * kRangeEntrySize + kRangeStartIndex, Smi::FromInt(value));
3511 } 3581 }
3512 3582
3513 3583
3514 void HandlerTable::SetRangeEnd(int index, int value) { 3584 void HandlerTable::SetRangeEnd(int index, int value) {
3515 set(index * kRangeEntrySize + kRangeEndIndex, Smi::FromInt(value)); 3585 set(index * kRangeEntrySize + kRangeEndIndex, Smi::FromInt(value));
3516 } 3586 }
3517 3587
3518 3588
(...skipping 2796 matching lines...) Expand 10 before | Expand all | Expand 10 after
6315 return LiteralsArray::cast(literals_or_bindings()); 6385 return LiteralsArray::cast(literals_or_bindings());
6316 } 6386 }
6317 6387
6318 6388
6319 void JSFunction::set_literals(LiteralsArray* literals) { 6389 void JSFunction::set_literals(LiteralsArray* literals) {
6320 DCHECK(!shared()->bound()); 6390 DCHECK(!shared()->bound());
6321 set_literals_or_bindings(literals); 6391 set_literals_or_bindings(literals);
6322 } 6392 }
6323 6393
6324 6394
6325 FixedArray* JSFunction::function_bindings() { 6395 BindingsArray* JSFunction::function_bindings() {
6326 DCHECK(shared()->bound()); 6396 DCHECK(shared()->bound());
6327 return literals_or_bindings(); 6397 return BindingsArray::cast(literals_or_bindings());
6328 } 6398 }
6329 6399
6330 6400
6331 void JSFunction::set_function_bindings(FixedArray* bindings) { 6401 void JSFunction::set_function_bindings(BindingsArray* bindings) {
6332 DCHECK(shared()->bound()); 6402 DCHECK(shared()->bound());
6333 // Bound function literal may be initialized to the empty fixed array 6403 // Bound function literal may be initialized to the empty fixed array
6334 // before the bindings are set. 6404 // before the bindings are set.
6335 DCHECK(bindings == GetHeap()->empty_fixed_array() || 6405 DCHECK(bindings == GetHeap()->empty_fixed_array() ||
6336 bindings->map() == GetHeap()->fixed_array_map()); 6406 bindings->map() == GetHeap()->fixed_array_map());
6337 set_literals_or_bindings(bindings); 6407 set_literals_or_bindings(bindings);
6338 } 6408 }
6339 6409
6340 6410
6341 int JSFunction::NumberOfLiterals() { 6411 int JSFunction::NumberOfLiterals() {
(...skipping 1700 matching lines...) Expand 10 before | Expand all | Expand 10 after
8042 #undef READ_INT64_FIELD 8112 #undef READ_INT64_FIELD
8043 #undef WRITE_INT64_FIELD 8113 #undef WRITE_INT64_FIELD
8044 #undef READ_BYTE_FIELD 8114 #undef READ_BYTE_FIELD
8045 #undef WRITE_BYTE_FIELD 8115 #undef WRITE_BYTE_FIELD
8046 #undef NOBARRIER_READ_BYTE_FIELD 8116 #undef NOBARRIER_READ_BYTE_FIELD
8047 #undef NOBARRIER_WRITE_BYTE_FIELD 8117 #undef NOBARRIER_WRITE_BYTE_FIELD
8048 8118
8049 } } // namespace v8::internal 8119 } } // namespace v8::internal
8050 8120
8051 #endif // V8_OBJECTS_INL_H_ 8121 #endif // V8_OBJECTS_INL_H_
OLDNEW
« no previous file with comments | « src/objects.cc ('k') | src/profiler/heap-snapshot-generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698