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

Side by Side Diff: runtime/vm/intermediate_language_x64.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_X64. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64.
6 #if defined(TARGET_ARCH_X64) 6 #if defined(TARGET_ARCH_X64)
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 2879 matching lines...) Expand 10 before | Expand all | Expand 10 after
2890 GetDeoptId(), 2890 GetDeoptId(),
2891 0); // No token position. 2891 0); // No token position.
2892 } 2892 }
2893 2893
2894 if (HasParallelMove()) { 2894 if (HasParallelMove()) {
2895 compiler->parallel_move_resolver()->EmitNativeCode(parallel_move()); 2895 compiler->parallel_move_resolver()->EmitNativeCode(parallel_move());
2896 } 2896 }
2897 2897
2898 // We can fall through if the successor is the next block in the list. 2898 // We can fall through if the successor is the next block in the list.
2899 // Otherwise, we need a jump. 2899 // Otherwise, we need a jump.
2900 if (!compiler->IsNextBlock(successor())) { 2900 if (!compiler->CanFallThroughTo(successor())) {
2901 __ jmp(compiler->GetBlockLabel(successor())); 2901 __ jmp(compiler->GetJumpLabel(successor()));
2902 } 2902 }
2903 } 2903 }
2904 2904
2905 2905
2906 static Condition NegateCondition(Condition condition) { 2906 static Condition NegateCondition(Condition condition) {
2907 switch (condition) { 2907 switch (condition) {
2908 case EQUAL: return NOT_EQUAL; 2908 case EQUAL: return NOT_EQUAL;
2909 case NOT_EQUAL: return EQUAL; 2909 case NOT_EQUAL: return EQUAL;
2910 case LESS: return GREATER_EQUAL; 2910 case LESS: return GREATER_EQUAL;
2911 case LESS_EQUAL: return GREATER; 2911 case LESS_EQUAL: return GREATER;
2912 case GREATER: return LESS_EQUAL; 2912 case GREATER: return LESS_EQUAL;
2913 case GREATER_EQUAL: return LESS; 2913 case GREATER_EQUAL: return LESS;
2914 case BELOW: return ABOVE_EQUAL; 2914 case BELOW: return ABOVE_EQUAL;
2915 case BELOW_EQUAL: return ABOVE; 2915 case BELOW_EQUAL: return ABOVE;
2916 case ABOVE: return BELOW_EQUAL; 2916 case ABOVE: return BELOW_EQUAL;
2917 case ABOVE_EQUAL: return BELOW; 2917 case ABOVE_EQUAL: return BELOW;
2918 default: 2918 default:
2919 OS::Print("Error %d\n", condition); 2919 OS::Print("Error %d\n", condition);
2920 UNIMPLEMENTED(); 2920 UNIMPLEMENTED();
2921 return EQUAL; 2921 return EQUAL;
2922 } 2922 }
2923 } 2923 }
2924 2924
2925 2925
2926 void ControlInstruction::EmitBranchOnValue(FlowGraphCompiler* compiler, 2926 void ControlInstruction::EmitBranchOnValue(FlowGraphCompiler* compiler,
2927 bool value) { 2927 bool value) {
2928 if (value && compiler->IsNextBlock(false_successor())) { 2928 if (value && !compiler->CanFallThroughTo(true_successor())) {
2929 __ jmp(compiler->GetBlockLabel(true_successor())); 2929 __ jmp(compiler->GetJumpLabel(true_successor()));
2930 } else if (!value && compiler->IsNextBlock(true_successor())) { 2930 } else if (!value && !compiler->CanFallThroughTo(false_successor())) {
2931 __ jmp(compiler->GetBlockLabel(false_successor())); 2931 __ jmp(compiler->GetJumpLabel(false_successor()));
2932 } 2932 }
2933 } 2933 }
2934 2934
2935 2935
2936 void ControlInstruction::EmitBranchOnCondition(FlowGraphCompiler* compiler, 2936 void ControlInstruction::EmitBranchOnCondition(FlowGraphCompiler* compiler,
2937 Condition true_condition) { 2937 Condition true_condition) {
2938 if (compiler->IsNextBlock(false_successor())) { 2938 if (compiler->CanFallThroughTo(false_successor())) {
2939 // If the next block is the false successor we will fall through to it. 2939 // If the next block is the false successor we will fall through to it.
2940 __ j(true_condition, compiler->GetBlockLabel(true_successor())); 2940 __ j(true_condition, compiler->GetJumpLabel(true_successor()));
2941 } else { 2941 } else {
2942 // If the next block is the true successor we negate comparison and fall 2942 // If the next block is the true successor we negate comparison and fall
2943 // through to it. 2943 // through to it.
2944 ASSERT(compiler->IsNextBlock(true_successor()));
2945 Condition false_condition = NegateCondition(true_condition); 2944 Condition false_condition = NegateCondition(true_condition);
2946 __ j(false_condition, compiler->GetBlockLabel(false_successor())); 2945 __ j(false_condition, compiler->GetJumpLabel(false_successor()));
2946
2947 // Fall through or jump to the true successor.
2948 if (!compiler->CanFallThroughTo(true_successor())) {
2949 __ jmp(compiler->GetJumpLabel(true_successor()));
2950 }
2947 } 2951 }
2948 } 2952 }
2949 2953
2950 2954
2951 LocationSummary* CurrentContextInstr::MakeLocationSummary() const { 2955 LocationSummary* CurrentContextInstr::MakeLocationSummary() const {
2952 return LocationSummary::Make(0, 2956 return LocationSummary::Make(0,
2953 Location::RequiresRegister(), 2957 Location::RequiresRegister(),
2954 LocationSummary::kNoCall); 2958 LocationSummary::kNoCall);
2955 } 2959 }
2956 2960
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
3159 PcDescriptors::kOther, 3163 PcDescriptors::kOther,
3160 locs()); 3164 locs());
3161 __ Drop(2); // Discard type arguments and receiver. 3165 __ Drop(2); // Discard type arguments and receiver.
3162 } 3166 }
3163 3167
3164 } // namespace dart 3168 } // namespace dart
3165 3169
3166 #undef __ 3170 #undef __
3167 3171
3168 #endif // defined TARGET_ARCH_X64 3172 #endif // defined TARGET_ARCH_X64
OLDNEW
« runtime/vm/flow_graph_compiler.h ('K') | « runtime/vm/intermediate_language_ia32.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698