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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 const type* type::cast(const Object* object) { \ | 71 const type* type::cast(const Object* object) { \ |
72 SLOW_DCHECK(object->Is##type()); \ | 72 SLOW_DCHECK(object->Is##type()); \ |
73 return reinterpret_cast<const type*>(object); \ | 73 return reinterpret_cast<const type*>(object); \ |
74 } | 74 } |
75 | 75 |
76 | 76 |
77 #define INT_ACCESSORS(holder, name, offset) \ | 77 #define INT_ACCESSORS(holder, name, offset) \ |
78 int holder::name() const { return READ_INT_FIELD(this, offset); } \ | 78 int holder::name() const { return READ_INT_FIELD(this, offset); } \ |
79 void holder::set_##name(int value) { WRITE_INT_FIELD(this, offset, value); } | 79 void holder::set_##name(int value) { WRITE_INT_FIELD(this, offset, value); } |
80 | 80 |
81 | 81 #define ACCESSORS_CHECKED(holder, name, type, offset, condition) \ |
82 #define ACCESSORS(holder, name, type, offset) \ | 82 type* holder::name() const { \ |
83 type* holder::name() const { return type::cast(READ_FIELD(this, offset)); } \ | 83 DCHECK(condition); \ |
84 void holder::set_##name(type* value, WriteBarrierMode mode) { \ | 84 return type::cast(READ_FIELD(this, offset)); \ |
85 WRITE_FIELD(this, offset, value); \ | 85 } \ |
86 CONDITIONAL_WRITE_BARRIER(GetHeap(), this, offset, value, mode); \ | 86 void holder::set_##name(type* value, WriteBarrierMode mode) { \ |
| 87 DCHECK(condition); \ |
| 88 WRITE_FIELD(this, offset, value); \ |
| 89 CONDITIONAL_WRITE_BARRIER(GetHeap(), this, offset, value, mode); \ |
87 } | 90 } |
88 | 91 |
| 92 #define ACCESSORS(holder, name, type, offset) \ |
| 93 ACCESSORS_CHECKED(holder, name, type, offset, true) |
89 | 94 |
90 // Getter that returns a Smi as an int and writes an int as a Smi. | 95 // Getter that returns a Smi as an int and writes an int as a Smi. |
91 #define SMI_ACCESSORS(holder, name, offset) \ | 96 #define SMI_ACCESSORS_CHECKED(holder, name, offset, condition) \ |
92 int holder::name() const { \ | 97 int holder::name() const { \ |
93 Object* value = READ_FIELD(this, offset); \ | 98 DCHECK(condition); \ |
94 return Smi::cast(value)->value(); \ | 99 Object* value = READ_FIELD(this, offset); \ |
95 } \ | 100 return Smi::cast(value)->value(); \ |
96 void holder::set_##name(int value) { \ | 101 } \ |
97 WRITE_FIELD(this, offset, Smi::FromInt(value)); \ | 102 void holder::set_##name(int value) { \ |
| 103 DCHECK(condition); \ |
| 104 WRITE_FIELD(this, offset, Smi::FromInt(value)); \ |
98 } | 105 } |
99 | 106 |
| 107 #define SMI_ACCESSORS(holder, name, offset) \ |
| 108 SMI_ACCESSORS_CHECKED(holder, name, offset, true) |
| 109 |
100 #define SYNCHRONIZED_SMI_ACCESSORS(holder, name, offset) \ | 110 #define SYNCHRONIZED_SMI_ACCESSORS(holder, name, offset) \ |
101 int holder::synchronized_##name() const { \ | 111 int holder::synchronized_##name() const { \ |
102 Object* value = ACQUIRE_READ_FIELD(this, offset); \ | 112 Object* value = ACQUIRE_READ_FIELD(this, offset); \ |
103 return Smi::cast(value)->value(); \ | 113 return Smi::cast(value)->value(); \ |
104 } \ | 114 } \ |
105 void holder::synchronized_set_##name(int value) { \ | 115 void holder::synchronized_set_##name(int value) { \ |
106 RELEASE_WRITE_FIELD(this, offset, Smi::FromInt(value)); \ | 116 RELEASE_WRITE_FIELD(this, offset, Smi::FromInt(value)); \ |
107 } | 117 } |
108 | 118 |
109 #define NOBARRIER_SMI_ACCESSORS(holder, name, offset) \ | 119 #define NOBARRIER_SMI_ACCESSORS(holder, name, offset) \ |
(...skipping 5470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5580 | 5590 |
5581 ACCESSORS(Script, source, Object, kSourceOffset) | 5591 ACCESSORS(Script, source, Object, kSourceOffset) |
5582 ACCESSORS(Script, name, Object, kNameOffset) | 5592 ACCESSORS(Script, name, Object, kNameOffset) |
5583 SMI_ACCESSORS(Script, id, kIdOffset) | 5593 SMI_ACCESSORS(Script, id, kIdOffset) |
5584 SMI_ACCESSORS(Script, line_offset, kLineOffsetOffset) | 5594 SMI_ACCESSORS(Script, line_offset, kLineOffsetOffset) |
5585 SMI_ACCESSORS(Script, column_offset, kColumnOffsetOffset) | 5595 SMI_ACCESSORS(Script, column_offset, kColumnOffsetOffset) |
5586 ACCESSORS(Script, context_data, Object, kContextOffset) | 5596 ACCESSORS(Script, context_data, Object, kContextOffset) |
5587 ACCESSORS(Script, wrapper, HeapObject, kWrapperOffset) | 5597 ACCESSORS(Script, wrapper, HeapObject, kWrapperOffset) |
5588 SMI_ACCESSORS(Script, type, kTypeOffset) | 5598 SMI_ACCESSORS(Script, type, kTypeOffset) |
5589 ACCESSORS(Script, line_ends, Object, kLineEndsOffset) | 5599 ACCESSORS(Script, line_ends, Object, kLineEndsOffset) |
5590 ACCESSORS(Script, eval_from_shared, Object, kEvalFromSharedOffset) | 5600 ACCESSORS_CHECKED(Script, eval_from_shared, Object, kEvalFromSharedOffset, |
5591 SMI_ACCESSORS(Script, eval_from_position, kEvalFromPositionOffset) | 5601 this->type() != TYPE_WASM) |
| 5602 SMI_ACCESSORS_CHECKED(Script, eval_from_position, kEvalFromPositionOffset, |
| 5603 this->type() != TYPE_WASM) |
5592 ACCESSORS(Script, shared_function_infos, Object, kSharedFunctionInfosOffset) | 5604 ACCESSORS(Script, shared_function_infos, Object, kSharedFunctionInfosOffset) |
5593 SMI_ACCESSORS(Script, flags, kFlagsOffset) | 5605 SMI_ACCESSORS(Script, flags, kFlagsOffset) |
5594 ACCESSORS(Script, source_url, Object, kSourceUrlOffset) | 5606 ACCESSORS(Script, source_url, Object, kSourceUrlOffset) |
5595 ACCESSORS(Script, source_mapping_url, Object, kSourceMappingUrlOffset) | 5607 ACCESSORS(Script, source_mapping_url, Object, kSourceMappingUrlOffset) |
| 5608 ACCESSORS_CHECKED(Script, wasm_object, JSObject, kEvalFromSharedOffset, |
| 5609 this->type() == TYPE_WASM) |
| 5610 SMI_ACCESSORS_CHECKED(Script, wasm_function_index, kEvalFromPositionOffset, |
| 5611 this->type() == TYPE_WASM) |
5596 | 5612 |
5597 Script::CompilationType Script::compilation_type() { | 5613 Script::CompilationType Script::compilation_type() { |
5598 return BooleanBit::get(flags(), kCompilationTypeBit) ? | 5614 return BooleanBit::get(flags(), kCompilationTypeBit) ? |
5599 COMPILATION_TYPE_EVAL : COMPILATION_TYPE_HOST; | 5615 COMPILATION_TYPE_EVAL : COMPILATION_TYPE_HOST; |
5600 } | 5616 } |
5601 void Script::set_compilation_type(CompilationType type) { | 5617 void Script::set_compilation_type(CompilationType type) { |
5602 set_flags(BooleanBit::set(flags(), kCompilationTypeBit, | 5618 set_flags(BooleanBit::set(flags(), kCompilationTypeBit, |
5603 type == COMPILATION_TYPE_EVAL)); | 5619 type == COMPILATION_TYPE_EVAL)); |
5604 } | 5620 } |
5605 bool Script::hide_source() { return BooleanBit::get(flags(), kHideSourceBit); } | 5621 bool Script::hide_source() { return BooleanBit::get(flags(), kHideSourceBit); } |
(...skipping 2345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7951 #undef WRITE_INT64_FIELD | 7967 #undef WRITE_INT64_FIELD |
7952 #undef READ_BYTE_FIELD | 7968 #undef READ_BYTE_FIELD |
7953 #undef WRITE_BYTE_FIELD | 7969 #undef WRITE_BYTE_FIELD |
7954 #undef NOBARRIER_READ_BYTE_FIELD | 7970 #undef NOBARRIER_READ_BYTE_FIELD |
7955 #undef NOBARRIER_WRITE_BYTE_FIELD | 7971 #undef NOBARRIER_WRITE_BYTE_FIELD |
7956 | 7972 |
7957 } // namespace internal | 7973 } // namespace internal |
7958 } // namespace v8 | 7974 } // namespace v8 |
7959 | 7975 |
7960 #endif // V8_OBJECTS_INL_H_ | 7976 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |