OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 info_(info), | 82 info_(info), |
83 scope_(info->scope()), | 83 scope_(info->scope()), |
84 nesting_stack_(NULL), | 84 nesting_stack_(NULL), |
85 loop_depth_(0), | 85 loop_depth_(0), |
86 global_count_(0), | 86 global_count_(0), |
87 context_(NULL), | 87 context_(NULL), |
88 bailout_entries_(info->HasDeoptimizationSupport() | 88 bailout_entries_(info->HasDeoptimizationSupport() |
89 ? info->function()->ast_node_count() : 0), | 89 ? info->function()->ast_node_count() : 0), |
90 stack_checks_(2), // There's always at least one. | 90 stack_checks_(2), // There's always at least one. |
91 type_feedback_cells_(info->HasDeoptimizationSupport() | 91 type_feedback_cells_(info->HasDeoptimizationSupport() |
92 ? info->function()->ast_node_count() : 0) { } | 92 ? info->function()->ast_node_count() : 0), |
| 93 ic_total_count_(0) { } |
93 | 94 |
94 static bool MakeCode(CompilationInfo* info); | 95 static bool MakeCode(CompilationInfo* info); |
95 | 96 |
96 void Generate(); | |
97 void PopulateDeoptimizationData(Handle<Code> code); | |
98 void PopulateTypeFeedbackCells(Handle<Code> code); | |
99 | |
100 Handle<FixedArray> handler_table() { return handler_table_; } | |
101 | |
102 // Encode state and pc-offset as a BitField<type, start, size>. | 97 // Encode state and pc-offset as a BitField<type, start, size>. |
103 // Only use 30 bits because we encode the result as a smi. | 98 // Only use 30 bits because we encode the result as a smi. |
104 class StateField : public BitField<State, 0, 1> { }; | 99 class StateField : public BitField<State, 0, 1> { }; |
105 class PcField : public BitField<unsigned, 1, 30-1> { }; | 100 class PcField : public BitField<unsigned, 1, 30-1> { }; |
106 | 101 |
107 static const char* State2String(State state) { | 102 static const char* State2String(State state) { |
108 switch (state) { | 103 switch (state) { |
109 case NO_REGISTERS: return "NO_REGISTERS"; | 104 case NO_REGISTERS: return "NO_REGISTERS"; |
110 case TOS_REG: return "TOS_REG"; | 105 case TOS_REG: return "TOS_REG"; |
111 } | 106 } |
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
509 | 504 |
510 // Complete a named property assignment. The receiver is expected on top | 505 // Complete a named property assignment. The receiver is expected on top |
511 // of the stack and the right-hand-side value in the accumulator. | 506 // of the stack and the right-hand-side value in the accumulator. |
512 void EmitNamedPropertyAssignment(Assignment* expr); | 507 void EmitNamedPropertyAssignment(Assignment* expr); |
513 | 508 |
514 // Complete a keyed property assignment. The receiver and key are | 509 // Complete a keyed property assignment. The receiver and key are |
515 // expected on top of the stack and the right-hand-side value in the | 510 // expected on top of the stack and the right-hand-side value in the |
516 // accumulator. | 511 // accumulator. |
517 void EmitKeyedPropertyAssignment(Assignment* expr); | 512 void EmitKeyedPropertyAssignment(Assignment* expr); |
518 | 513 |
| 514 void CallIC(Handle<Code> code, |
| 515 RelocInfo::Mode rmode = RelocInfo::CODE_TARGET, |
| 516 unsigned ast_id = kNoASTId); |
| 517 |
519 void SetFunctionPosition(FunctionLiteral* fun); | 518 void SetFunctionPosition(FunctionLiteral* fun); |
520 void SetReturnPosition(FunctionLiteral* fun); | 519 void SetReturnPosition(FunctionLiteral* fun); |
521 void SetStatementPosition(Statement* stmt); | 520 void SetStatementPosition(Statement* stmt); |
522 void SetExpressionPosition(Expression* expr, int pos); | 521 void SetExpressionPosition(Expression* expr, int pos); |
523 void SetStatementPosition(int pos); | 522 void SetStatementPosition(int pos); |
524 void SetSourcePosition(int pos); | 523 void SetSourcePosition(int pos); |
525 | 524 |
526 // Non-local control flow support. | 525 // Non-local control flow support. |
527 void EnterFinallyBlock(); | 526 void EnterFinallyBlock(); |
528 void ExitFinallyBlock(); | 527 void ExitFinallyBlock(); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
574 #undef DECLARE_VISIT | 573 #undef DECLARE_VISIT |
575 | 574 |
576 void EmitUnaryOperation(UnaryOperation* expr, const char* comment); | 575 void EmitUnaryOperation(UnaryOperation* expr, const char* comment); |
577 | 576 |
578 void VisitComma(BinaryOperation* expr); | 577 void VisitComma(BinaryOperation* expr); |
579 void VisitLogicalExpression(BinaryOperation* expr); | 578 void VisitLogicalExpression(BinaryOperation* expr); |
580 void VisitArithmeticExpression(BinaryOperation* expr); | 579 void VisitArithmeticExpression(BinaryOperation* expr); |
581 | 580 |
582 void VisitForTypeofValue(Expression* expr); | 581 void VisitForTypeofValue(Expression* expr); |
583 | 582 |
| 583 void Generate(); |
| 584 void PopulateDeoptimizationData(Handle<Code> code); |
| 585 void PopulateTypeFeedbackInfo(Handle<Code> code); |
| 586 void PopulateTypeFeedbackCells(Handle<Code> code); |
| 587 |
| 588 Handle<FixedArray> handler_table() { return handler_table_; } |
| 589 |
584 struct BailoutEntry { | 590 struct BailoutEntry { |
585 unsigned id; | 591 unsigned id; |
586 unsigned pc_and_state; | 592 unsigned pc_and_state; |
587 }; | 593 }; |
588 | 594 |
589 struct TypeFeedbackCellEntry { | 595 struct TypeFeedbackCellEntry { |
590 unsigned ast_id; | 596 unsigned ast_id; |
591 Handle<JSGlobalPropertyCell> cell; | 597 Handle<JSGlobalPropertyCell> cell; |
592 }; | 598 }; |
593 | 599 |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
772 CompilationInfo* info_; | 778 CompilationInfo* info_; |
773 Scope* scope_; | 779 Scope* scope_; |
774 Label return_label_; | 780 Label return_label_; |
775 NestedStatement* nesting_stack_; | 781 NestedStatement* nesting_stack_; |
776 int loop_depth_; | 782 int loop_depth_; |
777 int global_count_; | 783 int global_count_; |
778 const ExpressionContext* context_; | 784 const ExpressionContext* context_; |
779 ZoneList<BailoutEntry> bailout_entries_; | 785 ZoneList<BailoutEntry> bailout_entries_; |
780 ZoneList<BailoutEntry> stack_checks_; | 786 ZoneList<BailoutEntry> stack_checks_; |
781 ZoneList<TypeFeedbackCellEntry> type_feedback_cells_; | 787 ZoneList<TypeFeedbackCellEntry> type_feedback_cells_; |
| 788 int ic_total_count_; |
782 Handle<FixedArray> handler_table_; | 789 Handle<FixedArray> handler_table_; |
783 Handle<JSGlobalPropertyCell> profiling_counter_; | 790 Handle<JSGlobalPropertyCell> profiling_counter_; |
784 | 791 |
785 friend class NestedStatement; | 792 friend class NestedStatement; |
786 | 793 |
787 DISALLOW_COPY_AND_ASSIGN(FullCodeGenerator); | 794 DISALLOW_COPY_AND_ASSIGN(FullCodeGenerator); |
788 }; | 795 }; |
789 | 796 |
790 | 797 |
791 } } // namespace v8::internal | 798 } } // namespace v8::internal |
792 | 799 |
793 #endif // V8_FULL_CODEGEN_H_ | 800 #endif // V8_FULL_CODEGEN_H_ |
OLD | NEW |