| 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 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 | 424 |
| 428 // Platform-specific code for equality comparison with a nil-like value. | 425 // Platform-specific code for equality comparison with a nil-like value. |
| 429 void EmitLiteralCompareNil(CompareOperation* expr, | 426 void EmitLiteralCompareNil(CompareOperation* expr, |
| 430 Expression* sub_expr, | 427 Expression* sub_expr, |
| 431 NilValue nil); | 428 NilValue nil); |
| 432 | 429 |
| 433 // Bailout support. | 430 // Bailout support. |
| 434 void PrepareForBailout(Expression* node, State state); | 431 void PrepareForBailout(Expression* node, State state); |
| 435 void PrepareForBailoutForId(BailoutId id, State state); | 432 void PrepareForBailoutForId(BailoutId id, State state); |
| 436 | 433 |
| 437 // Cache cell support. This associates AST ids with global property cells | 434 // Feedback slot support. The feedback vector will be cleared during gc and |
| 438 // that will be cleared during GC and collected by the type-feedback oracle. | 435 // collected by the type-feedback oracle. |
| 439 void RecordTypeFeedbackCell(TypeFeedbackId id, Handle<Cell> cell); | 436 Handle<FixedArray> FeedbackVector() { |
| 437 return feedback_vector_; |
| 438 } |
| 439 void StoreFeedbackVectorSlot(int slot, Handle<Object> object) { |
| 440 feedback_vector_->set(slot, *object); |
| 441 } |
| 442 void InitializeFeedbackVector(); |
| 440 | 443 |
| 441 // Record a call's return site offset, used to rebuild the frame if the | 444 // Record a call's return site offset, used to rebuild the frame if the |
| 442 // called function was inlined at the site. | 445 // called function was inlined at the site. |
| 443 void RecordJSReturnSite(Call* call); | 446 void RecordJSReturnSite(Call* call); |
| 444 | 447 |
| 445 // Prepare for bailout before a test (or compare) and branch. If | 448 // Prepare for bailout before a test (or compare) and branch. If |
| 446 // should_normalize, then the following comparison will not handle the | 449 // should_normalize, then the following comparison will not handle the |
| 447 // canonical JS true value so we will insert a (dead) test against true at | 450 // canonical JS true value so we will insert a (dead) test against true at |
| 448 // the actual bailout target from the optimized code. If not | 451 // the actual bailout target from the optimized code. If not |
| 449 // should_normalize, the true and false labels are ignored. | 452 // should_normalize, the true and false labels are ignored. |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 628 | 631 |
| 629 void VisitComma(BinaryOperation* expr); | 632 void VisitComma(BinaryOperation* expr); |
| 630 void VisitLogicalExpression(BinaryOperation* expr); | 633 void VisitLogicalExpression(BinaryOperation* expr); |
| 631 void VisitArithmeticExpression(BinaryOperation* expr); | 634 void VisitArithmeticExpression(BinaryOperation* expr); |
| 632 | 635 |
| 633 void VisitForTypeofValue(Expression* expr); | 636 void VisitForTypeofValue(Expression* expr); |
| 634 | 637 |
| 635 void Generate(); | 638 void Generate(); |
| 636 void PopulateDeoptimizationData(Handle<Code> code); | 639 void PopulateDeoptimizationData(Handle<Code> code); |
| 637 void PopulateTypeFeedbackInfo(Handle<Code> code); | 640 void PopulateTypeFeedbackInfo(Handle<Code> code); |
| 638 void PopulateTypeFeedbackCells(Handle<Code> code); | |
| 639 | 641 |
| 640 Handle<FixedArray> handler_table() { return handler_table_; } | 642 Handle<FixedArray> handler_table() { return handler_table_; } |
| 641 | 643 |
| 642 struct BailoutEntry { | 644 struct BailoutEntry { |
| 643 BailoutId id; | 645 BailoutId id; |
| 644 unsigned pc_and_state; | 646 unsigned pc_and_state; |
| 645 }; | 647 }; |
| 646 | 648 |
| 647 struct BackEdgeEntry { | 649 struct BackEdgeEntry { |
| 648 BailoutId id; | 650 BailoutId id; |
| 649 unsigned pc; | 651 unsigned pc; |
| 650 uint32_t loop_depth; | 652 uint32_t loop_depth; |
| 651 }; | 653 }; |
| 652 | 654 |
| 653 struct TypeFeedbackCellEntry { | |
| 654 TypeFeedbackId ast_id; | |
| 655 Handle<Cell> cell; | |
| 656 }; | |
| 657 | |
| 658 | |
| 659 class ExpressionContext BASE_EMBEDDED { | 655 class ExpressionContext BASE_EMBEDDED { |
| 660 public: | 656 public: |
| 661 explicit ExpressionContext(FullCodeGenerator* codegen) | 657 explicit ExpressionContext(FullCodeGenerator* codegen) |
| 662 : masm_(codegen->masm()), old_(codegen->context()), codegen_(codegen) { | 658 : masm_(codegen->masm()), old_(codegen->context()), codegen_(codegen) { |
| 663 codegen->set_new_context(this); | 659 codegen->set_new_context(this); |
| 664 } | 660 } |
| 665 | 661 |
| 666 virtual ~ExpressionContext() { | 662 virtual ~ExpressionContext() { |
| 667 codegen_->set_new_context(old_); | 663 codegen_->set_new_context(old_); |
| 668 } | 664 } |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 838 Label return_label_; | 834 Label return_label_; |
| 839 NestedStatement* nesting_stack_; | 835 NestedStatement* nesting_stack_; |
| 840 int loop_depth_; | 836 int loop_depth_; |
| 841 ZoneList<Handle<Object> >* globals_; | 837 ZoneList<Handle<Object> >* globals_; |
| 842 Handle<FixedArray> modules_; | 838 Handle<FixedArray> modules_; |
| 843 int module_index_; | 839 int module_index_; |
| 844 const ExpressionContext* context_; | 840 const ExpressionContext* context_; |
| 845 ZoneList<BailoutEntry> bailout_entries_; | 841 ZoneList<BailoutEntry> bailout_entries_; |
| 846 GrowableBitVector prepared_bailout_ids_; | 842 GrowableBitVector prepared_bailout_ids_; |
| 847 ZoneList<BackEdgeEntry> back_edges_; | 843 ZoneList<BackEdgeEntry> back_edges_; |
| 848 ZoneList<TypeFeedbackCellEntry> type_feedback_cells_; | |
| 849 int ic_total_count_; | 844 int ic_total_count_; |
| 850 Handle<FixedArray> handler_table_; | 845 Handle<FixedArray> handler_table_; |
| 846 Handle<FixedArray> feedback_vector_; |
| 851 Handle<Cell> profiling_counter_; | 847 Handle<Cell> profiling_counter_; |
| 852 bool generate_debug_code_; | 848 bool generate_debug_code_; |
| 853 | 849 |
| 854 friend class NestedStatement; | 850 friend class NestedStatement; |
| 855 | 851 |
| 856 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); | 852 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); |
| 857 DISALLOW_COPY_AND_ASSIGN(FullCodeGenerator); | 853 DISALLOW_COPY_AND_ASSIGN(FullCodeGenerator); |
| 858 }; | 854 }; |
| 859 | 855 |
| 860 | 856 |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 963 | 959 |
| 964 Address start_; | 960 Address start_; |
| 965 Address instruction_start_; | 961 Address instruction_start_; |
| 966 uint32_t length_; | 962 uint32_t length_; |
| 967 }; | 963 }; |
| 968 | 964 |
| 969 | 965 |
| 970 } } // namespace v8::internal | 966 } } // namespace v8::internal |
| 971 | 967 |
| 972 #endif // V8_FULL_CODEGEN_H_ | 968 #endif // V8_FULL_CODEGEN_H_ |
| OLD | NEW |