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 #ifndef V8_MACRO_ASSEMBLER_H_ | 5 #ifndef V8_MACRO_ASSEMBLER_H_ |
6 #define V8_MACRO_ASSEMBLER_H_ | 6 #define V8_MACRO_ASSEMBLER_H_ |
7 | 7 |
8 | 8 |
9 // Helper types to make boolean flag easier to read at call-site. | 9 // Helper types to make boolean flag easier to read at call-site. |
10 enum InvokeFlag { | 10 enum InvokeFlag { |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 DCHECK(type_ != StackFrame::MANUAL && type_ != StackFrame::NONE); | 117 DCHECK(type_ != StackFrame::MANUAL && type_ != StackFrame::NONE); |
118 masm_->LeaveFrame(type_); | 118 masm_->LeaveFrame(type_); |
119 } | 119 } |
120 | 120 |
121 private: | 121 private: |
122 MacroAssembler* masm_; | 122 MacroAssembler* masm_; |
123 StackFrame::Type type_; | 123 StackFrame::Type type_; |
124 bool old_has_frame_; | 124 bool old_has_frame_; |
125 }; | 125 }; |
126 | 126 |
| 127 class FrameAndConstantPoolScope { |
| 128 public: |
| 129 FrameAndConstantPoolScope(MacroAssembler* masm, StackFrame::Type type) |
| 130 : masm_(masm), |
| 131 type_(type), |
| 132 old_has_frame_(masm->has_frame()), |
| 133 old_constant_pool_available_(FLAG_enable_ool_constant_pool && |
| 134 masm->is_ool_constant_pool_available()) { |
| 135 masm->set_has_frame(true); |
| 136 if (FLAG_enable_ool_constant_pool) { |
| 137 masm->set_ool_constant_pool_available(true); |
| 138 } |
| 139 if (type_ != StackFrame::MANUAL && type_ != StackFrame::NONE) { |
| 140 masm->EnterFrame(type, !old_constant_pool_available_); |
| 141 } |
| 142 } |
| 143 |
| 144 ~FrameAndConstantPoolScope() { |
| 145 masm_->LeaveFrame(type_); |
| 146 masm_->set_has_frame(old_has_frame_); |
| 147 if (FLAG_enable_ool_constant_pool) { |
| 148 masm_->set_ool_constant_pool_available(old_constant_pool_available_); |
| 149 } |
| 150 } |
| 151 |
| 152 // Normally we generate the leave-frame code when this object goes |
| 153 // out of scope. Sometimes we may need to generate the code somewhere else |
| 154 // in addition. Calling this will achieve that, but the object stays in |
| 155 // scope, the MacroAssembler is still marked as being in a frame scope, and |
| 156 // the code will be generated again when it goes out of scope. |
| 157 void GenerateLeaveFrame() { |
| 158 DCHECK(type_ != StackFrame::MANUAL && type_ != StackFrame::NONE); |
| 159 masm_->LeaveFrame(type_); |
| 160 } |
| 161 |
| 162 private: |
| 163 MacroAssembler* masm_; |
| 164 StackFrame::Type type_; |
| 165 bool old_has_frame_; |
| 166 bool old_constant_pool_available_; |
| 167 |
| 168 DISALLOW_IMPLICIT_CONSTRUCTORS(FrameAndConstantPoolScope); |
| 169 }; |
| 170 |
| 171 // Class for scoping the the unavailability of constant pool access. |
| 172 class ConstantPoolUnavailableScope { |
| 173 public: |
| 174 explicit ConstantPoolUnavailableScope(MacroAssembler* masm) |
| 175 : masm_(masm), |
| 176 old_constant_pool_available_(FLAG_enable_ool_constant_pool && |
| 177 masm->is_ool_constant_pool_available()) { |
| 178 if (FLAG_enable_ool_constant_pool) { |
| 179 masm_->set_ool_constant_pool_available(false); |
| 180 } |
| 181 } |
| 182 ~ConstantPoolUnavailableScope() { |
| 183 if (FLAG_enable_ool_constant_pool) { |
| 184 masm_->set_ool_constant_pool_available(old_constant_pool_available_); |
| 185 } |
| 186 } |
| 187 |
| 188 private: |
| 189 MacroAssembler* masm_; |
| 190 int old_constant_pool_available_; |
| 191 |
| 192 DISALLOW_IMPLICIT_CONSTRUCTORS(ConstantPoolUnavailableScope); |
| 193 }; |
| 194 |
127 | 195 |
128 class AllowExternalCallThatCantCauseGC: public FrameScope { | 196 class AllowExternalCallThatCantCauseGC: public FrameScope { |
129 public: | 197 public: |
130 explicit AllowExternalCallThatCantCauseGC(MacroAssembler* masm) | 198 explicit AllowExternalCallThatCantCauseGC(MacroAssembler* masm) |
131 : FrameScope(masm, StackFrame::NONE) { } | 199 : FrameScope(masm, StackFrame::NONE) { } |
132 }; | 200 }; |
133 | 201 |
134 | 202 |
135 class NoCurrentFrameScope { | 203 class NoCurrentFrameScope { |
136 public: | 204 public: |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 isolate); | 264 isolate); |
197 } | 265 } |
198 return ExternalReference::new_space_allocation_limit_address(isolate); | 266 return ExternalReference::new_space_allocation_limit_address(isolate); |
199 } | 267 } |
200 }; | 268 }; |
201 | 269 |
202 | 270 |
203 } } // namespace v8::internal | 271 } } // namespace v8::internal |
204 | 272 |
205 #endif // V8_MACRO_ASSEMBLER_H_ | 273 #endif // V8_MACRO_ASSEMBLER_H_ |
OLD | NEW |