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

Side by Side Diff: src/hydrogen.cc

Issue 13649003: Fix worst-case behavior of MergeRemovableSimulates(). (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | src/hydrogen-instructions.h » ('j') | src/hydrogen-instructions.cc » ('J')
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 3277 matching lines...) Expand 10 before | Expand all | Expand 10 after
3288 if (current->representation().IsNone() && 3288 if (current->representation().IsNone() &&
3289 current->CheckFlag(HInstruction::kFlexibleRepresentation)) { 3289 current->CheckFlag(HInstruction::kFlexibleRepresentation)) {
3290 current->ChangeRepresentation(Representation::Tagged()); 3290 current->ChangeRepresentation(Representation::Tagged());
3291 } 3291 }
3292 } 3292 }
3293 } 3293 }
3294 } 3294 }
3295 3295
3296 3296
3297 void HGraph::MergeRemovableSimulates() { 3297 void HGraph::MergeRemovableSimulates() {
3298 ZoneList<HSimulate*> mergelist(2, zone());
3298 for (int i = 0; i < blocks()->length(); ++i) { 3299 for (int i = 0; i < blocks()->length(); ++i) {
3299 HBasicBlock* block = blocks()->at(i); 3300 HBasicBlock* block = blocks()->at(i);
3300 // Always reset the folding candidate at the start of a block. 3301 // Always reset the folding candidate at the start of a block.
3301 HSimulate* folding_candidate = NULL; 3302 mergelist.Clear();
3302 // Nasty heuristic: Never remove the first simulate in a block. This 3303 // Nasty heuristic: Never remove the first simulate in a block. This
3303 // just so happens to have a beneficial effect on register allocation. 3304 // just so happens to have a beneficial effect on register allocation.
3304 bool first = true; 3305 bool first = true;
3305 for (HInstruction* current = block->first(); 3306 for (HInstruction* current = block->first();
3306 current != NULL; current = current->next()) { 3307 current != NULL; current = current->next()) {
3307 if (current->IsLeaveInlined()) { 3308 if (current->IsLeaveInlined()) {
3308 // Never fold simulates from inlined environments into simulates 3309 // Never fold simulates from inlined environments into simulates
3309 // in the outer environment. 3310 // in the outer environment.
3310 // (Before each HEnterInlined, there is a non-foldable HSimulate 3311 // (Before each HEnterInlined, there is a non-foldable HSimulate
3311 // anyway, so we get the barrier in the other direction for free.) 3312 // anyway, so we get the barrier in the other direction for free.)
3312 if (folding_candidate != NULL) { 3313 if (!mergelist.is_empty()) {
3313 folding_candidate->DeleteAndReplaceWith(NULL); 3314 // Merge the simulates accumulated so far.
3315 HSimulate* last = mergelist.RemoveLast();
3316 last->MergeWith(&mergelist);
3314 } 3317 }
3315 folding_candidate = NULL;
3316 continue; 3318 continue;
3317 } 3319 }
3318 // If we have an HSimulate and a candidate, perform the folding. 3320 // Skip the non-simulates and the first simulate.
3319 if (!current->IsSimulate()) continue; 3321 if (!current->IsSimulate()) continue;
3320 if (first) { 3322 if (first) {
3321 first = false; 3323 first = false;
3322 continue; 3324 continue;
3323 } 3325 }
3324 HSimulate* current_simulate = HSimulate::cast(current); 3326 HSimulate* current_simulate = HSimulate::cast(current);
3325 if (folding_candidate != NULL) { 3327 if ((current_simulate->previous()->HasObservableSideEffects() &&
3326 folding_candidate->MergeInto(current_simulate); 3328 !current_simulate->next()->IsSimulate()) ||
3327 folding_candidate->DeleteAndReplaceWith(NULL); 3329 !current_simulate->is_candidate_for_removal()) {
3328 folding_candidate = NULL; 3330 // This simulate is not suitable for folding.
3331 // Fold the ones accumulated so far.
3332 current_simulate->MergeWith(&mergelist);
3333 continue;
3334 } else {
3335 // Accumulate this simulate for folding later on.
3336 mergelist.Add(current_simulate, zone());
3329 } 3337 }
3330 // Check if the current simulate is a candidate for folding. 3338 }
3331 if (current_simulate->previous()->HasObservableSideEffects() && 3339
3332 !current_simulate->next()->IsSimulate()) { 3340 if (!mergelist.is_empty()) {
3333 continue; 3341 // Merge the accumulated simulates at the end of the block.
3334 } 3342 HSimulate* last = mergelist.RemoveLast();
3335 if (!current_simulate->is_candidate_for_removal()) { 3343 last->MergeWith(&mergelist);
3336 continue;
3337 }
3338 folding_candidate = current_simulate;
3339 } 3344 }
3340 } 3345 }
3341 } 3346 }
3342 3347
3343 3348
3344 void HGraph::InitializeInferredTypes() { 3349 void HGraph::InitializeInferredTypes() {
3345 HPhase phase("H_Inferring types", this); 3350 HPhase phase("H_Inferring types", this);
3346 InitializeInferredTypes(0, this->blocks_.length() - 1); 3351 InitializeInferredTypes(0, this->blocks_.length() - 1);
3347 } 3352 }
3348 3353
(...skipping 7937 matching lines...) Expand 10 before | Expand all | Expand 10 after
11286 } 11291 }
11287 } 11292 }
11288 11293
11289 #ifdef DEBUG 11294 #ifdef DEBUG
11290 if (graph_ != NULL) graph_->Verify(false); // No full verify. 11295 if (graph_ != NULL) graph_->Verify(false); // No full verify.
11291 if (allocator_ != NULL) allocator_->Verify(); 11296 if (allocator_ != NULL) allocator_->Verify();
11292 #endif 11297 #endif
11293 } 11298 }
11294 11299
11295 } } // namespace v8::internal 11300 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/hydrogen-instructions.h » ('j') | src/hydrogen-instructions.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698