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 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()); | |
335 new_branch->InsertAfter(last()); | |
336 end_ = new_branch; | |
337 } | |
338 | |
339 | |
340 void HBasicBlock::PostProcessLoopHeader(IterationStatement* stmt) { | 316 void HBasicBlock::PostProcessLoopHeader(IterationStatement* stmt) { |
341 ASSERT(IsLoopHeader()); | 317 ASSERT(IsLoopHeader()); |
342 | 318 |
343 SetJoinId(stmt->EntryId()); | 319 SetJoinId(stmt->EntryId()); |
344 if (predecessors()->length() == 1) { | 320 if (predecessors()->length() == 1) { |
345 // This is a degenerated loop. | 321 // This is a degenerated loop. |
346 DetachLoopInformation(); | 322 DetachLoopInformation(); |
347 return; | 323 return; |
348 } | 324 } |
349 | 325 |
350 // Only the first entry into the loop is from outside the loop. All other | 326 // Only the first entry into the loop is from outside the loop. All other |
351 // entries must be back edges. | 327 // entries must be back edges. |
352 for (int i = 1; i < predecessors()->length(); ++i) { | 328 for (int i = 1; i < predecessors()->length(); ++i) { |
353 loop_information()->RegisterBackEdge(predecessors()->at(i)); | 329 loop_information()->RegisterBackEdge(predecessors()->at(i)); |
354 } | 330 } |
355 } | 331 } |
356 | 332 |
357 | 333 |
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 | |
367 void HBasicBlock::RegisterPredecessor(HBasicBlock* pred) { | 334 void HBasicBlock::RegisterPredecessor(HBasicBlock* pred) { |
368 if (HasPredecessor()) { | 335 if (HasPredecessor()) { |
369 // Only loop header blocks can have a predecessor added after | 336 // Only loop header blocks can have a predecessor added after |
370 // instructions have been added to the block (they have phis for all | 337 // instructions have been added to the block (they have phis for all |
371 // values in the environment, these phis may be eliminated later). | 338 // values in the environment, these phis may be eliminated later). |
372 ASSERT(IsLoopHeader() || first_ == NULL); | 339 ASSERT(IsLoopHeader() || first_ == NULL); |
373 HEnvironment* incoming_env = pred->last_environment(); | 340 HEnvironment* incoming_env = pred->last_environment(); |
374 if (IsLoopHeader()) { | 341 if (IsLoopHeader()) { |
375 ASSERT(phis()->length() == incoming_env->length()); | 342 ASSERT(phis()->length() == incoming_env->length()); |
376 for (int i = 0; i < phis_.length(); ++i) { | 343 for (int i = 0; i < phis_.length(); ++i) { |
(...skipping 10564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10941 if (ShouldProduceTraceOutput()) { | 10908 if (ShouldProduceTraceOutput()) { |
10942 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 10909 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
10943 } | 10910 } |
10944 | 10911 |
10945 #ifdef DEBUG | 10912 #ifdef DEBUG |
10946 graph_->Verify(false); // No full verify. | 10913 graph_->Verify(false); // No full verify. |
10947 #endif | 10914 #endif |
10948 } | 10915 } |
10949 | 10916 |
10950 } } // namespace v8::internal | 10917 } } // namespace v8::internal |
OLD | NEW |