| Index: runtime/vm/intermediate_language_ia32.cc
|
| ===================================================================
|
| --- runtime/vm/intermediate_language_ia32.cc (revision 31282)
|
| +++ runtime/vm/intermediate_language_ia32.cc (working copy)
|
| @@ -721,7 +721,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,
|
| @@ -730,15 +730,32 @@
|
| }
|
|
|
|
|
| -void StringFromCharCodeInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
|
| - Register char_code = locs()->in(0).reg();
|
| - Register result = locs()->out().reg();
|
| - __ movl(result,
|
| - Immediate(reinterpret_cast<uword>(Symbols::PredefinedAddress())));
|
| - __ movl(result, Address(result,
|
| - char_code,
|
| - TIMES_HALF_WORD_SIZE, // Char code is a smi.
|
| - Symbols::kNullCharCodeSymbolOffset * kWordSize));
|
| +void StringCharCodeInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
|
| + if (kind() == StringCharCodeInstr::kFromCharCode) {
|
| + Register char_code = locs()->in(0).reg();
|
| + Register result = locs()->out().reg();
|
| + __ movl(result,
|
| + Immediate(reinterpret_cast<uword>(Symbols::PredefinedAddress())));
|
| + __ movl(result, Address(result,
|
| + char_code,
|
| + TIMES_HALF_WORD_SIZE, // Char code is a smi.
|
| + Symbols::kNullCharCodeSymbolOffset * kWordSize));
|
| + } else {
|
| + ASSERT(kind() == StringCharCodeInstr::kToCharCode);
|
| + ASSERT(cid_ == kOneByteStringCid);
|
| + Register str = locs()->in(0).reg();
|
| + Register result = locs()->out().reg();
|
| + Label is_one, done;
|
| + __ movl(result, FieldAddress(str, String::length_offset()));
|
| + __ cmpl(result, Immediate(Smi::RawValue(1)));
|
| + __ j(EQUAL, &is_one, Assembler::kNearJump);
|
| + __ movl(result, Immediate(Smi::RawValue(-1)));
|
| + __ jmp(&done);
|
| + __ Bind(&is_one);
|
| + __ movzxb(result, FieldAddress(str, OneByteString::data_offset()));
|
| + __ SmiTag(result);
|
| + __ Bind(&done);
|
| + }
|
| }
|
|
|
|
|
|
|