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

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

Issue 258563004: Copy of Issue 231383002 after hard disk crash: First step in improving instance of test for a fixed… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 8 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 "vm/dart_entry.h" 10 #include "vm/dart_entry.h"
(...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 575
576 576
577 void TestSmiInstr::EmitBranchCode(FlowGraphCompiler* compiler, 577 void TestSmiInstr::EmitBranchCode(FlowGraphCompiler* compiler,
578 BranchInstr* branch) { 578 BranchInstr* branch) {
579 BranchLabels labels = compiler->CreateBranchLabels(branch); 579 BranchLabels labels = compiler->CreateBranchLabels(branch);
580 Condition true_condition = EmitComparisonCode(compiler, labels); 580 Condition true_condition = EmitComparisonCode(compiler, labels);
581 EmitBranchOnCondition(compiler, true_condition, labels); 581 EmitBranchOnCondition(compiler, true_condition, labels);
582 } 582 }
583 583
584 584
585
586 LocationSummary* TestCidsInstr::MakeLocationSummary(bool opt) const {
587 const intptr_t kNumInputs = 1;
588 const intptr_t kNumTemps = 1;
589 LocationSummary* locs =
590 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
591 locs->set_in(0, Location::RequiresRegister());
592 locs->set_temp(0, Location::RequiresRegister());
593 locs->set_out(0, Location::RequiresRegister());
594 return locs;
595 }
596
597
598 Condition TestCidsInstr::EmitComparisonCode(FlowGraphCompiler* compiler,
599 BranchLabels labels) {
600 ASSERT((kind() == Token::kIS) || (kind() == Token::kISNOT));
601 Register val_reg = locs()->in(0).reg();
602 Register cid_reg = locs()->temp(0).reg();
603
604 Label* deopt = CanDeoptimize() ?
605 compiler->AddDeoptStub(deopt_id(), kDeoptTestCids) : NULL;
606
607 const intptr_t true_result = (kind() == Token::kIS) ? 1 : 0;
608 const ZoneGrowableArray<intptr_t>& data = cid_results();
609 ASSERT(data[0] == kSmiCid);
610 bool result = data[1] == true_result;
611 __ testl(val_reg, Immediate(kSmiTagMask));
612 __ j(ZERO, result ? labels.true_label : labels.false_label);
613 __ LoadClassId(cid_reg, val_reg);
614 for (intptr_t i = 2; i < data.length(); i += 2) {
615 const intptr_t test_cid = data[i];
616 ASSERT(test_cid != kSmiCid);
617 result = data[i + 1] == true_result;
618 __ cmpl(cid_reg, Immediate(test_cid));
619 __ j(EQUAL, result ? labels.true_label : labels.false_label);
620 }
621 // No match found, deoptimize or false.
622 if (deopt == NULL) {
623 Label* target = result ? labels.false_label : labels.true_label;
624 if (target != labels.fall_through) {
625 __ jmp(target);
626 }
627 } else {
628 __ jmp(deopt);
629 }
630 // Dummy result as the last instruction is a jump, any conditional
631 // branch using the result will therefore be skipped.
632 return ZERO;
633 }
634
635
636 void TestCidsInstr::EmitBranchCode(FlowGraphCompiler* compiler,
637 BranchInstr* branch) {
638 BranchLabels labels = compiler->CreateBranchLabels(branch);
639 EmitComparisonCode(compiler, labels);
640 }
641
642
643 void TestCidsInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
644 Register result_reg = locs()->out(0).reg();
645 Label is_true, is_false, done;
646 BranchLabels labels = { &is_true, &is_false, &is_false };
647 EmitComparisonCode(compiler, labels);
648 __ Bind(&is_false);
649 __ LoadObject(result_reg, Bool::False());
650 __ jmp(&done, Assembler::kNearJump);
651 __ Bind(&is_true);
652 __ LoadObject(result_reg, Bool::True());
653 __ Bind(&done);
654 }
655
656
585 LocationSummary* RelationalOpInstr::MakeLocationSummary(bool opt) const { 657 LocationSummary* RelationalOpInstr::MakeLocationSummary(bool opt) const {
586 const intptr_t kNumInputs = 2; 658 const intptr_t kNumInputs = 2;
587 const intptr_t kNumTemps = 0; 659 const intptr_t kNumTemps = 0;
588 if (operation_cid() == kMintCid) { 660 if (operation_cid() == kMintCid) {
589 const intptr_t kNumTemps = 2; 661 const intptr_t kNumTemps = 2;
590 LocationSummary* locs = 662 LocationSummary* locs =
591 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); 663 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
592 locs->set_in(0, Location::RequiresFpuRegister()); 664 locs->set_in(0, Location::RequiresFpuRegister());
593 locs->set_in(1, Location::RequiresFpuRegister()); 665 locs->set_in(1, Location::RequiresFpuRegister());
594 locs->set_temp(0, Location::RequiresRegister()); 666 locs->set_temp(0, Location::RequiresRegister());
(...skipping 5314 matching lines...) Expand 10 before | Expand all | Expand 10 after
5909 PcDescriptors::kOther, 5981 PcDescriptors::kOther,
5910 locs()); 5982 locs());
5911 __ Drop(ArgumentCount()); // Discard arguments. 5983 __ Drop(ArgumentCount()); // Discard arguments.
5912 } 5984 }
5913 5985
5914 } // namespace dart 5986 } // namespace dart
5915 5987
5916 #undef __ 5988 #undef __
5917 5989
5918 #endif // defined TARGET_ARCH_IA32 5990 #endif // defined TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698