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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/intermediate_language_mips.cc ('k') | tests/language/string_charcode_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/intermediate_language_x64.cc
===================================================================
--- runtime/vm/intermediate_language_x64.cc (revision 31338)
+++ runtime/vm/intermediate_language_x64.cc (working copy)
@@ -665,7 +665,7 @@
Register char_code = locs()->in(0).reg();
Register result = locs()->out().reg();
__ LoadImmediate(result,
- Immediate(reinterpret_cast<uword>(Symbols::PredefinedAddress())), PP);
+ Immediate(reinterpret_cast<uword>(Symbols::PredefinedAddress())), PP);
__ movq(result, Address(result,
char_code,
TIMES_HALF_WORD_SIZE, // Char code is a smi.
@@ -673,6 +673,31 @@
}
+LocationSummary* StringToCharCodeInstr::MakeLocationSummary(bool opt) const {
+ const intptr_t kNumInputs = 1;
+ return LocationSummary::Make(kNumInputs,
+ Location::RequiresRegister(),
+ LocationSummary::kNoCall);
+}
+
+
+void StringToCharCodeInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
+ ASSERT(cid_ == kOneByteStringCid);
+ Register str = locs()->in(0).reg();
+ Register result = locs()->out().reg();
+ Label is_one, done;
+ __ movq(result, FieldAddress(str, String::length_offset()));
+ __ cmpq(result, Immediate(Smi::RawValue(1)));
+ __ j(EQUAL, &is_one, Assembler::kNearJump);
+ __ movq(result, Immediate(Smi::RawValue(-1)));
+ __ jmp(&done);
+ __ Bind(&is_one);
+ __ movzxb(result, FieldAddress(str, OneByteString::data_offset()));
+ __ SmiTag(result);
+ __ Bind(&done);
+}
+
+
LocationSummary* StringInterpolateInstr::MakeLocationSummary(bool opt) const {
const intptr_t kNumInputs = 1;
const intptr_t kNumTemps = 0;
« 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