Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 // Replace control instruction with if(true) or if(false). | |
| 322 HConstant* value = (succ == 0) | |
| 323 ? graph()->GetConstantTrue() | |
| 324 : graph()->GetConstantFalse(); | |
| 325 | |
| 326 HBranch* new_branch = HBranch::New( | |
| 327 zone(), | |
| 328 NULL, | |
| 329 value, | |
|
titzer
2014/01/14 13:40:32
Why not always if(true) {succ} else {1 - succ}?
Igor Sheludko
2014/01/14 15:28:00
Done.
| |
| 330 ToBooleanStub::Types(ToBooleanStub::BOOLEAN), | |
| 331 end()->SuccessorAt(0), | |
| 332 end()->SuccessorAt(1)); | |
| 333 | |
| 334 int unreachable_succ = 1 - succ; | |
| 335 | |
| 336 MarkSuccEdgeUnreachable(unreachable_succ); | |
| 337 | |
| 338 end()->DeleteAndReplaceWith(end()->ActualValue()); | |
| 339 new_branch->InsertAfter(last()); | |
| 340 end_ = new_branch; | |
| 341 } | |
| 342 | |
| 343 | |
| 316 void HBasicBlock::PostProcessLoopHeader(IterationStatement* stmt) { | 344 void HBasicBlock::PostProcessLoopHeader(IterationStatement* stmt) { |
| 317 ASSERT(IsLoopHeader()); | 345 ASSERT(IsLoopHeader()); |
| 318 | 346 |
| 319 SetJoinId(stmt->EntryId()); | 347 SetJoinId(stmt->EntryId()); |
| 320 if (predecessors()->length() == 1) { | 348 if (predecessors()->length() == 1) { |
| 321 // This is a degenerated loop. | 349 // This is a degenerated loop. |
| 322 DetachLoopInformation(); | 350 DetachLoopInformation(); |
| 323 return; | 351 return; |
| 324 } | 352 } |
| 325 | 353 |
| 326 // Only the first entry into the loop is from outside the loop. All other | 354 // Only the first entry into the loop is from outside the loop. All other |
| 327 // entries must be back edges. | 355 // entries must be back edges. |
| 328 for (int i = 1; i < predecessors()->length(); ++i) { | 356 for (int i = 1; i < predecessors()->length(); ++i) { |
| 329 loop_information()->RegisterBackEdge(predecessors()->at(i)); | 357 loop_information()->RegisterBackEdge(predecessors()->at(i)); |
| 330 } | 358 } |
| 331 } | 359 } |
| 332 | 360 |
| 333 | 361 |
| 362 void HBasicBlock::MarkSuccEdgeUnreachable(int succ) { | |
| 363 ASSERT(IsFinished()); | |
| 364 HBasicBlock* succ_block = end()->SuccessorAt(succ); | |
| 365 | |
| 366 ASSERT(succ_block->predecessors()->length() == 1); | |
| 367 succ_block->MarkUnreachable(); | |
| 368 } | |
| 369 | |
| 370 | |
| 334 void HBasicBlock::RegisterPredecessor(HBasicBlock* pred) { | 371 void HBasicBlock::RegisterPredecessor(HBasicBlock* pred) { |
| 335 if (HasPredecessor()) { | 372 if (HasPredecessor()) { |
| 336 // Only loop header blocks can have a predecessor added after | 373 // Only loop header blocks can have a predecessor added after |
| 337 // instructions have been added to the block (they have phis for all | 374 // instructions have been added to the block (they have phis for all |
| 338 // values in the environment, these phis may be eliminated later). | 375 // values in the environment, these phis may be eliminated later). |
| 339 ASSERT(IsLoopHeader() || first_ == NULL); | 376 ASSERT(IsLoopHeader() || first_ == NULL); |
| 340 HEnvironment* incoming_env = pred->last_environment(); | 377 HEnvironment* incoming_env = pred->last_environment(); |
| 341 if (IsLoopHeader()) { | 378 if (IsLoopHeader()) { |
| 342 ASSERT(phis()->length() == incoming_env->length()); | 379 ASSERT(phis()->length() == incoming_env->length()); |
| 343 for (int i = 0; i < phis_.length(); ++i) { | 380 for (int i = 0; i < phis_.length(); ++i) { |
| (...skipping 10628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 10972 if (ShouldProduceTraceOutput()) { | 11009 if (ShouldProduceTraceOutput()) { |
| 10973 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 11010 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
| 10974 } | 11011 } |
| 10975 | 11012 |
| 10976 #ifdef DEBUG | 11013 #ifdef DEBUG |
| 10977 graph_->Verify(false); // No full verify. | 11014 graph_->Verify(false); // No full verify. |
| 10978 #endif | 11015 #endif |
| 10979 } | 11016 } |
| 10980 | 11017 |
| 10981 } } // namespace v8::internal | 11018 } } // namespace v8::internal |
| OLD | NEW |