Chromium Code Reviews| 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 // Move R12 into RDI. | |
|
Florian Schneider
2012/11/22 14:35:53
This comment is not very useful. I suggest removin
| |
| 482 __ movq(RDI, R12); | |
| 483 // Load the value into R12. | |
| 484 __ movq(R12, Address(RSP, + 1 * kWordSize)); // Value. | |
|
Florian Schneider
2012/11/22 14:35:53
Maybe use a different register than R12 vor the va
| |
| 485 // If R12 is not an Smi, jump to fall through. | |
| 486 __ testq(R12, Immediate(kSmiTagMask)); | |
| 487 __ j(NOT_ZERO, &fall_through, Assembler::kNearJump); | |
| 488 __ SmiUntag(R12); | |
| 489 // Add 128 to R12 to bring it into the range 0..FF. | |
| 490 __ addq(R12, Immediate(128)); | |
| 491 // If R12 is too large for an Int8, jump to fall through. | |
| 492 __ cmpq(R12, Immediate(0xFF)); | |
| 493 __ j(ABOVE, &fall_through, Assembler::kNearJump); | |
| 494 // Undo addition. | |
| 495 __ subq(R12, Immediate(128)); | |
| 496 // Store byte from RBX into array RAX[RDI]. | |
| 497 __ movb(FieldAddress(RAX, RDI, TIMES_1, Uint8Array::data_offset()), R12); | |
| 498 __ ret(); | |
| 474 __ Bind(&fall_through); | 499 __ Bind(&fall_through); |
| 475 return false; | 500 return false; |
| 476 } | 501 } |
| 477 | 502 |
| 478 | 503 |
| 479 bool Intrinsifier::Uint8Array_setIndexed(Assembler* assembler) { | 504 bool Intrinsifier::Uint8Array_setIndexed(Assembler* assembler) { |
| 480 Label fall_through; | 505 Label fall_through; |
| 506 // Verify that the array index is valid. | |
| 507 TestByteArraySetIndex(assembler, &fall_through); | |
| 508 // After TestByteArraySetIndex: | |
| 509 // * RAX has the base address of the byte array. | |
| 510 // * R12 has the index into the array. | |
| 511 // R12 contains the SMI index which is shifted by 1. | |
| 512 __ SmiUntag(R12); | |
| 513 // Move R12 into RDI. | |
|
Florian Schneider
2012/11/22 14:35:53
Same comments as for Int8Array.
| |
| 514 __ movq(RDI, R12); | |
| 515 // Load the value into R12. | |
| 516 __ movq(R12, Address(RSP, + 1 * kWordSize)); // Value. | |
| 517 // If R12 is not an Smi, jump to fall through. | |
| 518 __ testq(R12, Immediate(kSmiTagMask)); | |
| 519 __ j(NOT_ZERO, &fall_through, Assembler::kNearJump); | |
| 520 __ SmiUntag(R12); | |
| 521 // If R12 is too large for an Uint8, jump to fall through. | |
| 522 __ cmpq(R12, Immediate(0xFF)); | |
| 523 __ j(ABOVE, &fall_through, Assembler::kNearJump); | |
| 524 // Store byte from RBX into array RAX[RDI]. | |
| 525 __ movb(FieldAddress(RAX, RDI, TIMES_1, Uint8Array::data_offset()), R12); | |
| 526 __ ret(); | |
| 481 __ Bind(&fall_through); | 527 __ Bind(&fall_through); |
| 482 return false; | 528 return false; |
| 483 } | 529 } |
| 484 | 530 |
| 485 | 531 |
| 486 bool Intrinsifier::Uint8Array_getIndexed(Assembler* assembler) { | 532 bool Intrinsifier::Uint8Array_getIndexed(Assembler* assembler) { |
| 487 Label fall_through; | 533 Label fall_through; |
| 488 TestByteArrayIndex(assembler, &fall_through); | 534 TestByteArrayIndex(assembler, &fall_through); |
| 489 __ SmiUntag(R12); | 535 __ SmiUntag(R12); |
| 490 __ movzxb(RAX, FieldAddress(RAX, | 536 __ movzxb(RAX, FieldAddress(RAX, |
| (...skipping 1080 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1571 __ LoadObject(RAX, bool_true); | 1617 __ LoadObject(RAX, bool_true); |
| 1572 __ ret(); | 1618 __ ret(); |
| 1573 return true; | 1619 return true; |
| 1574 } | 1620 } |
| 1575 | 1621 |
| 1576 #undef __ | 1622 #undef __ |
| 1577 | 1623 |
| 1578 } // namespace dart | 1624 } // namespace dart |
| 1579 | 1625 |
| 1580 #endif // defined TARGET_ARCH_X64 | 1626 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |