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 class FeedbackVectorWrapper { |
438 // that will be cleared during GC and collected by the type-feedback oracle. | 435 public: |
439 void RecordTypeFeedbackCell(TypeFeedbackId id, Handle<Cell> cell); | 436 FeedbackVectorWrapper() : used_(0), maximum_length_(0) {} |
| 437 |
| 438 void Initialize(Isolate* isolate, int minimum_length, int maximum_length); |
| 439 Handle<FixedArray> FeedbackVector() { return feedback_vector_; } |
| 440 void Visit(Isolate* isolate, AstNode* node); |
| 441 void Set(int slot, Handle<Object> object); |
| 442 void Finalize(Isolate* isolate); |
| 443 |
| 444 private: |
| 445 int used_; |
| 446 int maximum_length_; |
| 447 Handle<FixedArray> feedback_vector_; |
| 448 }; |
| 449 |
| 450 // Feedback slot support. The feedback vector will be cleared during gc and |
| 451 // collected by the type-feedback oracle. |
| 452 Handle<FixedArray> FeedbackVector() { |
| 453 return feedback_wrapper_.FeedbackVector(); |
| 454 } |
| 455 void StoreFeedbackVectorSlot(int slot, Handle<Object> object) { |
| 456 feedback_wrapper_.Set(slot, object); |
| 457 } |
440 | 458 |
441 // Record a call's return site offset, used to rebuild the frame if the | 459 // Record a call's return site offset, used to rebuild the frame if the |
442 // called function was inlined at the site. | 460 // called function was inlined at the site. |
443 void RecordJSReturnSite(Call* call); | 461 void RecordJSReturnSite(Call* call); |
444 | 462 |
445 // Prepare for bailout before a test (or compare) and branch. If | 463 // Prepare for bailout before a test (or compare) and branch. If |
446 // should_normalize, then the following comparison will not handle the | 464 // 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 | 465 // 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 | 466 // the actual bailout target from the optimized code. If not |
449 // should_normalize, the true and false labels are ignored. | 467 // should_normalize, the true and false labels are ignored. |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
628 | 646 |
629 void VisitComma(BinaryOperation* expr); | 647 void VisitComma(BinaryOperation* expr); |
630 void VisitLogicalExpression(BinaryOperation* expr); | 648 void VisitLogicalExpression(BinaryOperation* expr); |
631 void VisitArithmeticExpression(BinaryOperation* expr); | 649 void VisitArithmeticExpression(BinaryOperation* expr); |
632 | 650 |
633 void VisitForTypeofValue(Expression* expr); | 651 void VisitForTypeofValue(Expression* expr); |
634 | 652 |
635 void Generate(); | 653 void Generate(); |
636 void PopulateDeoptimizationData(Handle<Code> code); | 654 void PopulateDeoptimizationData(Handle<Code> code); |
637 void PopulateTypeFeedbackInfo(Handle<Code> code); | 655 void PopulateTypeFeedbackInfo(Handle<Code> code); |
638 void PopulateTypeFeedbackCells(Handle<Code> code); | |
639 | 656 |
640 Handle<FixedArray> handler_table() { return handler_table_; } | 657 Handle<FixedArray> handler_table() { return handler_table_; } |
641 | 658 |
642 struct BailoutEntry { | 659 struct BailoutEntry { |
643 BailoutId id; | 660 BailoutId id; |
644 unsigned pc_and_state; | 661 unsigned pc_and_state; |
645 }; | 662 }; |
646 | 663 |
647 struct BackEdgeEntry { | 664 struct BackEdgeEntry { |
648 BailoutId id; | 665 BailoutId id; |
649 unsigned pc; | 666 unsigned pc; |
650 uint32_t loop_depth; | 667 uint32_t loop_depth; |
651 }; | 668 }; |
652 | 669 |
653 struct TypeFeedbackCellEntry { | |
654 TypeFeedbackId ast_id; | |
655 Handle<Cell> cell; | |
656 }; | |
657 | |
658 | |
659 class ExpressionContext BASE_EMBEDDED { | 670 class ExpressionContext BASE_EMBEDDED { |
660 public: | 671 public: |
661 explicit ExpressionContext(FullCodeGenerator* codegen) | 672 explicit ExpressionContext(FullCodeGenerator* codegen) |
662 : masm_(codegen->masm()), old_(codegen->context()), codegen_(codegen) { | 673 : masm_(codegen->masm()), old_(codegen->context()), codegen_(codegen) { |
663 codegen->set_new_context(this); | 674 codegen->set_new_context(this); |
664 } | 675 } |
665 | 676 |
666 virtual ~ExpressionContext() { | 677 virtual ~ExpressionContext() { |
667 codegen_->set_new_context(old_); | 678 codegen_->set_new_context(old_); |
668 } | 679 } |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
838 Label return_label_; | 849 Label return_label_; |
839 NestedStatement* nesting_stack_; | 850 NestedStatement* nesting_stack_; |
840 int loop_depth_; | 851 int loop_depth_; |
841 ZoneList<Handle<Object> >* globals_; | 852 ZoneList<Handle<Object> >* globals_; |
842 Handle<FixedArray> modules_; | 853 Handle<FixedArray> modules_; |
843 int module_index_; | 854 int module_index_; |
844 const ExpressionContext* context_; | 855 const ExpressionContext* context_; |
845 ZoneList<BailoutEntry> bailout_entries_; | 856 ZoneList<BailoutEntry> bailout_entries_; |
846 GrowableBitVector prepared_bailout_ids_; | 857 GrowableBitVector prepared_bailout_ids_; |
847 ZoneList<BackEdgeEntry> back_edges_; | 858 ZoneList<BackEdgeEntry> back_edges_; |
848 ZoneList<TypeFeedbackCellEntry> type_feedback_cells_; | |
849 int ic_total_count_; | 859 int ic_total_count_; |
850 Handle<FixedArray> handler_table_; | 860 Handle<FixedArray> handler_table_; |
| 861 FeedbackVectorWrapper feedback_wrapper_; |
851 Handle<Cell> profiling_counter_; | 862 Handle<Cell> profiling_counter_; |
852 bool generate_debug_code_; | 863 bool generate_debug_code_; |
853 | 864 |
854 friend class NestedStatement; | 865 friend class NestedStatement; |
855 | 866 |
856 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); | 867 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); |
857 DISALLOW_COPY_AND_ASSIGN(FullCodeGenerator); | 868 DISALLOW_COPY_AND_ASSIGN(FullCodeGenerator); |
858 }; | 869 }; |
859 | 870 |
860 | 871 |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
963 | 974 |
964 Address start_; | 975 Address start_; |
965 Address instruction_start_; | 976 Address instruction_start_; |
966 uint32_t length_; | 977 uint32_t length_; |
967 }; | 978 }; |
968 | 979 |
969 | 980 |
970 } } // namespace v8::internal | 981 } } // namespace v8::internal |
971 | 982 |
972 #endif // V8_FULL_CODEGEN_H_ | 983 #endif // V8_FULL_CODEGEN_H_ |
OLD | NEW |