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

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

Issue 62203018: Remove dead code from IfThenElse and StrictCompare in the compiler. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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
« no previous file with comments | « runtime/vm/intermediate_language_arm.cc ('k') | runtime/vm/intermediate_language_mips.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 4674 matching lines...) Expand 10 before | Expand all | Expand 10 after
4685 (Utils::IsPowerOfTwo(v2) && (v1 == 0)); 4685 (Utils::IsPowerOfTwo(v2) && (v1 == 0));
4686 } 4686 }
4687 4687
4688 4688
4689 LocationSummary* IfThenElseInstr::MakeLocationSummary() const { 4689 LocationSummary* IfThenElseInstr::MakeLocationSummary() const {
4690 const intptr_t kNumInputs = 2; 4690 const intptr_t kNumInputs = 2;
4691 const intptr_t kNumTemps = 0; 4691 const intptr_t kNumTemps = 0;
4692 LocationSummary* locs = 4692 LocationSummary* locs =
4693 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall); 4693 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
4694 locs->set_in(0, Location::RegisterOrConstant(left())); 4694 locs->set_in(0, Location::RegisterOrConstant(left()));
4695 locs->set_in(1, Location::RegisterOrConstant(right())); 4695 // Only one of the inputs can be a constant. Choose register if the first one
4696 // is a constant.
4697 locs->set_in(1, locs->in(0).IsConstant()
4698 ? Location::RequiresRegister()
4699 : Location::RegisterOrConstant(right()));
4696 // TODO(vegorov): support byte register constraints in the register allocator. 4700 // TODO(vegorov): support byte register constraints in the register allocator.
4697 locs->set_out(Location::RegisterLocation(EDX)); 4701 locs->set_out(Location::RegisterLocation(EDX));
4698 return locs; 4702 return locs;
4699 } 4703 }
4700 4704
4701 4705
4702 void IfThenElseInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 4706 void IfThenElseInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
4703 ASSERT(locs()->out().reg() == EDX); 4707 ASSERT(locs()->out().reg() == EDX);
4704 ASSERT(Token::IsEqualityOperator(kind())); 4708 ASSERT(Token::IsEqualityOperator(kind()));
4705 4709
4706 Location left = locs()->in(0); 4710 Location left = locs()->in(0);
4707 Location right = locs()->in(1); 4711 Location right = locs()->in(1);
4708 if (left.IsConstant() && right.IsConstant()) {
4709 // TODO(srdjan): Determine why this instruction was not eliminated.
4710 bool result = (left.constant().raw() == right.constant().raw());
4711 if ((kind_ == Token::kNE_STRICT) || (kind_ == Token::kNE)) {
4712 result = !result;
4713 }
4714 __ movl(locs()->out().reg(),
4715 Immediate(reinterpret_cast<int32_t>(
4716 Smi::New(result ? if_true_ : if_false_))));
4717 return;
4718 }
4719
4720 ASSERT(!left.IsConstant() || !right.IsConstant()); 4712 ASSERT(!left.IsConstant() || !right.IsConstant());
4721 4713
4722 // Clear upper part of the out register. We are going to use setcc on it 4714 // Clear upper part of the out register. We are going to use setcc on it
4723 // which is a byte move. 4715 // which is a byte move.
4724 __ xorl(EDX, EDX); 4716 __ xorl(EDX, EDX);
4725 4717
4726 // Compare left and right. For now only equality comparison is supported. 4718 // Compare left and right. For now only equality comparison is supported.
4727 // TODO(vegorov): reuse code from the other comparison instructions instead of 4719 // TODO(vegorov): reuse code from the other comparison instructions instead of
4728 // generating it inline here. 4720 // generating it inline here.
4729 if (left.IsConstant()) { 4721 if (left.IsConstant()) {
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
4884 PcDescriptors::kOther, 4876 PcDescriptors::kOther,
4885 locs()); 4877 locs());
4886 __ Drop(2); // Discard type arguments and receiver. 4878 __ Drop(2); // Discard type arguments and receiver.
4887 } 4879 }
4888 4880
4889 } // namespace dart 4881 } // namespace dart
4890 4882
4891 #undef __ 4883 #undef __
4892 4884
4893 #endif // defined TARGET_ARCH_IA32 4885 #endif // defined TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language_arm.cc ('k') | runtime/vm/intermediate_language_mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698