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

Side by Side Diff: src/hydrogen.cc

Issue 130613003: Eliminatable CheckMaps replaced with if(true) or if(false). (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Review notes applied, rev.2 Created 6 years, 11 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.h ('k') | src/hydrogen-check-elimination.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 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 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 const HBasicBlock* current = this; 306 const HBasicBlock* current = this;
307 int result = (current->IsLoopHeader()) ? 1 : 0; 307 int result = (current->IsLoopHeader()) ? 1 : 0;
308 while (current->parent_loop_header() != NULL) { 308 while (current->parent_loop_header() != NULL) {
309 current = current->parent_loop_header(); 309 current = current->parent_loop_header();
310 result++; 310 result++;
311 } 311 }
312 return result; 312 return result;
313 } 313 }
314 314
315 315
316 void HBasicBlock::ReplaceControlWithGotoSuccessor(int succ) {
317 ASSERT(IsFinished());
318 ASSERT(end()->SuccessorCount() == 2); // Only this case is supported yet.
319 ASSERT(succ < end()->SuccessorCount());
320
321 int unreachable_succ = 1 - succ;
322
323 // Replace control instruction with if (true) {succ} else {unreachable_succ}.
324 HBranch* new_branch = HBranch::New(
325 zone(),
326 NULL,
327 graph()->GetConstantTrue(),
328 ToBooleanStub::Types(ToBooleanStub::BOOLEAN),
329 end()->SuccessorAt(succ),
330 end()->SuccessorAt(unreachable_succ));
331
332 MarkSuccEdgeUnreachable(unreachable_succ);
333
334 end()->DeleteAndReplaceWith(end()->ActualValue());
Jakob Kummerow 2014/01/15 10:30:19 As discussed offline, this is a bug. Some instruc
335 new_branch->InsertAfter(last());
336 end_ = new_branch;
337 }
338
339
316 void HBasicBlock::PostProcessLoopHeader(IterationStatement* stmt) { 340 void HBasicBlock::PostProcessLoopHeader(IterationStatement* stmt) {
317 ASSERT(IsLoopHeader()); 341 ASSERT(IsLoopHeader());
318 342
319 SetJoinId(stmt->EntryId()); 343 SetJoinId(stmt->EntryId());
320 if (predecessors()->length() == 1) { 344 if (predecessors()->length() == 1) {
321 // This is a degenerated loop. 345 // This is a degenerated loop.
322 DetachLoopInformation(); 346 DetachLoopInformation();
323 return; 347 return;
324 } 348 }
325 349
326 // Only the first entry into the loop is from outside the loop. All other 350 // Only the first entry into the loop is from outside the loop. All other
327 // entries must be back edges. 351 // entries must be back edges.
328 for (int i = 1; i < predecessors()->length(); ++i) { 352 for (int i = 1; i < predecessors()->length(); ++i) {
329 loop_information()->RegisterBackEdge(predecessors()->at(i)); 353 loop_information()->RegisterBackEdge(predecessors()->at(i));
330 } 354 }
331 } 355 }
332 356
333 357
358 void HBasicBlock::MarkSuccEdgeUnreachable(int succ) {
359 ASSERT(IsFinished());
360 HBasicBlock* succ_block = end()->SuccessorAt(succ);
361
362 ASSERT(succ_block->predecessors()->length() == 1);
363 succ_block->MarkUnreachable();
364 }
365
366
334 void HBasicBlock::RegisterPredecessor(HBasicBlock* pred) { 367 void HBasicBlock::RegisterPredecessor(HBasicBlock* pred) {
335 if (HasPredecessor()) { 368 if (HasPredecessor()) {
336 // Only loop header blocks can have a predecessor added after 369 // Only loop header blocks can have a predecessor added after
337 // instructions have been added to the block (they have phis for all 370 // instructions have been added to the block (they have phis for all
338 // values in the environment, these phis may be eliminated later). 371 // values in the environment, these phis may be eliminated later).
339 ASSERT(IsLoopHeader() || first_ == NULL); 372 ASSERT(IsLoopHeader() || first_ == NULL);
340 HEnvironment* incoming_env = pred->last_environment(); 373 HEnvironment* incoming_env = pred->last_environment();
341 if (IsLoopHeader()) { 374 if (IsLoopHeader()) {
342 ASSERT(phis()->length() == incoming_env->length()); 375 ASSERT(phis()->length() == incoming_env->length());
343 for (int i = 0; i < phis_.length(); ++i) { 376 for (int i = 0; i < phis_.length(); ++i) {
(...skipping 10631 matching lines...) Expand 10 before | Expand all | Expand 10 after
10975 if (ShouldProduceTraceOutput()) { 11008 if (ShouldProduceTraceOutput()) {
10976 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); 11009 isolate()->GetHTracer()->TraceHydrogen(name(), graph_);
10977 } 11010 }
10978 11011
10979 #ifdef DEBUG 11012 #ifdef DEBUG
10980 graph_->Verify(false); // No full verify. 11013 graph_->Verify(false); // No full verify.
10981 #endif 11014 #endif
10982 } 11015 }
10983 11016
10984 } } // namespace v8::internal 11017 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/hydrogen.h ('k') | src/hydrogen-check-elimination.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698