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

Side by Side Diff: src/hydrogen-load-elimination.cc

Issue 152953004: Improve computation of effects for load elimination. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 Zone* zone_; 423 Zone* zone_;
424 ZoneList<HFieldApproximation*> fields_; 424 ZoneList<HFieldApproximation*> fields_;
425 HAliasAnalyzer* aliasing_; 425 HAliasAnalyzer* aliasing_;
426 }; 426 };
427 427
428 428
429 // Support for HFlowEngine: collect store effects within loops. 429 // Support for HFlowEngine: collect store effects within loops.
430 class HLoadEliminationEffects : public ZoneObject { 430 class HLoadEliminationEffects : public ZoneObject {
431 public: 431 public:
432 explicit HLoadEliminationEffects(Zone* zone) 432 explicit HLoadEliminationEffects(Zone* zone)
433 : zone_(zone), 433 : zone_(zone), stores_(5, zone) { }
434 maps_stored_(false),
435 fields_stored_(false),
436 elements_stored_(false),
437 stores_(5, zone) { }
438 434
439 inline bool Disabled() { 435 inline bool Disabled() {
440 return false; // Effects are _not_ disabled. 436 return false; // Effects are _not_ disabled.
441 } 437 }
442 438
443 // Process a possibly side-effecting instruction. 439 // Process a possibly side-effecting instruction.
444 void Process(HInstruction* instr, Zone* zone) { 440 void Process(HInstruction* instr, Zone* zone) {
445 switch (instr->opcode()) { 441 if (instr->IsStoreNamedField()) {
446 case HValue::kStoreNamedField: { 442 stores_.Add(HStoreNamedField::cast(instr), zone_);
447 stores_.Add(HStoreNamedField::cast(instr), zone_); 443 } else {
448 break; 444 flags_.Add(instr->ChangesFlags());
449 }
450 case HValue::kOsrEntry: {
451 // Kill everything. Loads must not be hoisted past the OSR entry.
452 maps_stored_ = true;
453 fields_stored_ = true;
454 elements_stored_ = true;
455 }
456 default: {
457 fields_stored_ |= instr->CheckChangesFlag(kInobjectFields);
458 maps_stored_ |= instr->CheckChangesFlag(kMaps);
459 maps_stored_ |= instr->CheckChangesFlag(kElementsKind);
460 elements_stored_ |= instr->CheckChangesFlag(kElementsKind);
461 elements_stored_ |= instr->CheckChangesFlag(kElementsPointer);
462 }
463 } 445 }
464 } 446 }
465 447
466 // Apply these effects to the given load elimination table. 448 // Apply these effects to the given load elimination table.
467 void Apply(HLoadEliminationTable* table) { 449 void Apply(HLoadEliminationTable* table) {
468 if (fields_stored_) { 450 if (flags_.Contains(kInobjectFields) || flags_.Contains(kOsrEntries)) {
469 table->Kill(); 451 table->Kill();
470 return; 452 return;
471 } 453 }
472 if (maps_stored_) { 454 if (flags_.Contains(kElementsKind) || flags_.Contains(kMaps)) {
473 table->KillOffset(JSObject::kMapOffset); 455 table->KillOffset(JSObject::kMapOffset);
474 } 456 }
475 if (elements_stored_) { 457 if (flags_.Contains(kElementsKind) || flags_.Contains(kElementsPointer)) {
476 table->KillOffset(JSObject::kElementsOffset); 458 table->KillOffset(JSObject::kElementsOffset);
477 } 459 }
478 460
479 // Kill non-agreeing fields for each store contained in these effects. 461 // Kill non-agreeing fields for each store contained in these effects.
480 for (int i = 0; i < stores_.length(); i++) { 462 for (int i = 0; i < stores_.length(); i++) {
481 table->KillStore(stores_[i]); 463 table->KillStore(stores_[i]);
482 } 464 }
483 } 465 }
484 466
485 // Union these effects with the other effects. 467 // Union these effects with the other effects.
486 void Union(HLoadEliminationEffects* that, Zone* zone) { 468 void Union(HLoadEliminationEffects* that, Zone* zone) {
487 maps_stored_ |= that->maps_stored_; 469 flags_ = that->flags_;
Igor Sheludko 2014/02/11 13:01:57 Probably you want to union GVN flags here instead
Benedikt Meurer 2014/02/12 06:22:43 Indeed, thanks for spotting.
488 fields_stored_ |= that->fields_stored_;
489 elements_stored_ |= that->elements_stored_;
490 for (int i = 0; i < that->stores_.length(); i++) { 470 for (int i = 0; i < that->stores_.length(); i++) {
491 stores_.Add(that->stores_[i], zone); 471 stores_.Add(that->stores_[i], zone);
492 } 472 }
493 } 473 }
494 474
495 private: 475 private:
496 Zone* zone_; 476 Zone* zone_;
497 bool maps_stored_ : 1; 477 GVNFlagSet flags_;
498 bool fields_stored_ : 1;
499 bool elements_stored_ : 1;
500 ZoneList<HStoreNamedField*> stores_; 478 ZoneList<HStoreNamedField*> stores_;
501 }; 479 };
502 480
503 481
504 // The main routine of the analysis phase. Use the HFlowEngine for either a 482 // The main routine of the analysis phase. Use the HFlowEngine for either a
505 // local or a global analysis. 483 // local or a global analysis.
506 void HLoadEliminationPhase::Run() { 484 void HLoadEliminationPhase::Run() {
507 HFlowEngine<HLoadEliminationTable, HLoadEliminationEffects> 485 HFlowEngine<HLoadEliminationTable, HLoadEliminationEffects>
508 engine(graph(), zone()); 486 engine(graph(), zone());
509 HAliasAnalyzer aliasing; 487 HAliasAnalyzer aliasing;
510 HLoadEliminationTable* table = 488 HLoadEliminationTable* table =
511 new(zone()) HLoadEliminationTable(zone(), &aliasing); 489 new(zone()) HLoadEliminationTable(zone(), &aliasing);
512 490
513 if (GLOBAL) { 491 if (GLOBAL) {
514 // Perform a global analysis. 492 // Perform a global analysis.
515 engine.AnalyzeDominatedBlocks(graph()->blocks()->at(0), table); 493 engine.AnalyzeDominatedBlocks(graph()->blocks()->at(0), table);
516 } else { 494 } else {
517 // Perform only local analysis. 495 // Perform only local analysis.
518 for (int i = 0; i < graph()->blocks()->length(); i++) { 496 for (int i = 0; i < graph()->blocks()->length(); i++) {
519 table->Kill(); 497 table->Kill();
520 engine.AnalyzeOneBlock(graph()->blocks()->at(i), table); 498 engine.AnalyzeOneBlock(graph()->blocks()->at(i), table);
521 } 499 }
522 } 500 }
523 } 501 }
524 502
525 } } // namespace v8::internal 503 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698