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

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

Issue 105143011: Optimize one byte string comparisons. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years 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_mips.cc ('k') | tests/language/string_charcode_test.dart » ('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_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 "vm/dart_entry.h" 10 #include "vm/dart_entry.h"
(...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after
658 return LocationSummary::Make(kNumInputs, 658 return LocationSummary::Make(kNumInputs,
659 Location::RequiresRegister(), 659 Location::RequiresRegister(),
660 LocationSummary::kNoCall); 660 LocationSummary::kNoCall);
661 } 661 }
662 662
663 663
664 void StringFromCharCodeInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 664 void StringFromCharCodeInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
665 Register char_code = locs()->in(0).reg(); 665 Register char_code = locs()->in(0).reg();
666 Register result = locs()->out().reg(); 666 Register result = locs()->out().reg();
667 __ LoadImmediate(result, 667 __ LoadImmediate(result,
668 Immediate(reinterpret_cast<uword>(Symbols::PredefinedAddress())), PP); 668 Immediate(reinterpret_cast<uword>(Symbols::PredefinedAddress())), PP);
669 __ movq(result, Address(result, 669 __ movq(result, Address(result,
670 char_code, 670 char_code,
671 TIMES_HALF_WORD_SIZE, // Char code is a smi. 671 TIMES_HALF_WORD_SIZE, // Char code is a smi.
672 Symbols::kNullCharCodeSymbolOffset * kWordSize)); 672 Symbols::kNullCharCodeSymbolOffset * kWordSize));
673 } 673 }
674 674
675 675
676 LocationSummary* StringToCharCodeInstr::MakeLocationSummary(bool opt) const {
677 const intptr_t kNumInputs = 1;
678 return LocationSummary::Make(kNumInputs,
679 Location::RequiresRegister(),
680 LocationSummary::kNoCall);
681 }
682
683
684 void StringToCharCodeInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
685 ASSERT(cid_ == kOneByteStringCid);
686 Register str = locs()->in(0).reg();
687 Register result = locs()->out().reg();
688 Label is_one, done;
689 __ movq(result, FieldAddress(str, String::length_offset()));
690 __ cmpq(result, Immediate(Smi::RawValue(1)));
691 __ j(EQUAL, &is_one, Assembler::kNearJump);
692 __ movq(result, Immediate(Smi::RawValue(-1)));
693 __ jmp(&done);
694 __ Bind(&is_one);
695 __ movzxb(result, FieldAddress(str, OneByteString::data_offset()));
696 __ SmiTag(result);
697 __ Bind(&done);
698 }
699
700
676 LocationSummary* StringInterpolateInstr::MakeLocationSummary(bool opt) const { 701 LocationSummary* StringInterpolateInstr::MakeLocationSummary(bool opt) const {
677 const intptr_t kNumInputs = 1; 702 const intptr_t kNumInputs = 1;
678 const intptr_t kNumTemps = 0; 703 const intptr_t kNumTemps = 0;
679 LocationSummary* summary = 704 LocationSummary* summary =
680 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kCall); 705 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kCall);
681 summary->set_in(0, Location::RegisterLocation(RAX)); 706 summary->set_in(0, Location::RegisterLocation(RAX));
682 summary->set_out(Location::RegisterLocation(RAX)); 707 summary->set_out(Location::RegisterLocation(RAX));
683 return summary; 708 return summary;
684 } 709 }
685 710
(...skipping 4253 matching lines...) Expand 10 before | Expand all | Expand 10 after
4939 PcDescriptors::kOther, 4964 PcDescriptors::kOther,
4940 locs()); 4965 locs());
4941 __ Drop(2); // Discard type arguments and receiver. 4966 __ Drop(2); // Discard type arguments and receiver.
4942 } 4967 }
4943 4968
4944 } // namespace dart 4969 } // namespace dart
4945 4970
4946 #undef __ 4971 #undef __
4947 4972
4948 #endif // defined TARGET_ARCH_X64 4973 #endif // defined TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language_mips.cc ('k') | tests/language/string_charcode_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698