| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 class FullCodeGenerator: public AstVisitor { | 73 class FullCodeGenerator: public AstVisitor { |
| 74 public: | 74 public: |
| 75 enum State { | 75 enum State { |
| 76 NO_REGISTERS, | 76 NO_REGISTERS, |
| 77 TOS_REG | 77 TOS_REG |
| 78 }; | 78 }; |
| 79 | 79 |
| 80 explicit FullCodeGenerator(MacroAssembler* masm) | 80 explicit FullCodeGenerator(MacroAssembler* masm) |
| 81 : masm_(masm), | 81 : masm_(masm), |
| 82 info_(NULL), | 82 info_(NULL), |
| 83 scope_(NULL), |
| 83 nesting_stack_(NULL), | 84 nesting_stack_(NULL), |
| 84 loop_depth_(0), | 85 loop_depth_(0), |
| 85 context_(NULL), | 86 context_(NULL), |
| 86 bailout_entries_(0), | 87 bailout_entries_(0), |
| 87 stack_checks_(2), // There's always at least one. | 88 stack_checks_(2), // There's always at least one. |
| 88 forward_bailout_stack_(NULL), | 89 forward_bailout_stack_(NULL), |
| 89 forward_bailout_pending_(NULL) { | 90 forward_bailout_pending_(NULL) { |
| 90 } | 91 } |
| 91 | 92 |
| 92 static bool MakeCode(CompilationInfo* info); | 93 static bool MakeCode(CompilationInfo* info); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 106 return NULL; | 107 return NULL; |
| 107 } | 108 } |
| 108 | 109 |
| 109 private: | 110 private: |
| 110 class Breakable; | 111 class Breakable; |
| 111 class Iteration; | 112 class Iteration; |
| 112 class TryCatch; | 113 class TryCatch; |
| 113 class TryFinally; | 114 class TryFinally; |
| 114 class Finally; | 115 class Finally; |
| 115 class ForIn; | 116 class ForIn; |
| 117 class TestContext; |
| 116 | 118 |
| 117 class NestedStatement BASE_EMBEDDED { | 119 class NestedStatement BASE_EMBEDDED { |
| 118 public: | 120 public: |
| 119 explicit NestedStatement(FullCodeGenerator* codegen) : codegen_(codegen) { | 121 explicit NestedStatement(FullCodeGenerator* codegen) : codegen_(codegen) { |
| 120 // Link into codegen's nesting stack. | 122 // Link into codegen's nesting stack. |
| 121 previous_ = codegen->nesting_stack_; | 123 previous_ = codegen->nesting_stack_; |
| 122 codegen->nesting_stack_ = this; | 124 codegen->nesting_stack_ = this; |
| 123 } | 125 } |
| 124 virtual ~NestedStatement() { | 126 virtual ~NestedStatement() { |
| 125 // Unlink from codegen's nesting stack. | 127 // Unlink from codegen's nesting stack. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 144 // nested statement's stack, and returns a number of stack | 146 // nested statement's stack, and returns a number of stack |
| 145 // elements left on top of the surrounding statement's stack. | 147 // elements left on top of the surrounding statement's stack. |
| 146 // The generated code must preserve the result register (which | 148 // The generated code must preserve the result register (which |
| 147 // contains the value in case of a return). | 149 // contains the value in case of a return). |
| 148 virtual int Exit(int stack_depth) { | 150 virtual int Exit(int stack_depth) { |
| 149 // Default implementation for the case where there is | 151 // Default implementation for the case where there is |
| 150 // nothing to clean up. | 152 // nothing to clean up. |
| 151 return stack_depth; | 153 return stack_depth; |
| 152 } | 154 } |
| 153 NestedStatement* outer() { return previous_; } | 155 NestedStatement* outer() { return previous_; } |
| 154 protected: | 156 |
| 157 protected: |
| 155 MacroAssembler* masm() { return codegen_->masm(); } | 158 MacroAssembler* masm() { return codegen_->masm(); } |
| 156 private: | 159 |
| 160 private: |
| 157 FullCodeGenerator* codegen_; | 161 FullCodeGenerator* codegen_; |
| 158 NestedStatement* previous_; | 162 NestedStatement* previous_; |
| 159 DISALLOW_COPY_AND_ASSIGN(NestedStatement); | 163 DISALLOW_COPY_AND_ASSIGN(NestedStatement); |
| 160 }; | 164 }; |
| 161 | 165 |
| 162 class Breakable : public NestedStatement { | 166 class Breakable : public NestedStatement { |
| 163 public: | 167 public: |
| 164 Breakable(FullCodeGenerator* codegen, | 168 Breakable(FullCodeGenerator* codegen, |
| 165 BreakableStatement* break_target) | 169 BreakableStatement* break_target) |
| 166 : NestedStatement(codegen), | 170 : NestedStatement(codegen), |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 // parameter slot. | 293 // parameter slot. |
| 290 int SlotOffset(Slot* slot); | 294 int SlotOffset(Slot* slot); |
| 291 | 295 |
| 292 // Determine whether or not to inline the smi case for the given | 296 // Determine whether or not to inline the smi case for the given |
| 293 // operation. | 297 // operation. |
| 294 bool ShouldInlineSmiCase(Token::Value op); | 298 bool ShouldInlineSmiCase(Token::Value op); |
| 295 | 299 |
| 296 // Helper function to convert a pure value into a test context. The value | 300 // 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. | 301 // is expected on the stack or the accumulator, depending on the platform. |
| 298 // See the platform-specific implementation for details. | 302 // See the platform-specific implementation for details. |
| 299 void DoTest(Label* if_true, Label* if_false, Label* fall_through); | 303 void DoTest(Expression* condition, |
| 304 Label* if_true, |
| 305 Label* if_false, |
| 306 Label* fall_through); |
| 307 void DoTest(const TestContext* context); |
| 300 | 308 |
| 301 // Helper function to split control flow and avoid a branch to the | 309 // Helper function to split control flow and avoid a branch to the |
| 302 // fall-through label if it is set up. | 310 // fall-through label if it is set up. |
| 303 #ifdef V8_TARGET_ARCH_MIPS | 311 #ifdef V8_TARGET_ARCH_MIPS |
| 304 void Split(Condition cc, | 312 void Split(Condition cc, |
| 305 Register lhs, | 313 Register lhs, |
| 306 const Operand& rhs, | 314 const Operand& rhs, |
| 307 Label* if_true, | 315 Label* if_true, |
| 308 Label* if_false, | 316 Label* if_false, |
| 309 Label* fall_through); | 317 Label* fall_through); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 321 // May emit code to traverse the context chain, destroying the scratch | 329 // May emit code to traverse the context chain, destroying the scratch |
| 322 // register. | 330 // register. |
| 323 MemOperand EmitSlotSearch(Slot* slot, Register scratch); | 331 MemOperand EmitSlotSearch(Slot* slot, Register scratch); |
| 324 | 332 |
| 325 // Forward the bailout responsibility for the given expression to | 333 // Forward the bailout responsibility for the given expression to |
| 326 // the next child visited (which must be in a test context). | 334 // the next child visited (which must be in a test context). |
| 327 void ForwardBailoutToChild(Expression* expr); | 335 void ForwardBailoutToChild(Expression* expr); |
| 328 | 336 |
| 329 void VisitForEffect(Expression* expr) { | 337 void VisitForEffect(Expression* expr) { |
| 330 EffectContext context(this); | 338 EffectContext context(this); |
| 331 HandleInNonTestContext(expr, NO_REGISTERS); | 339 VisitInCurrentContext(expr); |
| 332 } | 340 } |
| 333 | 341 |
| 334 void VisitForAccumulatorValue(Expression* expr) { | 342 void VisitForAccumulatorValue(Expression* expr) { |
| 335 AccumulatorValueContext context(this); | 343 AccumulatorValueContext context(this); |
| 336 HandleInNonTestContext(expr, TOS_REG); | 344 VisitInCurrentContext(expr); |
| 337 } | 345 } |
| 338 | 346 |
| 339 void VisitForStackValue(Expression* expr) { | 347 void VisitForStackValue(Expression* expr) { |
| 340 StackValueContext context(this); | 348 StackValueContext context(this); |
| 341 HandleInNonTestContext(expr, NO_REGISTERS); | 349 VisitInCurrentContext(expr); |
| 342 } | 350 } |
| 343 | 351 |
| 344 void VisitForControl(Expression* expr, | 352 void VisitForControl(Expression* expr, |
| 345 Label* if_true, | 353 Label* if_true, |
| 346 Label* if_false, | 354 Label* if_false, |
| 347 Label* fall_through) { | 355 Label* fall_through) { |
| 348 TestContext context(this, if_true, if_false, fall_through); | 356 TestContext context(this, expr, if_true, if_false, fall_through); |
| 349 VisitInTestContext(expr); | 357 VisitInCurrentContext(expr); |
| 350 // Forwarding bailouts to children is a one shot operation. It | |
| 351 // should have been processed at this point. | |
| 352 ASSERT(forward_bailout_pending_ == NULL); | |
| 353 } | 358 } |
| 354 | 359 |
| 355 void HandleInNonTestContext(Expression* expr, State state); | |
| 356 void VisitInTestContext(Expression* expr); | |
| 357 | |
| 358 void VisitDeclarations(ZoneList<Declaration*>* declarations); | 360 void VisitDeclarations(ZoneList<Declaration*>* declarations); |
| 359 void DeclareGlobals(Handle<FixedArray> pairs); | 361 void DeclareGlobals(Handle<FixedArray> pairs); |
| 360 | 362 |
| 361 // Try to perform a comparison as a fast inlined literal compare if | 363 // Try to perform a comparison as a fast inlined literal compare if |
| 362 // the operands allow it. Returns true if the compare operations | 364 // the operands allow it. Returns true if the compare operations |
| 363 // has been matched and all code generated; false otherwise. | 365 // has been matched and all code generated; false otherwise. |
| 364 bool TryLiteralCompare(Token::Value op, | 366 bool TryLiteralCompare(CompareOperation* compare, |
| 365 Expression* left, | |
| 366 Expression* right, | |
| 367 Label* if_true, | 367 Label* if_true, |
| 368 Label* if_false, | 368 Label* if_false, |
| 369 Label* fall_through); | 369 Label* fall_through); |
| 370 | 370 |
| 371 // Platform-specific code for comparing the type of a value with |
| 372 // a given literal string. |
| 373 void EmitLiteralCompareTypeof(Expression* expr, |
| 374 Handle<String> check, |
| 375 Label* if_true, |
| 376 Label* if_false, |
| 377 Label* fall_through); |
| 378 |
| 379 // Platform-specific code for strict equality comparison with |
| 380 // the undefined value. |
| 381 void EmitLiteralCompareUndefined(Expression* expr, |
| 382 Label* if_true, |
| 383 Label* if_false, |
| 384 Label* fall_through); |
| 385 |
| 371 // Bailout support. | 386 // Bailout support. |
| 372 void PrepareForBailout(AstNode* node, State state); | 387 void PrepareForBailout(Expression* node, State state); |
| 373 void PrepareForBailoutForId(int id, State state); | 388 void PrepareForBailoutForId(int id, State state); |
| 374 | 389 |
| 375 // Record a call's return site offset, used to rebuild the frame if the | 390 // Record a call's return site offset, used to rebuild the frame if the |
| 376 // called function was inlined at the site. | 391 // called function was inlined at the site. |
| 377 void RecordJSReturnSite(Call* call); | 392 void RecordJSReturnSite(Call* call); |
| 378 | 393 |
| 379 // Prepare for bailout before a test (or compare) and branch. If | 394 // Prepare for bailout before a test (or compare) and branch. If |
| 380 // should_normalize, then the following comparison will not handle the | 395 // should_normalize, then the following comparison will not handle the |
| 381 // canonical JS true value so we will insert a (dead) test against true at | 396 // canonical JS true value so we will insert a (dead) test against true at |
| 382 // the actual bailout target from the optimized code. If not | 397 // the actual bailout target from the optimized code. If not |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 510 const ExpressionContext* context() { return context_; } | 525 const ExpressionContext* context() { return context_; } |
| 511 void set_new_context(const ExpressionContext* context) { context_ = context; } | 526 void set_new_context(const ExpressionContext* context) { context_ = context; } |
| 512 | 527 |
| 513 Handle<Script> script() { return info_->script(); } | 528 Handle<Script> script() { return info_->script(); } |
| 514 bool is_eval() { return info_->is_eval(); } | 529 bool is_eval() { return info_->is_eval(); } |
| 515 bool is_strict_mode() { return function()->strict_mode(); } | 530 bool is_strict_mode() { return function()->strict_mode(); } |
| 516 StrictModeFlag strict_mode_flag() { | 531 StrictModeFlag strict_mode_flag() { |
| 517 return is_strict_mode() ? kStrictMode : kNonStrictMode; | 532 return is_strict_mode() ? kStrictMode : kNonStrictMode; |
| 518 } | 533 } |
| 519 FunctionLiteral* function() { return info_->function(); } | 534 FunctionLiteral* function() { return info_->function(); } |
| 520 Scope* scope() { return info_->scope(); } | 535 Scope* scope() { return scope_; } |
| 521 | 536 |
| 522 static Register result_register(); | 537 static Register result_register(); |
| 523 static Register context_register(); | 538 static Register context_register(); |
| 524 | 539 |
| 525 // Helper for calling an IC stub. | |
| 526 void EmitCallIC(Handle<Code> ic, | |
| 527 RelocInfo::Mode mode, | |
| 528 unsigned ast_id); | |
| 529 | |
| 530 // Calling an IC stub with a patch site. Passing NULL for patch_site | |
| 531 // or non NULL patch_site which is not activated indicates no inlined smi code | |
| 532 // and emits a nop after the IC call. | |
| 533 void EmitCallIC(Handle<Code> ic, | |
| 534 JumpPatchSite* patch_site, | |
| 535 unsigned ast_id); | |
| 536 | |
| 537 // Set fields in the stack frame. Offsets are the frame pointer relative | 540 // Set fields in the stack frame. Offsets are the frame pointer relative |
| 538 // offsets defined in, e.g., StandardFrameConstants. | 541 // offsets defined in, e.g., StandardFrameConstants. |
| 539 void StoreToFrameField(int frame_offset, Register value); | 542 void StoreToFrameField(int frame_offset, Register value); |
| 540 | 543 |
| 541 // Load a value from the current context. Indices are defined as an enum | 544 // Load a value from the current context. Indices are defined as an enum |
| 542 // in v8::internal::Context. | 545 // in v8::internal::Context. |
| 543 void LoadContextField(Register dst, int context_index); | 546 void LoadContextField(Register dst, int context_index); |
| 544 | 547 |
| 548 // Push the function argument for the runtime functions PushWithContext |
| 549 // and PushCatchContext. |
| 550 void PushFunctionArgumentForContextAllocation(); |
| 551 |
| 545 // AST node visit functions. | 552 // AST node visit functions. |
| 546 #define DECLARE_VISIT(type) virtual void Visit##type(type* node); | 553 #define DECLARE_VISIT(type) virtual void Visit##type(type* node); |
| 547 AST_NODE_LIST(DECLARE_VISIT) | 554 AST_NODE_LIST(DECLARE_VISIT) |
| 548 #undef DECLARE_VISIT | 555 #undef DECLARE_VISIT |
| 549 | 556 |
| 550 void EmitUnaryOperation(UnaryOperation* expr, const char* comment); | 557 void EmitUnaryOperation(UnaryOperation* expr, const char* comment); |
| 551 | 558 |
| 552 // Handles the shortcutted logical binary operations in VisitBinaryOperation. | 559 void VisitComma(BinaryOperation* expr); |
| 553 void EmitLogicalOperation(BinaryOperation* expr); | 560 void VisitLogicalExpression(BinaryOperation* expr); |
| 561 void VisitArithmeticExpression(BinaryOperation* expr); |
| 562 void VisitInCurrentContext(Expression* expr); |
| 554 | 563 |
| 555 void VisitForTypeofValue(Expression* expr); | 564 void VisitForTypeofValue(Expression* expr); |
| 556 | 565 |
| 557 struct BailoutEntry { | 566 struct BailoutEntry { |
| 558 unsigned id; | 567 unsigned id; |
| 559 unsigned pc_and_state; | 568 unsigned pc_and_state; |
| 560 }; | 569 }; |
| 561 | 570 |
| 562 | 571 |
| 563 class ExpressionContext BASE_EMBEDDED { | 572 class ExpressionContext BASE_EMBEDDED { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 591 // implementation will bind both labels unless it's a TestContext, which | 600 // implementation will bind both labels unless it's a TestContext, which |
| 592 // won't bind them at this point. | 601 // won't bind them at this point. |
| 593 virtual void Plug(Label* materialize_true, | 602 virtual void Plug(Label* materialize_true, |
| 594 Label* materialize_false) const = 0; | 603 Label* materialize_false) const = 0; |
| 595 | 604 |
| 596 // Emit code to discard count elements from the top of stack, then convert | 605 // Emit code to discard count elements from the top of stack, then convert |
| 597 // a pure value into the result expected according to this expression | 606 // a pure value into the result expected according to this expression |
| 598 // context. | 607 // context. |
| 599 virtual void DropAndPlug(int count, Register reg) const = 0; | 608 virtual void DropAndPlug(int count, Register reg) const = 0; |
| 600 | 609 |
| 601 // For shortcutting operations || and &&. | |
| 602 virtual void EmitLogicalLeft(BinaryOperation* expr, | |
| 603 Label* eval_right, | |
| 604 Label* done) const = 0; | |
| 605 | |
| 606 // Set up branch labels for a test expression. The three Label** parameters | 610 // Set up branch labels for a test expression. The three Label** parameters |
| 607 // are output parameters. | 611 // are output parameters. |
| 608 virtual void PrepareTest(Label* materialize_true, | 612 virtual void PrepareTest(Label* materialize_true, |
| 609 Label* materialize_false, | 613 Label* materialize_false, |
| 610 Label** if_true, | 614 Label** if_true, |
| 611 Label** if_false, | 615 Label** if_false, |
| 612 Label** fall_through) const = 0; | 616 Label** fall_through) const = 0; |
| 613 | 617 |
| 614 virtual void HandleExpression(Expression* expr) const = 0; | |
| 615 | |
| 616 // Returns true if we are evaluating only for side effects (ie if the result | 618 // Returns true if we are evaluating only for side effects (ie if the result |
| 617 // will be discarded). | 619 // will be discarded). |
| 618 virtual bool IsEffect() const { return false; } | 620 virtual bool IsEffect() const { return false; } |
| 619 | 621 |
| 622 // Returns true if we are evaluating for the value (in accu/on stack). |
| 623 virtual bool IsAccumulatorValue() const { return false; } |
| 624 virtual bool IsStackValue() const { return false; } |
| 625 |
| 620 // Returns true if we are branching on the value rather than materializing | 626 // Returns true if we are branching on the value rather than materializing |
| 621 // it. Only used for asserts. | 627 // it. Only used for asserts. |
| 622 virtual bool IsTest() const { return false; } | 628 virtual bool IsTest() const { return false; } |
| 623 | 629 |
| 624 protected: | 630 protected: |
| 625 FullCodeGenerator* codegen() const { return codegen_; } | 631 FullCodeGenerator* codegen() const { return codegen_; } |
| 626 MacroAssembler* masm() const { return masm_; } | 632 MacroAssembler* masm() const { return masm_; } |
| 627 MacroAssembler* masm_; | 633 MacroAssembler* masm_; |
| 628 | 634 |
| 629 private: | 635 private: |
| 630 const ExpressionContext* old_; | 636 const ExpressionContext* old_; |
| 631 FullCodeGenerator* codegen_; | 637 FullCodeGenerator* codegen_; |
| 632 }; | 638 }; |
| 633 | 639 |
| 634 class AccumulatorValueContext : public ExpressionContext { | 640 class AccumulatorValueContext : public ExpressionContext { |
| 635 public: | 641 public: |
| 636 explicit AccumulatorValueContext(FullCodeGenerator* codegen) | 642 explicit AccumulatorValueContext(FullCodeGenerator* codegen) |
| 637 : ExpressionContext(codegen) { } | 643 : ExpressionContext(codegen) { } |
| 638 | 644 |
| 639 virtual void Plug(bool flag) const; | 645 virtual void Plug(bool flag) const; |
| 640 virtual void Plug(Register reg) const; | 646 virtual void Plug(Register reg) const; |
| 641 virtual void Plug(Label* materialize_true, Label* materialize_false) const; | 647 virtual void Plug(Label* materialize_true, Label* materialize_false) const; |
| 642 virtual void Plug(Slot* slot) const; | 648 virtual void Plug(Slot* slot) const; |
| 643 virtual void Plug(Handle<Object> lit) const; | 649 virtual void Plug(Handle<Object> lit) const; |
| 644 virtual void Plug(Heap::RootListIndex) const; | 650 virtual void Plug(Heap::RootListIndex) const; |
| 645 virtual void PlugTOS() const; | 651 virtual void PlugTOS() const; |
| 646 virtual void DropAndPlug(int count, Register reg) const; | 652 virtual void DropAndPlug(int count, Register reg) const; |
| 647 virtual void EmitLogicalLeft(BinaryOperation* expr, | |
| 648 Label* eval_right, | |
| 649 Label* done) const; | |
| 650 virtual void PrepareTest(Label* materialize_true, | 653 virtual void PrepareTest(Label* materialize_true, |
| 651 Label* materialize_false, | 654 Label* materialize_false, |
| 652 Label** if_true, | 655 Label** if_true, |
| 653 Label** if_false, | 656 Label** if_false, |
| 654 Label** fall_through) const; | 657 Label** fall_through) const; |
| 655 virtual void HandleExpression(Expression* expr) const; | 658 virtual bool IsAccumulatorValue() const { return true; } |
| 656 }; | 659 }; |
| 657 | 660 |
| 658 class StackValueContext : public ExpressionContext { | 661 class StackValueContext : public ExpressionContext { |
| 659 public: | 662 public: |
| 660 explicit StackValueContext(FullCodeGenerator* codegen) | 663 explicit StackValueContext(FullCodeGenerator* codegen) |
| 661 : ExpressionContext(codegen) { } | 664 : ExpressionContext(codegen) { } |
| 662 | 665 |
| 663 virtual void Plug(bool flag) const; | 666 virtual void Plug(bool flag) const; |
| 664 virtual void Plug(Register reg) const; | 667 virtual void Plug(Register reg) const; |
| 665 virtual void Plug(Label* materialize_true, Label* materialize_false) const; | 668 virtual void Plug(Label* materialize_true, Label* materialize_false) const; |
| 666 virtual void Plug(Slot* slot) const; | 669 virtual void Plug(Slot* slot) const; |
| 667 virtual void Plug(Handle<Object> lit) const; | 670 virtual void Plug(Handle<Object> lit) const; |
| 668 virtual void Plug(Heap::RootListIndex) const; | 671 virtual void Plug(Heap::RootListIndex) const; |
| 669 virtual void PlugTOS() const; | 672 virtual void PlugTOS() const; |
| 670 virtual void DropAndPlug(int count, Register reg) const; | 673 virtual void DropAndPlug(int count, Register reg) const; |
| 671 virtual void EmitLogicalLeft(BinaryOperation* expr, | |
| 672 Label* eval_right, | |
| 673 Label* done) const; | |
| 674 virtual void PrepareTest(Label* materialize_true, | 674 virtual void PrepareTest(Label* materialize_true, |
| 675 Label* materialize_false, | 675 Label* materialize_false, |
| 676 Label** if_true, | 676 Label** if_true, |
| 677 Label** if_false, | 677 Label** if_false, |
| 678 Label** fall_through) const; | 678 Label** fall_through) const; |
| 679 virtual void HandleExpression(Expression* expr) const; | 679 virtual bool IsStackValue() const { return true; } |
| 680 }; | 680 }; |
| 681 | 681 |
| 682 class TestContext : public ExpressionContext { | 682 class TestContext : public ExpressionContext { |
| 683 public: | 683 public: |
| 684 explicit TestContext(FullCodeGenerator* codegen, | 684 TestContext(FullCodeGenerator* codegen, |
| 685 Label* true_label, | 685 Expression* condition, |
| 686 Label* false_label, | 686 Label* true_label, |
| 687 Label* fall_through) | 687 Label* false_label, |
| 688 Label* fall_through) |
| 688 : ExpressionContext(codegen), | 689 : ExpressionContext(codegen), |
| 690 condition_(condition), |
| 689 true_label_(true_label), | 691 true_label_(true_label), |
| 690 false_label_(false_label), | 692 false_label_(false_label), |
| 691 fall_through_(fall_through) { } | 693 fall_through_(fall_through) { } |
| 692 | 694 |
| 693 static const TestContext* cast(const ExpressionContext* context) { | 695 static const TestContext* cast(const ExpressionContext* context) { |
| 694 ASSERT(context->IsTest()); | 696 ASSERT(context->IsTest()); |
| 695 return reinterpret_cast<const TestContext*>(context); | 697 return reinterpret_cast<const TestContext*>(context); |
| 696 } | 698 } |
| 697 | 699 |
| 700 Expression* condition() const { return condition_; } |
| 698 Label* true_label() const { return true_label_; } | 701 Label* true_label() const { return true_label_; } |
| 699 Label* false_label() const { return false_label_; } | 702 Label* false_label() const { return false_label_; } |
| 700 Label* fall_through() const { return fall_through_; } | 703 Label* fall_through() const { return fall_through_; } |
| 701 | 704 |
| 702 virtual void Plug(bool flag) const; | 705 virtual void Plug(bool flag) const; |
| 703 virtual void Plug(Register reg) const; | 706 virtual void Plug(Register reg) const; |
| 704 virtual void Plug(Label* materialize_true, Label* materialize_false) const; | 707 virtual void Plug(Label* materialize_true, Label* materialize_false) const; |
| 705 virtual void Plug(Slot* slot) const; | 708 virtual void Plug(Slot* slot) const; |
| 706 virtual void Plug(Handle<Object> lit) const; | 709 virtual void Plug(Handle<Object> lit) const; |
| 707 virtual void Plug(Heap::RootListIndex) const; | 710 virtual void Plug(Heap::RootListIndex) const; |
| 708 virtual void PlugTOS() const; | 711 virtual void PlugTOS() const; |
| 709 virtual void DropAndPlug(int count, Register reg) const; | 712 virtual void DropAndPlug(int count, Register reg) const; |
| 710 virtual void EmitLogicalLeft(BinaryOperation* expr, | |
| 711 Label* eval_right, | |
| 712 Label* done) const; | |
| 713 virtual void PrepareTest(Label* materialize_true, | 713 virtual void PrepareTest(Label* materialize_true, |
| 714 Label* materialize_false, | 714 Label* materialize_false, |
| 715 Label** if_true, | 715 Label** if_true, |
| 716 Label** if_false, | 716 Label** if_false, |
| 717 Label** fall_through) const; | 717 Label** fall_through) const; |
| 718 virtual void HandleExpression(Expression* expr) const; | |
| 719 virtual bool IsTest() const { return true; } | 718 virtual bool IsTest() const { return true; } |
| 720 | 719 |
| 721 private: | 720 private: |
| 721 Expression* condition_; |
| 722 Label* true_label_; | 722 Label* true_label_; |
| 723 Label* false_label_; | 723 Label* false_label_; |
| 724 Label* fall_through_; | 724 Label* fall_through_; |
| 725 }; | 725 }; |
| 726 | 726 |
| 727 class EffectContext : public ExpressionContext { | 727 class EffectContext : public ExpressionContext { |
| 728 public: | 728 public: |
| 729 explicit EffectContext(FullCodeGenerator* codegen) | 729 explicit EffectContext(FullCodeGenerator* codegen) |
| 730 : ExpressionContext(codegen) { } | 730 : ExpressionContext(codegen) { } |
| 731 | 731 |
| 732 virtual void Plug(bool flag) const; | 732 virtual void Plug(bool flag) const; |
| 733 virtual void Plug(Register reg) const; | 733 virtual void Plug(Register reg) const; |
| 734 virtual void Plug(Label* materialize_true, Label* materialize_false) const; | 734 virtual void Plug(Label* materialize_true, Label* materialize_false) const; |
| 735 virtual void Plug(Slot* slot) const; | 735 virtual void Plug(Slot* slot) const; |
| 736 virtual void Plug(Handle<Object> lit) const; | 736 virtual void Plug(Handle<Object> lit) const; |
| 737 virtual void Plug(Heap::RootListIndex) const; | 737 virtual void Plug(Heap::RootListIndex) const; |
| 738 virtual void PlugTOS() const; | 738 virtual void PlugTOS() const; |
| 739 virtual void DropAndPlug(int count, Register reg) const; | 739 virtual void DropAndPlug(int count, Register reg) const; |
| 740 virtual void EmitLogicalLeft(BinaryOperation* expr, | |
| 741 Label* eval_right, | |
| 742 Label* done) const; | |
| 743 virtual void PrepareTest(Label* materialize_true, | 740 virtual void PrepareTest(Label* materialize_true, |
| 744 Label* materialize_false, | 741 Label* materialize_false, |
| 745 Label** if_true, | 742 Label** if_true, |
| 746 Label** if_false, | 743 Label** if_false, |
| 747 Label** fall_through) const; | 744 Label** fall_through) const; |
| 748 virtual void HandleExpression(Expression* expr) const; | |
| 749 virtual bool IsEffect() const { return true; } | 745 virtual bool IsEffect() const { return true; } |
| 750 }; | 746 }; |
| 751 | 747 |
| 752 MacroAssembler* masm_; | 748 MacroAssembler* masm_; |
| 753 CompilationInfo* info_; | 749 CompilationInfo* info_; |
| 750 Scope* scope_; |
| 754 Label return_label_; | 751 Label return_label_; |
| 755 NestedStatement* nesting_stack_; | 752 NestedStatement* nesting_stack_; |
| 756 int loop_depth_; | 753 int loop_depth_; |
| 757 const ExpressionContext* context_; | 754 const ExpressionContext* context_; |
| 758 ZoneList<BailoutEntry> bailout_entries_; | 755 ZoneList<BailoutEntry> bailout_entries_; |
| 759 ZoneList<BailoutEntry> stack_checks_; | 756 ZoneList<BailoutEntry> stack_checks_; |
| 760 ForwardBailoutStack* forward_bailout_stack_; | 757 ForwardBailoutStack* forward_bailout_stack_; |
| 761 ForwardBailoutStack* forward_bailout_pending_; | 758 ForwardBailoutStack* forward_bailout_pending_; |
| 762 | 759 |
| 763 friend class NestedStatement; | 760 friend class NestedStatement; |
| 764 | 761 |
| 765 DISALLOW_COPY_AND_ASSIGN(FullCodeGenerator); | 762 DISALLOW_COPY_AND_ASSIGN(FullCodeGenerator); |
| 766 }; | 763 }; |
| 767 | 764 |
| 768 | 765 |
| 769 } } // namespace v8::internal | 766 } } // namespace v8::internal |
| 770 | 767 |
| 771 #endif // V8_FULL_CODEGEN_H_ | 768 #endif // V8_FULL_CODEGEN_H_ |
| OLD | NEW |