| 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_MIPS. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_MIPS. |
| 6 #if defined(TARGET_ARCH_MIPS) | 6 #if defined(TARGET_ARCH_MIPS) |
| 7 | 7 |
| 8 #include "vm/intrinsifier.h" | 8 #include "vm/intrinsifier.h" |
| 9 | 9 |
| 10 #include "vm/assembler.h" | 10 #include "vm/assembler.h" |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 __ delay_slot()->addiu(T2, T2, Immediate(kWordSize)); | 127 __ delay_slot()->addiu(T2, T2, Immediate(kWordSize)); |
| 128 __ Bind(&done); | 128 __ Bind(&done); |
| 129 | 129 |
| 130 __ Ret(); // Returns the newly allocated object in V0. | 130 __ Ret(); // Returns the newly allocated object in V0. |
| 131 __ delay_slot()->mov(V0, T0); | 131 __ delay_slot()->mov(V0, T0); |
| 132 __ Bind(&fall_through); | 132 __ Bind(&fall_through); |
| 133 return false; | 133 return false; |
| 134 } | 134 } |
| 135 | 135 |
| 136 | 136 |
| 137 bool Intrinsifier::Array_getLength(Assembler* assembler) { | |
| 138 __ lw(V0, Address(SP, 0 * kWordSize)); | |
| 139 __ Ret(); | |
| 140 __ delay_slot()->lw(V0, FieldAddress(V0, Array::length_offset())); | |
| 141 return true; | |
| 142 } | |
| 143 | |
| 144 | |
| 145 bool Intrinsifier::ImmutableArray_getLength(Assembler* assembler) { | |
| 146 return Array_getLength(assembler); | |
| 147 } | |
| 148 | |
| 149 | |
| 150 bool Intrinsifier::Array_getIndexed(Assembler* assembler) { | 137 bool Intrinsifier::Array_getIndexed(Assembler* assembler) { |
| 151 Label fall_through; | 138 Label fall_through; |
| 152 | 139 |
| 153 __ lw(T0, Address(SP, + 0 * kWordSize)); // Index | 140 __ lw(T0, Address(SP, + 0 * kWordSize)); // Index |
| 154 | 141 |
| 155 __ andi(CMPRES, T0, Immediate(kSmiTagMask)); | 142 __ andi(CMPRES, T0, Immediate(kSmiTagMask)); |
| 156 __ bne(CMPRES, ZR, &fall_through); // Index is not an smi, fall through | 143 __ bne(CMPRES, ZR, &fall_through); // Index is not an smi, fall through |
| 157 __ delay_slot()->lw(T1, Address(SP, + 1 * kWordSize)); // Array | 144 __ delay_slot()->lw(T1, Address(SP, + 1 * kWordSize)); // Array |
| 158 | 145 |
| 159 // range check | 146 // range check |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 // Set the length field in the growable array object to 0. | 302 // Set the length field in the growable array object to 0. |
| 316 __ Ret(); // Returns the newly allocated object in V0. | 303 __ Ret(); // Returns the newly allocated object in V0. |
| 317 __ delay_slot()->sw(ZR, | 304 __ delay_slot()->sw(ZR, |
| 318 FieldAddress(V0, GrowableObjectArray::length_offset())); | 305 FieldAddress(V0, GrowableObjectArray::length_offset())); |
| 319 | 306 |
| 320 __ Bind(&fall_through); | 307 __ Bind(&fall_through); |
| 321 return false; | 308 return false; |
| 322 } | 309 } |
| 323 | 310 |
| 324 | 311 |
| 325 bool Intrinsifier::GrowableArray_getLength(Assembler* assembler) { | |
| 326 __ lw(V0, Address(SP, 0 * kWordSize)); | |
| 327 __ Ret(); | |
| 328 __ delay_slot()->lw(V0, | |
| 329 FieldAddress(V0, GrowableObjectArray::length_offset())); | |
| 330 return true; | |
| 331 } | |
| 332 | |
| 333 | |
| 334 bool Intrinsifier::GrowableArray_getCapacity(Assembler* assembler) { | 312 bool Intrinsifier::GrowableArray_getCapacity(Assembler* assembler) { |
| 335 __ lw(V0, Address(SP, 0 * kWordSize)); | 313 __ lw(V0, Address(SP, 0 * kWordSize)); |
| 336 __ lw(V0, FieldAddress(V0, GrowableObjectArray::data_offset())); | 314 __ lw(V0, FieldAddress(V0, GrowableObjectArray::data_offset())); |
| 337 __ Ret(); | 315 __ Ret(); |
| 338 __ delay_slot()->lw(V0, FieldAddress(V0, Array::length_offset())); | 316 __ delay_slot()->lw(V0, FieldAddress(V0, Array::length_offset())); |
| 339 return true; | 317 return true; |
| 340 } | 318 } |
| 341 | 319 |
| 342 | 320 |
| 343 bool Intrinsifier::GrowableArray_getIndexed(Assembler* assembler) { | 321 bool Intrinsifier::GrowableArray_getIndexed(Assembler* assembler) { |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 551 __ BranchUnsignedGreaterEqual(T2, T1, &done); \ | 529 __ BranchUnsignedGreaterEqual(T2, T1, &done); \ |
| 552 __ sw(ZR, Address(T2, 0)); \ | 530 __ sw(ZR, Address(T2, 0)); \ |
| 553 __ b(&init_loop); \ | 531 __ b(&init_loop); \ |
| 554 __ delay_slot()->addiu(T2, T2, Immediate(kWordSize)); \ | 532 __ delay_slot()->addiu(T2, T2, Immediate(kWordSize)); \ |
| 555 __ Bind(&done); \ | 533 __ Bind(&done); \ |
| 556 \ | 534 \ |
| 557 __ Ret(); \ | 535 __ Ret(); \ |
| 558 __ Bind(&fall_through); \ | 536 __ Bind(&fall_through); \ |
| 559 | 537 |
| 560 | 538 |
| 561 // Gets the length of a TypedData. | |
| 562 bool Intrinsifier::TypedData_getLength(Assembler* assembler) { | |
| 563 __ lw(T0, Address(SP, 0 * kWordSize)); | |
| 564 __ Ret(); | |
| 565 __ delay_slot()->lw(V0, FieldAddress(T0, TypedData::length_offset())); | |
| 566 return true; | |
| 567 } | |
| 568 | |
| 569 | |
| 570 static int GetScaleFactor(intptr_t size) { | 539 static int GetScaleFactor(intptr_t size) { |
| 571 switch (size) { | 540 switch (size) { |
| 572 case 1: return 0; | 541 case 1: return 0; |
| 573 case 2: return 1; | 542 case 2: return 1; |
| 574 case 4: return 2; | 543 case 4: return 2; |
| 575 case 8: return 3; | 544 case 8: return 3; |
| 576 case 16: return 4; | 545 case 16: return 4; |
| 577 } | 546 } |
| 578 UNREACHABLE(); | 547 UNREACHABLE(); |
| 579 return -1; | 548 return -1; |
| (...skipping 911 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1491 Label fall_through; | 1460 Label fall_through; |
| 1492 __ lw(T0, Address(SP, 0 * kWordSize)); | 1461 __ lw(T0, Address(SP, 0 * kWordSize)); |
| 1493 __ lw(V0, FieldAddress(T0, String::hash_offset())); | 1462 __ lw(V0, FieldAddress(T0, String::hash_offset())); |
| 1494 __ beq(V0, ZR, &fall_through); | 1463 __ beq(V0, ZR, &fall_through); |
| 1495 __ Ret(); | 1464 __ Ret(); |
| 1496 __ Bind(&fall_through); // Hash not yet computed. | 1465 __ Bind(&fall_through); // Hash not yet computed. |
| 1497 return false; | 1466 return false; |
| 1498 } | 1467 } |
| 1499 | 1468 |
| 1500 | 1469 |
| 1501 bool Intrinsifier::String_getLength(Assembler* assembler) { | |
| 1502 __ lw(T0, Address(SP, 0 * kWordSize)); | |
| 1503 __ Ret(); | |
| 1504 __ delay_slot()->lw(V0, FieldAddress(T0, String::length_offset())); | |
| 1505 return true; | |
| 1506 } | |
| 1507 | |
| 1508 | |
| 1509 bool Intrinsifier::String_codeUnitAt(Assembler* assembler) { | 1470 bool Intrinsifier::String_codeUnitAt(Assembler* assembler) { |
| 1510 Label fall_through, try_two_byte_string; | 1471 Label fall_through, try_two_byte_string; |
| 1511 | 1472 |
| 1512 __ lw(T1, Address(SP, 0 * kWordSize)); // Index. | 1473 __ lw(T1, Address(SP, 0 * kWordSize)); // Index. |
| 1513 __ lw(T0, Address(SP, 1 * kWordSize)); // String. | 1474 __ lw(T0, Address(SP, 1 * kWordSize)); // String. |
| 1514 | 1475 |
| 1515 // Checks. | 1476 // Checks. |
| 1516 __ andi(CMPRES, T1, Immediate(kSmiTagMask)); | 1477 __ andi(CMPRES, T1, Immediate(kSmiTagMask)); |
| 1517 __ bne(T1, ZR, &fall_through); // Index is not a Smi. | 1478 __ bne(T1, ZR, &fall_through); // Index is not a Smi. |
| 1518 __ lw(T2, FieldAddress(T0, String::length_offset())); // Range check. | 1479 __ lw(T2, FieldAddress(T0, String::length_offset())); // Range check. |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1775 __ Bind(&ok); | 1736 __ Bind(&ok); |
| 1776 __ Ret(); | 1737 __ Ret(); |
| 1777 | 1738 |
| 1778 __ Bind(&fall_through); | 1739 __ Bind(&fall_through); |
| 1779 return false; | 1740 return false; |
| 1780 } | 1741 } |
| 1781 | 1742 |
| 1782 } // namespace dart | 1743 } // namespace dart |
| 1783 | 1744 |
| 1784 #endif // defined TARGET_ARCH_MIPS | 1745 #endif // defined TARGET_ARCH_MIPS |
| OLD | NEW |