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

Side by Side Diff: src/hydrogen.h

Issue 148503002: A64: Synchronize with r15545. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « src/heap-snapshot-generator.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 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 28 matching lines...) Expand all
39 39
40 namespace v8 { 40 namespace v8 {
41 namespace internal { 41 namespace internal {
42 42
43 // Forward declarations. 43 // Forward declarations.
44 class BitVector; 44 class BitVector;
45 class FunctionState; 45 class FunctionState;
46 class HEnvironment; 46 class HEnvironment;
47 class HGraph; 47 class HGraph;
48 class HLoopInformation; 48 class HLoopInformation;
49 class HOsrBuilder;
49 class HTracer; 50 class HTracer;
50 class LAllocator; 51 class LAllocator;
51 class LChunk; 52 class LChunk;
52 class LiveRange; 53 class LiveRange;
53 54
54 55
55 class HBasicBlock: public ZoneObject { 56 class HBasicBlock: public ZoneObject {
56 public: 57 public:
57 explicit HBasicBlock(HGraph* graph); 58 explicit HBasicBlock(HGraph* graph);
58 virtual ~HBasicBlock() { } 59 virtual ~HBasicBlock() { }
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 bool Done() { return current_ >= predecessor_list_->length(); } 224 bool Done() { return current_ >= predecessor_list_->length(); }
224 HBasicBlock* Current() { return predecessor_list_->at(current_); } 225 HBasicBlock* Current() { return predecessor_list_->at(current_); }
225 void Advance() { current_++; } 226 void Advance() { current_++; }
226 227
227 private: 228 private:
228 const ZoneList<HBasicBlock*>* predecessor_list_; 229 const ZoneList<HBasicBlock*>* predecessor_list_;
229 int current_; 230 int current_;
230 }; 231 };
231 232
232 233
234 class HInstructionIterator BASE_EMBEDDED {
235 public:
236 explicit HInstructionIterator(HBasicBlock* block) : instr_(block->first()) { }
237
238 bool Done() { return instr_ == NULL; }
239 HInstruction* Current() { return instr_; }
240 void Advance() { instr_ = instr_->next(); }
241
242 private:
243 HInstruction* instr_;
244 };
245
246
233 class HLoopInformation: public ZoneObject { 247 class HLoopInformation: public ZoneObject {
234 public: 248 public:
235 HLoopInformation(HBasicBlock* loop_header, Zone* zone) 249 HLoopInformation(HBasicBlock* loop_header, Zone* zone)
236 : back_edges_(4, zone), 250 : back_edges_(4, zone),
237 loop_header_(loop_header), 251 loop_header_(loop_header),
238 blocks_(8, zone), 252 blocks_(8, zone),
239 stack_check_(NULL) { 253 stack_check_(NULL) {
240 blocks_.Add(loop_header, zone); 254 blocks_.Add(loop_header, zone);
241 } 255 }
242 virtual ~HLoopInformation() {} 256 virtual ~HLoopInformation() {}
(...skipping 27 matching lines...) Expand all
270 Isolate* isolate() const { return isolate_; } 284 Isolate* isolate() const { return isolate_; }
271 Zone* zone() const { return zone_; } 285 Zone* zone() const { return zone_; }
272 CompilationInfo* info() const { return info_; } 286 CompilationInfo* info() const { return info_; }
273 287
274 const ZoneList<HBasicBlock*>* blocks() const { return &blocks_; } 288 const ZoneList<HBasicBlock*>* blocks() const { return &blocks_; }
275 const ZoneList<HPhi*>* phi_list() const { return phi_list_; } 289 const ZoneList<HPhi*>* phi_list() const { return phi_list_; }
276 HBasicBlock* entry_block() const { return entry_block_; } 290 HBasicBlock* entry_block() const { return entry_block_; }
277 HEnvironment* start_environment() const { return start_environment_; } 291 HEnvironment* start_environment() const { return start_environment_; }
278 292
279 void FinalizeUniqueValueIds(); 293 void FinalizeUniqueValueIds();
280 void InitializeInferredTypes();
281 void InsertTypeConversions(); 294 void InsertTypeConversions();
282 void MergeRemovableSimulates(); 295 void MergeRemovableSimulates();
283 void InsertRepresentationChanges();
284 void MarkDeoptimizeOnUndefined(); 296 void MarkDeoptimizeOnUndefined();
285 void ComputeMinusZeroChecks(); 297 void ComputeMinusZeroChecks();
286 void ComputeSafeUint32Operations();
287 bool ProcessArgumentsObject(); 298 bool ProcessArgumentsObject();
288 void EliminateRedundantPhis();
289 void Canonicalize(); 299 void Canonicalize();
290 void OrderBlocks(); 300 void OrderBlocks();
291 void AssignDominators(); 301 void AssignDominators();
292 void SetupInformativeDefinitions(); 302 void SetupInformativeDefinitions();
293 void EliminateRedundantBoundsChecks();
294 void DehoistSimpleArrayIndexComputations(); 303 void DehoistSimpleArrayIndexComputations();
295 void RestoreActualValues(); 304 void RestoreActualValues();
296 void DeadCodeElimination(const char *phase_name);
297 void PropagateDeoptimizingMark(); 305 void PropagateDeoptimizingMark();
298 void AnalyzeAndPruneEnvironmentLiveness(); 306 void AnalyzeAndPruneEnvironmentLiveness();
299 307
300 // Returns false if there are phi-uses of the arguments-object 308 // Returns false if there are phi-uses of the arguments-object
301 // which are not supported by the optimizing compiler. 309 // which are not supported by the optimizing compiler.
302 bool CheckArgumentsPhiUses(); 310 bool CheckArgumentsPhiUses();
303 311
304 // Returns false if there are phi-uses of an uninitialized const 312 // Returns false if there are phi-uses of an uninitialized const
305 // which are not supported by the optimizing compiler. 313 // which are not supported by the optimizing compiler.
306 bool CheckConstPhiUses(); 314 bool CheckConstPhiUses();
307 315
308 void CollectPhis(); 316 void CollectPhis();
309 317
310 void set_undefined_constant(HConstant* constant) { 318 void set_undefined_constant(HConstant* constant) {
311 undefined_constant_.set(constant); 319 undefined_constant_.set(constant);
312 } 320 }
313 HConstant* GetConstantUndefined() const { return undefined_constant_.get(); } 321 HConstant* GetConstantUndefined() const { return undefined_constant_.get(); }
314 HConstant* GetConstant0(); 322 HConstant* GetConstant0();
315 HConstant* GetConstant1(); 323 HConstant* GetConstant1();
316 HConstant* GetConstantMinus1(); 324 HConstant* GetConstantMinus1();
317 HConstant* GetConstantTrue(); 325 HConstant* GetConstantTrue();
318 HConstant* GetConstantFalse(); 326 HConstant* GetConstantFalse();
319 HConstant* GetConstantHole(); 327 HConstant* GetConstantHole();
320 HConstant* GetConstantNull(); 328 HConstant* GetConstantNull();
321 HConstant* GetInvalidContext(); 329 HConstant* GetInvalidContext();
322 330
331 bool IsStandardConstant(HConstant* constant);
332
323 HBasicBlock* CreateBasicBlock(); 333 HBasicBlock* CreateBasicBlock();
324 HArgumentsObject* GetArgumentsObject() const { 334 HArgumentsObject* GetArgumentsObject() const {
325 return arguments_object_.get(); 335 return arguments_object_.get();
326 } 336 }
327 337
328 void SetArgumentsObject(HArgumentsObject* object) { 338 void SetArgumentsObject(HArgumentsObject* object) {
329 arguments_object_.set(object); 339 arguments_object_.set(object);
330 } 340 }
331 341
332 int GetMaximumValueID() const { return values_.length(); } 342 int GetMaximumValueID() const { return values_.length(); }
333 int GetNextBlockID() { return next_block_id_++; } 343 int GetNextBlockID() { return next_block_id_++; }
334 int GetNextValueID(HValue* value) { 344 int GetNextValueID(HValue* value) {
335 values_.Add(value, zone()); 345 values_.Add(value, zone());
336 return values_.length() - 1; 346 return values_.length() - 1;
337 } 347 }
338 HValue* LookupValue(int id) const { 348 HValue* LookupValue(int id) const {
339 if (id >= 0 && id < values_.length()) return values_[id]; 349 if (id >= 0 && id < values_.length()) return values_[id];
340 return NULL; 350 return NULL;
341 } 351 }
342 352
343 bool Optimize(SmartArrayPointer<char>* bailout_reason); 353 bool Optimize(SmartArrayPointer<char>* bailout_reason);
344 354
345 #ifdef DEBUG 355 #ifdef DEBUG
346 void Verify(bool do_full_verify) const; 356 void Verify(bool do_full_verify) const;
347 #endif 357 #endif
348 358
349 bool has_osr_loop_entry() { 359 bool has_osr() {
350 return osr_loop_entry_.is_set(); 360 return osr_ != NULL;
351 } 361 }
352 362
353 HBasicBlock* osr_loop_entry() { 363 void set_osr(HOsrBuilder* osr) {
354 return osr_loop_entry_.get(); 364 osr_ = osr;
355 } 365 }
356 366
357 void set_osr_loop_entry(HBasicBlock* entry) { 367 HOsrBuilder* osr() {
358 osr_loop_entry_.set(entry); 368 return osr_;
359 }
360
361 ZoneList<HUnknownOSRValue*>* osr_values() {
362 return osr_values_.get();
363 }
364
365 void set_osr_values(ZoneList<HUnknownOSRValue*>* values) {
366 osr_values_.set(values);
367 } 369 }
368 370
369 int update_type_change_checksum(int delta) { 371 int update_type_change_checksum(int delta) {
370 type_change_checksum_ += delta; 372 type_change_checksum_ += delta;
371 return type_change_checksum_; 373 return type_change_checksum_;
372 } 374 }
373 375
374 void update_maximum_environment_size(int environment_size) { 376 void update_maximum_environment_size(int environment_size) {
375 if (environment_size > maximum_environment_size_) { 377 if (environment_size > maximum_environment_size_) {
376 maximum_environment_size_ = environment_size; 378 maximum_environment_size_ = environment_size;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 DependentCode::kElementsCantBeAddedGroup, info()); 411 DependentCode::kElementsCantBeAddedGroup, info());
410 isolate()->initial_array_prototype()->map()->AddDependentCompilationInfo( 412 isolate()->initial_array_prototype()->map()->AddDependentCompilationInfo(
411 DependentCode::kElementsCantBeAddedGroup, info()); 413 DependentCode::kElementsCantBeAddedGroup, info());
412 depends_on_empty_array_proto_elements_ = true; 414 depends_on_empty_array_proto_elements_ = true;
413 } 415 }
414 416
415 bool depends_on_empty_array_proto_elements() { 417 bool depends_on_empty_array_proto_elements() {
416 return depends_on_empty_array_proto_elements_; 418 return depends_on_empty_array_proto_elements_;
417 } 419 }
418 420
421 bool has_uint32_instructions() {
422 ASSERT(uint32_instructions_ == NULL || !uint32_instructions_->is_empty());
423 return uint32_instructions_ != NULL;
424 }
425
426 ZoneList<HInstruction*>* uint32_instructions() {
427 ASSERT(uint32_instructions_ == NULL || !uint32_instructions_->is_empty());
428 return uint32_instructions_;
429 }
430
419 void RecordUint32Instruction(HInstruction* instr) { 431 void RecordUint32Instruction(HInstruction* instr) {
432 ASSERT(uint32_instructions_ == NULL || !uint32_instructions_->is_empty());
420 if (uint32_instructions_ == NULL) { 433 if (uint32_instructions_ == NULL) {
421 uint32_instructions_ = new(zone()) ZoneList<HInstruction*>(4, zone()); 434 uint32_instructions_ = new(zone()) ZoneList<HInstruction*>(4, zone());
422 } 435 }
423 uint32_instructions_->Add(instr, zone()); 436 uint32_instructions_->Add(instr, zone());
424 } 437 }
425 438
426 private: 439 private:
427 HConstant* GetConstant(SetOncePointer<HConstant>* pointer, 440 HConstant* GetConstant(SetOncePointer<HConstant>* pointer,
428 int32_t integer_value); 441 int32_t integer_value);
429 442
430 template<class Phase> 443 template<class Phase>
431 void Run() { Phase phase(this); phase.Run(); } 444 void Run() {
445 Phase phase(this);
446 phase.Run();
447 }
432 448
433 void MarkLive(HValue* ref, HValue* instr, ZoneList<HValue*>* worklist);
434 void MarkLiveInstructions();
435 void RemoveDeadInstructions();
436 void MarkAsDeoptimizingRecursively(HBasicBlock* block); 449 void MarkAsDeoptimizingRecursively(HBasicBlock* block);
437 void NullifyUnreachableInstructions(); 450 void NullifyUnreachableInstructions();
438 void InsertTypeConversions(HInstruction* instr); 451 void InsertTypeConversions(HInstruction* instr);
439 void PropagateMinusZeroChecks(HValue* value, BitVector* visited); 452 void PropagateMinusZeroChecks(HValue* value, BitVector* visited);
440 void RecursivelyMarkPhiDeoptimizeOnUndefined(HPhi* phi); 453 void RecursivelyMarkPhiDeoptimizeOnUndefined(HPhi* phi);
441 void InsertRepresentationChangeForUse(HValue* value,
442 HValue* use_value,
443 int use_index,
444 Representation to);
445 void InsertRepresentationChangesForValue(HValue* value);
446 void InferTypes(ZoneList<HValue*>* worklist);
447 void InitializeInferredTypes(int from_inclusive, int to_inclusive);
448 void CheckForBackEdge(HBasicBlock* block, HBasicBlock* successor); 454 void CheckForBackEdge(HBasicBlock* block, HBasicBlock* successor);
449 void SetupInformativeDefinitionsInBlock(HBasicBlock* block); 455 void SetupInformativeDefinitionsInBlock(HBasicBlock* block);
450 void SetupInformativeDefinitionsRecursively(HBasicBlock* block); 456 void SetupInformativeDefinitionsRecursively(HBasicBlock* block);
451 void EliminateRedundantBoundsChecks(HBasicBlock* bb, BoundsCheckTable* table);
452 457
453 Isolate* isolate_; 458 Isolate* isolate_;
454 int next_block_id_; 459 int next_block_id_;
455 HBasicBlock* entry_block_; 460 HBasicBlock* entry_block_;
456 HEnvironment* start_environment_; 461 HEnvironment* start_environment_;
457 ZoneList<HBasicBlock*> blocks_; 462 ZoneList<HBasicBlock*> blocks_;
458 ZoneList<HValue*> values_; 463 ZoneList<HValue*> values_;
459 ZoneList<HPhi*>* phi_list_; 464 ZoneList<HPhi*>* phi_list_;
460 ZoneList<HInstruction*>* uint32_instructions_; 465 ZoneList<HInstruction*>* uint32_instructions_;
461 SetOncePointer<HConstant> undefined_constant_; 466 SetOncePointer<HConstant> undefined_constant_;
462 SetOncePointer<HConstant> constant_0_; 467 SetOncePointer<HConstant> constant_0_;
463 SetOncePointer<HConstant> constant_1_; 468 SetOncePointer<HConstant> constant_1_;
464 SetOncePointer<HConstant> constant_minus1_; 469 SetOncePointer<HConstant> constant_minus1_;
465 SetOncePointer<HConstant> constant_true_; 470 SetOncePointer<HConstant> constant_true_;
466 SetOncePointer<HConstant> constant_false_; 471 SetOncePointer<HConstant> constant_false_;
467 SetOncePointer<HConstant> constant_the_hole_; 472 SetOncePointer<HConstant> constant_the_hole_;
468 SetOncePointer<HConstant> constant_null_; 473 SetOncePointer<HConstant> constant_null_;
469 SetOncePointer<HConstant> constant_invalid_context_; 474 SetOncePointer<HConstant> constant_invalid_context_;
470 SetOncePointer<HArgumentsObject> arguments_object_; 475 SetOncePointer<HArgumentsObject> arguments_object_;
471 476
472 SetOncePointer<HBasicBlock> osr_loop_entry_; 477 HOsrBuilder* osr_;
473 SetOncePointer<ZoneList<HUnknownOSRValue*> > osr_values_;
474 478
475 CompilationInfo* info_; 479 CompilationInfo* info_;
476 Zone* zone_; 480 Zone* zone_;
477 481
478 bool is_recursive_; 482 bool is_recursive_;
479 bool use_optimistic_licm_; 483 bool use_optimistic_licm_;
480 bool has_soft_deoptimize_; 484 bool has_soft_deoptimize_;
481 bool depends_on_empty_array_proto_elements_; 485 bool depends_on_empty_array_proto_elements_;
482 int type_change_checksum_; 486 int type_change_checksum_;
483 int maximum_environment_size_; 487 int maximum_environment_size_;
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
696 int local_count_; 700 int local_count_;
697 HEnvironment* outer_; 701 HEnvironment* outer_;
698 HEnterInlined* entry_; 702 HEnterInlined* entry_;
699 int pop_count_; 703 int pop_count_;
700 int push_count_; 704 int push_count_;
701 BailoutId ast_id_; 705 BailoutId ast_id_;
702 Zone* zone_; 706 Zone* zone_;
703 }; 707 };
704 708
705 709
706 class HInferRepresentation BASE_EMBEDDED {
707 public:
708 explicit HInferRepresentation(HGraph* graph)
709 : graph_(graph),
710 worklist_(8, graph->zone()),
711 in_worklist_(graph->GetMaximumValueID(), graph->zone()) { }
712
713 void Analyze();
714 void AddToWorklist(HValue* current);
715
716 private:
717 Zone* zone() const { return graph_->zone(); }
718
719 HGraph* graph_;
720 ZoneList<HValue*> worklist_;
721 BitVector in_worklist_;
722 };
723
724
725 class HOptimizedGraphBuilder; 710 class HOptimizedGraphBuilder;
726 711
727 enum ArgumentsAllowedFlag { 712 enum ArgumentsAllowedFlag {
728 ARGUMENTS_NOT_ALLOWED, 713 ARGUMENTS_NOT_ALLOWED,
729 ARGUMENTS_ALLOWED 714 ARGUMENTS_ALLOWED
730 }; 715 };
731 716
732 717
733 class HIfContinuation; 718 class HIfContinuation;
734 719
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
987 CompilationInfo* top_info() { return info_; } 972 CompilationInfo* top_info() { return info_; }
988 973
989 HGraph* CreateGraph(); 974 HGraph* CreateGraph();
990 975
991 // Bailout environment manipulation. 976 // Bailout environment manipulation.
992 void Push(HValue* value) { environment()->Push(value); } 977 void Push(HValue* value) { environment()->Push(value); }
993 HValue* Pop() { return environment()->Pop(); } 978 HValue* Pop() { return environment()->Pop(); }
994 979
995 // Adding instructions. 980 // Adding instructions.
996 HInstruction* AddInstruction(HInstruction* instr); 981 HInstruction* AddInstruction(HInstruction* instr);
982
983 template<class I>
984 I* Add() { return static_cast<I*>(AddInstruction(new(zone()) I())); }
985
986 template<class I, class P1>
987 I* Add(P1 p1) {
988 return static_cast<I*>(AddInstruction(new(zone()) I(p1)));
989 }
990
991 template<class I, class P1, class P2>
992 I* Add(P1 p1, P2 p2) {
993 return static_cast<I*>(AddInstruction(new(zone()) I(p1, p2)));
994 }
995
996 template<class I, class P1, class P2, class P3>
997 I* Add(P1 p1, P2 p2, P3 p3) {
998 return static_cast<I*>(AddInstruction(new(zone()) I(p1, p2, p3)));
999 }
1000
1001 template<class I, class P1, class P2, class P3, class P4>
1002 I* Add(P1 p1, P2 p2, P3 p3, P4 p4) {
1003 return static_cast<I*>(AddInstruction(new(zone()) I(p1, p2, p3, p4)));
1004 }
1005
1006 template<class I, class P1, class P2, class P3, class P4, class P5>
1007 I* Add(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5) {
1008 return static_cast<I*>(AddInstruction(new(zone()) I(p1, p2, p3, p4, p5)));
1009 }
1010
1011 template<class I, class P1, class P2, class P3, class P4, class P5, class P6>
1012 I* Add(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6) {
1013 return static_cast<I*>(AddInstruction(
1014 new(zone()) I(p1, p2, p3, p4, p5, p6)));
1015 }
1016
1017 template<class I, class P1, class P2, class P3,
1018 class P4, class P5, class P6, class P7>
1019 I* Add(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7) {
1020 return static_cast<I*>(AddInstruction(
1021 new(zone()) I(p1, p2, p3, p4, p5, p6, p7)));
1022 }
1023
1024 template<class I, class P1, class P2, class P3, class P4,
1025 class P5, class P6, class P7, class P8>
1026 I* Add(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8) {
1027 return static_cast<I*>(AddInstruction(
1028 new(zone()) I(p1, p2, p3, p4, p5, p6, p7, p8)));
1029 }
1030
997 void AddSimulate(BailoutId id, 1031 void AddSimulate(BailoutId id,
998 RemovableSimulate removable = FIXED_SIMULATE); 1032 RemovableSimulate removable = FIXED_SIMULATE);
999 HBoundsCheck* AddBoundsCheck(HValue* index, HValue* length);
1000 1033
1001 HReturn* AddReturn(HValue* value); 1034 HReturn* AddReturn(HValue* value);
1002 1035
1003 void IncrementInNoSideEffectsScope() { 1036 void IncrementInNoSideEffectsScope() {
1004 no_side_effects_scope_count_++; 1037 no_side_effects_scope_count_++;
1005 } 1038 }
1006 1039
1007 void DecrementInNoSideEffectsScope() { 1040 void DecrementInNoSideEffectsScope() {
1008 no_side_effects_scope_count_--; 1041 no_side_effects_scope_count_--;
1009 } 1042 }
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
1073 HStoreNamedField* AddStore( 1106 HStoreNamedField* AddStore(
1074 HValue *object, 1107 HValue *object,
1075 HObjectAccess access, 1108 HObjectAccess access,
1076 HValue *val, 1109 HValue *val,
1077 Representation representation = Representation::Tagged()); 1110 Representation representation = Representation::Tagged());
1078 1111
1079 HStoreNamedField* AddStoreMapConstant(HValue *object, Handle<Map>); 1112 HStoreNamedField* AddStoreMapConstant(HValue *object, Handle<Map>);
1080 1113
1081 HLoadNamedField* AddLoadElements(HValue *object, HValue *typecheck = NULL); 1114 HLoadNamedField* AddLoadElements(HValue *object, HValue *typecheck = NULL);
1082 1115
1116 HLoadNamedField* AddLoadFixedArrayLength(HValue *object);
1117
1118 HValue* AddLoadJSBuiltin(Builtins::JavaScript builtin, HContext* context);
1119
1120 enum SoftDeoptimizeMode {
1121 MUST_EMIT_SOFT_DEOPT,
1122 CAN_OMIT_SOFT_DEOPT
1123 };
1124
1125 void AddSoftDeoptimize(SoftDeoptimizeMode mode = CAN_OMIT_SOFT_DEOPT);
1126
1083 class IfBuilder { 1127 class IfBuilder {
1084 public: 1128 public:
1085 explicit IfBuilder(HGraphBuilder* builder, 1129 explicit IfBuilder(HGraphBuilder* builder,
1086 int position = RelocInfo::kNoPosition); 1130 int position = RelocInfo::kNoPosition);
1087 IfBuilder(HGraphBuilder* builder, 1131 IfBuilder(HGraphBuilder* builder,
1088 HIfContinuation* continuation); 1132 HIfContinuation* continuation);
1089 1133
1090 ~IfBuilder() { 1134 ~IfBuilder() {
1091 if (!finished_) End(); 1135 if (!finished_) End();
1092 } 1136 }
1093 1137
1094 HInstruction* IfCompare(
1095 HValue* left,
1096 HValue* right,
1097 Token::Value token);
1098
1099 HInstruction* IfCompareMap(HValue* left, Handle<Map> map);
1100
1101 template<class Condition> 1138 template<class Condition>
1102 HInstruction* If(HValue *p) { 1139 HInstruction* If(HValue *p) {
1103 HControlInstruction* compare = new(zone()) Condition(p); 1140 HControlInstruction* compare = new(zone()) Condition(p);
1104 AddCompare(compare); 1141 AddCompare(compare);
1105 return compare; 1142 return compare;
1106 } 1143 }
1107 1144
1108 template<class Condition, class P2> 1145 template<class Condition, class P2>
1109 HInstruction* If(HValue* p1, P2 p2) { 1146 HInstruction* If(HValue* p1, P2 p2) {
1110 HControlInstruction* compare = new(zone()) Condition(p1, p2); 1147 HControlInstruction* compare = new(zone()) Condition(p1, p2);
1111 AddCompare(compare); 1148 AddCompare(compare);
1112 return compare; 1149 return compare;
1113 } 1150 }
1114 1151
1152 template<class Condition, class P2, class P3>
1153 HInstruction* If(HValue* p1, P2 p2, P3 p3) {
1154 HControlInstruction* compare = new(zone()) Condition(p1, p2, p3);
1155 AddCompare(compare);
1156 return compare;
1157 }
1158
1115 template<class Condition, class P2> 1159 template<class Condition, class P2>
1116 HInstruction* IfNot(HValue* p1, P2 p2) { 1160 HInstruction* IfNot(HValue* p1, P2 p2) {
1117 HControlInstruction* compare = new(zone()) Condition(p1, p2); 1161 HControlInstruction* compare = new(zone()) Condition(p1, p2);
1118 AddCompare(compare); 1162 AddCompare(compare);
1119 HBasicBlock* block0 = compare->SuccessorAt(0); 1163 HBasicBlock* block0 = compare->SuccessorAt(0);
1120 HBasicBlock* block1 = compare->SuccessorAt(1); 1164 HBasicBlock* block1 = compare->SuccessorAt(1);
1121 compare->SetSuccessorAt(0, block1); 1165 compare->SetSuccessorAt(0, block1);
1122 compare->SetSuccessorAt(1, block0); 1166 compare->SetSuccessorAt(1, block0);
1123 return compare; 1167 return compare;
1124 } 1168 }
1125 1169
1126 HInstruction* OrIfCompare( 1170 template<class Condition, class P2, class P3>
1127 HValue* p1, 1171 HInstruction* IfNot(HValue* p1, P2 p2, P3 p3) {
1128 HValue* p2, 1172 HControlInstruction* compare = new(zone()) Condition(p1, p2, p3);
1129 Token::Value token) { 1173 AddCompare(compare);
1130 Or(); 1174 HBasicBlock* block0 = compare->SuccessorAt(0);
1131 return IfCompare(p1, p2, token); 1175 HBasicBlock* block1 = compare->SuccessorAt(1);
1132 } 1176 compare->SetSuccessorAt(0, block1);
1133 1177 compare->SetSuccessorAt(1, block0);
1134 HInstruction* OrIfCompareMap(HValue* left, Handle<Map> map) { 1178 return compare;
1135 Or();
1136 return IfCompareMap(left, map);
1137 } 1179 }
1138 1180
1139 template<class Condition> 1181 template<class Condition>
1140 HInstruction* OrIf(HValue *p) { 1182 HInstruction* OrIf(HValue *p) {
1141 Or(); 1183 Or();
1142 return If<Condition>(p); 1184 return If<Condition>(p);
1143 } 1185 }
1144 1186
1145 template<class Condition, class P2> 1187 template<class Condition, class P2>
1146 HInstruction* OrIf(HValue* p1, P2 p2) { 1188 HInstruction* OrIf(HValue* p1, P2 p2) {
1147 Or(); 1189 Or();
1148 return If<Condition>(p1, p2); 1190 return If<Condition>(p1, p2);
1149 } 1191 }
1150 1192
1151 HInstruction* AndIfCompare( 1193 template<class Condition, class P2, class P3>
1152 HValue* p1, 1194 HInstruction* OrIf(HValue* p1, P2 p2, P3 p3) {
1153 HValue* p2, 1195 Or();
1154 Token::Value token) { 1196 return If<Condition>(p1, p2, p3);
1155 And();
1156 return IfCompare(p1, p2, token);
1157 }
1158
1159 HInstruction* AndIfCompareMap(HValue* left, Handle<Map> map) {
1160 And();
1161 return IfCompareMap(left, map);
1162 } 1197 }
1163 1198
1164 template<class Condition> 1199 template<class Condition>
1165 HInstruction* AndIf(HValue *p) { 1200 HInstruction* AndIf(HValue *p) {
1166 And(); 1201 And();
1167 return If<Condition>(p); 1202 return If<Condition>(p);
1168 } 1203 }
1169 1204
1170 template<class Condition, class P2> 1205 template<class Condition, class P2>
1171 HInstruction* AndIf(HValue* p1, P2 p2) { 1206 HInstruction* AndIf(HValue* p1, P2 p2) {
1172 And(); 1207 And();
1173 return If<Condition>(p1, p2); 1208 return If<Condition>(p1, p2);
1174 } 1209 }
1175 1210
1211 template<class Condition, class P2, class P3>
1212 HInstruction* AndIf(HValue* p1, P2 p2, P3 p3) {
1213 And();
1214 return If<Condition>(p1, p2, p3);
1215 }
1216
1176 void Or(); 1217 void Or();
1177 void And(); 1218 void And();
1178 1219
1179 void CaptureContinuation(HIfContinuation* continuation); 1220 void CaptureContinuation(HIfContinuation* continuation);
1180 1221
1181 void Then(); 1222 void Then();
1182 void Else(); 1223 void Else();
1183 void End(); 1224 void End();
1184 1225
1185 void Deopt(); 1226 void Deopt();
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
1266 HValue* old_capacity); 1307 HValue* old_capacity);
1267 1308
1268 void BuildNewSpaceArrayCheck(HValue* length, 1309 void BuildNewSpaceArrayCheck(HValue* length,
1269 ElementsKind kind); 1310 ElementsKind kind);
1270 1311
1271 class JSArrayBuilder { 1312 class JSArrayBuilder {
1272 public: 1313 public:
1273 JSArrayBuilder(HGraphBuilder* builder, 1314 JSArrayBuilder(HGraphBuilder* builder,
1274 ElementsKind kind, 1315 ElementsKind kind,
1275 HValue* allocation_site_payload, 1316 HValue* allocation_site_payload,
1276 bool disable_allocation_sites); 1317 HValue* constructor_function,
1318 AllocationSiteOverrideMode override_mode);
1277 1319
1278 JSArrayBuilder(HGraphBuilder* builder, 1320 JSArrayBuilder(HGraphBuilder* builder,
1279 ElementsKind kind, 1321 ElementsKind kind,
1280 HValue* constructor_function); 1322 HValue* constructor_function);
1281 1323
1282 HValue* AllocateEmptyArray(); 1324 HValue* AllocateEmptyArray();
1283 HValue* AllocateArray(HValue* capacity, HValue* length_field, 1325 HValue* AllocateArray(HValue* capacity, HValue* length_field,
1284 bool fill_with_hole); 1326 bool fill_with_hole);
1285 HValue* GetElementsLocation() { return elements_location_; } 1327 HValue* GetElementsLocation() { return elements_location_; }
1286 1328
1287 private: 1329 private:
1288 Zone* zone() const { return builder_->zone(); } 1330 Zone* zone() const { return builder_->zone(); }
1289 int elements_size() const { 1331 int elements_size() const {
1290 return IsFastDoubleElementsKind(kind_) ? kDoubleSize : kPointerSize; 1332 return IsFastDoubleElementsKind(kind_) ? kDoubleSize : kPointerSize;
1291 } 1333 }
1292 HInstruction* AddInstruction(HInstruction* instr) {
1293 return builder_->AddInstruction(instr);
1294 }
1295 HGraphBuilder* builder() { return builder_; } 1334 HGraphBuilder* builder() { return builder_; }
1296 HGraph* graph() { return builder_->graph(); } 1335 HGraph* graph() { return builder_->graph(); }
1297 int initial_capacity() { 1336 int initial_capacity() {
1298 STATIC_ASSERT(JSArray::kPreallocatedArrayElements > 0); 1337 STATIC_ASSERT(JSArray::kPreallocatedArrayElements > 0);
1299 return JSArray::kPreallocatedArrayElements; 1338 return JSArray::kPreallocatedArrayElements;
1300 } 1339 }
1301 1340
1302 HValue* EmitMapCode(HValue* context); 1341 HValue* EmitMapCode(HValue* context);
1303 HValue* EmitInternalMapCode(); 1342 HValue* EmitInternalMapCode();
1304 HValue* EstablishEmptyArrayAllocationSize(); 1343 HValue* EstablishEmptyArrayAllocationSize();
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1351 void BuildCopyElements(HValue* context, 1390 void BuildCopyElements(HValue* context,
1352 HValue* from_elements, 1391 HValue* from_elements,
1353 ElementsKind from_elements_kind, 1392 ElementsKind from_elements_kind,
1354 HValue* to_elements, 1393 HValue* to_elements,
1355 ElementsKind to_elements_kind, 1394 ElementsKind to_elements_kind,
1356 HValue* length, 1395 HValue* length,
1357 HValue* capacity); 1396 HValue* capacity);
1358 1397
1359 HValue* BuildCloneShallowArray(HContext* context, 1398 HValue* BuildCloneShallowArray(HContext* context,
1360 HValue* boilerplate, 1399 HValue* boilerplate,
1400 HValue* allocation_site,
1361 AllocationSiteMode mode, 1401 AllocationSiteMode mode,
1362 ElementsKind kind, 1402 ElementsKind kind,
1363 int length); 1403 int length);
1364 1404
1405 HInstruction* BuildUnaryMathOp(
1406 HValue* value, Handle<Type> type, Token::Value token);
1407
1365 void BuildCompareNil( 1408 void BuildCompareNil(
1366 HValue* value, 1409 HValue* value,
1367 Handle<Type> type, 1410 Handle<Type> type,
1368 int position, 1411 int position,
1369 HIfContinuation* continuation); 1412 HIfContinuation* continuation);
1370 1413
1371 HValue* BuildCreateAllocationSiteInfo(HValue* previous_object, 1414 HValue* BuildCreateAllocationSiteInfo(HValue* previous_object,
1372 int previous_object_size, 1415 int previous_object_size,
1373 HValue* payload); 1416 HValue* payload);
1374 1417
1375 HInstruction* BuildGetNativeContext(HValue* context); 1418 HInstruction* BuildGetNativeContext(HValue* context);
1376 HInstruction* BuildGetArrayFunction(HValue* context); 1419 HInstruction* BuildGetArrayFunction(HValue* context);
1377 1420
1378 private: 1421 private:
1379 HGraphBuilder(); 1422 HGraphBuilder();
1380 CompilationInfo* info_; 1423 CompilationInfo* info_;
1381 HGraph* graph_; 1424 HGraph* graph_;
1382 HBasicBlock* current_block_; 1425 HBasicBlock* current_block_;
1383 int no_side_effects_scope_count_; 1426 int no_side_effects_scope_count_;
1384 }; 1427 };
1385 1428
1386
1387 class HOptimizedGraphBuilder: public HGraphBuilder, public AstVisitor { 1429 class HOptimizedGraphBuilder: public HGraphBuilder, public AstVisitor {
1388 public: 1430 public:
1389 // A class encapsulating (lazily-allocated) break and continue blocks for 1431 // A class encapsulating (lazily-allocated) break and continue blocks for
1390 // a breakable statement. Separated from BreakAndContinueScope so that it 1432 // a breakable statement. Separated from BreakAndContinueScope so that it
1391 // can have a separate lifetime. 1433 // can have a separate lifetime.
1392 class BreakAndContinueInfo BASE_EMBEDDED { 1434 class BreakAndContinueInfo BASE_EMBEDDED {
1393 public: 1435 public:
1394 explicit BreakAndContinueInfo(BreakableStatement* target, 1436 explicit BreakAndContinueInfo(BreakableStatement* target,
1395 int drop_extra = 0) 1437 int drop_extra = 0)
1396 : target_(target), 1438 : target_(target),
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1442 explicit HOptimizedGraphBuilder(CompilationInfo* info); 1484 explicit HOptimizedGraphBuilder(CompilationInfo* info);
1443 1485
1444 virtual bool BuildGraph(); 1486 virtual bool BuildGraph();
1445 1487
1446 // Simple accessors. 1488 // Simple accessors.
1447 BreakAndContinueScope* break_scope() const { return break_scope_; } 1489 BreakAndContinueScope* break_scope() const { return break_scope_; }
1448 void set_break_scope(BreakAndContinueScope* head) { break_scope_ = head; } 1490 void set_break_scope(BreakAndContinueScope* head) { break_scope_ = head; }
1449 1491
1450 bool inline_bailout() { return inline_bailout_; } 1492 bool inline_bailout() { return inline_bailout_; }
1451 1493
1452 void AddSoftDeoptimize();
1453
1454 void Bailout(const char* reason); 1494 void Bailout(const char* reason);
1455 1495
1456 HBasicBlock* CreateJoin(HBasicBlock* first, 1496 HBasicBlock* CreateJoin(HBasicBlock* first,
1457 HBasicBlock* second, 1497 HBasicBlock* second,
1458 BailoutId join_id); 1498 BailoutId join_id);
1459 1499
1460 FunctionState* function_state() const { return function_state_; } 1500 FunctionState* function_state() const { return function_state_; }
1461 1501
1462 void VisitDeclarations(ZoneList<Declaration*>* declarations); 1502 void VisitDeclarations(ZoneList<Declaration*>* declarations);
1463 1503
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
1534 void VisitTypeof(UnaryOperation* expr); 1574 void VisitTypeof(UnaryOperation* expr);
1535 void VisitSub(UnaryOperation* expr); 1575 void VisitSub(UnaryOperation* expr);
1536 void VisitBitNot(UnaryOperation* expr); 1576 void VisitBitNot(UnaryOperation* expr);
1537 void VisitNot(UnaryOperation* expr); 1577 void VisitNot(UnaryOperation* expr);
1538 1578
1539 void VisitComma(BinaryOperation* expr); 1579 void VisitComma(BinaryOperation* expr);
1540 void VisitLogicalExpression(BinaryOperation* expr); 1580 void VisitLogicalExpression(BinaryOperation* expr);
1541 void VisitArithmeticExpression(BinaryOperation* expr); 1581 void VisitArithmeticExpression(BinaryOperation* expr);
1542 1582
1543 bool PreProcessOsrEntry(IterationStatement* statement); 1583 bool PreProcessOsrEntry(IterationStatement* statement);
1544 // True iff. we are compiling for OSR and the statement is the entry.
1545 bool HasOsrEntryAt(IterationStatement* statement);
1546 void VisitLoopBody(IterationStatement* stmt, 1584 void VisitLoopBody(IterationStatement* stmt,
1547 HBasicBlock* loop_entry, 1585 HBasicBlock* loop_entry,
1548 BreakAndContinueInfo* break_info); 1586 BreakAndContinueInfo* break_info);
1549 1587
1550 // Create a back edge in the flow graph. body_exit is the predecessor 1588 // Create a back edge in the flow graph. body_exit is the predecessor
1551 // block and loop_entry is the successor block. loop_successor is the 1589 // block and loop_entry is the successor block. loop_successor is the
1552 // block where control flow exits the loop normally (e.g., via failure of 1590 // block where control flow exits the loop normally (e.g., via failure of
1553 // the condition) and break_block is the block where control flow breaks 1591 // the condition) and break_block is the block where control flow breaks
1554 // from the loop. All blocks except loop_entry can be NULL. The return 1592 // from the loop. All blocks except loop_entry can be NULL. The return
1555 // value is the new successor block which is the join of loop_successor 1593 // value is the new successor block which is the join of loop_successor
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
1625 1663
1626 // Visit a list of expressions from left to right, each in a value context. 1664 // Visit a list of expressions from left to right, each in a value context.
1627 void VisitExpressions(ZoneList<Expression*>* exprs); 1665 void VisitExpressions(ZoneList<Expression*>* exprs);
1628 1666
1629 void PushAndAdd(HInstruction* instr); 1667 void PushAndAdd(HInstruction* instr);
1630 1668
1631 // Remove the arguments from the bailout environment and emit instructions 1669 // Remove the arguments from the bailout environment and emit instructions
1632 // to push them as outgoing parameters. 1670 // to push them as outgoing parameters.
1633 template <class Instruction> HInstruction* PreProcessCall(Instruction* call); 1671 template <class Instruction> HInstruction* PreProcessCall(Instruction* call);
1634 1672
1635 static Representation ToRepresentation(TypeInfo info);
1636 static Representation ToRepresentation(Handle<Type> type);
1637
1638 void SetUpScope(Scope* scope); 1673 void SetUpScope(Scope* scope);
1639 virtual void VisitStatements(ZoneList<Statement*>* statements); 1674 virtual void VisitStatements(ZoneList<Statement*>* statements);
1640 1675
1641 #define DECLARE_VISIT(type) virtual void Visit##type(type* node); 1676 #define DECLARE_VISIT(type) virtual void Visit##type(type* node);
1642 AST_NODE_LIST(DECLARE_VISIT) 1677 AST_NODE_LIST(DECLARE_VISIT)
1643 #undef DECLARE_VISIT 1678 #undef DECLARE_VISIT
1644 1679
1645 // Helpers for flow graph construction. 1680 // Helpers for flow graph construction.
1646 enum GlobalPropertyAccess { 1681 enum GlobalPropertyAccess {
1647 kUseCell, 1682 kUseCell,
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
1817 HValue* key, 1852 HValue* key,
1818 HValue* value); 1853 HValue* value);
1819 1854
1820 HValue* BuildContextChainWalk(Variable* var); 1855 HValue* BuildContextChainWalk(Variable* var);
1821 1856
1822 HInstruction* BuildThisFunction(); 1857 HInstruction* BuildThisFunction();
1823 1858
1824 HInstruction* BuildFastLiteral(HValue* context, 1859 HInstruction* BuildFastLiteral(HValue* context,
1825 Handle<JSObject> boilerplate_object, 1860 Handle<JSObject> boilerplate_object,
1826 Handle<JSObject> original_boilerplate_object, 1861 Handle<JSObject> original_boilerplate_object,
1862 Handle<Object> allocation_site,
1827 int data_size, 1863 int data_size,
1828 int pointer_size, 1864 int pointer_size,
1829 AllocationSiteMode mode); 1865 AllocationSiteMode mode);
1830 1866
1831 void BuildEmitDeepCopy(Handle<JSObject> boilerplat_object, 1867 void BuildEmitDeepCopy(Handle<JSObject> boilerplat_object,
1832 Handle<JSObject> object, 1868 Handle<JSObject> object,
1869 Handle<Object> allocation_site,
1833 HInstruction* target, 1870 HInstruction* target,
1834 int* offset, 1871 int* offset,
1835 HInstruction* data_target, 1872 HInstruction* data_target,
1836 int* data_offset, 1873 int* data_offset,
1837 AllocationSiteMode mode); 1874 AllocationSiteMode mode);
1838 1875
1839 MUST_USE_RESULT HValue* BuildEmitObjectHeader( 1876 MUST_USE_RESULT HValue* BuildEmitObjectHeader(
1840 Handle<JSObject> boilerplat_object, 1877 Handle<JSObject> boilerplat_object,
1841 HInstruction* target, 1878 HInstruction* target,
1842 HInstruction* data_target, 1879 HInstruction* data_target,
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1897 AstContext* ast_context_; 1934 AstContext* ast_context_;
1898 1935
1899 // A stack of breakable statements entered. 1936 // A stack of breakable statements entered.
1900 BreakAndContinueScope* break_scope_; 1937 BreakAndContinueScope* break_scope_;
1901 1938
1902 int inlined_count_; 1939 int inlined_count_;
1903 ZoneList<Handle<Object> > globals_; 1940 ZoneList<Handle<Object> > globals_;
1904 1941
1905 bool inline_bailout_; 1942 bool inline_bailout_;
1906 1943
1944 HOsrBuilder* osr_;
1945
1907 friend class FunctionState; // Pushes and pops the state stack. 1946 friend class FunctionState; // Pushes and pops the state stack.
1908 friend class AstContext; // Pushes and pops the AST context stack. 1947 friend class AstContext; // Pushes and pops the AST context stack.
1909 friend class KeyedLoadFastElementStub; 1948 friend class KeyedLoadFastElementStub;
1949 friend class HOsrBuilder;
1910 1950
1911 DISALLOW_COPY_AND_ASSIGN(HOptimizedGraphBuilder); 1951 DISALLOW_COPY_AND_ASSIGN(HOptimizedGraphBuilder);
1912 }; 1952 };
1913 1953
1914 1954
1915 Zone* AstContext::zone() const { return owner_->zone(); } 1955 Zone* AstContext::zone() const { return owner_->zone(); }
1916 1956
1917 1957
1918 class HStatistics: public Malloced { 1958 class HStatistics: public Malloced {
1919 public: 1959 public:
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
2052 EmbeddedVector<char, 64> filename_; 2092 EmbeddedVector<char, 64> filename_;
2053 HeapStringAllocator string_allocator_; 2093 HeapStringAllocator string_allocator_;
2054 StringStream trace_; 2094 StringStream trace_;
2055 int indent_; 2095 int indent_;
2056 }; 2096 };
2057 2097
2058 2098
2059 } } // namespace v8::internal 2099 } } // namespace v8::internal
2060 2100
2061 #endif // V8_HYDROGEN_H_ 2101 #endif // V8_HYDROGEN_H_
OLDNEW
« no previous file with comments | « src/heap-snapshot-generator.cc ('k') | src/hydrogen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698