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

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

Issue 11232063: Enable merging of comparisons into branches in checked mode. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 1 month 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 const intptr_t kNumInputs = 1; 192 const intptr_t kNumInputs = 1;
193 const intptr_t kNumTemps = 0; 193 const intptr_t kNumTemps = 0;
194 LocationSummary* locs = 194 LocationSummary* locs =
195 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kCall); 195 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kCall);
196 locs->set_in(0, Location::RegisterLocation(RAX)); 196 locs->set_in(0, Location::RegisterLocation(RAX));
197 locs->set_out(Location::RegisterLocation(RAX)); 197 locs->set_out(Location::RegisterLocation(RAX));
198 return locs; 198 return locs;
199 } 199 }
200 200
201 201
202 static void EmitAssertBoolean(Register reg,
203 intptr_t token_pos,
204 LocationSummary* locs,
205 FlowGraphCompiler* compiler) {
206 // Check that the type of the value is allowed in conditional context.
207 // Call the runtime if the object is not bool::true or bool::false.
208 ASSERT(locs->always_calls());
209 Label done;
210 __ CompareObject(reg, compiler->bool_true());
211 __ j(EQUAL, &done, Assembler::kNearJump);
212 __ CompareObject(reg, compiler->bool_false());
213 __ j(EQUAL, &done, Assembler::kNearJump);
214
215 __ pushq(reg); // Push the source object.
216 compiler->GenerateCallRuntime(token_pos,
217 kConditionTypeErrorRuntimeEntry,
218 locs);
219 // We should never return here.
220 __ int3();
221 __ Bind(&done);
222 }
223
224
202 void AssertBooleanInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 225 void AssertBooleanInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
203 Register obj = locs()->in(0).reg(); 226 Register obj = locs()->in(0).reg();
204 Register result = locs()->out().reg(); 227 Register result = locs()->out().reg();
205 228
206 if (!is_eliminated()) { 229 if (!is_eliminated()) {
207 // Check that the type of the value is allowed in conditional context. 230 EmitAssertBoolean(obj, token_pos(), locs(), compiler);
208 // Call the runtime if the object is not bool::true or bool::false.
209 Label done;
210 __ CompareObject(obj, compiler->bool_true());
211 __ j(EQUAL, &done, Assembler::kNearJump);
212 __ CompareObject(obj, compiler->bool_false());
213 __ j(EQUAL, &done, Assembler::kNearJump);
214
215 __ pushq(obj); // Push the source object.
216 compiler->GenerateCallRuntime(token_pos(),
217 kConditionTypeErrorRuntimeEntry,
218 locs());
219 // We should never return here.
220 __ int3();
221 __ Bind(&done);
222 } 231 }
223 ASSERT(obj == result); 232 ASSERT(obj == result);
224 } 233 }
225 234
226 235
227 LocationSummary* ArgumentDefinitionTestInstr::MakeLocationSummary() const { 236 LocationSummary* ArgumentDefinitionTestInstr::MakeLocationSummary() const {
228 const intptr_t kNumInputs = 1; 237 const intptr_t kNumInputs = 1;
229 const intptr_t kNumTemps = 0; 238 const intptr_t kNumTemps = 0;
230 LocationSummary* locs = 239 LocationSummary* locs =
231 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kCall); 240 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kCall);
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 Label false_label; 457 Label false_label;
449 __ CompareObject(RAX, compiler->bool_true()); 458 __ CompareObject(RAX, compiler->bool_true());
450 __ j(EQUAL, &false_label, Assembler::kNearJump); 459 __ j(EQUAL, &false_label, Assembler::kNearJump);
451 __ LoadObject(RAX, compiler->bool_true()); 460 __ LoadObject(RAX, compiler->bool_true());
452 __ jmp(&done); 461 __ jmp(&done);
453 __ Bind(&false_label); 462 __ Bind(&false_label);
454 __ LoadObject(RAX, compiler->bool_false()); 463 __ LoadObject(RAX, compiler->bool_false());
455 __ jmp(&done); 464 __ jmp(&done);
456 } 465 }
457 } else { 466 } else {
467 if (branch->is_checked()) {
468 EmitAssertBoolean(RAX, token_pos, locs, compiler);
469 }
458 __ CompareObject(RAX, compiler->bool_true()); 470 __ CompareObject(RAX, compiler->bool_true());
459 branch->EmitBranchOnCondition(compiler, cond); 471 branch->EmitBranchOnCondition(compiler, cond);
460 } 472 }
461 } 473 }
462 __ jmp(&done); 474 __ jmp(&done);
463 __ Bind(&next_test); 475 __ Bind(&next_test);
464 } 476 }
465 // Fall through leads to deoptimization 477 // Fall through leads to deoptimization
466 __ jmp(deopt); 478 __ jmp(deopt);
467 __ Bind(&done); 479 __ Bind(&done);
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
725 } 737 }
726 Register left = locs()->in(0).reg(); 738 Register left = locs()->in(0).reg();
727 Register right = locs()->in(1).reg(); 739 Register right = locs()->in(1).reg();
728 __ pushq(left); 740 __ pushq(left);
729 __ pushq(right); 741 __ pushq(right);
730 EmitEqualityAsInstanceCall(compiler, 742 EmitEqualityAsInstanceCall(compiler,
731 deopt_id(), 743 deopt_id(),
732 token_pos(), 744 token_pos(),
733 Token::kEQ, // kNE reverse occurs at branch. 745 Token::kEQ, // kNE reverse occurs at branch.
734 locs()); 746 locs());
747 if (branch->is_checked()) {
748 EmitAssertBoolean(RAX, token_pos(), locs(), compiler);
749 }
735 Condition branch_condition = (kind() == Token::kNE) ? NOT_EQUAL : EQUAL; 750 Condition branch_condition = (kind() == Token::kNE) ? NOT_EQUAL : EQUAL;
736 __ CompareObject(RAX, compiler->bool_true()); 751 __ CompareObject(RAX, compiler->bool_true());
737 branch->EmitBranchOnCondition(compiler, branch_condition); 752 branch->EmitBranchOnCondition(compiler, branch_condition);
738 } 753 }
739 754
740 755
741 LocationSummary* RelationalOpInstr::MakeLocationSummary() const { 756 LocationSummary* RelationalOpInstr::MakeLocationSummary() const {
742 const intptr_t kNumInputs = 2; 757 const intptr_t kNumInputs = 2;
743 const intptr_t kNumTemps = 0; 758 const intptr_t kNumTemps = 0;
744 if (operands_class_id() == kDoubleCid) { 759 if (operands_class_id() == kDoubleCid) {
(...skipping 1547 matching lines...) Expand 10 before | Expand all | Expand 10 after
2292 2307
2293 void ShiftMintOpInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 2308 void ShiftMintOpInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
2294 UNIMPLEMENTED(); 2309 UNIMPLEMENTED();
2295 } 2310 }
2296 2311
2297 } // namespace dart 2312 } // namespace dart
2298 2313
2299 #undef __ 2314 #undef __
2300 2315
2301 #endif // defined TARGET_ARCH_X64 2316 #endif // defined TARGET_ARCH_X64
OLDNEW
« runtime/vm/intermediate_language_ia32.cc ('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