OLD | NEW |
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 703 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
714 return false; | 714 return false; |
715 } | 715 } |
716 const int64_t index = Smi::Cast(constant->value()).AsInt64Value(); | 716 const int64_t index = Smi::Cast(constant->value()).AsInt64Value(); |
717 const intptr_t scale = FlowGraphCompiler::ElementSizeFor(cid); | 717 const intptr_t scale = FlowGraphCompiler::ElementSizeFor(cid); |
718 const intptr_t offset = FlowGraphCompiler::DataOffsetFor(cid); | 718 const intptr_t offset = FlowGraphCompiler::DataOffsetFor(cid); |
719 const int64_t displacement = index * scale + offset; | 719 const int64_t displacement = index * scale + offset; |
720 return Utils::IsInt(32, displacement); | 720 return Utils::IsInt(32, displacement); |
721 } | 721 } |
722 | 722 |
723 | 723 |
724 LocationSummary* StringFromCharCodeInstr::MakeLocationSummary(bool opt) const { | 724 LocationSummary* StringCharCodeInstr::MakeLocationSummary(bool opt) const { |
725 const intptr_t kNumInputs = 1; | 725 const intptr_t kNumInputs = 1; |
726 // TODO(fschneider): Allow immediate operands for the char code. | 726 // TODO(fschneider): Allow immediate operands for the char code. |
727 return LocationSummary::Make(kNumInputs, | 727 return LocationSummary::Make(kNumInputs, |
728 Location::RequiresRegister(), | 728 Location::RequiresRegister(), |
729 LocationSummary::kNoCall); | 729 LocationSummary::kNoCall); |
730 } | 730 } |
731 | 731 |
732 | 732 |
733 void StringFromCharCodeInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 733 void StringCharCodeInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
734 Register char_code = locs()->in(0).reg(); | 734 if (kind() == StringCharCodeInstr::kFromCharCode) { |
735 Register result = locs()->out().reg(); | 735 Register char_code = locs()->in(0).reg(); |
736 __ movl(result, | 736 Register result = locs()->out().reg(); |
737 Immediate(reinterpret_cast<uword>(Symbols::PredefinedAddress()))); | 737 __ movl(result, |
738 __ movl(result, Address(result, | 738 Immediate(reinterpret_cast<uword>(Symbols::PredefinedAddress()))); |
739 char_code, | 739 __ movl(result, Address(result, |
740 TIMES_HALF_WORD_SIZE, // Char code is a smi. | 740 char_code, |
741 Symbols::kNullCharCodeSymbolOffset * kWordSize)); | 741 TIMES_HALF_WORD_SIZE, // Char code is a smi. |
| 742 Symbols::kNullCharCodeSymbolOffset * kWordSize)); |
| 743 } else { |
| 744 ASSERT(kind() == StringCharCodeInstr::kToCharCode); |
| 745 ASSERT(cid_ == kOneByteStringCid); |
| 746 Register str = locs()->in(0).reg(); |
| 747 Register result = locs()->out().reg(); |
| 748 Label is_one, done; |
| 749 __ movl(result, FieldAddress(str, String::length_offset())); |
| 750 __ cmpl(result, Immediate(Smi::RawValue(1))); |
| 751 __ j(EQUAL, &is_one, Assembler::kNearJump); |
| 752 __ movl(result, Immediate(Smi::RawValue(-1))); |
| 753 __ jmp(&done); |
| 754 __ Bind(&is_one); |
| 755 __ movzxb(result, FieldAddress(str, OneByteString::data_offset())); |
| 756 __ SmiTag(result); |
| 757 __ Bind(&done); |
| 758 } |
742 } | 759 } |
743 | 760 |
744 | 761 |
745 LocationSummary* StringInterpolateInstr::MakeLocationSummary(bool opt) const { | 762 LocationSummary* StringInterpolateInstr::MakeLocationSummary(bool opt) const { |
746 const intptr_t kNumInputs = 1; | 763 const intptr_t kNumInputs = 1; |
747 const intptr_t kNumTemps = 0; | 764 const intptr_t kNumTemps = 0; |
748 LocationSummary* summary = | 765 LocationSummary* summary = |
749 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kCall); | 766 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kCall); |
750 summary->set_in(0, Location::RegisterLocation(EAX)); | 767 summary->set_in(0, Location::RegisterLocation(EAX)); |
751 summary->set_out(Location::RegisterLocation(EAX)); | 768 summary->set_out(Location::RegisterLocation(EAX)); |
(...skipping 4450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5202 PcDescriptors::kOther, | 5219 PcDescriptors::kOther, |
5203 locs()); | 5220 locs()); |
5204 __ Drop(2); // Discard type arguments and receiver. | 5221 __ Drop(2); // Discard type arguments and receiver. |
5205 } | 5222 } |
5206 | 5223 |
5207 } // namespace dart | 5224 } // namespace dart |
5208 | 5225 |
5209 #undef __ | 5226 #undef __ |
5210 | 5227 |
5211 #endif // defined TARGET_ARCH_IA32 | 5228 #endif // defined TARGET_ARCH_IA32 |
OLD | NEW |