Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(392)

Side by Side Diff: runtime/vm/intrinsifier_ia32.cc

Issue 11032011: Intrinsify Float32Array_setIndexed on IA32 and X64 (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix register usage. Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/vm/intrinsifier_x64.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // The intrinsic code below is executed before a method has built its frame. 5 // The intrinsic code below is executed before a method has built its frame.
6 // The return address is on the stack and the arguments below it. 6 // The return address is on the stack and the arguments below it.
7 // Registers EDX (arguments descriptor) and ECX (function) must be preserved. 7 // Registers EDX (arguments descriptor) and ECX (function) must be preserved.
8 // Each intrinsification method returns true if the corresponding 8 // Each intrinsification method returns true if the corresponding
9 // Dart method was intrinsified. 9 // Dart method was intrinsified.
10 10
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 __ movl(EBX, Address(ESP, + 1 * kWordSize)); // Index. 484 __ movl(EBX, Address(ESP, + 1 * kWordSize)); // Index.
485 __ testl(EBX, Immediate(kSmiTagMask)); 485 __ testl(EBX, Immediate(kSmiTagMask));
486 __ j(NOT_ZERO, fall_through, Assembler::kNearJump); // Non-smi index. 486 __ j(NOT_ZERO, fall_through, Assembler::kNearJump); // Non-smi index.
487 // Range check. 487 // Range check.
488 __ cmpl(EBX, FieldAddress(EAX, ByteArray::length_offset())); 488 __ cmpl(EBX, FieldAddress(EAX, ByteArray::length_offset()));
489 // Runtime throws exception. 489 // Runtime throws exception.
490 __ j(ABOVE_EQUAL, fall_through, Assembler::kNearJump); 490 __ j(ABOVE_EQUAL, fall_through, Assembler::kNearJump);
491 } 491 }
492 492
493 493
494 // Operates in the same manner as TestByteArrayIndex.
495 // This should be used only for setIndexed intrinsics.
496 static void TestByteArraySetIndex(Assembler* assembler, Label* fall_through) {
497 __ movl(EAX, Address(ESP, + 3 * kWordSize)); // Array.
498 __ movl(EBX, Address(ESP, + 2 * kWordSize)); // Index.
499 __ testl(EBX, Immediate(kSmiTagMask));
500 __ j(NOT_ZERO, fall_through, Assembler::kNearJump); // Non-smi index.
501 // Range check.
502 __ cmpl(EBX, FieldAddress(EAX, ByteArray::length_offset()));
503 // Runtime throws exception.
504 __ j(ABOVE_EQUAL, fall_through, Assembler::kNearJump);
505 }
506
507
494 bool Intrinsifier::Int8Array_getIndexed(Assembler* assembler) { 508 bool Intrinsifier::Int8Array_getIndexed(Assembler* assembler) {
495 Label fall_through; 509 Label fall_through;
496 TestByteArrayIndex(assembler, &fall_through); 510 TestByteArrayIndex(assembler, &fall_through);
497 __ SmiUntag(EBX); 511 __ SmiUntag(EBX);
498 __ movsxb(EAX, FieldAddress(EAX, 512 __ movsxb(EAX, FieldAddress(EAX,
499 EBX, 513 EBX,
500 TIMES_1, 514 TIMES_1,
501 Int8Array::data_offset())); 515 Int8Array::data_offset()));
502 __ SmiTag(EAX); 516 __ SmiTag(EAX);
503 __ ret(); 517 __ ret();
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 565
552 bool Intrinsifier::Int32Array_getIndexed(Assembler* assembler) { 566 bool Intrinsifier::Int32Array_getIndexed(Assembler* assembler) {
553 return false; 567 return false;
554 } 568 }
555 569
556 570
557 bool Intrinsifier::Uint32Array_getIndexed(Assembler* assembler) { 571 bool Intrinsifier::Uint32Array_getIndexed(Assembler* assembler) {
558 return false; 572 return false;
559 } 573 }
560 574
575
561 bool Intrinsifier::Float32Array_getIndexed(Assembler* assembler) { 576 bool Intrinsifier::Float32Array_getIndexed(Assembler* assembler) {
562 Label fall_through; 577 Label fall_through;
563 TestByteArrayIndex(assembler, &fall_through); 578 TestByteArrayIndex(assembler, &fall_through);
564 // After TestByteArrayIndex: 579 // After TestByteArrayIndex:
565 // * EAX has the base address of the byte array. 580 // * EAX has the base address of the byte array.
566 // * EBX has the index into the array. 581 // * EBX has the index into the array.
567 // EBX contains the SMI index which is shifted left by 1. 582 // EBX contains the SMI index which is shifted left by 1.
568 // This shift means we only multiply the index by 2 not 4 (sizeof float). 583 // This shift means we only multiply the index by 2 not 4 (sizeof float).
569 // Load single precision float into XMM7. 584 // Load single precision float into XMM7.
570 __ movss(XMM7, FieldAddress(EAX, EBX, TIMES_2, 585 __ movss(XMM7, FieldAddress(EAX, EBX, TIMES_2,
571 Float32Array::data_offset())); 586 Float32Array::data_offset()));
572 // Convert into a double precision float. 587 // Convert into a double precision float.
573 __ cvtss2sd(XMM7, XMM7); 588 __ cvtss2sd(XMM7, XMM7);
574 // Allocate a double instance. 589 // Allocate a double instance.
575 const Class& double_class = Class::Handle( 590 const Class& double_class = Class::Handle(
576 Isolate::Current()->object_store()->double_class()); 591 Isolate::Current()->object_store()->double_class());
577 AssemblerMacros::TryAllocate(assembler, 592 AssemblerMacros::TryAllocate(assembler,
578 double_class, 593 double_class,
579 &fall_through, 594 &fall_through,
580 Assembler::kNearJump, EAX); 595 Assembler::kNearJump, EAX);
581 // Store XMM7 into double instance. 596 // Store XMM7 into double instance.
582 __ movsd(FieldAddress(EAX, Double::value_offset()), XMM7); 597 __ movsd(FieldAddress(EAX, Double::value_offset()), XMM7);
583 __ ret(); 598 __ ret();
584 __ Bind(&fall_through); 599 __ Bind(&fall_through);
585 600
586 return false; 601 return false;
587 } 602 }
588 603
604
589 bool Intrinsifier::Float32Array_setIndexed(Assembler* assembler) { 605 bool Intrinsifier::Float32Array_setIndexed(Assembler* assembler) {
590 return false; 606 Label fall_through;
607 __ movl(EAX, Address(ESP, + 1 * kWordSize)); // Value.
608 // If EAX is not an instance of double, jump to fall through.
609 __ CompareClassId(EAX, kDoubleCid, EDI);
610 __ j(NOT_EQUAL, &fall_through);
611 // Load double value into XMM7.
612 __ movsd(XMM7, FieldAddress(EAX, Double::value_offset()));
613 TestByteArraySetIndex(assembler, &fall_through);
614 // After TestByteArraySetIndex:
615 // * EAX has the base address of the byte array.
616 // * EBX has the index into the array.
617 // EBX contains the SMI index which is shifted by 1.
618 // This shift means we only multiply the index by 2 not 4 (sizeof float).
619 // Convert from double precision float to single precision float.
620 __ cvtsd2ss(XMM7, XMM7);
621 // Store into array.
622 __ movss(FieldAddress(EAX, EBX, TIMES_2, Float32Array::data_offset()), XMM7);
623 // End fast path.
624 __ ret();
625 __ Bind(&fall_through);
626 return false;
591 } 627 }
592 628
629
593 // Tests if two top most arguments are smis, jumps to label not_smi if not. 630 // Tests if two top most arguments are smis, jumps to label not_smi if not.
594 // Topmost argument is in EAX. 631 // Topmost argument is in EAX.
595 static void TestBothArgumentsSmis(Assembler* assembler, Label* not_smi) { 632 static void TestBothArgumentsSmis(Assembler* assembler, Label* not_smi) {
596 __ movl(EAX, Address(ESP, + 1 * kWordSize)); 633 __ movl(EAX, Address(ESP, + 1 * kWordSize));
597 __ movl(EBX, Address(ESP, + 2 * kWordSize)); 634 __ movl(EBX, Address(ESP, + 2 * kWordSize));
598 __ orl(EBX, EAX); 635 __ orl(EBX, EAX);
599 __ testl(EBX, Immediate(kSmiTagMask)); 636 __ testl(EBX, Immediate(kSmiTagMask));
600 __ j(NOT_ZERO, not_smi, Assembler::kNearJump); 637 __ j(NOT_ZERO, not_smi, Assembler::kNearJump);
601 } 638 }
602 639
(...skipping 858 matching lines...) Expand 10 before | Expand all | Expand 10 after
1461 __ Bind(&is_true); 1498 __ Bind(&is_true);
1462 __ LoadObject(EAX, bool_true); 1499 __ LoadObject(EAX, bool_true);
1463 __ ret(); 1500 __ ret();
1464 return true; 1501 return true;
1465 } 1502 }
1466 1503
1467 #undef __ 1504 #undef __
1468 } // namespace dart 1505 } // namespace dart
1469 1506
1470 #endif // defined TARGET_ARCH_IA32 1507 #endif // defined TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/intrinsifier_x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698