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

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

Issue 1230753004: [Interpreter] Add BytecodeArray class and add to SharedFunctionInfo. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Don't use extra memory for BytecodeArray in SharedFunctionInfo and add a BytecodeArray test. Created 5 years, 5 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
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 630 matching lines...) Expand 10 before | Expand all | Expand 10 after
641 uint32_t seed_; 641 uint32_t seed_;
642 }; 642 };
643 643
644 644
645 bool Object::IsNumber() const { 645 bool Object::IsNumber() const {
646 return IsSmi() || IsHeapNumber(); 646 return IsSmi() || IsHeapNumber();
647 } 647 }
648 648
649 649
650 TYPE_CHECKER(ByteArray, BYTE_ARRAY_TYPE) 650 TYPE_CHECKER(ByteArray, BYTE_ARRAY_TYPE)
651 TYPE_CHECKER(BytecodeArray, BYTECODE_ARRAY_TYPE)
651 TYPE_CHECKER(FreeSpace, FREE_SPACE_TYPE) 652 TYPE_CHECKER(FreeSpace, FREE_SPACE_TYPE)
652 653
653 654
654 bool Object::IsFiller() const { 655 bool Object::IsFiller() const {
655 if (!Object::IsHeapObject()) return false; 656 if (!Object::IsHeapObject()) return false;
656 InstanceType instance_type = HeapObject::cast(this)->map()->instance_type(); 657 InstanceType instance_type = HeapObject::cast(this)->map()->instance_type();
657 return instance_type == FREE_SPACE_TYPE || instance_type == FILLER_TYPE; 658 return instance_type == FREE_SPACE_TYPE || instance_type == FILLER_TYPE;
658 } 659 }
659 660
660 661
(...skipping 2282 matching lines...) Expand 10 before | Expand all | Expand 10 after
2943 } 2944 }
2944 2945
2945 2946
2946 // ------------------------------------ 2947 // ------------------------------------
2947 // Cast operations 2948 // Cast operations
2948 2949
2949 2950
2950 CAST_ACCESSOR(AccessorInfo) 2951 CAST_ACCESSOR(AccessorInfo)
2951 CAST_ACCESSOR(ArrayList) 2952 CAST_ACCESSOR(ArrayList)
2952 CAST_ACCESSOR(ByteArray) 2953 CAST_ACCESSOR(ByteArray)
2954 CAST_ACCESSOR(BytecodeArray)
2953 CAST_ACCESSOR(Cell) 2955 CAST_ACCESSOR(Cell)
2954 CAST_ACCESSOR(Code) 2956 CAST_ACCESSOR(Code)
2955 CAST_ACCESSOR(CodeCacheHashTable) 2957 CAST_ACCESSOR(CodeCacheHashTable)
2956 CAST_ACCESSOR(CompilationCacheTable) 2958 CAST_ACCESSOR(CompilationCacheTable)
2957 CAST_ACCESSOR(ConsString) 2959 CAST_ACCESSOR(ConsString)
2958 CAST_ACCESSOR(DeoptimizationInputData) 2960 CAST_ACCESSOR(DeoptimizationInputData)
2959 CAST_ACCESSOR(DeoptimizationOutputData) 2961 CAST_ACCESSOR(DeoptimizationOutputData)
2960 CAST_ACCESSOR(DependentCode) 2962 CAST_ACCESSOR(DependentCode)
2961 CAST_ACCESSOR(DescriptorArray) 2963 CAST_ACCESSOR(DescriptorArray)
2962 CAST_ACCESSOR(ExternalArray) 2964 CAST_ACCESSOR(ExternalArray)
(...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after
3644 DCHECK_TAG_ALIGNED(address); 3646 DCHECK_TAG_ALIGNED(address);
3645 return reinterpret_cast<ByteArray*>(address - kHeaderSize + kHeapObjectTag); 3647 return reinterpret_cast<ByteArray*>(address - kHeaderSize + kHeapObjectTag);
3646 } 3648 }
3647 3649
3648 3650
3649 Address ByteArray::GetDataStartAddress() { 3651 Address ByteArray::GetDataStartAddress() {
3650 return reinterpret_cast<Address>(this) - kHeapObjectTag + kHeaderSize; 3652 return reinterpret_cast<Address>(this) - kHeapObjectTag + kHeaderSize;
3651 } 3653 }
3652 3654
3653 3655
3656 byte BytecodeArray::get(int index) {
3657 DCHECK(index >= 0 && index < this->length());
3658 return READ_BYTE_FIELD(this, kHeaderSize + index * kCharSize);
3659 }
3660
3661
3662 void BytecodeArray::set(int index, byte value) {
3663 DCHECK(index >= 0 && index < this->length());
3664 WRITE_BYTE_FIELD(this, kHeaderSize + index * kCharSize, value);
3665 }
3666
3667
3668 SMI_ACCESSORS(BytecodeArray, frame_size, kFrameSizeOffset);
3669 SMI_ACCESSORS(BytecodeArray, number_of_locals, kNumberOfLocalsOffset);
3670
3671
3672 Address BytecodeArray::GetFirstBytecodeAddress() {
3673 return reinterpret_cast<Address>(this) - kHeapObjectTag + kHeaderSize;
3674 }
3675
3676
3654 uint8_t* ExternalUint8ClampedArray::external_uint8_clamped_pointer() { 3677 uint8_t* ExternalUint8ClampedArray::external_uint8_clamped_pointer() {
3655 return reinterpret_cast<uint8_t*>(external_pointer()); 3678 return reinterpret_cast<uint8_t*>(external_pointer());
3656 } 3679 }
3657 3680
3658 3681
3659 uint8_t ExternalUint8ClampedArray::get_scalar(int index) { 3682 uint8_t ExternalUint8ClampedArray::get_scalar(int index) {
3660 DCHECK((index >= 0) && (index < this->length())); 3683 DCHECK((index >= 0) && (index < this->length()));
3661 uint8_t* ptr = external_uint8_clamped_pointer(); 3684 uint8_t* ptr = external_uint8_clamped_pointer();
3662 return ptr[index]; 3685 return ptr[index];
3663 } 3686 }
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
4119 if (instance_type == ONE_BYTE_STRING_TYPE || 4142 if (instance_type == ONE_BYTE_STRING_TYPE ||
4120 instance_type == ONE_BYTE_INTERNALIZED_STRING_TYPE) { 4143 instance_type == ONE_BYTE_INTERNALIZED_STRING_TYPE) {
4121 // Strings may get concurrently truncated, hence we have to access its 4144 // Strings may get concurrently truncated, hence we have to access its
4122 // length synchronized. 4145 // length synchronized.
4123 return SeqOneByteString::SizeFor( 4146 return SeqOneByteString::SizeFor(
4124 reinterpret_cast<SeqOneByteString*>(this)->synchronized_length()); 4147 reinterpret_cast<SeqOneByteString*>(this)->synchronized_length());
4125 } 4148 }
4126 if (instance_type == BYTE_ARRAY_TYPE) { 4149 if (instance_type == BYTE_ARRAY_TYPE) {
4127 return reinterpret_cast<ByteArray*>(this)->ByteArraySize(); 4150 return reinterpret_cast<ByteArray*>(this)->ByteArraySize();
4128 } 4151 }
4152 if (instance_type == BYTECODE_ARRAY_TYPE) {
4153 return reinterpret_cast<BytecodeArray*>(this)->BytecodeArraySize();
4154 }
4129 if (instance_type == FREE_SPACE_TYPE) { 4155 if (instance_type == FREE_SPACE_TYPE) {
4130 return reinterpret_cast<FreeSpace*>(this)->nobarrier_size(); 4156 return reinterpret_cast<FreeSpace*>(this)->nobarrier_size();
4131 } 4157 }
4132 if (instance_type == STRING_TYPE || 4158 if (instance_type == STRING_TYPE ||
4133 instance_type == INTERNALIZED_STRING_TYPE) { 4159 instance_type == INTERNALIZED_STRING_TYPE) {
4134 // Strings may get concurrently truncated, hence we have to access its 4160 // Strings may get concurrently truncated, hence we have to access its
4135 // length synchronized. 4161 // length synchronized.
4136 return SeqTwoByteString::SizeFor( 4162 return SeqTwoByteString::SizeFor(
4137 reinterpret_cast<SeqTwoByteString*>(this)->synchronized_length()); 4163 reinterpret_cast<SeqTwoByteString*>(this)->synchronized_length());
4138 } 4164 }
(...skipping 1363 matching lines...) Expand 10 before | Expand all | Expand 10 after
5502 return function_data()->IsSmi(); 5528 return function_data()->IsSmi();
5503 } 5529 }
5504 5530
5505 5531
5506 BuiltinFunctionId SharedFunctionInfo::builtin_function_id() { 5532 BuiltinFunctionId SharedFunctionInfo::builtin_function_id() {
5507 DCHECK(HasBuiltinFunctionId()); 5533 DCHECK(HasBuiltinFunctionId());
5508 return static_cast<BuiltinFunctionId>(Smi::cast(function_data())->value()); 5534 return static_cast<BuiltinFunctionId>(Smi::cast(function_data())->value());
5509 } 5535 }
5510 5536
5511 5537
5538 bool SharedFunctionInfo::HasBytecodeArray() {
5539 return function_data()->IsBytecodeArray();
5540 }
5541
5542
5543 BytecodeArray* SharedFunctionInfo::bytecode_array() {
5544 DCHECK(HasBytecodeArray());
5545 return BytecodeArray::cast(function_data());
5546 }
5547
5548
5512 int SharedFunctionInfo::ic_age() { 5549 int SharedFunctionInfo::ic_age() {
5513 return ICAgeBits::decode(counters()); 5550 return ICAgeBits::decode(counters());
5514 } 5551 }
5515 5552
5516 5553
5517 void SharedFunctionInfo::set_ic_age(int ic_age) { 5554 void SharedFunctionInfo::set_ic_age(int ic_age) {
5518 set_counters(ICAgeBits::update(counters(), ic_age)); 5555 set_counters(ICAgeBits::update(counters(), ic_age));
5519 } 5556 }
5520 5557
5521 5558
(...skipping 1792 matching lines...) Expand 10 before | Expand all | Expand 10 after
7314 #undef READ_SHORT_FIELD 7351 #undef READ_SHORT_FIELD
7315 #undef WRITE_SHORT_FIELD 7352 #undef WRITE_SHORT_FIELD
7316 #undef READ_BYTE_FIELD 7353 #undef READ_BYTE_FIELD
7317 #undef WRITE_BYTE_FIELD 7354 #undef WRITE_BYTE_FIELD
7318 #undef NOBARRIER_READ_BYTE_FIELD 7355 #undef NOBARRIER_READ_BYTE_FIELD
7319 #undef NOBARRIER_WRITE_BYTE_FIELD 7356 #undef NOBARRIER_WRITE_BYTE_FIELD
7320 7357
7321 } } // namespace v8::internal 7358 } } // namespace v8::internal
7322 7359
7323 #endif // V8_OBJECTS_INL_H_ 7360 #endif // V8_OBJECTS_INL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698