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_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 634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
645 const Object& constant = index->definition()->AsConstant()->value(); | 645 const Object& constant = index->definition()->AsConstant()->value(); |
646 if (!constant.IsSmi()) return false; | 646 if (!constant.IsSmi()) return false; |
647 const Smi& smi_const = Smi::Cast(constant); | 647 const Smi& smi_const = Smi::Cast(constant); |
648 const intptr_t scale = FlowGraphCompiler::ElementSizeFor(cid); | 648 const intptr_t scale = FlowGraphCompiler::ElementSizeFor(cid); |
649 const intptr_t data_offset = FlowGraphCompiler::DataOffsetFor(cid); | 649 const intptr_t data_offset = FlowGraphCompiler::DataOffsetFor(cid); |
650 const int64_t disp = smi_const.AsInt64Value() * scale + data_offset; | 650 const int64_t disp = smi_const.AsInt64Value() * scale + data_offset; |
651 return Utils::IsInt(32, disp); | 651 return Utils::IsInt(32, disp); |
652 } | 652 } |
653 | 653 |
654 | 654 |
655 LocationSummary* StringFromCharCodeInstr::MakeLocationSummary(bool opt) const { | 655 LocationSummary* StringCharCodeInstr::MakeLocationSummary(bool opt) const { |
656 const intptr_t kNumInputs = 1; | 656 const intptr_t kNumInputs = 1; |
657 // TODO(fschneider): Allow immediate operands for the char code. | 657 // TODO(fschneider): Allow immediate operands for the char code. |
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 StringCharCodeInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
665 Register char_code = locs()->in(0).reg(); | 665 if (kind() == StringCharCodeInstr::kFromCharCode) { |
666 Register result = locs()->out().reg(); | 666 ASSERT(kind() == StringCharCodeInstr::kFromCharCode); |
667 __ LoadImmediate(result, | 667 Register char_code = locs()->in(0).reg(); |
668 Immediate(reinterpret_cast<uword>(Symbols::PredefinedAddress())), PP); | 668 Register result = locs()->out().reg(); |
669 __ movq(result, Address(result, | 669 __ LoadImmediate(result, |
670 char_code, | 670 Immediate(reinterpret_cast<uword>(Symbols::PredefinedAddress())), PP); |
671 TIMES_HALF_WORD_SIZE, // Char code is a smi. | 671 __ movq(result, Address(result, |
672 Symbols::kNullCharCodeSymbolOffset * kWordSize)); | 672 char_code, |
| 673 TIMES_HALF_WORD_SIZE, // Char code is a smi. |
| 674 Symbols::kNullCharCodeSymbolOffset * kWordSize)); |
| 675 } else { |
| 676 ASSERT(kind() == StringCharCodeInstr::kToCharCode); |
| 677 ASSERT(cid_ == kOneByteStringCid); |
| 678 Register str = locs()->in(0).reg(); |
| 679 Register result = locs()->out().reg(); |
| 680 Label is_one, done; |
| 681 __ movq(result, FieldAddress(str, String::length_offset())); |
| 682 __ cmpq(result, Immediate(Smi::RawValue(1))); |
| 683 __ j(EQUAL, &is_one, Assembler::kNearJump); |
| 684 __ movq(result, Immediate(Smi::RawValue(-1))); |
| 685 __ jmp(&done); |
| 686 __ Bind(&is_one); |
| 687 __ movzxb(result, FieldAddress(str, OneByteString::data_offset())); |
| 688 __ SmiTag(result); |
| 689 __ Bind(&done); |
| 690 } |
673 } | 691 } |
674 | 692 |
675 | 693 |
676 LocationSummary* StringInterpolateInstr::MakeLocationSummary(bool opt) const { | 694 LocationSummary* StringInterpolateInstr::MakeLocationSummary(bool opt) const { |
677 const intptr_t kNumInputs = 1; | 695 const intptr_t kNumInputs = 1; |
678 const intptr_t kNumTemps = 0; | 696 const intptr_t kNumTemps = 0; |
679 LocationSummary* summary = | 697 LocationSummary* summary = |
680 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kCall); | 698 new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kCall); |
681 summary->set_in(0, Location::RegisterLocation(RAX)); | 699 summary->set_in(0, Location::RegisterLocation(RAX)); |
682 summary->set_out(Location::RegisterLocation(RAX)); | 700 summary->set_out(Location::RegisterLocation(RAX)); |
(...skipping 4256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4939 PcDescriptors::kOther, | 4957 PcDescriptors::kOther, |
4940 locs()); | 4958 locs()); |
4941 __ Drop(2); // Discard type arguments and receiver. | 4959 __ Drop(2); // Discard type arguments and receiver. |
4942 } | 4960 } |
4943 | 4961 |
4944 } // namespace dart | 4962 } // namespace dart |
4945 | 4963 |
4946 #undef __ | 4964 #undef __ |
4947 | 4965 |
4948 #endif // defined TARGET_ARCH_X64 | 4966 #endif // defined TARGET_ARCH_X64 |
OLD | NEW |