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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 DCHECK(location() == kField); | 56 DCHECK(location() == kField); |
57 if (!FLAG_unbox_double_fields) return 1; | 57 if (!FLAG_unbox_double_fields) return 1; |
58 if (kDoubleSize == kPointerSize) return 1; | 58 if (kDoubleSize == kPointerSize) return 1; |
59 return representation().IsDouble() ? kDoubleSize / kPointerSize : 1; | 59 return representation().IsDouble() ? kDoubleSize / kPointerSize : 1; |
60 } | 60 } |
61 | 61 |
62 #define INT_ACCESSORS(holder, name, offset) \ | 62 #define INT_ACCESSORS(holder, name, offset) \ |
63 int holder::name() const { return READ_INT_FIELD(this, offset); } \ | 63 int holder::name() const { return READ_INT_FIELD(this, offset); } \ |
64 void holder::set_##name(int value) { WRITE_INT_FIELD(this, offset, value); } | 64 void holder::set_##name(int value) { WRITE_INT_FIELD(this, offset, value); } |
65 | 65 |
66 #define ACCESSORS_CHECKED(holder, name, type, offset, condition) \ | 66 #define ACCESSORS_CHECKED2(holder, name, type, offset, get_condition, \ |
67 type* holder::name() const { \ | 67 set_condition) \ |
68 DCHECK(condition); \ | 68 type* holder::name() const { \ |
69 return type::cast(READ_FIELD(this, offset)); \ | 69 DCHECK(get_condition); \ |
70 } \ | 70 return type::cast(READ_FIELD(this, offset)); \ |
71 void holder::set_##name(type* value, WriteBarrierMode mode) { \ | 71 } \ |
72 DCHECK(condition); \ | 72 void holder::set_##name(type* value, WriteBarrierMode mode) { \ |
73 WRITE_FIELD(this, offset, value); \ | 73 DCHECK(set_condition); \ |
74 CONDITIONAL_WRITE_BARRIER(GetHeap(), this, offset, value, mode); \ | 74 WRITE_FIELD(this, offset, value); \ |
| 75 CONDITIONAL_WRITE_BARRIER(GetHeap(), this, offset, value, mode); \ |
75 } | 76 } |
| 77 #define ACCESSORS_CHECKED(holder, name, type, offset, condition) \ |
| 78 ACCESSORS_CHECKED2(holder, name, type, offset, condition, condition) |
76 | 79 |
77 #define ACCESSORS(holder, name, type, offset) \ | 80 #define ACCESSORS(holder, name, type, offset) \ |
78 ACCESSORS_CHECKED(holder, name, type, offset, true) | 81 ACCESSORS_CHECKED(holder, name, type, offset, true) |
79 | 82 |
80 // Getter that returns a Smi as an int and writes an int as a Smi. | 83 // Getter that returns a Smi as an int and writes an int as a Smi. |
81 #define SMI_ACCESSORS_CHECKED(holder, name, offset, condition) \ | 84 #define SMI_ACCESSORS_CHECKED(holder, name, offset, condition) \ |
82 int holder::name() const { \ | 85 int holder::name() const { \ |
83 DCHECK(condition); \ | 86 DCHECK(condition); \ |
84 Object* value = READ_FIELD(this, offset); \ | 87 Object* value = READ_FIELD(this, offset); \ |
85 return Smi::cast(value)->value(); \ | 88 return Smi::cast(value)->value(); \ |
(...skipping 6687 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6773 ACCESSORS(JSMessageObject, argument, Object, kArgumentsOffset) | 6776 ACCESSORS(JSMessageObject, argument, Object, kArgumentsOffset) |
6774 ACCESSORS(JSMessageObject, script, Object, kScriptOffset) | 6777 ACCESSORS(JSMessageObject, script, Object, kScriptOffset) |
6775 ACCESSORS(JSMessageObject, stack_frames, Object, kStackFramesOffset) | 6778 ACCESSORS(JSMessageObject, stack_frames, Object, kStackFramesOffset) |
6776 SMI_ACCESSORS(JSMessageObject, start_position, kStartPositionOffset) | 6779 SMI_ACCESSORS(JSMessageObject, start_position, kStartPositionOffset) |
6777 SMI_ACCESSORS(JSMessageObject, end_position, kEndPositionOffset) | 6780 SMI_ACCESSORS(JSMessageObject, end_position, kEndPositionOffset) |
6778 SMI_ACCESSORS(JSMessageObject, error_level, kErrorLevelOffset) | 6781 SMI_ACCESSORS(JSMessageObject, error_level, kErrorLevelOffset) |
6779 | 6782 |
6780 INT_ACCESSORS(Code, instruction_size, kInstructionSizeOffset) | 6783 INT_ACCESSORS(Code, instruction_size, kInstructionSizeOffset) |
6781 INT_ACCESSORS(Code, prologue_offset, kPrologueOffset) | 6784 INT_ACCESSORS(Code, prologue_offset, kPrologueOffset) |
6782 INT_ACCESSORS(Code, constant_pool_offset, kConstantPoolOffset) | 6785 INT_ACCESSORS(Code, constant_pool_offset, kConstantPoolOffset) |
6783 ACCESSORS(Code, relocation_info, ByteArray, kRelocationInfoOffset) | 6786 #define CODE_ACCESSORS(name, type, offset) \ |
6784 ACCESSORS(Code, handler_table, FixedArray, kHandlerTableOffset) | 6787 ACCESSORS_CHECKED2(Code, name, type, offset, true, \ |
6785 ACCESSORS(Code, deoptimization_data, FixedArray, kDeoptimizationDataOffset) | 6788 !GetHeap()->InNewSpace(value)) |
6786 ACCESSORS(Code, source_position_table, ByteArray, kSourcePositionTableOffset) | 6789 CODE_ACCESSORS(relocation_info, ByteArray, kRelocationInfoOffset) |
6787 ACCESSORS(Code, protected_instructions, FixedArray, kProtectedInstructionOffset) | 6790 CODE_ACCESSORS(handler_table, FixedArray, kHandlerTableOffset) |
6788 ACCESSORS(Code, raw_type_feedback_info, Object, kTypeFeedbackInfoOffset) | 6791 CODE_ACCESSORS(deoptimization_data, FixedArray, kDeoptimizationDataOffset) |
6789 ACCESSORS(Code, next_code_link, Object, kNextCodeLinkOffset) | 6792 CODE_ACCESSORS(source_position_table, ByteArray, kSourcePositionTableOffset) |
| 6793 CODE_ACCESSORS(protected_instructions, FixedArray, kProtectedInstructionOffset) |
| 6794 CODE_ACCESSORS(raw_type_feedback_info, Object, kTypeFeedbackInfoOffset) |
| 6795 CODE_ACCESSORS(next_code_link, Object, kNextCodeLinkOffset) |
| 6796 #undef CODE_ACCESSORS |
6790 | 6797 |
6791 void Code::WipeOutHeader() { | 6798 void Code::WipeOutHeader() { |
6792 WRITE_FIELD(this, kRelocationInfoOffset, NULL); | 6799 WRITE_FIELD(this, kRelocationInfoOffset, NULL); |
6793 WRITE_FIELD(this, kHandlerTableOffset, NULL); | 6800 WRITE_FIELD(this, kHandlerTableOffset, NULL); |
6794 WRITE_FIELD(this, kDeoptimizationDataOffset, NULL); | 6801 WRITE_FIELD(this, kDeoptimizationDataOffset, NULL); |
6795 WRITE_FIELD(this, kSourcePositionTableOffset, NULL); | 6802 WRITE_FIELD(this, kSourcePositionTableOffset, NULL); |
6796 // Do not wipe out major/minor keys on a code stub or IC | 6803 // Do not wipe out major/minor keys on a code stub or IC |
6797 if (!READ_FIELD(this, kTypeFeedbackInfoOffset)->IsSmi()) { | 6804 if (!READ_FIELD(this, kTypeFeedbackInfoOffset)->IsSmi()) { |
6798 WRITE_FIELD(this, kTypeFeedbackInfoOffset, NULL); | 6805 WRITE_FIELD(this, kTypeFeedbackInfoOffset, NULL); |
6799 } | 6806 } |
(...skipping 1585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8385 | 8392 |
8386 ACCESSORS(JSArrayIterator, object, Object, kIteratedObjectOffset) | 8393 ACCESSORS(JSArrayIterator, object, Object, kIteratedObjectOffset) |
8387 ACCESSORS(JSArrayIterator, index, Object, kNextIndexOffset) | 8394 ACCESSORS(JSArrayIterator, index, Object, kNextIndexOffset) |
8388 ACCESSORS(JSArrayIterator, object_map, Object, kIteratedObjectMapOffset) | 8395 ACCESSORS(JSArrayIterator, object_map, Object, kIteratedObjectMapOffset) |
8389 | 8396 |
8390 ACCESSORS(JSStringIterator, string, String, kStringOffset) | 8397 ACCESSORS(JSStringIterator, string, String, kStringOffset) |
8391 SMI_ACCESSORS(JSStringIterator, index, kNextIndexOffset) | 8398 SMI_ACCESSORS(JSStringIterator, index, kNextIndexOffset) |
8392 | 8399 |
8393 #undef INT_ACCESSORS | 8400 #undef INT_ACCESSORS |
8394 #undef ACCESSORS | 8401 #undef ACCESSORS |
| 8402 #undef ACCESSORS_CHECKED |
| 8403 #undef ACCESSORS_CHECKED2 |
8395 #undef SMI_ACCESSORS | 8404 #undef SMI_ACCESSORS |
8396 #undef SYNCHRONIZED_SMI_ACCESSORS | 8405 #undef SYNCHRONIZED_SMI_ACCESSORS |
8397 #undef NOBARRIER_SMI_ACCESSORS | 8406 #undef NOBARRIER_SMI_ACCESSORS |
8398 #undef BOOL_GETTER | 8407 #undef BOOL_GETTER |
8399 #undef BOOL_ACCESSORS | 8408 #undef BOOL_ACCESSORS |
8400 #undef FIELD_ADDR | 8409 #undef FIELD_ADDR |
8401 #undef FIELD_ADDR_CONST | 8410 #undef FIELD_ADDR_CONST |
8402 #undef READ_FIELD | 8411 #undef READ_FIELD |
8403 #undef NOBARRIER_READ_FIELD | 8412 #undef NOBARRIER_READ_FIELD |
8404 #undef WRITE_FIELD | 8413 #undef WRITE_FIELD |
(...skipping 26 matching lines...) Expand all Loading... |
8431 #undef WRITE_INT64_FIELD | 8440 #undef WRITE_INT64_FIELD |
8432 #undef READ_BYTE_FIELD | 8441 #undef READ_BYTE_FIELD |
8433 #undef WRITE_BYTE_FIELD | 8442 #undef WRITE_BYTE_FIELD |
8434 #undef NOBARRIER_READ_BYTE_FIELD | 8443 #undef NOBARRIER_READ_BYTE_FIELD |
8435 #undef NOBARRIER_WRITE_BYTE_FIELD | 8444 #undef NOBARRIER_WRITE_BYTE_FIELD |
8436 | 8445 |
8437 } // namespace internal | 8446 } // namespace internal |
8438 } // namespace v8 | 8447 } // namespace v8 |
8439 | 8448 |
8440 #endif // V8_OBJECTS_INL_H_ | 8449 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |