| 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 NO_REGISTERS, | 76 NO_REGISTERS, |
| 77 TOS_REG | 77 TOS_REG |
| 78 }; | 78 }; |
| 79 | 79 |
| 80 FullCodeGenerator(MacroAssembler* masm, CompilationInfo* info) | 80 FullCodeGenerator(MacroAssembler* masm, CompilationInfo* info) |
| 81 : masm_(masm), | 81 : masm_(masm), |
| 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 globals_(NULL), |
| 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 ic_total_count_(0) { } |
| 94 | 94 |
| 95 static bool MakeCode(CompilationInfo* info); | 95 static bool MakeCode(CompilationInfo* info); |
| 96 | 96 |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 | 195 |
| 196 // A nested block statement. | 196 // A nested block statement. |
| 197 class NestedBlock : public Breakable { | 197 class NestedBlock : public Breakable { |
| 198 public: | 198 public: |
| 199 NestedBlock(FullCodeGenerator* codegen, Block* block) | 199 NestedBlock(FullCodeGenerator* codegen, Block* block) |
| 200 : Breakable(codegen, block) { | 200 : Breakable(codegen, block) { |
| 201 } | 201 } |
| 202 virtual ~NestedBlock() {} | 202 virtual ~NestedBlock() {} |
| 203 | 203 |
| 204 virtual NestedStatement* Exit(int* stack_depth, int* context_length) { | 204 virtual NestedStatement* Exit(int* stack_depth, int* context_length) { |
| 205 if (statement()->AsBlock()->block_scope() != NULL) { | 205 if (statement()->AsBlock()->scope() != NULL) { |
| 206 ++(*context_length); | 206 ++(*context_length); |
| 207 } | 207 } |
| 208 return previous_; | 208 return previous_; |
| 209 }; | 209 }; |
| 210 }; | 210 }; |
| 211 | 211 |
| 212 // The try block of a try/catch statement. | 212 // The try block of a try/catch statement. |
| 213 class TryCatch : public NestedStatement { | 213 class TryCatch : public NestedStatement { |
| 214 public: | 214 public: |
| 215 explicit TryCatch(FullCodeGenerator* codegen) : NestedStatement(codegen) { | 215 explicit TryCatch(FullCodeGenerator* codegen) : NestedStatement(codegen) { |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 // Prepare for bailout before a test (or compare) and branch. If | 406 // Prepare for bailout before a test (or compare) and branch. If |
| 407 // should_normalize, then the following comparison will not handle the | 407 // should_normalize, then the following comparison will not handle the |
| 408 // canonical JS true value so we will insert a (dead) test against true at | 408 // canonical JS true value so we will insert a (dead) test against true at |
| 409 // the actual bailout target from the optimized code. If not | 409 // the actual bailout target from the optimized code. If not |
| 410 // should_normalize, the true and false labels are ignored. | 410 // should_normalize, the true and false labels are ignored. |
| 411 void PrepareForBailoutBeforeSplit(Expression* expr, | 411 void PrepareForBailoutBeforeSplit(Expression* expr, |
| 412 bool should_normalize, | 412 bool should_normalize, |
| 413 Label* if_true, | 413 Label* if_true, |
| 414 Label* if_false); | 414 Label* if_false); |
| 415 | 415 |
| 416 // Platform-specific code for a variable, constant, or function | 416 // If enabled, emit debug code for checking that the current context is |
| 417 // declaration. Functions have an initial value. | 417 // neither a with nor a catch context. |
| 418 // Increments global_count_ for unallocated variables. | 418 void EmitDebugCheckDeclarationContext(Variable* variable); |
| 419 void EmitDeclaration(VariableProxy* proxy, | |
| 420 VariableMode mode, | |
| 421 FunctionLiteral* function); | |
| 422 | 419 |
| 423 // Platform-specific code for checking the stack limit at the back edge of | 420 // Platform-specific code for checking the stack limit at the back edge of |
| 424 // a loop. | 421 // a loop. |
| 425 // This is meant to be called at loop back edges, |back_edge_target| is | 422 // This is meant to be called at loop back edges, |back_edge_target| is |
| 426 // the jump target of the back edge and is used to approximate the amount | 423 // the jump target of the back edge and is used to approximate the amount |
| 427 // of code inside the loop. | 424 // of code inside the loop. |
| 428 void EmitStackCheck(IterationStatement* stmt, Label* back_edge_target); | 425 void EmitStackCheck(IterationStatement* stmt, Label* back_edge_target); |
| 429 // Record the OSR AST id corresponding to a stack check in the code. | 426 // Record the OSR AST id corresponding to a stack check in the code. |
| 430 void RecordStackCheck(unsigned osr_ast_id); | 427 void RecordStackCheck(unsigned osr_ast_id); |
| 431 // Emit a table of stack check ids and pcs into the code stream. Return | 428 // Emit a table of stack check ids and pcs into the code stream. Return |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 541 | 538 |
| 542 MacroAssembler* masm() { return masm_; } | 539 MacroAssembler* masm() { return masm_; } |
| 543 | 540 |
| 544 class ExpressionContext; | 541 class ExpressionContext; |
| 545 const ExpressionContext* context() { return context_; } | 542 const ExpressionContext* context() { return context_; } |
| 546 void set_new_context(const ExpressionContext* context) { context_ = context; } | 543 void set_new_context(const ExpressionContext* context) { context_ = context; } |
| 547 | 544 |
| 548 Handle<Script> script() { return info_->script(); } | 545 Handle<Script> script() { return info_->script(); } |
| 549 bool is_eval() { return info_->is_eval(); } | 546 bool is_eval() { return info_->is_eval(); } |
| 550 bool is_native() { return info_->is_native(); } | 547 bool is_native() { return info_->is_native(); } |
| 551 bool is_classic_mode() { | 548 bool is_classic_mode() { return language_mode() == CLASSIC_MODE; } |
| 552 return language_mode() == CLASSIC_MODE; | 549 LanguageMode language_mode() { return function()->language_mode(); } |
| 553 } | |
| 554 LanguageMode language_mode() { | |
| 555 return function()->language_mode(); | |
| 556 } | |
| 557 FunctionLiteral* function() { return info_->function(); } | 550 FunctionLiteral* function() { return info_->function(); } |
| 558 Scope* scope() { return scope_; } | 551 Scope* scope() { return scope_; } |
| 559 | 552 |
| 560 static Register result_register(); | 553 static Register result_register(); |
| 561 static Register context_register(); | 554 static Register context_register(); |
| 562 | 555 |
| 563 // Set fields in the stack frame. Offsets are the frame pointer relative | 556 // Set fields in the stack frame. Offsets are the frame pointer relative |
| 564 // offsets defined in, e.g., StandardFrameConstants. | 557 // offsets defined in, e.g., StandardFrameConstants. |
| 565 void StoreToFrameField(int frame_offset, Register value); | 558 void StoreToFrameField(int frame_offset, Register value); |
| 566 | 559 |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 778 Label** fall_through) const; | 771 Label** fall_through) const; |
| 779 virtual bool IsEffect() const { return true; } | 772 virtual bool IsEffect() const { return true; } |
| 780 }; | 773 }; |
| 781 | 774 |
| 782 MacroAssembler* masm_; | 775 MacroAssembler* masm_; |
| 783 CompilationInfo* info_; | 776 CompilationInfo* info_; |
| 784 Scope* scope_; | 777 Scope* scope_; |
| 785 Label return_label_; | 778 Label return_label_; |
| 786 NestedStatement* nesting_stack_; | 779 NestedStatement* nesting_stack_; |
| 787 int loop_depth_; | 780 int loop_depth_; |
| 788 int global_count_; | 781 ZoneList<Handle<Object> >* globals_; |
| 789 const ExpressionContext* context_; | 782 const ExpressionContext* context_; |
| 790 ZoneList<BailoutEntry> bailout_entries_; | 783 ZoneList<BailoutEntry> bailout_entries_; |
| 791 ZoneList<BailoutEntry> stack_checks_; | 784 ZoneList<BailoutEntry> stack_checks_; |
| 792 ZoneList<TypeFeedbackCellEntry> type_feedback_cells_; | 785 ZoneList<TypeFeedbackCellEntry> type_feedback_cells_; |
| 793 int ic_total_count_; | 786 int ic_total_count_; |
| 794 Handle<FixedArray> handler_table_; | 787 Handle<FixedArray> handler_table_; |
| 795 Handle<JSGlobalPropertyCell> profiling_counter_; | 788 Handle<JSGlobalPropertyCell> profiling_counter_; |
| 796 | 789 |
| 797 friend class NestedStatement; | 790 friend class NestedStatement; |
| 798 | 791 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 818 } | 811 } |
| 819 | 812 |
| 820 private: | 813 private: |
| 821 Zone* zone_; | 814 Zone* zone_; |
| 822 }; | 815 }; |
| 823 | 816 |
| 824 | 817 |
| 825 } } // namespace v8::internal | 818 } } // namespace v8::internal |
| 826 | 819 |
| 827 #endif // V8_FULL_CODEGEN_H_ | 820 #endif // V8_FULL_CODEGEN_H_ |
| OLD | NEW |