| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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/intrinsifier.h" | 8 #include "vm/intrinsifier.h" |
| 9 | 9 |
| 10 #include "vm/assembler.h" | 10 #include "vm/assembler.h" |
| (...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 Int8Array::data_offset())); | 464 Int8Array::data_offset())); |
| 465 __ SmiTag(RAX); | 465 __ SmiTag(RAX); |
| 466 __ ret(); | 466 __ ret(); |
| 467 __ Bind(&fall_through); | 467 __ Bind(&fall_through); |
| 468 return false; | 468 return false; |
| 469 } | 469 } |
| 470 | 470 |
| 471 | 471 |
| 472 bool Intrinsifier::Int8Array_setIndexed(Assembler* assembler) { | 472 bool Intrinsifier::Int8Array_setIndexed(Assembler* assembler) { |
| 473 Label fall_through; | 473 Label fall_through; |
| 474 // Verify that the array index is valid. |
| 475 TestByteArraySetIndex(assembler, &fall_through); |
| 476 // After TestByteArraySetIndex: |
| 477 // * RAX has the base address of the byte array. |
| 478 // * R12 has the index into the array. |
| 479 // R12 contains the SMI index which is shifted by 1. |
| 480 __ SmiUntag(R12); |
| 481 __ movq(RDI, Address(RSP, + 1 * kWordSize)); // Value. |
| 482 __ testq(RDI, Immediate(kSmiTagMask)); |
| 483 __ j(NOT_ZERO, &fall_through, Assembler::kNearJump); |
| 484 __ SmiUntag(RDI); |
| 485 // Check that the value is a byte. Add 128 to the value to bring it into |
| 486 // the range 0..FF. |
| 487 __ addq(RDI, Immediate(128)); |
| 488 __ cmpq(RDI, Immediate(0xFF)); |
| 489 __ j(ABOVE, &fall_through, Assembler::kNearJump); |
| 490 // Undo addition. |
| 491 __ subq(RDI, Immediate(128)); |
| 492 __ movb(FieldAddress(RAX, R12, TIMES_1, Uint8Array::data_offset()), RDI); |
| 493 __ ret(); |
| 474 __ Bind(&fall_through); | 494 __ Bind(&fall_through); |
| 475 return false; | 495 return false; |
| 476 } | 496 } |
| 477 | 497 |
| 478 | 498 |
| 479 bool Intrinsifier::Uint8Array_setIndexed(Assembler* assembler) { | 499 bool Intrinsifier::Uint8Array_setIndexed(Assembler* assembler) { |
| 480 Label fall_through; | 500 Label fall_through; |
| 501 // Verify that the array index is valid. |
| 502 TestByteArraySetIndex(assembler, &fall_through); |
| 503 // After TestByteArraySetIndex: |
| 504 // * RAX has the base address of the byte array. |
| 505 // * R12 has the index into the array. |
| 506 // R12 contains the SMI index which is shifted by 1. |
| 507 __ SmiUntag(R12); |
| 508 __ movq(RDI, Address(RSP, + 1 * kWordSize)); // Value. |
| 509 __ testq(RDI, Immediate(kSmiTagMask)); |
| 510 __ j(NOT_ZERO, &fall_through, Assembler::kNearJump); |
| 511 __ SmiUntag(RDI); |
| 512 // Check that value is a byte. |
| 513 __ cmpq(RDI, Immediate(0xFF)); |
| 514 __ j(ABOVE, &fall_through, Assembler::kNearJump); |
| 515 __ movb(FieldAddress(RAX, R12, TIMES_1, Uint8Array::data_offset()), RDI); |
| 516 __ ret(); |
| 481 __ Bind(&fall_through); | 517 __ Bind(&fall_through); |
| 482 return false; | 518 return false; |
| 483 } | 519 } |
| 484 | 520 |
| 485 | 521 |
| 486 bool Intrinsifier::Uint8Array_getIndexed(Assembler* assembler) { | 522 bool Intrinsifier::Uint8Array_getIndexed(Assembler* assembler) { |
| 487 Label fall_through; | 523 Label fall_through; |
| 488 TestByteArrayIndex(assembler, &fall_through); | 524 TestByteArrayIndex(assembler, &fall_through); |
| 489 __ SmiUntag(R12); | 525 __ SmiUntag(R12); |
| 490 __ movzxb(RAX, FieldAddress(RAX, | 526 __ movzxb(RAX, FieldAddress(RAX, |
| (...skipping 1080 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1571 __ LoadObject(RAX, bool_true); | 1607 __ LoadObject(RAX, bool_true); |
| 1572 __ ret(); | 1608 __ ret(); |
| 1573 return true; | 1609 return true; |
| 1574 } | 1610 } |
| 1575 | 1611 |
| 1576 #undef __ | 1612 #undef __ |
| 1577 | 1613 |
| 1578 } // namespace dart | 1614 } // namespace dart |
| 1579 | 1615 |
| 1580 #endif // defined TARGET_ARCH_X64 | 1616 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |