Chromium Code Reviews| 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 1310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1321 __ SmiTag(result); | 1321 __ SmiTag(result); |
| 1322 break; | 1322 break; |
| 1323 default: | 1323 default: |
| 1324 ASSERT((class_id() == kArrayCid) || (class_id() == kImmutableArrayCid)); | 1324 ASSERT((class_id() == kArrayCid) || (class_id() == kImmutableArrayCid)); |
| 1325 __ ldr(result, element_address); | 1325 __ ldr(result, element_address); |
| 1326 break; | 1326 break; |
| 1327 } | 1327 } |
| 1328 } | 1328 } |
| 1329 | 1329 |
| 1330 | 1330 |
| 1331 Representation LoadCodeUnitsInstr::representation() const { | |
| 1332 switch (class_id()) { | |
| 1333 case kOneByteStringCid: | |
| 1334 case kExternalOneByteStringCid: | |
| 1335 case kTwoByteStringCid: | |
| 1336 case kExternalTwoByteStringCid: | |
| 1337 // TODO(zerny): kUnboxedUint32 could be a better choice. | |
| 1338 return can_pack_into_smi() ? kTagged : kUnboxedMint; | |
| 1339 default: | |
| 1340 UNIMPLEMENTED(); | |
| 1341 return kTagged; | |
| 1342 } | |
| 1343 } | |
| 1344 | |
| 1345 | |
| 1346 LocationSummary* LoadCodeUnitsInstr::MakeLocationSummary(Isolate* isolate, | |
| 1347 bool opt) const { | |
| 1348 const intptr_t kNumInputs = 2; | |
| 1349 const intptr_t kNumTemps = 0; | |
| 1350 LocationSummary* summary = new(isolate) LocationSummary( | |
| 1351 isolate, kNumInputs, kNumTemps, LocationSummary::kNoCall); | |
| 1352 summary->set_in(0, Location::RequiresRegister()); | |
| 1353 summary->set_in(1, Location::RequiresRegister()); | |
| 1354 | |
| 1355 if (representation() == kUnboxedMint) { | |
| 1356 summary->set_out(0, Location::Pair(Location::RequiresRegister(), | |
| 1357 Location::RequiresRegister())); | |
| 1358 } else { | |
| 1359 ASSERT(representation() == kTagged); | |
| 1360 summary->set_out(0, Location::RequiresRegister()); | |
| 1361 } | |
| 1362 | |
| 1363 return summary; | |
| 1364 } | |
| 1365 | |
| 1366 | |
| 1367 void LoadCodeUnitsInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | |
| 1368 const Register array = locs()->in(0).reg(); | |
| 1369 const Location index = locs()->in(1); | |
| 1370 | |
| 1371 Address element_address = __ ElementAddressForRegIndex( | |
| 1372 true, IsExternal(), class_id(), index_scale(), array, index.reg()); | |
| 1373 // Warning: element_address may use register IP as base. | |
| 1374 | |
| 1375 if (representation() == kUnboxedMint) { | |
| 1376 ASSERT(locs()->out(0).IsPairLocation()); | |
| 1377 PairLocation* result_pair = locs()->out(0).AsPairLocation(); | |
| 1378 Register result1 = result_pair->At(0).reg(); | |
| 1379 Register result2 = result_pair->At(1).reg(); | |
| 1380 switch (class_id()) { | |
| 1381 case kOneByteStringCid: | |
| 1382 case kExternalOneByteStringCid: | |
| 1383 ASSERT(element_count() == 4); | |
| 1384 __ ldr(result1, element_address); | |
| 1385 __ eor(result2, result2, Operand(result2)); | |
| 1386 break; | |
| 1387 case kTwoByteStringCid: | |
| 1388 case kExternalTwoByteStringCid: | |
| 1389 ASSERT(element_count() == 2); | |
| 1390 __ ldr(result1, element_address); | |
| 1391 __ eor(result2, result2, Operand(result2)); | |
| 1392 break; | |
| 1393 default: | |
| 1394 UNREACHABLE(); | |
| 1395 } | |
| 1396 } else { | |
| 1397 ASSERT(representation() == kTagged); | |
| 1398 Register result = locs()->out(0).reg(); | |
| 1399 switch (class_id()) { | |
| 1400 case kOneByteStringCid: | |
| 1401 case kExternalOneByteStringCid: | |
| 1402 switch (element_count()) { | |
| 1403 case 1: __ ldrb(result, element_address); break; | |
| 1404 case 2: __ ldrh(result, element_address); break; | |
| 1405 default: UNREACHABLE(); | |
| 1406 } | |
| 1407 __ SmiTag(result); | |
| 1408 break; | |
| 1409 case kTwoByteStringCid: | |
| 1410 case kExternalTwoByteStringCid: | |
| 1411 ASSERT(element_count() == 1); | |
| 1412 __ ldrh(result, element_address); | |
| 1413 __ SmiTag(result); | |
| 1414 break; | |
| 1415 default: | |
| 1416 UNREACHABLE(); | |
| 1417 break; | |
| 1418 } | |
| 1419 } | |
| 1420 } | |
| 1421 | |
| 1422 | |
| 1423 Representation StoreIndexedInstr::RequiredInputRepresentation( | 1331 Representation StoreIndexedInstr::RequiredInputRepresentation( |
| 1424 intptr_t idx) const { | 1332 intptr_t idx) const { |
| 1425 // Array can be a Dart object or a pointer to external data. | 1333 // Array can be a Dart object or a pointer to external data. |
| 1426 if (idx == 0) return kNoRepresentation; // Flexible input representation. | 1334 if (idx == 0) return kNoRepresentation; // Flexible input representation. |
| 1427 if (idx == 1) return kTagged; // Index is a smi. | 1335 if (idx == 1) return kTagged; // Index is a smi. |
| 1428 ASSERT(idx == 2); | 1336 ASSERT(idx == 2); |
| 1429 switch (class_id_) { | 1337 switch (class_id_) { |
| 1430 case kArrayCid: | 1338 case kArrayCid: |
| 1431 case kOneByteStringCid: | 1339 case kOneByteStringCid: |
| 1432 case kTypedDataInt8ArrayCid: | 1340 case kTypedDataInt8ArrayCid: |
| (...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1948 } | 1856 } |
| 1949 } | 1857 } |
| 1950 | 1858 |
| 1951 private: | 1859 private: |
| 1952 Instruction* instruction_; | 1860 Instruction* instruction_; |
| 1953 const Class& cls_; | 1861 const Class& cls_; |
| 1954 const Register result_; | 1862 const Register result_; |
| 1955 }; | 1863 }; |
| 1956 | 1864 |
| 1957 | 1865 |
| 1866 | |
| 1867 | |
| 1868 LocationSummary* LoadCodeUnitsInstr::MakeLocationSummary(Isolate* isolate, | |
| 1869 bool opt) const { | |
| 1870 const bool kMightBox = (representation() == kTagged) && !can_pack_into_smi(); | |
|
Florian Schneider
2014/11/18 12:20:24
Since this is not a compile-time constant, I'd ren
zerny-google
2014/11/18 12:34:04
Yes. Done here and in _ia32.cc
| |
| 1871 const intptr_t kNumInputs = 2; | |
| 1872 const intptr_t kNumTemps = kMightBox ? 1 : 0; | |
| 1873 LocationSummary* summary = new(isolate) LocationSummary( | |
| 1874 isolate, kNumInputs, kNumTemps, | |
| 1875 kMightBox ? LocationSummary::kCallOnSlowPath : LocationSummary::kNoCall); | |
| 1876 summary->set_in(0, Location::RequiresRegister()); | |
| 1877 summary->set_in(1, Location::RequiresRegister()); | |
| 1878 | |
| 1879 if (kMightBox) { | |
| 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 | |
| 1958 LocationSummary* StoreInstanceFieldInstr::MakeLocationSummary(Isolate* isolate, | 1976 LocationSummary* StoreInstanceFieldInstr::MakeLocationSummary(Isolate* isolate, |
| 1959 bool opt) const { | 1977 bool opt) const { |
| 1960 const intptr_t kNumInputs = 2; | 1978 const intptr_t kNumInputs = 2; |
| 1961 const intptr_t kNumTemps = | 1979 const intptr_t kNumTemps = |
| 1962 (IsUnboxedStore() && opt) ? 2 : | 1980 (IsUnboxedStore() && opt) ? 2 : |
| 1963 ((IsPotentialUnboxedStore()) ? 3 : 0); | 1981 ((IsPotentialUnboxedStore()) ? 3 : 0); |
| 1964 LocationSummary* summary = new(isolate) LocationSummary( | 1982 LocationSummary* summary = new(isolate) LocationSummary( |
| 1965 isolate, kNumInputs, kNumTemps, | 1983 isolate, kNumInputs, kNumTemps, |
| 1966 ((IsUnboxedStore() && opt && is_initialization_) || | 1984 ((IsUnboxedStore() && opt && is_initialization_) || |
| 1967 IsPotentialUnboxedStore()) | 1985 IsPotentialUnboxedStore()) |
| (...skipping 4928 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6896 compiler->GenerateCall(token_pos(), &label, stub_kind_, locs()); | 6914 compiler->GenerateCall(token_pos(), &label, stub_kind_, locs()); |
| 6897 #if defined(DEBUG) | 6915 #if defined(DEBUG) |
| 6898 __ LoadImmediate(R4, kInvalidObjectPointer); | 6916 __ LoadImmediate(R4, kInvalidObjectPointer); |
| 6899 __ LoadImmediate(R5, kInvalidObjectPointer); | 6917 __ LoadImmediate(R5, kInvalidObjectPointer); |
| 6900 #endif | 6918 #endif |
| 6901 } | 6919 } |
| 6902 | 6920 |
| 6903 } // namespace dart | 6921 } // namespace dart |
| 6904 | 6922 |
| 6905 #endif // defined TARGET_ARCH_ARM | 6923 #endif // defined TARGET_ARCH_ARM |
| OLD | NEW |