| 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 // 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 969 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 980 __ SmiUntag(EBX); | 980 __ SmiUntag(EBX); |
| 981 __ movl(EAX, FieldAddress(EAX, ExternalUint8Array::data_offset())); | 981 __ movl(EAX, FieldAddress(EAX, ExternalUint8Array::data_offset())); |
| 982 __ movzxb(EAX, Address(EAX, EBX, TIMES_1, 0)); | 982 __ movzxb(EAX, Address(EAX, EBX, TIMES_1, 0)); |
| 983 __ SmiTag(EAX); | 983 __ SmiTag(EAX); |
| 984 __ ret(); | 984 __ ret(); |
| 985 __ Bind(&fall_through); | 985 __ Bind(&fall_through); |
| 986 return false; | 986 return false; |
| 987 } | 987 } |
| 988 | 988 |
| 989 | 989 |
| 990 bool Intrinsifier::ExternalUint8ClampedArray_getIndexed(Assembler* assembler) { |
| 991 Label fall_through; |
| 992 TestByteArrayGetIndex(assembler, &fall_through); |
| 993 // EBX: index as Smi. |
| 994 // EAX: array. |
| 995 __ SmiUntag(EBX); |
| 996 __ movl(EAX, FieldAddress(EAX, ExternalUint8ClampedArray::data_offset())); |
| 997 __ movzxb(EAX, Address(EAX, EBX, TIMES_1, 0)); |
| 998 __ SmiTag(EAX); |
| 999 __ ret(); |
| 1000 __ Bind(&fall_through); |
| 1001 return false; |
| 1002 } |
| 1003 |
| 1004 |
| 1005 bool Intrinsifier::ExternalUint8ClampedArray_setIndexed(Assembler* assembler) { |
| 1006 Label fall_through, store_value, load_0xff; |
| 1007 TestByteArraySetIndex(assembler, &fall_through); |
| 1008 // EBX: index as Smi. |
| 1009 // EAX: array. |
| 1010 __ SmiUntag(EBX); |
| 1011 __ movl(EAX, FieldAddress(EAX, ExternalUint8ClampedArray::data_offset())); |
| 1012 // Free EBX for the value since we need a byte register. |
| 1013 __ leal(EAX, Address(EAX, EBX, TIMES_1, 0)); |
| 1014 __ movl(EBX, Address(ESP, + 1 * kWordSize)); // Value. |
| 1015 __ testl(EBX, Immediate(kSmiTagMask)); |
| 1016 __ j(NOT_ZERO, &fall_through, Assembler::kNearJump); |
| 1017 |
| 1018 __ SmiUntag(EBX); |
| 1019 __ cmpl(EBX, Immediate(0xFF)); |
| 1020 __ j(BELOW_EQUAL, &store_value, Assembler::kNearJump); |
| 1021 // Clamp to 0x00 or 0xFF respectively. |
| 1022 __ j(GREATER, &load_0xff, Assembler::kNearJump); |
| 1023 __ xorl(EBX, EBX); // Zero. |
| 1024 __ jmp(&store_value, Assembler::kNearJump); |
| 1025 __ Bind(&load_0xff); |
| 1026 __ movl(EBX, Immediate(0xFF)); |
| 1027 |
| 1028 __ Bind(&store_value); |
| 1029 __ movb(Address(EAX, 0), BL); |
| 1030 __ ret(); |
| 1031 __ Bind(&fall_through); |
| 1032 return false; |
| 1033 } |
| 1034 |
| 1035 |
| 990 // Tests if two top most arguments are smis, jumps to label not_smi if not. | 1036 // Tests if two top most arguments are smis, jumps to label not_smi if not. |
| 991 // Topmost argument is in EAX. | 1037 // Topmost argument is in EAX. |
| 992 static void TestBothArgumentsSmis(Assembler* assembler, Label* not_smi) { | 1038 static void TestBothArgumentsSmis(Assembler* assembler, Label* not_smi) { |
| 993 __ movl(EAX, Address(ESP, + 1 * kWordSize)); | 1039 __ movl(EAX, Address(ESP, + 1 * kWordSize)); |
| 994 __ movl(EBX, Address(ESP, + 2 * kWordSize)); | 1040 __ movl(EBX, Address(ESP, + 2 * kWordSize)); |
| 995 __ orl(EBX, EAX); | 1041 __ orl(EBX, EAX); |
| 996 __ testl(EBX, Immediate(kSmiTagMask)); | 1042 __ testl(EBX, Immediate(kSmiTagMask)); |
| 997 __ j(NOT_ZERO, not_smi, Assembler::kNearJump); | 1043 __ j(NOT_ZERO, not_smi, Assembler::kNearJump); |
| 998 } | 1044 } |
| 999 | 1045 |
| (...skipping 825 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1825 __ Bind(&is_true); | 1871 __ Bind(&is_true); |
| 1826 __ LoadObject(EAX, Bool::True()); | 1872 __ LoadObject(EAX, Bool::True()); |
| 1827 __ ret(); | 1873 __ ret(); |
| 1828 return true; | 1874 return true; |
| 1829 } | 1875 } |
| 1830 | 1876 |
| 1831 #undef __ | 1877 #undef __ |
| 1832 } // namespace dart | 1878 } // namespace dart |
| 1833 | 1879 |
| 1834 #endif // defined TARGET_ARCH_IA32 | 1880 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |