Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(721)

Side by Side Diff: src/hydrogen.h

Issue 6664001: [Isolates] Merge (7083,7111] from bleeding_edge. (Closed)
Patch Set: Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/heap.cc ('k') | src/hydrogen.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 185
186 private: 186 private:
187 void AddBlock(HBasicBlock* block); 187 void AddBlock(HBasicBlock* block);
188 188
189 ZoneList<HBasicBlock*> back_edges_; 189 ZoneList<HBasicBlock*> back_edges_;
190 HBasicBlock* loop_header_; 190 HBasicBlock* loop_header_;
191 ZoneList<HBasicBlock*> blocks_; 191 ZoneList<HBasicBlock*> blocks_;
192 }; 192 };
193 193
194 194
195 class HSubgraph: public ZoneObject { 195 class HGraph: public ZoneObject {
196 public:
197 explicit HSubgraph(HGraph* graph)
198 : graph_(graph),
199 entry_block_(NULL),
200 exit_block_(NULL) {
201 }
202
203 HGraph* graph() const { return graph_; }
204 HBasicBlock* entry_block() const { return entry_block_; }
205 HBasicBlock* exit_block() const { return exit_block_; }
206 void set_exit_block(HBasicBlock* block) {
207 exit_block_ = block;
208 }
209
210 void Initialize(HBasicBlock* block) {
211 ASSERT(entry_block_ == NULL);
212 entry_block_ = block;
213 exit_block_ = block;
214 }
215
216 protected:
217 HGraph* graph_; // The graph this is a subgraph of.
218 HBasicBlock* entry_block_;
219 HBasicBlock* exit_block_;
220 };
221
222
223 class HGraph: public HSubgraph {
224 public: 196 public:
225 explicit HGraph(CompilationInfo* info); 197 explicit HGraph(CompilationInfo* info);
226 198
227 const ZoneList<HBasicBlock*>* blocks() const { return &blocks_; } 199 const ZoneList<HBasicBlock*>* blocks() const { return &blocks_; }
228 const ZoneList<HPhi*>* phi_list() const { return phi_list_; } 200 const ZoneList<HPhi*>* phi_list() const { return phi_list_; }
201 HBasicBlock* entry_block() const { return entry_block_; }
229 HEnvironment* start_environment() const { return start_environment_; } 202 HEnvironment* start_environment() const { return start_environment_; }
230 203
231 void InitializeInferredTypes(); 204 void InitializeInferredTypes();
232 void InsertTypeConversions(); 205 void InsertTypeConversions();
233 void InsertRepresentationChanges(); 206 void InsertRepresentationChanges();
234 void ComputeMinusZeroChecks(); 207 void ComputeMinusZeroChecks();
235 bool ProcessArgumentsObject(); 208 bool ProcessArgumentsObject();
236 void EliminateRedundantPhis(); 209 void EliminateRedundantPhis();
237 void Canonicalize(); 210 void Canonicalize();
238 void OrderBlocks(); 211 void OrderBlocks();
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 ZoneList<HBasicBlock*>* order, 261 ZoneList<HBasicBlock*>* order,
289 HBasicBlock* loop_header); 262 HBasicBlock* loop_header);
290 HConstant* GetConstant(SetOncePointer<HConstant>* pointer, 263 HConstant* GetConstant(SetOncePointer<HConstant>* pointer,
291 Object* value); 264 Object* value);
292 265
293 void InsertTypeConversions(HInstruction* instr); 266 void InsertTypeConversions(HInstruction* instr);
294 void PropagateMinusZeroChecks(HValue* value, BitVector* visited); 267 void PropagateMinusZeroChecks(HValue* value, BitVector* visited);
295 void InsertRepresentationChangeForUse(HValue* value, 268 void InsertRepresentationChangeForUse(HValue* value,
296 HValue* use, 269 HValue* use,
297 Representation to); 270 Representation to);
298 void InsertRepresentationChanges(HValue* current); 271 void InsertRepresentationChangesForValue(HValue* current,
272 ZoneList<HValue*>* value_list,
273 ZoneList<Representation>* rep_list);
299 void InferTypes(ZoneList<HValue*>* worklist); 274 void InferTypes(ZoneList<HValue*>* worklist);
300 void InitializeInferredTypes(int from_inclusive, int to_inclusive); 275 void InitializeInferredTypes(int from_inclusive, int to_inclusive);
301 void CheckForBackEdge(HBasicBlock* block, HBasicBlock* successor); 276 void CheckForBackEdge(HBasicBlock* block, HBasicBlock* successor);
302 277
303 int next_block_id_; 278 int next_block_id_;
279 HBasicBlock* entry_block_;
304 HEnvironment* start_environment_; 280 HEnvironment* start_environment_;
305 ZoneList<HBasicBlock*> blocks_; 281 ZoneList<HBasicBlock*> blocks_;
306 ZoneList<HValue*> values_; 282 ZoneList<HValue*> values_;
307 ZoneList<HPhi*>* phi_list_; 283 ZoneList<HPhi*>* phi_list_;
308 SetOncePointer<HConstant> undefined_constant_; 284 SetOncePointer<HConstant> undefined_constant_;
309 SetOncePointer<HConstant> constant_1_; 285 SetOncePointer<HConstant> constant_1_;
310 SetOncePointer<HConstant> constant_minus1_; 286 SetOncePointer<HConstant> constant_minus1_;
311 SetOncePointer<HConstant> constant_true_; 287 SetOncePointer<HConstant> constant_true_;
312 SetOncePointer<HConstant> constant_false_; 288 SetOncePointer<HConstant> constant_false_;
313 SetOncePointer<HArgumentsObject> arguments_object_; 289 SetOncePointer<HArgumentsObject> arguments_object_;
314 290
315 friend class HSubgraph;
316
317 DISALLOW_COPY_AND_ASSIGN(HGraph); 291 DISALLOW_COPY_AND_ASSIGN(HGraph);
318 }; 292 };
319 293
320 294
321 class HEnvironment: public ZoneObject { 295 class HEnvironment: public ZoneObject {
322 public: 296 public:
323 HEnvironment(HEnvironment* outer, 297 HEnvironment(HEnvironment* outer,
324 Scope* scope, 298 Scope* scope,
325 Handle<JSFunction> closure); 299 Handle<JSFunction> closure);
326 300
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 HEnvironment* CopyForInlining(Handle<JSFunction> target, 371 HEnvironment* CopyForInlining(Handle<JSFunction> target,
398 FunctionLiteral* function, 372 FunctionLiteral* function,
399 bool is_speculative, 373 bool is_speculative,
400 HConstant* undefined) const; 374 HConstant* undefined) const;
401 375
402 void AddIncomingEdge(HBasicBlock* block, HEnvironment* other); 376 void AddIncomingEdge(HBasicBlock* block, HEnvironment* other);
403 377
404 void ClearHistory() { 378 void ClearHistory() {
405 pop_count_ = 0; 379 pop_count_ = 0;
406 push_count_ = 0; 380 push_count_ = 0;
407 assigned_variables_.Clear(); 381 assigned_variables_.Rewind(0);
408 } 382 }
409 383
410 void SetValueAt(int index, HValue* value) { 384 void SetValueAt(int index, HValue* value) {
411 ASSERT(index < length()); 385 ASSERT(index < length());
412 values_[index] = value; 386 values_[index] = value;
413 } 387 }
414 388
415 void PrintTo(StringStream* stream); 389 void PrintTo(StringStream* stream);
416 void PrintToStd(); 390 void PrintToStd();
417 391
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
633 HGraphBuilder* owner_; 607 HGraphBuilder* owner_;
634 BreakAndContinueScope* next_; 608 BreakAndContinueScope* next_;
635 }; 609 };
636 610
637 HGraphBuilder(CompilationInfo* info, TypeFeedbackOracle* oracle) 611 HGraphBuilder(CompilationInfo* info, TypeFeedbackOracle* oracle)
638 : function_state_(NULL), 612 : function_state_(NULL),
639 initial_function_state_(this, info, oracle), 613 initial_function_state_(this, info, oracle),
640 ast_context_(NULL), 614 ast_context_(NULL),
641 break_scope_(NULL), 615 break_scope_(NULL),
642 graph_(NULL), 616 graph_(NULL),
643 current_subgraph_(NULL), 617 current_block_(NULL),
644 inlined_count_(0) { 618 inlined_count_(0) {
645 // This is not initialized in the initializer list because the 619 // This is not initialized in the initializer list because the
646 // constructor for the initial state relies on function_state_ == NULL 620 // constructor for the initial state relies on function_state_ == NULL
647 // to know it's the initial state. 621 // to know it's the initial state.
648 function_state_= &initial_function_state_; 622 function_state_= &initial_function_state_;
649 } 623 }
650 624
651 HGraph* CreateGraph(); 625 HGraph* CreateGraph();
652 626
653 // Simple accessors. 627 // Simple accessors.
654 HGraph* graph() const { return graph_; } 628 HGraph* graph() const { return graph_; }
655 HSubgraph* subgraph() const { return current_subgraph_; }
656 BreakAndContinueScope* break_scope() const { return break_scope_; } 629 BreakAndContinueScope* break_scope() const { return break_scope_; }
657 void set_break_scope(BreakAndContinueScope* head) { break_scope_ = head; } 630 void set_break_scope(BreakAndContinueScope* head) { break_scope_ = head; }
658 631
659 HBasicBlock* current_block() const { return subgraph()->exit_block(); } 632 HBasicBlock* current_block() const { return current_block_; }
660 void set_current_block(HBasicBlock* block) { 633 void set_current_block(HBasicBlock* block) { current_block_ = block; }
661 subgraph()->set_exit_block(block);
662 }
663 HEnvironment* environment() const { 634 HEnvironment* environment() const {
664 return current_block()->last_environment(); 635 return current_block()->last_environment();
665 } 636 }
666 637
667 // Adding instructions. 638 // Adding instructions.
668 HInstruction* AddInstruction(HInstruction* instr); 639 HInstruction* AddInstruction(HInstruction* instr);
669 void AddSimulate(int id); 640 void AddSimulate(int id);
670 641
671 // Bailout environment manipulation. 642 // Bailout environment manipulation.
672 void Push(HValue* value) { environment()->Push(value); } 643 void Push(HValue* value) { environment()->Push(value); }
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
743 HBasicBlock* CreateLoop(IterationStatement* statement, 714 HBasicBlock* CreateLoop(IterationStatement* statement,
744 HBasicBlock* loop_entry, 715 HBasicBlock* loop_entry,
745 HBasicBlock* body_exit, 716 HBasicBlock* body_exit,
746 HBasicBlock* loop_successor, 717 HBasicBlock* loop_successor,
747 HBasicBlock* break_block); 718 HBasicBlock* break_block);
748 719
749 HBasicBlock* JoinContinue(IterationStatement* statement, 720 HBasicBlock* JoinContinue(IterationStatement* statement,
750 HBasicBlock* exit_block, 721 HBasicBlock* exit_block,
751 HBasicBlock* continue_block); 722 HBasicBlock* continue_block);
752 723
753 void AddToSubgraph(HSubgraph* graph, ZoneList<Statement*>* stmts);
754 void AddToSubgraph(HSubgraph* graph, Statement* stmt);
755 void AddToSubgraph(HSubgraph* graph, Expression* expr);
756
757 HValue* Top() const { return environment()->Top(); } 724 HValue* Top() const { return environment()->Top(); }
758 void Drop(int n) { environment()->Drop(n); } 725 void Drop(int n) { environment()->Drop(n); }
759 void Bind(Variable* var, HValue* value) { environment()->Bind(var, value); } 726 void Bind(Variable* var, HValue* value) { environment()->Bind(var, value); }
760 727
761 void VisitForValue(Expression* expr); 728 void VisitForValue(Expression* expr);
762 void VisitForEffect(Expression* expr); 729 void VisitForEffect(Expression* expr);
763 void VisitForControl(Expression* expr, 730 void VisitForControl(Expression* expr,
764 HBasicBlock* true_block, 731 HBasicBlock* true_block,
765 HBasicBlock* false_block); 732 HBasicBlock* false_block);
766 733
(...skipping 17 matching lines...) Expand all
784 static Representation ToRepresentation(TypeInfo info); 751 static Representation ToRepresentation(TypeInfo info);
785 752
786 void SetupScope(Scope* scope); 753 void SetupScope(Scope* scope);
787 virtual void VisitStatements(ZoneList<Statement*>* statements); 754 virtual void VisitStatements(ZoneList<Statement*>* statements);
788 755
789 #define DECLARE_VISIT(type) virtual void Visit##type(type* node); 756 #define DECLARE_VISIT(type) virtual void Visit##type(type* node);
790 AST_NODE_LIST(DECLARE_VISIT) 757 AST_NODE_LIST(DECLARE_VISIT)
791 #undef DECLARE_VISIT 758 #undef DECLARE_VISIT
792 759
793 HBasicBlock* CreateBasicBlock(HEnvironment* env); 760 HBasicBlock* CreateBasicBlock(HEnvironment* env);
794 HSubgraph* CreateEmptySubgraph();
795 HBasicBlock* CreateLoopHeaderBlock(); 761 HBasicBlock* CreateLoopHeaderBlock();
796 762
797 // Helpers for flow graph construction. 763 // Helpers for flow graph construction.
798 void LookupGlobalPropertyCell(Variable* var, 764 void LookupGlobalPropertyCell(Variable* var,
799 LookupResult* lookup, 765 LookupResult* lookup,
800 bool is_store); 766 bool is_store);
801 767
802 bool TryArgumentsAccess(Property* expr); 768 bool TryArgumentsAccess(Property* expr);
803 bool TryCallApply(Call* expr); 769 bool TryCallApply(Call* expr);
804 bool TryInline(Call* expr); 770 bool TryInline(Call* expr);
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
877 HInstruction* BuildStoreKeyedFastElement(HValue* object, 843 HInstruction* BuildStoreKeyedFastElement(HValue* object,
878 HValue* key, 844 HValue* key,
879 HValue* val, 845 HValue* val,
880 Expression* expr); 846 Expression* expr);
881 847
882 HInstruction* BuildStoreKeyedPixelArrayElement(HValue* object, 848 HInstruction* BuildStoreKeyedPixelArrayElement(HValue* object,
883 HValue* key, 849 HValue* key,
884 HValue* val, 850 HValue* val,
885 Expression* expr); 851 Expression* expr);
886 852
887 HCompare* BuildSwitchCompare(HSubgraph* subgraph,
888 HValue* switch_value,
889 CaseClause* clause);
890
891 HValue* BuildContextChainWalk(Variable* var); 853 HValue* BuildContextChainWalk(Variable* var);
892 854
893 void AddCheckConstantFunction(Call* expr, 855 void AddCheckConstantFunction(Call* expr,
894 HValue* receiver, 856 HValue* receiver,
895 Handle<Map> receiver_map, 857 Handle<Map> receiver_map,
896 bool smi_and_map_check); 858 bool smi_and_map_check);
897 859
898 860
899 // The translation state of the currently-being-translated function. 861 // The translation state of the currently-being-translated function.
900 FunctionState* function_state_; 862 FunctionState* function_state_;
901 863
902 // The base of the function state stack. 864 // The base of the function state stack.
903 FunctionState initial_function_state_; 865 FunctionState initial_function_state_;
904 866
905 // Expression context of the currently visited subexpression. NULL when 867 // Expression context of the currently visited subexpression. NULL when
906 // visiting statements. 868 // visiting statements.
907 AstContext* ast_context_; 869 AstContext* ast_context_;
908 870
909 // A stack of breakable statements entered. 871 // A stack of breakable statements entered.
910 BreakAndContinueScope* break_scope_; 872 BreakAndContinueScope* break_scope_;
911 873
912 HGraph* graph_; 874 HGraph* graph_;
913 HSubgraph* current_subgraph_; 875 HBasicBlock* current_block_;
914 876
915 int inlined_count_; 877 int inlined_count_;
916 878
917 friend class FunctionState; // Pushes and pops the state stack. 879 friend class FunctionState; // Pushes and pops the state stack.
918 friend class AstContext; // Pushes and pops the AST context stack. 880 friend class AstContext; // Pushes and pops the AST context stack.
919 881
920 DISALLOW_COPY_AND_ASSIGN(HGraphBuilder); 882 DISALLOW_COPY_AND_ASSIGN(HGraphBuilder);
921 }; 883 };
922 884
923 885
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
1128 const char* filename_; 1090 const char* filename_;
1129 HeapStringAllocator string_allocator_; 1091 HeapStringAllocator string_allocator_;
1130 StringStream trace_; 1092 StringStream trace_;
1131 int indent_; 1093 int indent_;
1132 }; 1094 };
1133 1095
1134 1096
1135 } } // namespace v8::internal 1097 } } // namespace v8::internal
1136 1098
1137 #endif // V8_HYDROGEN_H_ 1099 #endif // V8_HYDROGEN_H_
OLDNEW
« no previous file with comments | « src/heap.cc ('k') | src/hydrogen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698