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

Side by Side Diff: src/hydrogen-gvn.cc

Issue 153563006: Cosmetic cleanup for GVN. (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 | « src/hydrogen-gvn.h ('k') | 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 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 GVNFlag changes_flag = HValue::ChangesFlagFromInt(i); 357 GVNFlag changes_flag = HValue::ChangesFlagFromInt(i);
358 if (flags.Contains(changes_flag)) { 358 if (flags.Contains(changes_flag)) {
359 if (data_[i] == NULL) count_++; 359 if (data_[i] == NULL) count_++;
360 data_[i] = instr; 360 data_[i] = instr;
361 } 361 }
362 } 362 }
363 } 363 }
364 364
365 365
366 HGlobalValueNumberingPhase::HGlobalValueNumberingPhase(HGraph* graph) 366 HGlobalValueNumberingPhase::HGlobalValueNumberingPhase(HGraph* graph)
367 : HPhase("H_Global value numbering", graph), 367 : HPhase("H_Global value numbering", graph),
368 removed_side_effects_(false), 368 removed_side_effects_(false),
369 block_side_effects_(graph->blocks()->length(), zone()), 369 block_side_effects_(graph->blocks()->length(), zone()),
370 loop_side_effects_(graph->blocks()->length(), zone()), 370 loop_side_effects_(graph->blocks()->length(), zone()),
371 visited_on_paths_(graph->blocks()->length(), zone()) { 371 visited_on_paths_(graph->blocks()->length(), zone()) {
372 ASSERT(!AllowHandleAllocation::IsAllowed()); 372 ASSERT(!AllowHandleAllocation::IsAllowed());
373 block_side_effects_.AddBlock(GVNFlagSet(), graph->blocks()->length(), 373 block_side_effects_.AddBlock(GVNFlagSet(), graph->blocks()->length(),
374 zone());
375 loop_side_effects_.AddBlock(GVNFlagSet(), graph->blocks()->length(),
376 zone()); 374 zone());
375 loop_side_effects_.AddBlock(GVNFlagSet(), graph->blocks()->length(),
376 zone());
377 } 377 }
378 378
379 379
380 void HGlobalValueNumberingPhase::Reset() { 380 void HGlobalValueNumberingPhase::Run() {
381 ASSERT(block_side_effects_.length() == graph()->blocks()->length()); 381 ASSERT(!removed_side_effects_);
382 ASSERT(loop_side_effects_.length() == graph()->blocks()->length()); 382 for (int i = FLAG_gvn_iterations; i > 0; --i) {
383 for (int i = 0; i < graph()->blocks()->length(); ++i) { 383 // Compute the side effects.
384 block_side_effects_[i] = GVNFlagSet(); 384 ComputeBlockSideEffects();
385 loop_side_effects_[i] = GVNFlagSet(); 385
386 // Perform loop invariant code motion if requested.
387 if (FLAG_loop_invariant_code_motion) LoopInvariantCodeMotion();
388
389 // Perform the actual value numbering.
390 AnalyzeGraph();
391
392 // Continue GVN if we removed any side effects.
393 if (!removed_side_effects_) break;
394 removed_side_effects_ = false;
395
396 // Clear all side effects.
397 ASSERT_EQ(block_side_effects_.length(), graph()->blocks()->length());
398 ASSERT_EQ(loop_side_effects_.length(), graph()->blocks()->length());
399 for (int i = 0; i < graph()->blocks()->length(); ++i) {
400 block_side_effects_[i].RemoveAll();
401 loop_side_effects_[i].RemoveAll();
402 }
403 visited_on_paths_.Clear();
386 } 404 }
387 visited_on_paths_.Clear();
388 }
389
390
391 void HGlobalValueNumberingPhase::Analyze() {
392 removed_side_effects_ = false;
393 ComputeBlockSideEffects();
394 if (FLAG_loop_invariant_code_motion) {
395 LoopInvariantCodeMotion();
396 }
397 AnalyzeGraph();
398 } 405 }
399 406
400 407
401 void HGlobalValueNumberingPhase::ComputeBlockSideEffects() { 408 void HGlobalValueNumberingPhase::ComputeBlockSideEffects() {
402 // The Analyze phase of GVN can be called multiple times. Clear loop side
403 // effects before computing them to erase the contents from previous Analyze
404 // passes.
405 for (int i = 0; i < loop_side_effects_.length(); ++i) {
406 loop_side_effects_[i].RemoveAll();
407 }
408 for (int i = graph()->blocks()->length() - 1; i >= 0; --i) { 409 for (int i = graph()->blocks()->length() - 1; i >= 0; --i) {
409 // Compute side effects for the block. 410 // Compute side effects for the block.
410 HBasicBlock* block = graph()->blocks()->at(i); 411 HBasicBlock* block = graph()->blocks()->at(i);
411 GVNFlagSet side_effects; 412 GVNFlagSet side_effects;
412 if (block->IsReachable() && !block->IsDeoptimizing()) { 413 if (block->IsReachable() && !block->IsDeoptimizing()) {
413 int id = block->block_id(); 414 int id = block->block_id();
414 for (HInstructionIterator it(block); !it.Done(); it.Advance()) { 415 for (HInstructionIterator it(block); !it.Done(); it.Advance()) {
415 HInstruction* instr = it.Current(); 416 HInstruction* instr = it.Current();
416 side_effects.Add(instr->ChangesFlags()); 417 side_effects.Add(instr->ChangesFlags());
417 } 418 }
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after
862 dominated); 863 dominated);
863 successor_map->Kill(side_effects_on_all_paths); 864 successor_map->Kill(side_effects_on_all_paths);
864 successor_dominators->Kill(side_effects_on_all_paths); 865 successor_dominators->Kill(side_effects_on_all_paths);
865 } 866 }
866 } 867 }
867 current = next; 868 current = next;
868 } 869 }
869 } 870 }
870 871
871 } } // namespace v8::internal 872 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/hydrogen-gvn.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698