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_ARM. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_ARM. |
6 #if defined(TARGET_ARCH_ARM) | 6 #if defined(TARGET_ARCH_ARM) |
7 | 7 |
8 #include "vm/intermediate_language.h" | 8 #include "vm/intermediate_language.h" |
9 | 9 |
10 #include "vm/cpu.h" | 10 #include "vm/cpu.h" |
(...skipping 1845 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1856 } | 1856 } |
1857 } | 1857 } |
1858 | 1858 |
1859 private: | 1859 private: |
1860 Instruction* instruction_; | 1860 Instruction* instruction_; |
1861 const Class& cls_; | 1861 const Class& cls_; |
1862 const Register result_; | 1862 const Register result_; |
1863 }; | 1863 }; |
1864 | 1864 |
1865 | 1865 |
1866 | |
1867 | |
1868 LocationSummary* LoadCodeUnitsInstr::MakeLocationSummary(Isolate* isolate, | |
1869 bool opt) const { | |
1870 const bool might_box = (representation() == kTagged) && !can_pack_into_smi(); | |
1871 const intptr_t kNumInputs = 2; | |
1872 const intptr_t kNumTemps = might_box ? 1 : 0; | |
1873 LocationSummary* summary = new(isolate) LocationSummary( | |
1874 isolate, kNumInputs, kNumTemps, | |
1875 might_box ? LocationSummary::kCallOnSlowPath : LocationSummary::kNoCall); | |
1876 summary->set_in(0, Location::RequiresRegister()); | |
1877 summary->set_in(1, Location::RequiresRegister()); | |
1878 | |
1879 if (might_box) { | |
1880 summary->set_temp(0, Location::RequiresRegister()); | |
1881 } | |
1882 | |
1883 if (representation() == kUnboxedMint) { | |
1884 summary->set_out(0, Location::Pair(Location::RequiresRegister(), | |
1885 Location::RequiresRegister())); | |
1886 } else { | |
1887 ASSERT(representation() == kTagged); | |
1888 summary->set_out(0, Location::RequiresRegister()); | |
1889 } | |
1890 | |
1891 return summary; | |
1892 } | |
1893 | |
1894 | |
1895 void LoadCodeUnitsInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | |
1896 const Register array = locs()->in(0).reg(); | |
1897 const Location index = locs()->in(1); | |
1898 | |
1899 Address element_address = __ ElementAddressForRegIndex( | |
1900 true, IsExternal(), class_id(), index_scale(), array, index.reg()); | |
1901 // Warning: element_address may use register IP as base. | |
1902 | |
1903 if (representation() == kUnboxedMint) { | |
1904 ASSERT(compiler->is_optimizing()); | |
1905 ASSERT(locs()->out(0).IsPairLocation()); | |
1906 PairLocation* result_pair = locs()->out(0).AsPairLocation(); | |
1907 Register result1 = result_pair->At(0).reg(); | |
1908 Register result2 = result_pair->At(1).reg(); | |
1909 switch (class_id()) { | |
1910 case kOneByteStringCid: | |
1911 case kExternalOneByteStringCid: | |
1912 ASSERT(element_count() == 4); | |
1913 __ ldr(result1, element_address); | |
1914 __ eor(result2, result2, Operand(result2)); | |
1915 break; | |
1916 case kTwoByteStringCid: | |
1917 case kExternalTwoByteStringCid: | |
1918 ASSERT(element_count() == 2); | |
1919 __ ldr(result1, element_address); | |
1920 __ eor(result2, result2, Operand(result2)); | |
1921 break; | |
1922 default: | |
1923 UNREACHABLE(); | |
1924 } | |
1925 } else { | |
1926 ASSERT(representation() == kTagged); | |
1927 Register result = locs()->out(0).reg(); | |
1928 switch (class_id()) { | |
1929 case kOneByteStringCid: | |
1930 case kExternalOneByteStringCid: | |
1931 switch (element_count()) { | |
1932 case 1: __ ldrb(result, element_address); break; | |
1933 case 2: __ ldrh(result, element_address); break; | |
1934 case 4: __ ldr(result, element_address); break; | |
1935 default: UNREACHABLE(); | |
1936 } | |
1937 break; | |
1938 case kTwoByteStringCid: | |
1939 case kExternalTwoByteStringCid: | |
1940 switch (element_count()) { | |
1941 case 1: __ ldrh(result, element_address); break; | |
1942 case 2: __ ldr(result, element_address); break; | |
1943 default: UNREACHABLE(); | |
1944 } | |
1945 break; | |
1946 default: | |
1947 UNREACHABLE(); | |
1948 break; | |
1949 } | |
1950 if (can_pack_into_smi()) { | |
1951 __ SmiTag(result); | |
1952 } else { | |
1953 // If the value cannot fit in a smi then allocate a mint box for it. | |
1954 Register value = locs()->temp(0).reg(); | |
1955 Register temp = locs()->temp(1).reg(); | |
1956 ASSERT(result != value); | |
1957 __ MoveRegister(value, result); | |
1958 __ SmiTag(result); | |
1959 | |
1960 Label done; | |
1961 __ TestImmediate(value, 0xC0000000); | |
1962 __ b(&done, EQ); | |
1963 BoxAllocationSlowPath::Allocate( | |
1964 compiler, this, compiler->mint_class(), result, temp); | |
1965 __ eor(temp, temp, Operand(temp)); | |
1966 __ StoreToOffset(kWord, value, result, | |
1967 Mint::value_offset() - kHeapObjectTag); | |
1968 __ StoreToOffset(kWord, temp, result, | |
1969 Mint::value_offset() - kHeapObjectTag + kWordSize); | |
1970 __ Bind(&done); | |
1971 } | |
1972 } | |
1973 } | |
1974 | |
1975 | |
1976 LocationSummary* StoreInstanceFieldInstr::MakeLocationSummary(Isolate* isolate, | 1866 LocationSummary* StoreInstanceFieldInstr::MakeLocationSummary(Isolate* isolate, |
1977 bool opt) const { | 1867 bool opt) const { |
1978 const intptr_t kNumInputs = 2; | 1868 const intptr_t kNumInputs = 2; |
1979 const intptr_t kNumTemps = | 1869 const intptr_t kNumTemps = |
1980 (IsUnboxedStore() && opt) ? 2 : | 1870 (IsUnboxedStore() && opt) ? 2 : |
1981 ((IsPotentialUnboxedStore()) ? 3 : 0); | 1871 ((IsPotentialUnboxedStore()) ? 3 : 0); |
1982 LocationSummary* summary = new(isolate) LocationSummary( | 1872 LocationSummary* summary = new(isolate) LocationSummary( |
1983 isolate, kNumInputs, kNumTemps, | 1873 isolate, kNumInputs, kNumTemps, |
1984 ((IsUnboxedStore() && opt && is_initialization_) || | 1874 ((IsUnboxedStore() && opt && is_initialization_) || |
1985 IsPotentialUnboxedStore()) | 1875 IsPotentialUnboxedStore()) |
(...skipping 3243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5229 __ vmovrrd(R0, R1, D0); | 5119 __ vmovrrd(R0, R1, D0); |
5230 __ vmovrrd(R2, R3, D1); | 5120 __ vmovrrd(R2, R3, D1); |
5231 __ CallRuntime(TargetFunction(), InputCount()); | 5121 __ CallRuntime(TargetFunction(), InputCount()); |
5232 __ vmovdrr(D0, R0, R1); | 5122 __ vmovdrr(D0, R0, R1); |
5233 __ vmovdrr(D1, R2, R3); | 5123 __ vmovdrr(D1, R2, R3); |
5234 } | 5124 } |
5235 } | 5125 } |
5236 } | 5126 } |
5237 | 5127 |
5238 | 5128 |
5239 LocationSummary* CaseInsensitiveCompareUC16Instr::MakeLocationSummary( | |
5240 Isolate* isolate, bool opt) const { | |
5241 const intptr_t kNumTemps = 0; | |
5242 LocationSummary* summary = new(isolate) LocationSummary( | |
5243 isolate, InputCount(), kNumTemps, LocationSummary::kCall); | |
5244 summary->set_in(0, Location::RegisterLocation(R0)); | |
5245 summary->set_in(1, Location::RegisterLocation(R1)); | |
5246 summary->set_in(2, Location::RegisterLocation(R2)); | |
5247 summary->set_in(3, Location::RegisterLocation(R3)); | |
5248 summary->set_out(0, Location::RegisterLocation(R0)); | |
5249 return summary; | |
5250 } | |
5251 | |
5252 | |
5253 void CaseInsensitiveCompareUC16Instr::EmitNativeCode( | |
5254 FlowGraphCompiler* compiler) { | |
5255 | |
5256 // Call the function. | |
5257 __ CallRuntime(TargetFunction(), TargetFunction().argument_count()); | |
5258 } | |
5259 | |
5260 | |
5261 LocationSummary* MathMinMaxInstr::MakeLocationSummary(Isolate* isolate, | 5129 LocationSummary* MathMinMaxInstr::MakeLocationSummary(Isolate* isolate, |
5262 bool opt) const { | 5130 bool opt) const { |
5263 if (result_cid() == kDoubleCid) { | 5131 if (result_cid() == kDoubleCid) { |
5264 const intptr_t kNumInputs = 2; | 5132 const intptr_t kNumInputs = 2; |
5265 const intptr_t kNumTemps = 1; | 5133 const intptr_t kNumTemps = 1; |
5266 LocationSummary* summary = new(isolate) LocationSummary( | 5134 LocationSummary* summary = new(isolate) LocationSummary( |
5267 isolate, kNumInputs, kNumTemps, LocationSummary::kNoCall); | 5135 isolate, kNumInputs, kNumTemps, LocationSummary::kNoCall); |
5268 summary->set_in(0, Location::RequiresFpuRegister()); | 5136 summary->set_in(0, Location::RequiresFpuRegister()); |
5269 summary->set_in(1, Location::RequiresFpuRegister()); | 5137 summary->set_in(1, Location::RequiresFpuRegister()); |
5270 // Reuse the left register so that code can be made shorter. | 5138 // Reuse the left register so that code can be made shorter. |
(...skipping 1455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6726 } | 6594 } |
6727 | 6595 |
6728 // We can fall through if the successor is the next block in the list. | 6596 // We can fall through if the successor is the next block in the list. |
6729 // Otherwise, we need a jump. | 6597 // Otherwise, we need a jump. |
6730 if (!compiler->CanFallThroughTo(successor())) { | 6598 if (!compiler->CanFallThroughTo(successor())) { |
6731 __ b(compiler->GetJumpLabel(successor())); | 6599 __ b(compiler->GetJumpLabel(successor())); |
6732 } | 6600 } |
6733 } | 6601 } |
6734 | 6602 |
6735 | 6603 |
6736 LocationSummary* IndirectGotoInstr::MakeLocationSummary(Isolate* isolate, | |
6737 bool opt) const { | |
6738 const intptr_t kNumInputs = 1; | |
6739 const intptr_t kNumTemps = 1; | |
6740 | |
6741 LocationSummary* summary = new(isolate) LocationSummary( | |
6742 isolate, kNumInputs, kNumTemps, LocationSummary::kNoCall); | |
6743 | |
6744 summary->set_in(0, Location::RequiresRegister()); | |
6745 summary->set_temp(0, Location::RequiresRegister()); | |
6746 | |
6747 return summary; | |
6748 } | |
6749 | |
6750 | |
6751 void IndirectGotoInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | |
6752 Register target_address_reg = locs()->temp_slot(0)->reg(); | |
6753 | |
6754 // Load from [current frame pointer] + kPcMarkerSlotFromFp. | |
6755 __ ldr(target_address_reg, Address(FP, kPcMarkerSlotFromFp * kWordSize)); | |
6756 | |
6757 // Add the offset. | |
6758 Register offset_reg = locs()->in(0).reg(); | |
6759 __ add(target_address_reg, | |
6760 target_address_reg, | |
6761 Operand(offset_reg, ASR, kSmiTagSize)); | |
6762 | |
6763 // Jump to the absolute address. | |
6764 __ bx(target_address_reg); | |
6765 } | |
6766 | |
6767 | |
6768 LocationSummary* StrictCompareInstr::MakeLocationSummary(Isolate* isolate, | 6604 LocationSummary* StrictCompareInstr::MakeLocationSummary(Isolate* isolate, |
6769 bool opt) const { | 6605 bool opt) const { |
6770 const intptr_t kNumInputs = 2; | 6606 const intptr_t kNumInputs = 2; |
6771 const intptr_t kNumTemps = 0; | 6607 const intptr_t kNumTemps = 0; |
6772 if (needs_number_check()) { | 6608 if (needs_number_check()) { |
6773 LocationSummary* locs = new(isolate) LocationSummary( | 6609 LocationSummary* locs = new(isolate) LocationSummary( |
6774 isolate, kNumInputs, kNumTemps, LocationSummary::kCall); | 6610 isolate, kNumInputs, kNumTemps, LocationSummary::kCall); |
6775 locs->set_in(0, Location::RegisterLocation(R0)); | 6611 locs->set_in(0, Location::RegisterLocation(R0)); |
6776 locs->set_in(1, Location::RegisterLocation(R1)); | 6612 locs->set_in(1, Location::RegisterLocation(R1)); |
6777 locs->set_out(0, Location::RegisterLocation(R0)); | 6613 locs->set_out(0, Location::RegisterLocation(R0)); |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6900 compiler->GenerateCall(token_pos(), &label, stub_kind_, locs()); | 6736 compiler->GenerateCall(token_pos(), &label, stub_kind_, locs()); |
6901 #if defined(DEBUG) | 6737 #if defined(DEBUG) |
6902 __ LoadImmediate(R4, kInvalidObjectPointer); | 6738 __ LoadImmediate(R4, kInvalidObjectPointer); |
6903 __ LoadImmediate(R5, kInvalidObjectPointer); | 6739 __ LoadImmediate(R5, kInvalidObjectPointer); |
6904 #endif | 6740 #endif |
6905 } | 6741 } |
6906 | 6742 |
6907 } // namespace dart | 6743 } // namespace dart |
6908 | 6744 |
6909 #endif // defined TARGET_ARCH_ARM | 6745 #endif // defined TARGET_ARCH_ARM |
OLD | NEW |