| 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_FULL_CODEGEN_H_ | 5 #ifndef V8_FULL_CODEGEN_H_ |
| 6 #define V8_FULL_CODEGEN_H_ | 6 #define V8_FULL_CODEGEN_H_ |
| 7 | 7 |
| 8 #include "src/v8.h" | 8 #include "src/v8.h" |
| 9 | 9 |
| 10 #include "src/allocation.h" | 10 #include "src/allocation.h" |
| 11 #include "src/assert-scope.h" | 11 #include "src/assert-scope.h" |
| 12 #include "src/ast.h" | 12 #include "src/ast.h" |
| 13 #include "src/bit-vector.h" | 13 #include "src/bit-vector.h" |
| 14 #include "src/code-stubs.h" | 14 #include "src/code-stubs.h" |
| 15 #include "src/codegen.h" | 15 #include "src/codegen.h" |
| 16 #include "src/compiler.h" | 16 #include "src/compiler.h" |
| 17 #include "src/globals.h" | 17 #include "src/globals.h" |
| 18 #include "src/objects.h" | 18 #include "src/objects.h" |
| 19 #include "src/scopes.h" | 19 #include "src/scopes.h" |
| 20 | 20 |
| 21 namespace v8 { | 21 namespace v8 { |
| 22 namespace internal { | 22 namespace internal { |
| 23 | 23 |
| 24 // Forward declarations. | 24 // Forward declarations. |
| 25 class JumpPatchSite; | 25 class JumpPatchSite; |
| 26 | 26 |
| 27 // AST node visitor which can tell whether a given statement will be breakable | |
| 28 // when the code is compiled by the full compiler in the debugger. This means | |
| 29 // that there will be an IC (load/store/call) in the code generated for the | |
| 30 // debugger to piggybag on. | |
| 31 class BreakableStatementChecker: public AstVisitor { | |
| 32 public: | |
| 33 BreakableStatementChecker(Isolate* isolate, Zone* zone) | |
| 34 : is_breakable_(false) { | |
| 35 InitializeAstVisitor(isolate, zone); | |
| 36 } | |
| 37 | |
| 38 void Check(Statement* stmt); | |
| 39 void Check(Expression* stmt); | |
| 40 | |
| 41 bool is_breakable() { return is_breakable_; } | |
| 42 | |
| 43 private: | |
| 44 // AST node visit functions. | |
| 45 #define DECLARE_VISIT(type) virtual void Visit##type(type* node) override; | |
| 46 AST_NODE_LIST(DECLARE_VISIT) | |
| 47 #undef DECLARE_VISIT | |
| 48 | |
| 49 bool is_breakable_; | |
| 50 | |
| 51 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); | |
| 52 DISALLOW_COPY_AND_ASSIGN(BreakableStatementChecker); | |
| 53 }; | |
| 54 | |
| 55 | |
| 56 // ----------------------------------------------------------------------------- | 27 // ----------------------------------------------------------------------------- |
| 57 // Full code generator. | 28 // Full code generator. |
| 58 | 29 |
| 59 class FullCodeGenerator: public AstVisitor { | 30 class FullCodeGenerator: public AstVisitor { |
| 60 public: | 31 public: |
| 61 enum State { | 32 enum State { |
| 62 NO_REGISTERS, | 33 NO_REGISTERS, |
| 63 TOS_REG | 34 TOS_REG |
| 64 }; | 35 }; |
| 65 | 36 |
| (...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 681 void CallIC(Handle<Code> code, | 652 void CallIC(Handle<Code> code, |
| 682 TypeFeedbackId id = TypeFeedbackId::None()); | 653 TypeFeedbackId id = TypeFeedbackId::None()); |
| 683 | 654 |
| 684 void CallLoadIC(ContextualMode mode, LanguageMode language_mode = SLOPPY, | 655 void CallLoadIC(ContextualMode mode, LanguageMode language_mode = SLOPPY, |
| 685 TypeFeedbackId id = TypeFeedbackId::None()); | 656 TypeFeedbackId id = TypeFeedbackId::None()); |
| 686 void CallGlobalLoadIC(Handle<String> name); | 657 void CallGlobalLoadIC(Handle<String> name); |
| 687 void CallStoreIC(TypeFeedbackId id = TypeFeedbackId::None()); | 658 void CallStoreIC(TypeFeedbackId id = TypeFeedbackId::None()); |
| 688 | 659 |
| 689 void SetFunctionPosition(FunctionLiteral* fun); | 660 void SetFunctionPosition(FunctionLiteral* fun); |
| 690 void SetReturnPosition(FunctionLiteral* fun); | 661 void SetReturnPosition(FunctionLiteral* fun); |
| 691 void SetStatementPosition(Statement* stmt); | 662 |
| 692 void SetExpressionPosition(Expression* expr); | 663 enum InsertBreak { INSERT_BREAK, SKIP_BREAK }; |
| 693 void SetSourcePosition(int pos); | 664 |
| 665 // During stepping we want to be able to break at each statement, but not at |
| 666 // every (sub-)expression. That is why by default we insert breaks at every |
| 667 // statement position, but not at every expression position, unless stated |
| 668 // otherwise. |
| 669 void SetStatementPosition(Statement* stmt, |
| 670 InsertBreak insert_break = INSERT_BREAK); |
| 671 void SetExpressionPosition(Expression* expr, |
| 672 InsertBreak insert_break = SKIP_BREAK); |
| 673 |
| 674 // Consider an expression a statement. As such, we also insert a break. |
| 675 // This is used in loop headers where we want to break for each iteration. |
| 676 void SetExpressionAsStatementPosition(Expression* expr); |
| 694 | 677 |
| 695 // Non-local control flow support. | 678 // Non-local control flow support. |
| 696 void EnterTryBlock(int handler_index, Label* handler); | 679 void EnterTryBlock(int handler_index, Label* handler); |
| 697 void ExitTryBlock(int handler_index); | 680 void ExitTryBlock(int handler_index); |
| 698 void EnterFinallyBlock(); | 681 void EnterFinallyBlock(); |
| 699 void ExitFinallyBlock(); | 682 void ExitFinallyBlock(); |
| 700 void ClearPendingMessage(); | 683 void ClearPendingMessage(); |
| 701 | 684 |
| 702 // Loop nesting counter. | 685 // Loop nesting counter. |
| 703 int loop_depth() { return loop_depth_; } | 686 int loop_depth() { return loop_depth_; } |
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1098 | 1081 |
| 1099 Address start_; | 1082 Address start_; |
| 1100 Address instruction_start_; | 1083 Address instruction_start_; |
| 1101 uint32_t length_; | 1084 uint32_t length_; |
| 1102 }; | 1085 }; |
| 1103 | 1086 |
| 1104 | 1087 |
| 1105 } } // namespace v8::internal | 1088 } } // namespace v8::internal |
| 1106 | 1089 |
| 1107 #endif // V8_FULL_CODEGEN_H_ | 1090 #endif // V8_FULL_CODEGEN_H_ |
| OLD | NEW |