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

Side by Side Diff: src/hydrogen.h

Issue 6794041: Use placement new for zone objects in hydrogen. (Closed)
Patch Set: Created 9 years, 8 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 | « no previous file | src/hydrogen.cc » ('j') | src/hydrogen.cc » ('J')
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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 134
135 // If a target block is tagged as an inline function return, all 135 // If a target block is tagged as an inline function return, all
136 // predecessors should contain the inlined exit sequence: 136 // predecessors should contain the inlined exit sequence:
137 // 137 //
138 // LeaveInlined 138 // LeaveInlined
139 // Simulate (caller's environment) 139 // Simulate (caller's environment)
140 // Goto (target block) 140 // Goto (target block)
141 bool IsInlineReturnTarget() const { return is_inline_return_target_; } 141 bool IsInlineReturnTarget() const { return is_inline_return_target_; }
142 void MarkAsInlineReturnTarget() { is_inline_return_target_ = true; } 142 void MarkAsInlineReturnTarget() { is_inline_return_target_ = true; }
143 143
144 inline Zone* zone();
145
144 #ifdef DEBUG 146 #ifdef DEBUG
145 void Verify(); 147 void Verify();
146 #endif 148 #endif
147 149
148 private: 150 private:
149 void RegisterPredecessor(HBasicBlock* pred); 151 void RegisterPredecessor(HBasicBlock* pred);
150 void AddDominatedBlock(HBasicBlock* block); 152 void AddDominatedBlock(HBasicBlock* block);
151 153
152 HSimulate* CreateSimulate(int id); 154 HSimulate* CreateSimulate(int id);
153 HDeoptimize* CreateDeoptimize(); 155 HDeoptimize* CreateDeoptimize();
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 ZoneList<HBasicBlock*> back_edges_; 196 ZoneList<HBasicBlock*> back_edges_;
195 HBasicBlock* loop_header_; 197 HBasicBlock* loop_header_;
196 ZoneList<HBasicBlock*> blocks_; 198 ZoneList<HBasicBlock*> blocks_;
197 }; 199 };
198 200
199 201
200 class HGraph: public ZoneObject { 202 class HGraph: public ZoneObject {
201 public: 203 public:
202 explicit HGraph(CompilationInfo* info); 204 explicit HGraph(CompilationInfo* info);
203 205
206 Isolate* isolate() { return isolate_; }
207 Zone* zone() { return isolate_->zone(); }
208
204 const ZoneList<HBasicBlock*>* blocks() const { return &blocks_; } 209 const ZoneList<HBasicBlock*>* blocks() const { return &blocks_; }
205 const ZoneList<HPhi*>* phi_list() const { return phi_list_; } 210 const ZoneList<HPhi*>* phi_list() const { return phi_list_; }
206 HBasicBlock* entry_block() const { return entry_block_; } 211 HBasicBlock* entry_block() const { return entry_block_; }
207 HEnvironment* start_environment() const { return start_environment_; } 212 HEnvironment* start_environment() const { return start_environment_; }
208 213
209 void InitializeInferredTypes(); 214 void InitializeInferredTypes();
210 void InsertTypeConversions(); 215 void InsertTypeConversions();
211 void InsertRepresentationChanges(); 216 void InsertRepresentationChanges();
212 void ComputeMinusZeroChecks(); 217 void ComputeMinusZeroChecks();
213 bool ProcessArgumentsObject(); 218 bool ProcessArgumentsObject();
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 void InsertRepresentationChangeForUse(HValue* value, 279 void InsertRepresentationChangeForUse(HValue* value,
275 HValue* use, 280 HValue* use,
276 Representation to); 281 Representation to);
277 void InsertRepresentationChangesForValue(HValue* current, 282 void InsertRepresentationChangesForValue(HValue* current,
278 ZoneList<HValue*>* value_list, 283 ZoneList<HValue*>* value_list,
279 ZoneList<Representation>* rep_list); 284 ZoneList<Representation>* rep_list);
280 void InferTypes(ZoneList<HValue*>* worklist); 285 void InferTypes(ZoneList<HValue*>* worklist);
281 void InitializeInferredTypes(int from_inclusive, int to_inclusive); 286 void InitializeInferredTypes(int from_inclusive, int to_inclusive);
282 void CheckForBackEdge(HBasicBlock* block, HBasicBlock* successor); 287 void CheckForBackEdge(HBasicBlock* block, HBasicBlock* successor);
283 288
284 Isolate* isolate() { return isolate_; }
285
286 Isolate* isolate_; 289 Isolate* isolate_;
287 int next_block_id_; 290 int next_block_id_;
288 HBasicBlock* entry_block_; 291 HBasicBlock* entry_block_;
289 HEnvironment* start_environment_; 292 HEnvironment* start_environment_;
290 ZoneList<HBasicBlock*> blocks_; 293 ZoneList<HBasicBlock*> blocks_;
291 ZoneList<HValue*> values_; 294 ZoneList<HValue*> values_;
292 ZoneList<HPhi*>* phi_list_; 295 ZoneList<HPhi*>* phi_list_;
293 SetOncePointer<HConstant> undefined_constant_; 296 SetOncePointer<HConstant> undefined_constant_;
294 SetOncePointer<HConstant> constant_1_; 297 SetOncePointer<HConstant> constant_1_;
295 SetOncePointer<HConstant> constant_minus1_; 298 SetOncePointer<HConstant> constant_minus1_;
296 SetOncePointer<HConstant> constant_true_; 299 SetOncePointer<HConstant> constant_true_;
297 SetOncePointer<HConstant> constant_false_; 300 SetOncePointer<HConstant> constant_false_;
298 SetOncePointer<HArgumentsObject> arguments_object_; 301 SetOncePointer<HArgumentsObject> arguments_object_;
299 302
300 DISALLOW_COPY_AND_ASSIGN(HGraph); 303 DISALLOW_COPY_AND_ASSIGN(HGraph);
301 }; 304 };
302 305
303 306
307 Zone* HBasicBlock::zone() { return graph_->zone(); }
308
309
304 class HEnvironment: public ZoneObject { 310 class HEnvironment: public ZoneObject {
305 public: 311 public:
306 HEnvironment(HEnvironment* outer, 312 HEnvironment(HEnvironment* outer,
307 Scope* scope, 313 Scope* scope,
308 Handle<JSFunction> closure); 314 Handle<JSFunction> closure);
309 315
310 // Simple accessors. 316 // Simple accessors.
311 Handle<JSFunction> closure() const { return closure_; } 317 Handle<JSFunction> closure() const { return closure_; }
312 const ZoneList<HValue*>* values() const { return &values_; } 318 const ZoneList<HValue*>* values() const { return &values_; }
313 const ZoneList<int>* assigned_variables() const { 319 const ZoneList<int>* assigned_variables() const {
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 461
456 void set_for_typeof(bool for_typeof) { for_typeof_ = for_typeof; } 462 void set_for_typeof(bool for_typeof) { for_typeof_ = for_typeof; }
457 bool is_for_typeof() { return for_typeof_; } 463 bool is_for_typeof() { return for_typeof_; }
458 464
459 protected: 465 protected:
460 AstContext(HGraphBuilder* owner, Expression::Context kind); 466 AstContext(HGraphBuilder* owner, Expression::Context kind);
461 virtual ~AstContext(); 467 virtual ~AstContext();
462 468
463 HGraphBuilder* owner() const { return owner_; } 469 HGraphBuilder* owner() const { return owner_; }
464 470
471 inline Zone* zone();
472
465 // We want to be able to assert, in a context-specific way, that the stack 473 // We want to be able to assert, in a context-specific way, that the stack
466 // height makes sense when the context is filled. 474 // height makes sense when the context is filled.
467 #ifdef DEBUG 475 #ifdef DEBUG
468 int original_length_; 476 int original_length_;
469 #endif 477 #endif
470 478
471 private: 479 private:
472 HGraphBuilder* owner_; 480 HGraphBuilder* owner_;
473 Expression::Context kind_; 481 Expression::Context kind_;
474 AstContext* outer_; 482 AstContext* outer_;
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 BreakAndContinueScope* next_; 631 BreakAndContinueScope* next_;
624 }; 632 };
625 633
626 HGraphBuilder(CompilationInfo* info, TypeFeedbackOracle* oracle) 634 HGraphBuilder(CompilationInfo* info, TypeFeedbackOracle* oracle)
627 : function_state_(NULL), 635 : function_state_(NULL),
628 initial_function_state_(this, info, oracle), 636 initial_function_state_(this, info, oracle),
629 ast_context_(NULL), 637 ast_context_(NULL),
630 break_scope_(NULL), 638 break_scope_(NULL),
631 graph_(NULL), 639 graph_(NULL),
632 current_block_(NULL), 640 current_block_(NULL),
633 inlined_count_(0) { 641 inlined_count_(0),
642 zone_(info->isolate()->zone()) {
634 // This is not initialized in the initializer list because the 643 // This is not initialized in the initializer list because the
635 // constructor for the initial state relies on function_state_ == NULL 644 // constructor for the initial state relies on function_state_ == NULL
636 // to know it's the initial state. 645 // to know it's the initial state.
637 function_state_= &initial_function_state_; 646 function_state_= &initial_function_state_;
638 } 647 }
639 648
640 HGraph* CreateGraph(); 649 HGraph* CreateGraph();
641 650
642 // Simple accessors. 651 // Simple accessors.
643 HGraph* graph() const { return graph_; } 652 HGraph* graph() const { return graph_; }
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
867 HValue* val, 876 HValue* val,
868 Assignment* expr); 877 Assignment* expr);
869 878
870 HValue* BuildContextChainWalk(Variable* var); 879 HValue* BuildContextChainWalk(Variable* var);
871 880
872 void AddCheckConstantFunction(Call* expr, 881 void AddCheckConstantFunction(Call* expr,
873 HValue* receiver, 882 HValue* receiver,
874 Handle<Map> receiver_map, 883 Handle<Map> receiver_map,
875 bool smi_and_map_check); 884 bool smi_and_map_check);
876 885
886 Zone* zone() { return zone_; }
877 887
878 // The translation state of the currently-being-translated function. 888 // The translation state of the currently-being-translated function.
879 FunctionState* function_state_; 889 FunctionState* function_state_;
880 890
881 // The base of the function state stack. 891 // The base of the function state stack.
882 FunctionState initial_function_state_; 892 FunctionState initial_function_state_;
883 893
884 // Expression context of the currently visited subexpression. NULL when 894 // Expression context of the currently visited subexpression. NULL when
885 // visiting statements. 895 // visiting statements.
886 AstContext* ast_context_; 896 AstContext* ast_context_;
887 897
888 // A stack of breakable statements entered. 898 // A stack of breakable statements entered.
889 BreakAndContinueScope* break_scope_; 899 BreakAndContinueScope* break_scope_;
890 900
891 HGraph* graph_; 901 HGraph* graph_;
892 HBasicBlock* current_block_; 902 HBasicBlock* current_block_;
893 903
894 int inlined_count_; 904 int inlined_count_;
895 905
906 Zone* zone_;
907
896 friend class FunctionState; // Pushes and pops the state stack. 908 friend class FunctionState; // Pushes and pops the state stack.
897 friend class AstContext; // Pushes and pops the AST context stack. 909 friend class AstContext; // Pushes and pops the AST context stack.
898 910
899 DISALLOW_COPY_AND_ASSIGN(HGraphBuilder); 911 DISALLOW_COPY_AND_ASSIGN(HGraphBuilder);
900 }; 912 };
901 913
902 914
915 Zone* AstContext::zone() { return owner_->zone(); }
916
917
903 class HValueMap: public ZoneObject { 918 class HValueMap: public ZoneObject {
904 public: 919 public:
905 HValueMap() 920 HValueMap()
906 : array_size_(0), 921 : array_size_(0),
907 lists_size_(0), 922 lists_size_(0),
908 count_(0), 923 count_(0),
909 present_flags_(0), 924 present_flags_(0),
910 array_(NULL), 925 array_(NULL),
911 lists_(NULL), 926 lists_(NULL),
912 free_list_head_(kNil) { 927 free_list_head_(kNil) {
913 ResizeLists(kInitialSize); 928 ResizeLists(kInitialSize);
914 Resize(kInitialSize); 929 Resize(kInitialSize);
915 } 930 }
916 931
917 void Kill(int flags); 932 void Kill(int flags);
918 933
919 void Add(HValue* value) { 934 void Add(HValue* value) {
920 present_flags_ |= value->flags(); 935 present_flags_ |= value->flags();
921 Insert(value); 936 Insert(value);
922 } 937 }
923 938
924 HValue* Lookup(HValue* value) const; 939 HValue* Lookup(HValue* value) const;
925 HValueMap* Copy() const { return new HValueMap(this); } 940
941 HValueMap* Copy(Zone* zone) const {
942 return new(zone) HValueMap(this);
943 }
926 944
927 private: 945 private:
928 // A linked list of HValue* values. Stored in arrays. 946 // A linked list of HValue* values. Stored in arrays.
929 struct HValueMapListElement { 947 struct HValueMapListElement {
930 HValue* value; 948 HValue* value;
931 int next; // Index in the array of the next list element. 949 int next; // Index in the array of the next list element.
932 }; 950 };
933 static const int kNil = -1; // The end of a linked list 951 static const int kNil = -1; // The end of a linked list
934 952
935 // Must be a power of 2. 953 // Must be a power of 2.
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
1110 const char* filename_; 1128 const char* filename_;
1111 HeapStringAllocator string_allocator_; 1129 HeapStringAllocator string_allocator_;
1112 StringStream trace_; 1130 StringStream trace_;
1113 int indent_; 1131 int indent_;
1114 }; 1132 };
1115 1133
1116 1134
1117 } } // namespace v8::internal 1135 } } // namespace v8::internal
1118 1136
1119 #endif // V8_HYDROGEN_H_ 1137 #endif // V8_HYDROGEN_H_
OLDNEW
« no previous file with comments | « no previous file | src/hydrogen.cc » ('j') | src/hydrogen.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698