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 4301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4312 ASSERT(current_block() != NULL); | 4312 ASSERT(current_block() != NULL); |
| 4313 HBasicBlock* loop_entry = BuildLoopEntry(stmt); | 4313 HBasicBlock* loop_entry = BuildLoopEntry(stmt); |
| 4314 | 4314 |
| 4315 BreakAndContinueInfo break_info(stmt); | 4315 BreakAndContinueInfo break_info(stmt); |
| 4316 CHECK_BAILOUT(VisitLoopBody(stmt, loop_entry, &break_info)); | 4316 CHECK_BAILOUT(VisitLoopBody(stmt, loop_entry, &break_info)); |
| 4317 HBasicBlock* body_exit = | 4317 HBasicBlock* body_exit = |
| 4318 JoinContinue(stmt, current_block(), break_info.continue_block()); | 4318 JoinContinue(stmt, current_block(), break_info.continue_block()); |
| 4319 HBasicBlock* loop_successor = NULL; | 4319 HBasicBlock* loop_successor = NULL; |
| 4320 if (body_exit != NULL && !stmt->cond()->ToBooleanIsTrue()) { | 4320 if (body_exit != NULL && !stmt->cond()->ToBooleanIsTrue()) { |
| 4321 set_current_block(body_exit); | 4321 set_current_block(body_exit); |
| 4322 // The block for a true condition, the actual predecessor block of the | |
| 4323 // back edge. | |
| 4324 body_exit = graph()->CreateBasicBlock(); | |
| 4325 loop_successor = graph()->CreateBasicBlock(); | 4322 loop_successor = graph()->CreateBasicBlock(); |
| 4326 CHECK_BAILOUT(VisitForControl(stmt->cond(), body_exit, loop_successor)); | 4323 if (stmt->cond()->ToBooleanIsFalse()) { |
| 4327 if (body_exit->HasPredecessor()) { | 4324 Goto(loop_successor); |
| 4325 body_exit = NULL; | |
| 4326 } else { | |
| 4327 // The block for a true condition, the actual predecessor block of the | |
| 4328 // back edge. | |
| 4329 body_exit = graph()->CreateBasicBlock(); | |
| 4330 CHECK_BAILOUT(VisitForControl(stmt->cond(), body_exit, loop_successor)); | |
| 4331 ASSERT(body_exit->HasPredecessor()); | |
|
titzer
2014/01/09 14:19:53
I don't think this is strictly correct, e.g. if th
Jakob Kummerow
2014/01/09 15:01:44
I disagree. We are very careful to ensure that all
| |
| 4328 body_exit->SetJoinId(stmt->BackEdgeId()); | 4332 body_exit->SetJoinId(stmt->BackEdgeId()); |
| 4329 } else { | |
| 4330 body_exit = NULL; | |
| 4331 } | 4333 } |
| 4332 if (loop_successor->HasPredecessor()) { | 4334 ASSERT(loop_successor->HasPredecessor()); |
| 4333 loop_successor->SetJoinId(stmt->ExitId()); | 4335 loop_successor->SetJoinId(stmt->ExitId()); |
| 4334 } else { | |
| 4335 loop_successor = NULL; | |
| 4336 } | |
| 4337 } | 4336 } |
| 4338 HBasicBlock* loop_exit = CreateLoop(stmt, | 4337 HBasicBlock* loop_exit = CreateLoop(stmt, |
| 4339 loop_entry, | 4338 loop_entry, |
| 4340 body_exit, | 4339 body_exit, |
| 4341 loop_successor, | 4340 loop_successor, |
| 4342 break_info.break_block()); | 4341 break_info.break_block()); |
| 4343 set_current_block(loop_exit); | 4342 set_current_block(loop_exit); |
| 4344 } | 4343 } |
| 4345 | 4344 |
| 4346 | 4345 |
| 4347 void HOptimizedGraphBuilder::VisitWhileStatement(WhileStatement* stmt) { | 4346 void HOptimizedGraphBuilder::VisitWhileStatement(WhileStatement* stmt) { |
| 4348 ASSERT(!HasStackOverflow()); | 4347 ASSERT(!HasStackOverflow()); |
| 4349 ASSERT(current_block() != NULL); | 4348 ASSERT(current_block() != NULL); |
| 4350 ASSERT(current_block()->HasPredecessor()); | 4349 ASSERT(current_block()->HasPredecessor()); |
| 4351 ASSERT(current_block() != NULL); | 4350 ASSERT(current_block() != NULL); |
| 4352 HBasicBlock* loop_entry = BuildLoopEntry(stmt); | 4351 HBasicBlock* loop_entry = BuildLoopEntry(stmt); |
| 4353 | 4352 |
| 4354 // If the condition is constant true, do not generate a branch. | 4353 // If the condition is constant true, do not generate a branch. |
| 4355 HBasicBlock* loop_successor = NULL; | 4354 HBasicBlock* loop_successor = NULL; |
| 4356 if (!stmt->cond()->ToBooleanIsTrue()) { | 4355 if (!stmt->cond()->ToBooleanIsTrue()) { |
| 4357 HBasicBlock* body_entry = graph()->CreateBasicBlock(); | 4356 HBasicBlock* body_entry = graph()->CreateBasicBlock(); |
| 4358 loop_successor = graph()->CreateBasicBlock(); | 4357 loop_successor = graph()->CreateBasicBlock(); |
| 4359 CHECK_BAILOUT(VisitForControl(stmt->cond(), body_entry, loop_successor)); | 4358 CHECK_BAILOUT(VisitForControl(stmt->cond(), body_entry, loop_successor)); |
| 4360 if (body_entry->HasPredecessor()) { | 4359 ASSERT(body_entry->HasPredecessor()); |
|
titzer
2014/01/09 14:19:53
Same here.
| |
| 4361 body_entry->SetJoinId(stmt->BodyId()); | 4360 body_entry->SetJoinId(stmt->BodyId()); |
| 4362 set_current_block(body_entry); | 4361 set_current_block(body_entry); |
| 4363 } | 4362 ASSERT(loop_successor->HasPredecessor()); |
| 4364 if (loop_successor->HasPredecessor()) { | 4363 loop_successor->SetJoinId(stmt->ExitId()); |
| 4365 loop_successor->SetJoinId(stmt->ExitId()); | |
| 4366 } else { | |
| 4367 loop_successor = NULL; | |
| 4368 } | |
| 4369 } | 4364 } |
| 4370 | 4365 |
| 4371 BreakAndContinueInfo break_info(stmt); | 4366 BreakAndContinueInfo break_info(stmt); |
| 4372 if (current_block() != NULL) { | 4367 if (current_block() != NULL) { |
| 4373 CHECK_BAILOUT(VisitLoopBody(stmt, loop_entry, &break_info)); | 4368 CHECK_BAILOUT(VisitLoopBody(stmt, loop_entry, &break_info)); |
| 4374 } | 4369 } |
| 4375 HBasicBlock* body_exit = | 4370 HBasicBlock* body_exit = |
| 4376 JoinContinue(stmt, current_block(), break_info.continue_block()); | 4371 JoinContinue(stmt, current_block(), break_info.continue_block()); |
| 4377 HBasicBlock* loop_exit = CreateLoop(stmt, | 4372 HBasicBlock* loop_exit = CreateLoop(stmt, |
| 4378 loop_entry, | 4373 loop_entry, |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 4391 CHECK_ALIVE(Visit(stmt->init())); | 4386 CHECK_ALIVE(Visit(stmt->init())); |
| 4392 } | 4387 } |
| 4393 ASSERT(current_block() != NULL); | 4388 ASSERT(current_block() != NULL); |
| 4394 HBasicBlock* loop_entry = BuildLoopEntry(stmt); | 4389 HBasicBlock* loop_entry = BuildLoopEntry(stmt); |
| 4395 | 4390 |
| 4396 HBasicBlock* loop_successor = NULL; | 4391 HBasicBlock* loop_successor = NULL; |
| 4397 if (stmt->cond() != NULL) { | 4392 if (stmt->cond() != NULL) { |
| 4398 HBasicBlock* body_entry = graph()->CreateBasicBlock(); | 4393 HBasicBlock* body_entry = graph()->CreateBasicBlock(); |
| 4399 loop_successor = graph()->CreateBasicBlock(); | 4394 loop_successor = graph()->CreateBasicBlock(); |
| 4400 CHECK_BAILOUT(VisitForControl(stmt->cond(), body_entry, loop_successor)); | 4395 CHECK_BAILOUT(VisitForControl(stmt->cond(), body_entry, loop_successor)); |
| 4401 if (body_entry->HasPredecessor()) { | 4396 ASSERT(body_entry->HasPredecessor()); |
| 4402 body_entry->SetJoinId(stmt->BodyId()); | 4397 body_entry->SetJoinId(stmt->BodyId()); |
| 4403 set_current_block(body_entry); | 4398 set_current_block(body_entry); |
| 4404 } | 4399 ASSERT(loop_successor->HasPredecessor()); |
| 4405 if (loop_successor->HasPredecessor()) { | 4400 loop_successor->SetJoinId(stmt->ExitId()); |
| 4406 loop_successor->SetJoinId(stmt->ExitId()); | |
| 4407 } else { | |
| 4408 loop_successor = NULL; | |
| 4409 } | |
| 4410 } | 4401 } |
| 4411 | 4402 |
| 4412 BreakAndContinueInfo break_info(stmt); | 4403 BreakAndContinueInfo break_info(stmt); |
| 4413 if (current_block() != NULL) { | 4404 if (current_block() != NULL) { |
| 4414 CHECK_BAILOUT(VisitLoopBody(stmt, loop_entry, &break_info)); | 4405 CHECK_BAILOUT(VisitLoopBody(stmt, loop_entry, &break_info)); |
| 4415 } | 4406 } |
| 4416 HBasicBlock* body_exit = | 4407 HBasicBlock* body_exit = |
| 4417 JoinContinue(stmt, current_block(), break_info.continue_block()); | 4408 JoinContinue(stmt, current_block(), break_info.continue_block()); |
| 4418 | 4409 |
| 4419 if (stmt->next() != NULL && body_exit != NULL) { | 4410 if (stmt->next() != NULL && body_exit != NULL) { |
| (...skipping 6524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 10944 if (ShouldProduceTraceOutput()) { | 10935 if (ShouldProduceTraceOutput()) { |
| 10945 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 10936 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
| 10946 } | 10937 } |
| 10947 | 10938 |
| 10948 #ifdef DEBUG | 10939 #ifdef DEBUG |
| 10949 graph_->Verify(false); // No full verify. | 10940 graph_->Verify(false); // No full verify. |
| 10950 #endif | 10941 #endif |
| 10951 } | 10942 } |
| 10952 | 10943 |
| 10953 } } // namespace v8::internal | 10944 } } // namespace v8::internal |
| OLD | NEW |