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_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 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 | 429 |
430 __ movq(RAX, FieldAddress(RAX, ExternalTypedData::data_offset())); | 430 __ movq(RAX, FieldAddress(RAX, ExternalTypedData::data_offset())); |
431 __ SmiUntag(RCX); | 431 __ SmiUntag(RCX); |
432 __ movzxb(RAX, Address(RAX, RCX, TIMES_1, 0)); | 432 __ movzxb(RAX, Address(RAX, RCX, TIMES_1, 0)); |
433 __ SmiTag(RAX); | 433 __ SmiTag(RAX); |
434 __ ret(); | 434 __ ret(); |
435 __ Bind(&fall_through); | 435 __ Bind(&fall_through); |
436 } | 436 } |
437 | 437 |
438 | 438 |
| 439 void Intrinsifier::Float64Array_getIndexed(Assembler* assembler) { |
| 440 Label fall_through; |
| 441 __ movq(RCX, Address(RSP, + 1 * kWordSize)); // Index. |
| 442 __ movq(RAX, Address(RSP, + 2 * kWordSize)); // Array. |
| 443 __ testq(RCX, Immediate(kSmiTagMask)); |
| 444 __ j(NOT_ZERO, &fall_through, Assembler::kNearJump); // Non-smi index. |
| 445 // Range check. |
| 446 __ cmpq(RCX, FieldAddress(RAX, TypedData::length_offset())); |
| 447 // Runtime throws exception. |
| 448 __ j(ABOVE_EQUAL, &fall_through, Assembler::kNearJump); |
| 449 |
| 450 Address element_address = |
| 451 Assembler::ElementAddressForRegIndex(false, // Not external. |
| 452 kTypedDataFloat64ArrayCid, |
| 453 8, // Index scale. |
| 454 RAX, // Array. |
| 455 RCX); // Index. |
| 456 |
| 457 __ movsd(XMM0, element_address); |
| 458 |
| 459 const Class& double_class = Class::Handle( |
| 460 Isolate::Current()->object_store()->double_class()); |
| 461 __ TryAllocate(double_class, |
| 462 &fall_through, |
| 463 Assembler::kNearJump, |
| 464 RAX, // Result register. |
| 465 kNoRegister); |
| 466 __ movsd(FieldAddress(RAX, Double::value_offset()), XMM0); |
| 467 __ ret(); |
| 468 __ Bind(&fall_through); |
| 469 } |
| 470 |
| 471 |
| 472 void Intrinsifier::Float64Array_setIndexed(Assembler* assembler) { |
| 473 Label fall_through; |
| 474 __ movq(RCX, Address(RSP, + 2 * kWordSize)); // Index. |
| 475 __ movq(RAX, Address(RSP, + 3 * kWordSize)); // Array. |
| 476 __ testq(RCX, Immediate(kSmiTagMask)); |
| 477 __ j(NOT_ZERO, &fall_through, Assembler::kNearJump); // Non-smi index. |
| 478 // Range check. |
| 479 __ cmpq(RCX, FieldAddress(RAX, TypedData::length_offset())); |
| 480 // Runtime throws exception. |
| 481 __ j(ABOVE_EQUAL, &fall_through, Assembler::kNearJump); |
| 482 |
| 483 __ movq(RDX, Address(RSP, + 1 * kWordSize)); // Value |
| 484 __ testq(RDX, Immediate(kSmiTagMask)); |
| 485 __ j(ZERO, &fall_through, Assembler::kNearJump); // Value is Smi. |
| 486 |
| 487 __ LoadClassId(RDI, RDX); |
| 488 __ cmpq(RDI, Immediate(kTypedDataFloat64ArrayCid)); |
| 489 __ j(NOT_EQUAL, &fall_through, Assembler::kNearJump); |
| 490 |
| 491 __ movsd(XMM0, FieldAddress(RDX, Double::value_offset())); |
| 492 |
| 493 Address element_address = |
| 494 Assembler::ElementAddressForRegIndex(false, // Not external. |
| 495 kTypedDataFloat64ArrayCid, |
| 496 8, // Index scale. |
| 497 RAX, // Array. |
| 498 RCX); // Index. |
| 499 |
| 500 __ movsd(element_address, XMM0); |
| 501 __ ret(); |
| 502 __ Bind(&fall_through); |
| 503 } |
| 504 |
| 505 |
439 static ScaleFactor GetScaleFactor(intptr_t size) { | 506 static ScaleFactor GetScaleFactor(intptr_t size) { |
440 switch (size) { | 507 switch (size) { |
441 case 1: return TIMES_1; | 508 case 1: return TIMES_1; |
442 case 2: return TIMES_2; | 509 case 2: return TIMES_2; |
443 case 4: return TIMES_4; | 510 case 4: return TIMES_4; |
444 case 8: return TIMES_8; | 511 case 8: return TIMES_8; |
445 case 16: return TIMES_16; | 512 case 16: return TIMES_16; |
446 } | 513 } |
447 UNREACHABLE(); | 514 UNREACHABLE(); |
448 return static_cast<ScaleFactor>(0); | 515 return static_cast<ScaleFactor>(0); |
(...skipping 1166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1615 // Set return value to Isolate::current_tag_. | 1682 // Set return value to Isolate::current_tag_. |
1616 __ movq(RAX, Address(RBX, Isolate::current_tag_offset())); | 1683 __ movq(RAX, Address(RBX, Isolate::current_tag_offset())); |
1617 __ ret(); | 1684 __ ret(); |
1618 } | 1685 } |
1619 | 1686 |
1620 #undef __ | 1687 #undef __ |
1621 | 1688 |
1622 } // namespace dart | 1689 } // namespace dart |
1623 | 1690 |
1624 #endif // defined TARGET_ARCH_X64 | 1691 #endif // defined TARGET_ARCH_X64 |
OLD | NEW |