OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 Label* materialize_true, | 289 Label* materialize_true, |
290 Label* materialize_false); | 290 Label* materialize_false); |
291 | 291 |
292 // Emit code to convert constant control flow (true or false) into | 292 // Emit code to convert constant control flow (true or false) into |
293 // the result expected according to an expression context. | 293 // the result expected according to an expression context. |
294 void Apply(Expression::Context context, bool flag); | 294 void Apply(Expression::Context context, bool flag); |
295 | 295 |
296 // Helper function to convert a pure value into a test context. The value | 296 // Helper function to convert a pure value into a test context. The value |
297 // is expected on the stack or the accumulator, depending on the platform. | 297 // is expected on the stack or the accumulator, depending on the platform. |
298 // See the platform-specific implementation for details. | 298 // See the platform-specific implementation for details. |
299 void DoTest(Expression::Context context); | 299 void DoTest(Label* if_true, Label* if_false, Label* fall_through); |
| 300 |
| 301 // Helper function to split control flow and avoid a branch to the |
| 302 // fall-through label if it is set up. |
| 303 void Split(Condition cc, |
| 304 Label* if_true, |
| 305 Label* if_false, |
| 306 Label* fall_through); |
300 | 307 |
301 void Move(Slot* dst, Register source, Register scratch1, Register scratch2); | 308 void Move(Slot* dst, Register source, Register scratch1, Register scratch2); |
302 void Move(Register dst, Slot* source); | 309 void Move(Register dst, Slot* source); |
303 | 310 |
304 // Return an operand used to read/write to a known (ie, non-LOOKUP) slot. | 311 // Return an operand used to read/write to a known (ie, non-LOOKUP) slot. |
305 // May emit code to traverse the context chain, destroying the scratch | 312 // May emit code to traverse the context chain, destroying the scratch |
306 // register. | 313 // register. |
307 MemOperand EmitSlotSearch(Slot* slot, Register scratch); | 314 MemOperand EmitSlotSearch(Slot* slot, Register scratch); |
308 | 315 |
309 void VisitForEffect(Expression* expr) { | 316 void VisitForEffect(Expression* expr) { |
(...skipping 19 matching lines...) Expand all Loading... |
329 Label* saved_false = false_label_; | 336 Label* saved_false = false_label_; |
330 context_ = Expression::kTest; | 337 context_ = Expression::kTest; |
331 true_label_ = if_true; | 338 true_label_ = if_true; |
332 false_label_ = if_false; | 339 false_label_ = if_false; |
333 Visit(expr); | 340 Visit(expr); |
334 context_ = saved_context; | 341 context_ = saved_context; |
335 true_label_ = saved_true; | 342 true_label_ = saved_true; |
336 false_label_ = saved_false; | 343 false_label_ = saved_false; |
337 } | 344 } |
338 | 345 |
339 void VisitForValueControl(Expression* expr, | |
340 Location where, | |
341 Label* if_true, | |
342 Label* if_false) { | |
343 Expression::Context saved_context = context_; | |
344 Location saved_location = location_; | |
345 Label* saved_true = true_label_; | |
346 Label* saved_false = false_label_; | |
347 context_ = Expression::kValueTest; | |
348 location_ = where; | |
349 true_label_ = if_true; | |
350 false_label_ = if_false; | |
351 Visit(expr); | |
352 context_ = saved_context; | |
353 location_ = saved_location; | |
354 true_label_ = saved_true; | |
355 false_label_ = saved_false; | |
356 } | |
357 | |
358 void VisitForControlValue(Expression* expr, | |
359 Location where, | |
360 Label* if_true, | |
361 Label* if_false) { | |
362 Expression::Context saved_context = context_; | |
363 Location saved_location = location_; | |
364 Label* saved_true = true_label_; | |
365 Label* saved_false = false_label_; | |
366 context_ = Expression::kTestValue; | |
367 location_ = where; | |
368 true_label_ = if_true; | |
369 false_label_ = if_false; | |
370 Visit(expr); | |
371 context_ = saved_context; | |
372 location_ = saved_location; | |
373 true_label_ = saved_true; | |
374 false_label_ = saved_false; | |
375 } | |
376 | |
377 void VisitDeclarations(ZoneList<Declaration*>* declarations); | 346 void VisitDeclarations(ZoneList<Declaration*>* declarations); |
378 void DeclareGlobals(Handle<FixedArray> pairs); | 347 void DeclareGlobals(Handle<FixedArray> pairs); |
379 | 348 |
380 // Platform-specific code for a variable, constant, or function | 349 // Platform-specific code for a variable, constant, or function |
381 // declaration. Functions have an initial value. | 350 // declaration. Functions have an initial value. |
382 void EmitDeclaration(Variable* variable, | 351 void EmitDeclaration(Variable* variable, |
383 Variable::Mode mode, | 352 Variable::Mode mode, |
384 FunctionLiteral* function); | 353 FunctionLiteral* function); |
385 | 354 |
386 // Platform-specific return sequence | 355 // Platform-specific return sequence |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
484 // Load a value from the current context. Indices are defined as an enum | 453 // Load a value from the current context. Indices are defined as an enum |
485 // in v8::internal::Context. | 454 // in v8::internal::Context. |
486 void LoadContextField(Register dst, int context_index); | 455 void LoadContextField(Register dst, int context_index); |
487 | 456 |
488 // AST node visit functions. | 457 // AST node visit functions. |
489 #define DECLARE_VISIT(type) virtual void Visit##type(type* node); | 458 #define DECLARE_VISIT(type) virtual void Visit##type(type* node); |
490 AST_NODE_LIST(DECLARE_VISIT) | 459 AST_NODE_LIST(DECLARE_VISIT) |
491 #undef DECLARE_VISIT | 460 #undef DECLARE_VISIT |
492 // Handles the shortcutted logical binary operations in VisitBinaryOperation. | 461 // Handles the shortcutted logical binary operations in VisitBinaryOperation. |
493 void EmitLogicalOperation(BinaryOperation* expr); | 462 void EmitLogicalOperation(BinaryOperation* expr); |
| 463 void VisitLogicalForValue(Expression* expr, |
| 464 Token::Value op, |
| 465 Location where, |
| 466 Label* done); |
| 467 |
494 | 468 |
495 MacroAssembler* masm_; | 469 MacroAssembler* masm_; |
496 CompilationInfo* info_; | 470 CompilationInfo* info_; |
497 | 471 |
498 Label return_label_; | 472 Label return_label_; |
499 NestedStatement* nesting_stack_; | 473 NestedStatement* nesting_stack_; |
500 int loop_depth_; | 474 int loop_depth_; |
501 | 475 |
502 Expression::Context context_; | 476 Expression::Context context_; |
503 Location location_; | 477 Location location_; |
504 Label* true_label_; | 478 Label* true_label_; |
505 Label* false_label_; | 479 Label* false_label_; |
506 | 480 |
507 friend class NestedStatement; | 481 friend class NestedStatement; |
508 | 482 |
509 DISALLOW_COPY_AND_ASSIGN(FullCodeGenerator); | 483 DISALLOW_COPY_AND_ASSIGN(FullCodeGenerator); |
510 }; | 484 }; |
511 | 485 |
512 | 486 |
513 } } // namespace v8::internal | 487 } } // namespace v8::internal |
514 | 488 |
515 #endif // V8_FULL_CODEGEN_H_ | 489 #endif // V8_FULL_CODEGEN_H_ |
OLD | NEW |