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 4869 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4880 return is_crankshafted() && kind() != OPTIMIZED_FUNCTION; | 4880 return is_crankshafted() && kind() != OPTIMIZED_FUNCTION; |
4881 } | 4881 } |
4882 | 4882 |
4883 inline bool Code::is_interpreter_trampoline_builtin() { | 4883 inline bool Code::is_interpreter_trampoline_builtin() { |
4884 Builtins* builtins = GetIsolate()->builtins(); | 4884 Builtins* builtins = GetIsolate()->builtins(); |
4885 return this == *builtins->InterpreterEntryTrampoline() || | 4885 return this == *builtins->InterpreterEntryTrampoline() || |
4886 this == *builtins->InterpreterEnterBytecodeDispatch() || | 4886 this == *builtins->InterpreterEnterBytecodeDispatch() || |
4887 this == *builtins->InterpreterMarkBaselineOnReturn(); | 4887 this == *builtins->InterpreterMarkBaselineOnReturn(); |
4888 } | 4888 } |
4889 | 4889 |
4890 inline bool Code::has_unwinding_info() const { | |
4891 return HasUnwindingInfoField::decode(READ_UINT32_FIELD(this, kFlagsOffset)); | |
4892 } | |
4893 | |
4894 inline void Code::set_has_unwinding_info(bool state) { | |
4895 uint32_t previous = READ_UINT32_FIELD(this, kFlagsOffset); | |
4896 uint32_t updated_value = HasUnwindingInfoField::update(previous, state); | |
4897 WRITE_UINT32_FIELD(this, kFlagsOffset, updated_value); | |
4898 } | |
4899 | |
4890 inline void Code::set_is_crankshafted(bool value) { | 4900 inline void Code::set_is_crankshafted(bool value) { |
4891 int previous = READ_UINT32_FIELD(this, kKindSpecificFlags2Offset); | 4901 int previous = READ_UINT32_FIELD(this, kKindSpecificFlags2Offset); |
4892 int updated = IsCrankshaftedField::update(previous, value); | 4902 int updated = IsCrankshaftedField::update(previous, value); |
4893 WRITE_UINT32_FIELD(this, kKindSpecificFlags2Offset, updated); | 4903 WRITE_UINT32_FIELD(this, kKindSpecificFlags2Offset, updated); |
4894 } | 4904 } |
4895 | 4905 |
4896 | 4906 |
4897 inline bool Code::is_turbofanned() { | 4907 inline bool Code::is_turbofanned() { |
4898 return IsTurbofannedField::decode( | 4908 return IsTurbofannedField::decode( |
4899 READ_UINT32_FIELD(this, kKindSpecificFlags1Offset)); | 4909 READ_UINT32_FIELD(this, kKindSpecificFlags1Offset)); |
(...skipping 1502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6402 | 6412 |
6403 INT_ACCESSORS(Code, instruction_size, kInstructionSizeOffset) | 6413 INT_ACCESSORS(Code, instruction_size, kInstructionSizeOffset) |
6404 INT_ACCESSORS(Code, prologue_offset, kPrologueOffset) | 6414 INT_ACCESSORS(Code, prologue_offset, kPrologueOffset) |
6405 INT_ACCESSORS(Code, constant_pool_offset, kConstantPoolOffset) | 6415 INT_ACCESSORS(Code, constant_pool_offset, kConstantPoolOffset) |
6406 ACCESSORS(Code, relocation_info, ByteArray, kRelocationInfoOffset) | 6416 ACCESSORS(Code, relocation_info, ByteArray, kRelocationInfoOffset) |
6407 ACCESSORS(Code, handler_table, FixedArray, kHandlerTableOffset) | 6417 ACCESSORS(Code, handler_table, FixedArray, kHandlerTableOffset) |
6408 ACCESSORS(Code, deoptimization_data, FixedArray, kDeoptimizationDataOffset) | 6418 ACCESSORS(Code, deoptimization_data, FixedArray, kDeoptimizationDataOffset) |
6409 ACCESSORS(Code, raw_type_feedback_info, Object, kTypeFeedbackInfoOffset) | 6419 ACCESSORS(Code, raw_type_feedback_info, Object, kTypeFeedbackInfoOffset) |
6410 ACCESSORS(Code, next_code_link, Object, kNextCodeLinkOffset) | 6420 ACCESSORS(Code, next_code_link, Object, kNextCodeLinkOffset) |
6411 | 6421 |
6422 int Code::unwinding_info_size() const { | |
6423 DCHECK(has_unwinding_info()); | |
6424 int field_offset = RoundUp(kHeaderSize + instruction_size(), kInt64Size); | |
6425 return static_cast<int>(READ_UINT64_FIELD(this, field_offset)); | |
6426 } | |
6427 | |
6428 void Code::set_unwinding_info_size(int value) { | |
6429 DCHECK(has_unwinding_info()); | |
6430 int field_offset = RoundUp(kHeaderSize + instruction_size(), kInt64Size); | |
rmcilroy
2016/06/21 13:47:43
Factor out the code to get the offset of the unwin
Stefano Sanfilippo
2016/06/23 15:23:43
Done.
| |
6431 WRITE_UINT64_FIELD(this, field_offset, value); | |
6432 } | |
6412 | 6433 |
6413 void Code::WipeOutHeader() { | 6434 void Code::WipeOutHeader() { |
6414 WRITE_FIELD(this, kRelocationInfoOffset, NULL); | 6435 WRITE_FIELD(this, kRelocationInfoOffset, NULL); |
6415 WRITE_FIELD(this, kHandlerTableOffset, NULL); | 6436 WRITE_FIELD(this, kHandlerTableOffset, NULL); |
6416 WRITE_FIELD(this, kDeoptimizationDataOffset, NULL); | 6437 WRITE_FIELD(this, kDeoptimizationDataOffset, NULL); |
6417 // Do not wipe out major/minor keys on a code stub or IC | 6438 // Do not wipe out major/minor keys on a code stub or IC |
6418 if (!READ_FIELD(this, kTypeFeedbackInfoOffset)->IsSmi()) { | 6439 if (!READ_FIELD(this, kTypeFeedbackInfoOffset)->IsSmi()) { |
6419 WRITE_FIELD(this, kTypeFeedbackInfoOffset, NULL); | 6440 WRITE_FIELD(this, kTypeFeedbackInfoOffset, NULL); |
6420 } | 6441 } |
6421 WRITE_FIELD(this, kNextCodeLinkOffset, NULL); | 6442 WRITE_FIELD(this, kNextCodeLinkOffset, NULL); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6456 | 6477 |
6457 byte* Code::instruction_start() { | 6478 byte* Code::instruction_start() { |
6458 return FIELD_ADDR(this, kHeaderSize); | 6479 return FIELD_ADDR(this, kHeaderSize); |
6459 } | 6480 } |
6460 | 6481 |
6461 | 6482 |
6462 byte* Code::instruction_end() { | 6483 byte* Code::instruction_end() { |
6463 return instruction_start() + instruction_size(); | 6484 return instruction_start() + instruction_size(); |
6464 } | 6485 } |
6465 | 6486 |
6487 byte* Code::unwinding_info_start() { | |
6488 DCHECK(has_unwinding_info()); | |
6489 return RoundUp(instruction_end(), kInt64Size) + kInt64Size; | |
6490 } | |
6491 | |
6492 byte* Code::unwinding_info_end() { | |
6493 DCHECK(has_unwinding_info()); | |
6494 return unwinding_info_start() + unwinding_info_size(); | |
6495 } | |
6466 | 6496 |
6467 int Code::body_size() { | 6497 int Code::body_size() { |
6468 return RoundUp(instruction_size(), kObjectAlignment); | 6498 int unpadded_body_size = |
6499 has_unwinding_info() | |
6500 ? static_cast<int>(unwinding_info_end() - instruction_start()) | |
6501 : instruction_size(); | |
6502 return RoundUp(unpadded_body_size, kObjectAlignment); | |
6469 } | 6503 } |
6470 | 6504 |
6471 int Code::SizeIncludingMetadata() { | 6505 int Code::SizeIncludingMetadata() { |
6472 int size = CodeSize(); | 6506 int size = CodeSize(); |
6473 size += relocation_info()->Size(); | 6507 size += relocation_info()->Size(); |
6474 size += deoptimization_data()->Size(); | 6508 size += deoptimization_data()->Size(); |
6475 size += handler_table()->Size(); | 6509 size += handler_table()->Size(); |
6476 return size; | 6510 return size; |
6477 } | 6511 } |
6478 | 6512 |
(...skipping 1430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7909 #undef WRITE_INT64_FIELD | 7943 #undef WRITE_INT64_FIELD |
7910 #undef READ_BYTE_FIELD | 7944 #undef READ_BYTE_FIELD |
7911 #undef WRITE_BYTE_FIELD | 7945 #undef WRITE_BYTE_FIELD |
7912 #undef NOBARRIER_READ_BYTE_FIELD | 7946 #undef NOBARRIER_READ_BYTE_FIELD |
7913 #undef NOBARRIER_WRITE_BYTE_FIELD | 7947 #undef NOBARRIER_WRITE_BYTE_FIELD |
7914 | 7948 |
7915 } // namespace internal | 7949 } // namespace internal |
7916 } // namespace v8 | 7950 } // namespace v8 |
7917 | 7951 |
7918 #endif // V8_OBJECTS_INL_H_ | 7952 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |