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

Side by Side Diff: runtime/vm/intermediate_language_ia32.cc

Issue 12412013: Add pass to remove empty blocks and recompute fall-through targets. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 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
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32.
6 #if defined(TARGET_ARCH_IA32) 6 #if defined(TARGET_ARCH_IA32)
7 7
8 #include "vm/intermediate_language.h" 8 #include "vm/intermediate_language.h"
9 9
10 #include "lib/error.h" 10 #include "lib/error.h"
(...skipping 714 matching lines...) Expand 10 before | Expand all | Expand 10 after
725 default: 725 default:
726 break; 726 break;
727 } 727 }
728 ASSERT(hi_cond != OVERFLOW && lo_cond != OVERFLOW); 728 ASSERT(hi_cond != OVERFLOW && lo_cond != OVERFLOW);
729 Label is_true, is_false; 729 Label is_true, is_false;
730 // Compare upper halves first. 730 // Compare upper halves first.
731 __ pextrd(left_tmp, left, Immediate(1)); 731 __ pextrd(left_tmp, left, Immediate(1));
732 __ pextrd(right_tmp, right, Immediate(1)); 732 __ pextrd(right_tmp, right, Immediate(1));
733 __ cmpl(left_tmp, right_tmp); 733 __ cmpl(left_tmp, right_tmp);
734 if (branch != NULL) { 734 if (branch != NULL) {
735 __ j(hi_cond, compiler->GetBlockLabel(branch->true_successor())); 735 __ j(hi_cond, compiler->GetJumpLabel(branch->true_successor()));
736 __ j(FlowGraphCompiler::FlipCondition(hi_cond), 736 __ j(FlowGraphCompiler::FlipCondition(hi_cond),
737 compiler->GetBlockLabel(branch->false_successor())); 737 compiler->GetJumpLabel(branch->false_successor()));
738 } else { 738 } else {
739 __ j(hi_cond, &is_true); 739 __ j(hi_cond, &is_true);
740 __ j(FlowGraphCompiler::FlipCondition(hi_cond), &is_false); 740 __ j(FlowGraphCompiler::FlipCondition(hi_cond), &is_false);
741 } 741 }
742 742
743 // If upper is equal, compare lower half. 743 // If upper is equal, compare lower half.
744 __ pextrd(left_tmp, left, Immediate(0)); 744 __ pextrd(left_tmp, left, Immediate(0));
745 __ pextrd(right_tmp, right, Immediate(0)); 745 __ pextrd(right_tmp, right, Immediate(0));
746 __ cmpl(left_tmp, right_tmp); 746 __ cmpl(left_tmp, right_tmp);
747 if (branch != NULL) { 747 if (branch != NULL) {
(...skipping 2538 matching lines...) Expand 10 before | Expand all | Expand 10 after
3286 GetDeoptId(), 3286 GetDeoptId(),
3287 0); // No token position. 3287 0); // No token position.
3288 } 3288 }
3289 3289
3290 if (HasParallelMove()) { 3290 if (HasParallelMove()) {
3291 compiler->parallel_move_resolver()->EmitNativeCode(parallel_move()); 3291 compiler->parallel_move_resolver()->EmitNativeCode(parallel_move());
3292 } 3292 }
3293 3293
3294 // We can fall through if the successor is the next block in the list. 3294 // We can fall through if the successor is the next block in the list.
3295 // Otherwise, we need a jump. 3295 // Otherwise, we need a jump.
3296 if (!compiler->IsNextBlock(successor())) { 3296 if (!compiler->CanFallThroughTo(successor())) {
3297 __ jmp(compiler->GetBlockLabel(successor())); 3297 __ jmp(compiler->GetJumpLabel(successor()));
3298 } 3298 }
3299 } 3299 }
3300 3300
3301 3301
3302 static Condition NegateCondition(Condition condition) { 3302 static Condition NegateCondition(Condition condition) {
3303 switch (condition) { 3303 switch (condition) {
3304 case EQUAL: return NOT_EQUAL; 3304 case EQUAL: return NOT_EQUAL;
3305 case NOT_EQUAL: return EQUAL; 3305 case NOT_EQUAL: return EQUAL;
3306 case LESS: return GREATER_EQUAL; 3306 case LESS: return GREATER_EQUAL;
3307 case LESS_EQUAL: return GREATER; 3307 case LESS_EQUAL: return GREATER;
3308 case GREATER: return LESS_EQUAL; 3308 case GREATER: return LESS_EQUAL;
3309 case GREATER_EQUAL: return LESS; 3309 case GREATER_EQUAL: return LESS;
3310 case BELOW: return ABOVE_EQUAL; 3310 case BELOW: return ABOVE_EQUAL;
3311 case BELOW_EQUAL: return ABOVE; 3311 case BELOW_EQUAL: return ABOVE;
3312 case ABOVE: return BELOW_EQUAL; 3312 case ABOVE: return BELOW_EQUAL;
3313 case ABOVE_EQUAL: return BELOW; 3313 case ABOVE_EQUAL: return BELOW;
3314 default: 3314 default:
3315 OS::Print("Error %d\n", condition); 3315 OS::Print("Error %d\n", condition);
3316 UNIMPLEMENTED(); 3316 UNIMPLEMENTED();
3317 return EQUAL; 3317 return EQUAL;
3318 } 3318 }
3319 } 3319 }
3320 3320
3321 3321
3322 void ControlInstruction::EmitBranchOnValue(FlowGraphCompiler* compiler, 3322 void ControlInstruction::EmitBranchOnValue(FlowGraphCompiler* compiler,
3323 bool value) { 3323 bool value) {
3324 if (value && compiler->IsNextBlock(false_successor())) { 3324 if (value && !compiler->CanFallThroughTo(true_successor())) {
3325 __ jmp(compiler->GetBlockLabel(true_successor())); 3325 __ jmp(compiler->GetJumpLabel(true_successor()));
3326 } else if (!value && compiler->IsNextBlock(true_successor())) { 3326 } else if (!value && !compiler->CanFallThroughTo(false_successor())) {
3327 __ jmp(compiler->GetBlockLabel(false_successor())); 3327 __ jmp(compiler->GetJumpLabel(false_successor()));
3328 } 3328 }
3329 } 3329 }
3330 3330
3331 3331
3332 void ControlInstruction::EmitBranchOnCondition(FlowGraphCompiler* compiler, 3332 void ControlInstruction::EmitBranchOnCondition(FlowGraphCompiler* compiler,
3333 Condition true_condition) { 3333 Condition true_condition) {
3334 if (compiler->IsNextBlock(false_successor())) { 3334 if (compiler->CanFallThroughTo(false_successor())) {
3335 // If the next block is the false successor we will fall through to it. 3335 // If the next block is the false successor we will fall through to it.
3336 __ j(true_condition, compiler->GetBlockLabel(true_successor())); 3336 __ j(true_condition, compiler->GetJumpLabel(true_successor()));
3337 } else { 3337 } else {
3338 // If the next block is the true successor we negate comparison and fall 3338 // If the next block is the true successor we negate comparison and fall
3339 // through to it. 3339 // through to it.
3340 ASSERT(compiler->IsNextBlock(true_successor()));
3341 Condition false_condition = NegateCondition(true_condition); 3340 Condition false_condition = NegateCondition(true_condition);
3342 __ j(false_condition, compiler->GetBlockLabel(false_successor())); 3341 __ j(false_condition, compiler->GetJumpLabel(false_successor()));
3342
3343 // Fall through or jump to the true successor.
3344 if (!compiler->CanFallThroughTo(true_successor())) {
3345 __ jmp(compiler->GetJumpLabel(true_successor()));
3346 }
3343 } 3347 }
3344 } 3348 }
3345 3349
3346 3350
3347 LocationSummary* CurrentContextInstr::MakeLocationSummary() const { 3351 LocationSummary* CurrentContextInstr::MakeLocationSummary() const {
3348 return LocationSummary::Make(0, 3352 return LocationSummary::Make(0,
3349 Location::RequiresRegister(), 3353 Location::RequiresRegister(),
3350 LocationSummary::kNoCall); 3354 LocationSummary::kNoCall);
3351 } 3355 }
3352 3356
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
3555 PcDescriptors::kOther, 3559 PcDescriptors::kOther,
3556 locs()); 3560 locs());
3557 __ Drop(2); // Discard type arguments and receiver. 3561 __ Drop(2); // Discard type arguments and receiver.
3558 } 3562 }
3559 3563
3560 } // namespace dart 3564 } // namespace dart
3561 3565
3562 #undef __ 3566 #undef __
3563 3567
3564 #endif // defined TARGET_ARCH_IA32 3568 #endif // defined TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698