OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 10 matching lines...) Expand all Loading... |
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
28 #ifndef V8_CODEGEN_ARM_H_ | 28 #ifndef V8_CODEGEN_ARM_H_ |
29 #define V8_CODEGEN_ARM_H_ | 29 #define V8_CODEGEN_ARM_H_ |
30 | 30 |
31 #include "scopes.h" | |
32 | |
33 namespace v8 { namespace internal { | 31 namespace v8 { namespace internal { |
34 | 32 |
35 // Forward declarations | 33 // Forward declarations |
36 class DeferredCode; | 34 class DeferredCode; |
| 35 class RegisterAllocator; |
| 36 class RegisterFile; |
37 | 37 |
38 // Mode to overwrite BinaryExpression values. | 38 // Mode to overwrite BinaryExpression values. |
39 enum OverwriteMode { NO_OVERWRITE, OVERWRITE_LEFT, OVERWRITE_RIGHT }; | 39 enum OverwriteMode { NO_OVERWRITE, OVERWRITE_LEFT, OVERWRITE_RIGHT }; |
40 | 40 |
41 enum InitState { CONST_INIT, NOT_CONST_INIT }; | 41 enum InitState { CONST_INIT, NOT_CONST_INIT }; |
42 enum TypeofState { INSIDE_TYPEOF, NOT_INSIDE_TYPEOF }; | 42 enum TypeofState { INSIDE_TYPEOF, NOT_INSIDE_TYPEOF }; |
43 | 43 |
44 | 44 |
45 // ------------------------------------------------------------------------- | 45 // ------------------------------------------------------------------------- |
46 // Reference support | 46 // Reference support |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 | 213 |
214 #define DEF_VISIT(type) \ | 214 #define DEF_VISIT(type) \ |
215 void Visit##type(type* node); | 215 void Visit##type(type* node); |
216 NODE_LIST(DEF_VISIT) | 216 NODE_LIST(DEF_VISIT) |
217 #undef DEF_VISIT | 217 #undef DEF_VISIT |
218 | 218 |
219 // Visit a statement and then spill the virtual frame if control flow can | 219 // Visit a statement and then spill the virtual frame if control flow can |
220 // reach the end of the statement (ie, it does not exit via break, | 220 // reach the end of the statement (ie, it does not exit via break, |
221 // continue, return, or throw). This function is used temporarily while | 221 // continue, return, or throw). This function is used temporarily while |
222 // the code generator is being transformed. | 222 // the code generator is being transformed. |
223 void VisitAndSpill(Statement* statement) { | 223 void VisitAndSpill(Statement* statement); |
224 ASSERT(in_spilled_code()); | |
225 set_in_spilled_code(false); | |
226 Visit(statement); | |
227 if (frame_ != NULL) { | |
228 frame_->SpillAll(); | |
229 } | |
230 set_in_spilled_code(true); | |
231 } | |
232 | 224 |
233 // Visit a list of statements and then spill the virtual frame if control | 225 // Visit a list of statements and then spill the virtual frame if control |
234 // flow can reach the end of the list. | 226 // flow can reach the end of the list. |
235 void VisitStatementsAndSpill(ZoneList<Statement*>* statements) { | 227 void VisitStatementsAndSpill(ZoneList<Statement*>* statements); |
236 ASSERT(in_spilled_code()); | |
237 set_in_spilled_code(false); | |
238 VisitStatements(statements); | |
239 if (frame_ != NULL) { | |
240 frame_->SpillAll(); | |
241 } | |
242 set_in_spilled_code(true); | |
243 } | |
244 | 228 |
245 // Main code generation function | 229 // Main code generation function |
246 void GenCode(FunctionLiteral* fun); | 230 void GenCode(FunctionLiteral* fun); |
247 | 231 |
248 // The following are used by class Reference. | 232 // The following are used by class Reference. |
249 void LoadReference(Reference* ref); | 233 void LoadReference(Reference* ref); |
250 void UnloadReference(Reference* ref); | 234 void UnloadReference(Reference* ref); |
251 | 235 |
252 MemOperand ContextOperand(Register context, int index) const { | 236 MemOperand ContextOperand(Register context, int index) const { |
253 return MemOperand(context, Context::SlotOffset(index)); | 237 return MemOperand(context, Context::SlotOffset(index)); |
(...skipping 17 matching lines...) Expand all Loading... |
271 JumpTarget* false_target, | 255 JumpTarget* false_target, |
272 bool force_cc); | 256 bool force_cc); |
273 void Load(Expression* x, TypeofState typeof_state = NOT_INSIDE_TYPEOF); | 257 void Load(Expression* x, TypeofState typeof_state = NOT_INSIDE_TYPEOF); |
274 void LoadGlobal(); | 258 void LoadGlobal(); |
275 void LoadGlobalReceiver(Register scratch); | 259 void LoadGlobalReceiver(Register scratch); |
276 | 260 |
277 // Generate code to push the value of an expression on top of the frame | 261 // Generate code to push the value of an expression on top of the frame |
278 // and then spill the frame fully to memory. This function is used | 262 // and then spill the frame fully to memory. This function is used |
279 // temporarily while the code generator is being transformed. | 263 // temporarily while the code generator is being transformed. |
280 void LoadAndSpill(Expression* expression, | 264 void LoadAndSpill(Expression* expression, |
281 TypeofState typeof_state = NOT_INSIDE_TYPEOF) { | 265 TypeofState typeof_state = NOT_INSIDE_TYPEOF); |
282 ASSERT(in_spilled_code()); | |
283 set_in_spilled_code(false); | |
284 Load(expression, typeof_state); | |
285 frame_->SpillAll(); | |
286 set_in_spilled_code(true); | |
287 } | |
288 | 266 |
289 // Call LoadCondition and then spill the virtual frame unless control flow | 267 // Call LoadCondition and then spill the virtual frame unless control flow |
290 // cannot reach the end of the expression (ie, by emitting only | 268 // cannot reach the end of the expression (ie, by emitting only |
291 // unconditional jumps to the control targets). | 269 // unconditional jumps to the control targets). |
292 void LoadConditionAndSpill(Expression* expression, | 270 void LoadConditionAndSpill(Expression* expression, |
293 TypeofState typeof_state, | 271 TypeofState typeof_state, |
294 JumpTarget* true_target, | 272 JumpTarget* true_target, |
295 JumpTarget* false_target, | 273 JumpTarget* false_target, |
296 bool force_control) { | 274 bool force_control); |
297 ASSERT(in_spilled_code()); | |
298 set_in_spilled_code(false); | |
299 LoadCondition(expression, typeof_state, true_target, false_target, | |
300 force_control); | |
301 if (frame_ != NULL) { | |
302 frame_->SpillAll(); | |
303 } | |
304 set_in_spilled_code(true); | |
305 } | |
306 | 275 |
307 // Read a value from a slot and leave it on top of the expression stack. | 276 // Read a value from a slot and leave it on top of the expression stack. |
308 void LoadFromSlot(Slot* slot, TypeofState typeof_state); | 277 void LoadFromSlot(Slot* slot, TypeofState typeof_state); |
309 void LoadFromGlobalSlotCheckExtensions(Slot* slot, | 278 void LoadFromGlobalSlotCheckExtensions(Slot* slot, |
310 TypeofState typeof_state, | 279 TypeofState typeof_state, |
311 Register tmp, | 280 Register tmp, |
312 Register tmp2, | 281 Register tmp2, |
313 JumpTarget* slow); | 282 JumpTarget* slow); |
314 | 283 |
315 // Special code for typeof expressions: Unfortunately, we must | 284 // Special code for typeof expressions: Unfortunately, we must |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
463 bool in_spilled_code_; | 432 bool in_spilled_code_; |
464 | 433 |
465 friend class VirtualFrame; | 434 friend class VirtualFrame; |
466 friend class JumpTarget; | 435 friend class JumpTarget; |
467 friend class Reference; | 436 friend class Reference; |
468 | 437 |
469 DISALLOW_COPY_AND_ASSIGN(CodeGenerator); | 438 DISALLOW_COPY_AND_ASSIGN(CodeGenerator); |
470 }; | 439 }; |
471 | 440 |
472 | 441 |
473 void Reference::GetValueAndSpill(TypeofState typeof_state) { | |
474 ASSERT(cgen_->in_spilled_code()); | |
475 cgen_->set_in_spilled_code(false); | |
476 GetValue(typeof_state); | |
477 cgen_->frame()->SpillAll(); | |
478 cgen_->set_in_spilled_code(true); | |
479 } | |
480 | |
481 | |
482 } } // namespace v8::internal | 442 } } // namespace v8::internal |
483 | 443 |
484 #endif // V8_CODEGEN_ARM_H_ | 444 #endif // V8_CODEGEN_ARM_H_ |
OLD | NEW |