| 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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 info_(info), | 89 info_(info), |
| 90 scope_(info->scope()), | 90 scope_(info->scope()), |
| 91 nesting_stack_(NULL), | 91 nesting_stack_(NULL), |
| 92 loop_depth_(0), | 92 loop_depth_(0), |
| 93 globals_(NULL), | 93 globals_(NULL), |
| 94 context_(NULL), | 94 context_(NULL), |
| 95 bailout_entries_(info->HasDeoptimizationSupport() | 95 bailout_entries_(info->HasDeoptimizationSupport() |
| 96 ? info->function()->ast_node_count() : 0, | 96 ? info->function()->ast_node_count() : 0, |
| 97 info->zone()), | 97 info->zone()), |
| 98 back_edges_(2, info->zone()), | 98 back_edges_(2, info->zone()), |
| 99 type_feedback_cells_(info->HasDeoptimizationSupport() | |
| 100 ? info->function()->ast_node_count() : 0, | |
| 101 info->zone()), | |
| 102 ic_total_count_(0) { | 99 ic_total_count_(0) { |
| 103 Initialize(); | 100 Initialize(); |
| 104 } | 101 } |
| 105 | 102 |
| 106 void Initialize(); | 103 void Initialize(); |
| 107 | 104 |
| 108 static bool MakeCode(CompilationInfo* info); | 105 static bool MakeCode(CompilationInfo* info); |
| 109 | 106 |
| 110 // Encode state and pc-offset as a BitField<type, start, size>. | 107 // Encode state and pc-offset as a BitField<type, start, size>. |
| 111 // Only use 30 bits because we encode the result as a smi. | 108 // Only use 30 bits because we encode the result as a smi. |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 | 427 |
| 431 // Platform-specific code for equality comparison with a nil-like value. | 428 // Platform-specific code for equality comparison with a nil-like value. |
| 432 void EmitLiteralCompareNil(CompareOperation* expr, | 429 void EmitLiteralCompareNil(CompareOperation* expr, |
| 433 Expression* sub_expr, | 430 Expression* sub_expr, |
| 434 NilValue nil); | 431 NilValue nil); |
| 435 | 432 |
| 436 // Bailout support. | 433 // Bailout support. |
| 437 void PrepareForBailout(Expression* node, State state); | 434 void PrepareForBailout(Expression* node, State state); |
| 438 void PrepareForBailoutForId(BailoutId id, State state); | 435 void PrepareForBailoutForId(BailoutId id, State state); |
| 439 | 436 |
| 440 // Cache cell support. This associates AST ids with global property cells | 437 // Feedback slot support. The feedback vector will be cleared during gc and |
| 441 // that will be cleared during GC and collected by the type-feedback oracle. | 438 // collected by the type-feedback oracle. |
| 442 void RecordTypeFeedbackCell(TypeFeedbackId id, Handle<Cell> cell); | 439 Handle<FixedArray> FeedbackVector() { |
| 440 return feedback_vector_; |
| 441 } |
| 442 void StoreFeedbackVectorSlot(int slot, Handle<Object> object) { |
| 443 feedback_vector_->set(slot, *object); |
| 444 } |
| 445 void InitializeFeedbackVector(); |
| 443 | 446 |
| 444 // Record a call's return site offset, used to rebuild the frame if the | 447 // Record a call's return site offset, used to rebuild the frame if the |
| 445 // called function was inlined at the site. | 448 // called function was inlined at the site. |
| 446 void RecordJSReturnSite(Call* call); | 449 void RecordJSReturnSite(Call* call); |
| 447 | 450 |
| 448 // Prepare for bailout before a test (or compare) and branch. If | 451 // Prepare for bailout before a test (or compare) and branch. If |
| 449 // should_normalize, then the following comparison will not handle the | 452 // should_normalize, then the following comparison will not handle the |
| 450 // canonical JS true value so we will insert a (dead) test against true at | 453 // canonical JS true value so we will insert a (dead) test against true at |
| 451 // the actual bailout target from the optimized code. If not | 454 // the actual bailout target from the optimized code. If not |
| 452 // should_normalize, the true and false labels are ignored. | 455 // should_normalize, the true and false labels are ignored. |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 // Complete a named property assignment. The receiver is expected on top | 561 // Complete a named property assignment. The receiver is expected on top |
| 559 // of the stack and the right-hand-side value in the accumulator. | 562 // of the stack and the right-hand-side value in the accumulator. |
| 560 void EmitNamedPropertyAssignment(Assignment* expr); | 563 void EmitNamedPropertyAssignment(Assignment* expr); |
| 561 | 564 |
| 562 // Complete a keyed property assignment. The receiver and key are | 565 // Complete a keyed property assignment. The receiver and key are |
| 563 // expected on top of the stack and the right-hand-side value in the | 566 // expected on top of the stack and the right-hand-side value in the |
| 564 // accumulator. | 567 // accumulator. |
| 565 void EmitKeyedPropertyAssignment(Assignment* expr); | 568 void EmitKeyedPropertyAssignment(Assignment* expr); |
| 566 | 569 |
| 567 void CallIC(Handle<Code> code, | 570 void CallIC(Handle<Code> code, |
| 568 ContextualMode mode = NOT_CONTEXTUAL, | |
| 569 TypeFeedbackId id = TypeFeedbackId::None()); | 571 TypeFeedbackId id = TypeFeedbackId::None()); |
| 570 | 572 |
| 571 void CallLoadIC(ContextualMode mode, | 573 void CallLoadIC(ContextualMode mode, |
| 572 TypeFeedbackId id = TypeFeedbackId::None()); | 574 TypeFeedbackId id = TypeFeedbackId::None()); |
| 573 void CallStoreIC(ContextualMode mode, | 575 void CallStoreIC(TypeFeedbackId id = TypeFeedbackId::None()); |
| 574 TypeFeedbackId id = TypeFeedbackId::None()); | |
| 575 | 576 |
| 576 void SetFunctionPosition(FunctionLiteral* fun); | 577 void SetFunctionPosition(FunctionLiteral* fun); |
| 577 void SetReturnPosition(FunctionLiteral* fun); | 578 void SetReturnPosition(FunctionLiteral* fun); |
| 578 void SetStatementPosition(Statement* stmt); | 579 void SetStatementPosition(Statement* stmt); |
| 579 void SetExpressionPosition(Expression* expr); | 580 void SetExpressionPosition(Expression* expr); |
| 580 void SetStatementPosition(int pos); | 581 void SetStatementPosition(int pos); |
| 581 void SetSourcePosition(int pos); | 582 void SetSourcePosition(int pos); |
| 582 | 583 |
| 583 // Non-local control flow support. | 584 // Non-local control flow support. |
| 584 void EnterFinallyBlock(); | 585 void EnterFinallyBlock(); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 631 | 632 |
| 632 void VisitComma(BinaryOperation* expr); | 633 void VisitComma(BinaryOperation* expr); |
| 633 void VisitLogicalExpression(BinaryOperation* expr); | 634 void VisitLogicalExpression(BinaryOperation* expr); |
| 634 void VisitArithmeticExpression(BinaryOperation* expr); | 635 void VisitArithmeticExpression(BinaryOperation* expr); |
| 635 | 636 |
| 636 void VisitForTypeofValue(Expression* expr); | 637 void VisitForTypeofValue(Expression* expr); |
| 637 | 638 |
| 638 void Generate(); | 639 void Generate(); |
| 639 void PopulateDeoptimizationData(Handle<Code> code); | 640 void PopulateDeoptimizationData(Handle<Code> code); |
| 640 void PopulateTypeFeedbackInfo(Handle<Code> code); | 641 void PopulateTypeFeedbackInfo(Handle<Code> code); |
| 641 void PopulateTypeFeedbackCells(Handle<Code> code); | |
| 642 | 642 |
| 643 Handle<FixedArray> handler_table() { return handler_table_; } | 643 Handle<FixedArray> handler_table() { return handler_table_; } |
| 644 | 644 |
| 645 struct BailoutEntry { | 645 struct BailoutEntry { |
| 646 BailoutId id; | 646 BailoutId id; |
| 647 unsigned pc_and_state; | 647 unsigned pc_and_state; |
| 648 }; | 648 }; |
| 649 | 649 |
| 650 struct BackEdgeEntry { | 650 struct BackEdgeEntry { |
| 651 BailoutId id; | 651 BailoutId id; |
| 652 unsigned pc; | 652 unsigned pc; |
| 653 uint32_t loop_depth; | 653 uint32_t loop_depth; |
| 654 }; | 654 }; |
| 655 | 655 |
| 656 struct TypeFeedbackCellEntry { | |
| 657 TypeFeedbackId ast_id; | |
| 658 Handle<Cell> cell; | |
| 659 }; | |
| 660 | |
| 661 | |
| 662 class ExpressionContext BASE_EMBEDDED { | 656 class ExpressionContext BASE_EMBEDDED { |
| 663 public: | 657 public: |
| 664 explicit ExpressionContext(FullCodeGenerator* codegen) | 658 explicit ExpressionContext(FullCodeGenerator* codegen) |
| 665 : masm_(codegen->masm()), old_(codegen->context()), codegen_(codegen) { | 659 : masm_(codegen->masm()), old_(codegen->context()), codegen_(codegen) { |
| 666 codegen->set_new_context(this); | 660 codegen->set_new_context(this); |
| 667 } | 661 } |
| 668 | 662 |
| 669 virtual ~ExpressionContext() { | 663 virtual ~ExpressionContext() { |
| 670 codegen_->set_new_context(old_); | 664 codegen_->set_new_context(old_); |
| 671 } | 665 } |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 841 Label return_label_; | 835 Label return_label_; |
| 842 NestedStatement* nesting_stack_; | 836 NestedStatement* nesting_stack_; |
| 843 int loop_depth_; | 837 int loop_depth_; |
| 844 ZoneList<Handle<Object> >* globals_; | 838 ZoneList<Handle<Object> >* globals_; |
| 845 Handle<FixedArray> modules_; | 839 Handle<FixedArray> modules_; |
| 846 int module_index_; | 840 int module_index_; |
| 847 const ExpressionContext* context_; | 841 const ExpressionContext* context_; |
| 848 ZoneList<BailoutEntry> bailout_entries_; | 842 ZoneList<BailoutEntry> bailout_entries_; |
| 849 GrowableBitVector prepared_bailout_ids_; | 843 GrowableBitVector prepared_bailout_ids_; |
| 850 ZoneList<BackEdgeEntry> back_edges_; | 844 ZoneList<BackEdgeEntry> back_edges_; |
| 851 ZoneList<TypeFeedbackCellEntry> type_feedback_cells_; | |
| 852 int ic_total_count_; | 845 int ic_total_count_; |
| 853 Handle<FixedArray> handler_table_; | 846 Handle<FixedArray> handler_table_; |
| 847 Handle<FixedArray> feedback_vector_; |
| 854 Handle<Cell> profiling_counter_; | 848 Handle<Cell> profiling_counter_; |
| 855 bool generate_debug_code_; | 849 bool generate_debug_code_; |
| 856 | 850 |
| 857 friend class NestedStatement; | 851 friend class NestedStatement; |
| 858 | 852 |
| 859 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); | 853 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); |
| 860 DISALLOW_COPY_AND_ASSIGN(FullCodeGenerator); | 854 DISALLOW_COPY_AND_ASSIGN(FullCodeGenerator); |
| 861 }; | 855 }; |
| 862 | 856 |
| 863 | 857 |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 966 | 960 |
| 967 Address start_; | 961 Address start_; |
| 968 Address instruction_start_; | 962 Address instruction_start_; |
| 969 uint32_t length_; | 963 uint32_t length_; |
| 970 }; | 964 }; |
| 971 | 965 |
| 972 | 966 |
| 973 } } // namespace v8::internal | 967 } } // namespace v8::internal |
| 974 | 968 |
| 975 #endif // V8_FULL_CODEGEN_H_ | 969 #endif // V8_FULL_CODEGEN_H_ |
| OLD | NEW |