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

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

Issue 11794038: Bug fix and improvements to clamped arrays. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 11 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 566 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 __ cmpl(EBX, Immediate(0xFF)); 577 __ cmpl(EBX, Immediate(0xFF));
578 __ j(ABOVE, &fall_through, Assembler::kNearJump); 578 __ j(ABOVE, &fall_through, Assembler::kNearJump);
579 __ movb(FieldAddress(EAX, EDI, TIMES_1, Uint8Array::data_offset()), BL); 579 __ movb(FieldAddress(EAX, EDI, TIMES_1, Uint8Array::data_offset()), BL);
580 __ ret(); 580 __ ret();
581 __ Bind(&fall_through); 581 __ Bind(&fall_through);
582 return false; 582 return false;
583 } 583 }
584 584
585 585
586 bool Intrinsifier::UintClamped8Array_getIndexed(Assembler* assembler) { 586 bool Intrinsifier::UintClamped8Array_getIndexed(Assembler* assembler) {
587 return Uint8Array_setIndexed(assembler); 587 Label fall_through;
588 TestByteArrayIndex(assembler, &fall_through);
589 __ SmiUntag(EBX);
590 __ movzxb(EAX, FieldAddress(EAX,
591 EBX,
592 TIMES_1,
593 Uint8ClampedArray::data_offset()));
594 __ SmiTag(EAX);
595 __ ret();
596 __ Bind(&fall_through);
597 return false;
588 } 598 }
589 599
590 600
591 bool Intrinsifier::Uint8ClampedArray_setIndexed(Assembler* assembler) { 601 bool Intrinsifier::Uint8ClampedArray_setIndexed(Assembler* assembler) {
592 Label fall_through, store_value, load_0xff; 602 Label fall_through, store_value, load_0xff;
593 // Verify that the array index is valid. 603 // Verify that the array index is valid.
594 TestByteArraySetIndex(assembler, &fall_through); 604 TestByteArraySetIndex(assembler, &fall_through);
595 // After TestByteArraySetIndex: 605 // After TestByteArraySetIndex:
596 // * EAX has the base address of the byte array. 606 // * EAX has the base address of the byte array.
597 // * EBX has the index into the array. 607 // * EBX has the index into the array.
598 // EBX contains the SMI index which is shifted by 1. 608 // EBX contains the SMI index which is shifted by 1.
599 __ SmiUntag(EBX); 609 __ SmiUntag(EBX);
600 // Free EBX for the value since we want a byte register. 610 // Free EBX for the value since we need a byte register.
601 __ movl(EDI, EBX); 611 __ leal(EAX, FieldAddress(EAX, EBX, TIMES_1,
612 Uint8ClampedArray::data_offset()));
602 __ movl(EBX, Address(ESP, + 1 * kWordSize)); // Value. 613 __ movl(EBX, Address(ESP, + 1 * kWordSize)); // Value.
603 __ testl(EBX, Immediate(kSmiTagMask)); 614 __ testl(EBX, Immediate(kSmiTagMask));
604 __ j(NOT_ZERO, &fall_through, Assembler::kNearJump); 615 __ j(NOT_ZERO, &fall_through, Assembler::kNearJump);
605 616
606 __ SmiUntag(EBX); 617 __ SmiUntag(EBX);
607 __ cmpl(EBX, Immediate(0xFF)); 618 __ cmpl(EBX, Immediate(0xFF));
608 __ j(BELOW_EQUAL, &store_value, Assembler::kNearJump); 619 __ j(BELOW_EQUAL, &store_value, Assembler::kNearJump);
620 // Clamp to 0x00 or 0xFF respectively.
609 __ j(GREATER, &load_0xff, Assembler::kNearJump); 621 __ j(GREATER, &load_0xff, Assembler::kNearJump);
610 __ xorl(EBX, EBX); // Zero. 622 __ xorl(EBX, EBX); // Zero.
611 __ jmp(&store_value, Assembler::kNearJump); 623 __ jmp(&store_value, Assembler::kNearJump);
612 __ Bind(&load_0xff); 624 __ Bind(&load_0xff);
613 __ movl(EBX, Immediate(0xFF)); 625 __ movl(EBX, Immediate(0xFF));
614 626
615 __ Bind(&store_value); 627 __ Bind(&store_value);
616 __ movb(FieldAddress(EAX, EDI, TIMES_1, Uint8Array::data_offset()), BL); 628 __ movb(Address(EAX, 0), BL);
617 __ ret(); 629 __ ret();
618 __ Bind(&fall_through); 630 __ Bind(&fall_through);
619 return false; 631 return false;
620 } 632 }
621 633
622 634
623 bool Intrinsifier::Int16Array_getIndexed(Assembler* assembler) { 635 bool Intrinsifier::Int16Array_getIndexed(Assembler* assembler) {
624 Label fall_through; 636 Label fall_through;
625 TestByteArrayIndex(assembler, &fall_through); 637 TestByteArrayIndex(assembler, &fall_through);
626 __ movsxw(EAX, FieldAddress(EAX, 638 __ movsxw(EAX, FieldAddress(EAX,
(...skipping 1033 matching lines...) Expand 10 before | Expand all | Expand 10 after
1660 __ Bind(&is_true); 1672 __ Bind(&is_true);
1661 __ LoadObject(EAX, Bool::True()); 1673 __ LoadObject(EAX, Bool::True());
1662 __ ret(); 1674 __ ret();
1663 return true; 1675 return true;
1664 } 1676 }
1665 1677
1666 #undef __ 1678 #undef __
1667 } // namespace dart 1679 } // namespace dart
1668 1680
1669 #endif // defined TARGET_ARCH_IA32 1681 #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