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

Unified Diff: runtime/vm/intermediate_language_arm.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
Index: runtime/vm/intermediate_language_arm.cc
===================================================================
--- runtime/vm/intermediate_language_arm.cc (revision 31282)
+++ runtime/vm/intermediate_language_arm.cc (working copy)
@@ -720,7 +720,7 @@
}
-LocationSummary* StringFromCharCodeInstr::MakeLocationSummary(bool opt) const {
+LocationSummary* StringCharCodeInstr::MakeLocationSummary(bool opt) const {
const intptr_t kNumInputs = 1;
// TODO(fschneider): Allow immediate operands for the char code.
return LocationSummary::Make(kNumInputs,
@@ -729,13 +729,25 @@
}
-void StringFromCharCodeInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
- Register char_code = locs()->in(0).reg();
- Register result = locs()->out().reg();
- __ LoadImmediate(result,
- reinterpret_cast<uword>(Symbols::PredefinedAddress()));
- __ AddImmediate(result, Symbols::kNullCharCodeSymbolOffset * kWordSize);
- __ ldr(result, Address(result, char_code, LSL, 1)); // Char code is a smi.
+void StringCharCodeInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
+ if (kind() == StringCharCodeInstr::kFromCharCode) {
+ Register char_code = locs()->in(0).reg();
+ Register result = locs()->out().reg();
+ __ LoadImmediate(result,
+ reinterpret_cast<uword>(Symbols::PredefinedAddress()));
+ __ AddImmediate(result, Symbols::kNullCharCodeSymbolOffset * kWordSize);
+ __ ldr(result, Address(result, char_code, LSL, 1)); // Char code is a smi.
+ } else {
+ ASSERT(kind() == StringCharCodeInstr::kToCharCode);
+ ASSERT(cid_ == kOneByteStringCid);
+ Register str = locs()->in(0).reg();
+ Register result = locs()->out().reg();
+ __ ldr(result, FieldAddress(str, String::length_offset()));
+ __ cmp(result, ShifterOperand(Smi::RawValue(1)));
+ __ LoadImmediate(result, Smi::RawValue(-1), NE);
+ __ ldrb(result, FieldAddress(str, OneByteString::data_offset()), EQ);
+ __ SmiTag(result);
+ }
}

Powered by Google App Engine
This is Rietveld 408576698