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 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 425 __ movq(RBX, Address(RSP, + 1 * kWordSize)); // Index. | 425 __ movq(RBX, Address(RSP, + 1 * kWordSize)); // Index. |
| 426 __ testq(RBX, Immediate(kSmiTagMask)); | 426 __ testq(RBX, Immediate(kSmiTagMask)); |
| 427 __ j(NOT_ZERO, fall_through, Assembler::kNearJump); // Non-smi index. | 427 __ j(NOT_ZERO, fall_through, Assembler::kNearJump); // Non-smi index. |
| 428 // Range check. | 428 // Range check. |
| 429 __ cmpq(RBX, FieldAddress(RAX, ByteArray::length_offset())); | 429 __ cmpq(RBX, FieldAddress(RAX, ByteArray::length_offset())); |
| 430 // Runtime throws exception. | 430 // Runtime throws exception. |
| 431 __ j(ABOVE_EQUAL, fall_through, Assembler::kNearJump); | 431 __ j(ABOVE_EQUAL, fall_through, Assembler::kNearJump); |
| 432 } | 432 } |
| 433 | 433 |
| 434 | 434 |
| 435 // Operates in the same manner as TestByteArrayIndex. | |
| 436 // This should be used only for setIndexed intrinsics. | |
| 437 static void TestByteArraySetIndex(Assembler* assembler, Label* fall_through) { | |
| 438 __ movq(RAX, Address(RSP, + 3 * kWordSize)); // Array. | |
| 439 __ movq(RBX, Address(RSP, + 2 * kWordSize)); // Index. | |
|
srdjan
2012/10/01 22:59:40
You cannot use RBX if there is a slow path. This i
| |
| 440 __ testq(RBX, Immediate(kSmiTagMask)); | |
| 441 __ j(NOT_ZERO, fall_through, Assembler::kNearJump); // Non-smi index. | |
| 442 // Range check. | |
| 443 __ cmpq(RBX, FieldAddress(RAX, ByteArray::length_offset())); | |
| 444 // Runtime throws exception. | |
| 445 __ j(ABOVE_EQUAL, fall_through, Assembler::kNearJump); | |
| 446 } | |
| 447 | |
| 448 | |
| 435 bool Intrinsifier::Int8Array_getIndexed(Assembler* assembler) { | 449 bool Intrinsifier::Int8Array_getIndexed(Assembler* assembler) { |
| 436 Label fall_through; | 450 Label fall_through; |
| 437 TestByteArrayIndex(assembler, &fall_through); | 451 TestByteArrayIndex(assembler, &fall_through); |
| 438 __ SmiUntag(RBX); | 452 __ SmiUntag(RBX); |
| 439 __ movsxb(RAX, FieldAddress(RAX, | 453 __ movsxb(RAX, FieldAddress(RAX, |
| 440 RBX, | 454 RBX, |
| 441 TIMES_1, | 455 TIMES_1, |
| 442 Int8Array::data_offset())); | 456 Int8Array::data_offset())); |
| 443 __ SmiTag(RAX); | 457 __ SmiTag(RAX); |
| 444 __ ret(); | 458 __ ret(); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 510 __ movl(RAX, FieldAddress(RAX, | 524 __ movl(RAX, FieldAddress(RAX, |
| 511 RBX, | 525 RBX, |
| 512 TIMES_2, | 526 TIMES_2, |
| 513 Uint32Array::data_offset())); | 527 Uint32Array::data_offset())); |
| 514 __ SmiTag(RAX); | 528 __ SmiTag(RAX); |
| 515 __ ret(); | 529 __ ret(); |
| 516 __ Bind(&fall_through); | 530 __ Bind(&fall_through); |
| 517 return false; | 531 return false; |
| 518 } | 532 } |
| 519 | 533 |
| 534 | |
| 520 bool Intrinsifier::Float32Array_getIndexed(Assembler* assembler) { | 535 bool Intrinsifier::Float32Array_getIndexed(Assembler* assembler) { |
| 521 Label fall_through; | 536 Label fall_through; |
| 522 TestByteArrayIndex(assembler, &fall_through); | 537 TestByteArrayIndex(assembler, &fall_through); |
| 523 // After TestByteArrayIndex: | 538 // After TestByteArrayIndex: |
| 524 // * RAX has the base address of the byte array. | 539 // * RAX has the base address of the byte array. |
| 525 // * RBX has the index into the array. | 540 // * RBX has the index into the array. |
| 526 // RBX contains the SMI index which is shifted left by 1. | 541 // RBX contains the SMI index which is shifted left by 1. |
| 527 // This shift means we only multiply the index by 2 not 4 (sizeof float). | 542 // This shift means we only multiply the index by 2 not 4 (sizeof float). |
| 528 // Load single precision float into XMM7. | 543 // Load single precision float into XMM7. |
| 529 __ movss(XMM7, FieldAddress(RAX, RBX, TIMES_2, | 544 __ movss(XMM7, FieldAddress(RAX, RBX, TIMES_2, |
| 530 Float32Array::data_offset())); | 545 Float32Array::data_offset())); |
| 531 // Convert into a double precision float. | 546 // Convert into a double precision float. |
| 532 __ cvtss2sd(XMM7, XMM7); | 547 __ cvtss2sd(XMM7, XMM7); |
| 533 // Allocate a double instance. | 548 // Allocate a double instance. |
| 534 const Class& double_class = Class::Handle( | 549 const Class& double_class = Class::Handle( |
| 535 Isolate::Current()->object_store()->double_class()); | 550 Isolate::Current()->object_store()->double_class()); |
| 536 AssemblerMacros::TryAllocate(assembler, | 551 AssemblerMacros::TryAllocate(assembler, |
| 537 double_class, | 552 double_class, |
| 538 &fall_through, | 553 &fall_through, |
| 539 Assembler::kNearJump, RAX); | 554 Assembler::kNearJump, RAX); |
| 540 // Store XMM7 into double instance. | 555 // Store XMM7 into double instance. |
| 541 __ movsd(FieldAddress(RAX, Double::value_offset()), XMM7); | 556 __ movsd(FieldAddress(RAX, Double::value_offset()), XMM7); |
| 542 __ ret(); | 557 __ ret(); |
| 543 __ Bind(&fall_through); | 558 __ Bind(&fall_through); |
| 544 return false; | 559 return false; |
| 545 } | 560 } |
| 546 | 561 |
| 562 | |
| 547 bool Intrinsifier::Float32Array_setIndexed(Assembler* assembler) { | 563 bool Intrinsifier::Float32Array_setIndexed(Assembler* assembler) { |
| 548 return false; | 564 Label fall_through; |
| 565 TestByteArraySetIndex(assembler, &fall_through); | |
| 566 // After TestByteArraySetIndex: | |
| 567 // * RAX has the base address of the byte array. | |
| 568 // * RBX has the index into the array. | |
| 569 // RBX contains the SMI index which is shifted by 1. | |
| 570 // This shift means we only multiply the index by 2 not 4 (sizeof float). | |
| 571 __ movq(RDX, Address(RSP, + 1 * kWordSize)); // Value. | |
| 572 // If RDX is not an instance of double, jump to fall through. | |
| 573 __ CompareClassId(RDX, kDoubleCid); | |
| 574 __ j(NOT_EQUAL, &fall_through); | |
| 575 // Load double value into XMM7. | |
| 576 __ movsd(XMM7, FieldAddress(RDX, Double::value_offset())); | |
| 577 // Convert from double precision float to single precision float. | |
| 578 __ cvtsd2ss(XMM7, XMM7); | |
| 579 // Store into array. | |
| 580 __ movss(FieldAddress(RAX, RBX, TIMES_2, Float32Array::data_offset()), XMM7); | |
| 581 // End fast path. | |
| 582 __ ret(); | |
| 583 __ Bind(&fall_through); | |
| 584 return false; | |
| 549 } | 585 } |
| 550 | 586 |
| 551 | 587 |
| 552 // Tests if two top most arguments are smis, jumps to label not_smi if not. | 588 // Tests if two top most arguments are smis, jumps to label not_smi if not. |
| 553 // Topmost argument is in RAX. | 589 // Topmost argument is in RAX. |
| 554 static void TestBothArgumentsSmis(Assembler* assembler, Label* not_smi) { | 590 static void TestBothArgumentsSmis(Assembler* assembler, Label* not_smi) { |
| 555 __ movq(RAX, Address(RSP, + 1 * kWordSize)); | 591 __ movq(RAX, Address(RSP, + 1 * kWordSize)); |
| 556 __ movq(RCX, Address(RSP, + 2 * kWordSize)); | 592 __ movq(RCX, Address(RSP, + 2 * kWordSize)); |
| 557 __ orq(RCX, RAX); | 593 __ orq(RCX, RAX); |
| 558 __ testq(RCX, Immediate(kSmiTagMask)); | 594 __ testq(RCX, Immediate(kSmiTagMask)); |
| (...skipping 857 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1416 __ LoadObject(RAX, bool_true); | 1452 __ LoadObject(RAX, bool_true); |
| 1417 __ ret(); | 1453 __ ret(); |
| 1418 return true; | 1454 return true; |
| 1419 } | 1455 } |
| 1420 | 1456 |
| 1421 #undef __ | 1457 #undef __ |
| 1422 | 1458 |
| 1423 } // namespace dart | 1459 } // namespace dart |
| 1424 | 1460 |
| 1425 #endif // defined TARGET_ARCH_X64 | 1461 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |