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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
86 #include "src/x87/macro-assembler-x87.h" | 86 #include "src/x87/macro-assembler-x87.h" |
87 #else | 87 #else |
88 #error Unsupported target architecture. | 88 #error Unsupported target architecture. |
89 #endif | 89 #endif |
90 | 90 |
91 namespace v8 { | 91 namespace v8 { |
92 namespace internal { | 92 namespace internal { |
93 | 93 |
94 class FrameScope { | 94 class FrameScope { |
95 public: | 95 public: |
96 explicit FrameScope(MacroAssembler* masm, StackFrame::Type type) | 96 explicit FrameScope(MacroAssembler* masm, StackFrame::Type type, |
97 bool enter_frame = true) | |
rmcilroy
2014/09/26 15:54:57
I don't like this default argument. Rethinking thi
baixo
2014/10/02 09:18:21
I was worried about code duplication, since this c
| |
97 : masm_(masm), type_(type), old_has_frame_(masm->has_frame()) { | 98 : masm_(masm), type_(type), old_has_frame_(masm->has_frame()) { |
98 masm->set_has_frame(true); | 99 masm->set_has_frame(true); |
99 if (type != StackFrame::MANUAL && type_ != StackFrame::NONE) { | 100 if (enter_frame && type != StackFrame::MANUAL && |
101 type_ != StackFrame::NONE) { | |
100 masm->EnterFrame(type); | 102 masm->EnterFrame(type); |
101 } | 103 } |
102 } | 104 } |
103 | 105 |
104 ~FrameScope() { | 106 ~FrameScope() { |
105 if (type_ != StackFrame::MANUAL && type_ != StackFrame::NONE) { | 107 if (type_ != StackFrame::MANUAL && type_ != StackFrame::NONE) { |
106 masm_->LeaveFrame(type_); | 108 masm_->LeaveFrame(type_); |
107 } | 109 } |
108 masm_->set_has_frame(old_has_frame_); | 110 masm_->set_has_frame(old_has_frame_); |
109 } | 111 } |
110 | 112 |
111 // Normally we generate the leave-frame code when this object goes | 113 // Normally we generate the leave-frame code when this object goes |
112 // out of scope. Sometimes we may need to generate the code somewhere else | 114 // out of scope. Sometimes we may need to generate the code somewhere else |
113 // in addition. Calling this will achieve that, but the object stays in | 115 // in addition. Calling this will achieve that, but the object stays in |
114 // scope, the MacroAssembler is still marked as being in a frame scope, and | 116 // scope, the MacroAssembler is still marked as being in a frame scope, and |
115 // the code will be generated again when it goes out of scope. | 117 // the code will be generated again when it goes out of scope. |
116 void GenerateLeaveFrame() { | 118 void GenerateLeaveFrame() { |
117 DCHECK(type_ != StackFrame::MANUAL && type_ != StackFrame::NONE); | 119 DCHECK(type_ != StackFrame::MANUAL && type_ != StackFrame::NONE); |
118 masm_->LeaveFrame(type_); | 120 masm_->LeaveFrame(type_); |
119 } | 121 } |
120 | 122 |
121 private: | 123 protected: |
122 MacroAssembler* masm_; | 124 MacroAssembler* masm_; |
123 StackFrame::Type type_; | 125 StackFrame::Type type_; |
124 bool old_has_frame_; | 126 bool old_has_frame_; |
125 }; | 127 }; |
126 | 128 |
129 class FrameAndConstantPoolScope : public FrameScope { | |
130 public: | |
131 FrameAndConstantPoolScope(MacroAssembler* masm, StackFrame::Type type) | |
132 : FrameScope(masm, type, false), | |
133 old_constant_pool_available_(masm->is_constant_pool_available()) { | |
134 // We only want to enable constant pool access for non-manual frame scopes | |
135 // to ensure the constant pool pointer is valid throughout the scope. | |
136 DCHECK(type_ != StackFrame::MANUAL && type_ != StackFrame::NONE); | |
137 masm->set_constant_pool_available(true); | |
138 masm->EnterFrame(type, !old_constant_pool_available_); | |
139 } | |
140 | |
141 ~FrameAndConstantPoolScope() { | |
142 masm_->set_constant_pool_available(old_constant_pool_available_); | |
143 } | |
144 | |
145 private: | |
146 bool old_constant_pool_available_; | |
147 | |
148 DISALLOW_IMPLICIT_CONSTRUCTORS(FrameAndConstantPoolScope); | |
149 }; | |
150 | |
127 | 151 |
128 class AllowExternalCallThatCantCauseGC: public FrameScope { | 152 class AllowExternalCallThatCantCauseGC: public FrameScope { |
129 public: | 153 public: |
130 explicit AllowExternalCallThatCantCauseGC(MacroAssembler* masm) | 154 explicit AllowExternalCallThatCantCauseGC(MacroAssembler* masm) |
131 : FrameScope(masm, StackFrame::NONE) { } | 155 : FrameScope(masm, StackFrame::NONE) { } |
132 }; | 156 }; |
133 | 157 |
134 | 158 |
135 class NoCurrentFrameScope { | 159 class NoCurrentFrameScope { |
136 public: | 160 public: |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
196 isolate); | 220 isolate); |
197 } | 221 } |
198 return ExternalReference::new_space_allocation_limit_address(isolate); | 222 return ExternalReference::new_space_allocation_limit_address(isolate); |
199 } | 223 } |
200 }; | 224 }; |
201 | 225 |
202 | 226 |
203 } } // namespace v8::internal | 227 } } // namespace v8::internal |
204 | 228 |
205 #endif // V8_MACRO_ASSEMBLER_H_ | 229 #endif // V8_MACRO_ASSEMBLER_H_ |
OLD | NEW |