| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 V(GrowableObjectArray, [], GrowableArray_getIndexed) \ | 71 V(GrowableObjectArray, [], GrowableArray_getIndexed) \ |
| 72 V(ImmutableArray, [], Array_getIndexed) \ | 72 V(ImmutableArray, [], Array_getIndexed) \ |
| 73 V(ImmutableArray, get:length, Array_getLength) \ | 73 V(ImmutableArray, get:length, Array_getLength) \ |
| 74 V(Math, sqrt, Math_sqrt) \ | 74 V(Math, sqrt, Math_sqrt) \ |
| 75 V(Object, ==, Object_equal) \ | 75 V(Object, ==, Object_equal) \ |
| 76 V(FixedSizeArrayIterator, next, FixedSizeArrayIterator_next) \ | 76 V(FixedSizeArrayIterator, next, FixedSizeArrayIterator_next) \ |
| 77 V(FixedSizeArrayIterator, hasNext, FixedSizeArrayIterator_hasNext) \ | 77 V(FixedSizeArrayIterator, hasNext, FixedSizeArrayIterator_hasNext) \ |
| 78 V(StringBase, get:length, String_getLength) \ | 78 V(StringBase, get:length, String_getLength) \ |
| 79 V(StringBase, charCodeAt, String_charCodeAt) \ | 79 V(StringBase, charCodeAt, String_charCodeAt) \ |
| 80 V(StringBase, hashCode, String_hashCode) \ | 80 V(StringBase, hashCode, String_hashCode) \ |
| 81 V(StringBase, isEmpty, String_isEmpty) \ |
| 81 | 82 |
| 82 #define __ assembler-> | 83 #define __ assembler-> |
| 83 | 84 |
| 84 static bool ObjectArray_Allocate(Assembler* assembler) { | 85 static bool ObjectArray_Allocate(Assembler* assembler) { |
| 85 // This snippet of inlined code uses the following registers: | 86 // This snippet of inlined code uses the following registers: |
| 86 // EAX, EBX, EDI | 87 // EAX, EBX, EDI |
| 87 // and the newly allocated object is returned in EAX. | 88 // and the newly allocated object is returned in EAX. |
| 88 const intptr_t kTypeArgumentsOffset = 2 * kWordSize; | 89 const intptr_t kTypeArgumentsOffset = 2 * kWordSize; |
| 89 const intptr_t kArrayLengthOffset = 1 * kWordSize; | 90 const intptr_t kArrayLengthOffset = 1 * kWordSize; |
| 90 Label fall_through; | 91 Label fall_through; |
| (...skipping 847 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 938 __ movl(EAX, Address(ESP, + 1 * kWordSize)); // String object. | 939 __ movl(EAX, Address(ESP, + 1 * kWordSize)); // String object. |
| 939 __ movl(EAX, FieldAddress(EAX, String::hash_offset())); | 940 __ movl(EAX, FieldAddress(EAX, String::hash_offset())); |
| 940 __ cmpl(EAX, Immediate(0)); | 941 __ cmpl(EAX, Immediate(0)); |
| 941 __ j(EQUAL, &fall_through, Assembler::kNearJump); | 942 __ j(EQUAL, &fall_through, Assembler::kNearJump); |
| 942 __ ret(); | 943 __ ret(); |
| 943 __ Bind(&fall_through); | 944 __ Bind(&fall_through); |
| 944 // Hash not yet computed. | 945 // Hash not yet computed. |
| 945 return false; | 946 return false; |
| 946 } | 947 } |
| 947 | 948 |
| 949 |
| 950 static bool String_isEmpty(Assembler* assembler) { |
| 951 Label is_true; |
| 952 const Bool& bool_true = Bool::ZoneHandle(Bool::True()); |
| 953 const Bool& bool_false = Bool::ZoneHandle(Bool::False()); |
| 954 // Get length. |
| 955 __ movl(EAX, Address(ESP, + 1 * kWordSize)); // String object. |
| 956 __ movl(EAX, FieldAddress(EAX, String::length_offset())); |
| 957 __ cmpl(EAX, Immediate(Smi::RawValue(0))); |
| 958 __ j(EQUAL, &is_true, Assembler::kNearJump); |
| 959 __ LoadObject(EAX, bool_false); |
| 960 __ ret(); |
| 961 __ Bind(&is_true); |
| 962 __ LoadObject(EAX, bool_true); |
| 963 __ ret(); |
| 964 return true; |
| 965 } |
| 966 |
| 948 #undef __ | 967 #undef __ |
| 949 | 968 |
| 950 | 969 |
| 951 bool Intrinsifier::Intrinsify(const Function& function, Assembler* assembler) { | 970 bool Intrinsifier::Intrinsify(const Function& function, Assembler* assembler) { |
| 952 if (!FLAG_intrinsify) return false; | 971 if (!FLAG_intrinsify) return false; |
| 953 const char* function_name = String::Handle(function.name()).ToCString(); | 972 const char* function_name = String::Handle(function.name()).ToCString(); |
| 954 const Class& function_class = Class::Handle(function.owner()); | 973 const Class& function_class = Class::Handle(function.owner()); |
| 955 const char* class_name = String::Handle(function_class.Name()).ToCString(); | 974 const char* class_name = String::Handle(function_class.Name()).ToCString(); |
| 956 #define FIND_INTRINSICS(test_class_name, test_function_name, destination) \ | 975 #define FIND_INTRINSICS(test_class_name, test_function_name, destination) \ |
| 957 if ((strcmp(#test_function_name, function_name) == 0) && \ | 976 if ((strcmp(#test_function_name, function_name) == 0) && \ |
| 958 (strcmp(#test_class_name, class_name) == 0)) { \ | 977 (strcmp(#test_class_name, class_name) == 0)) { \ |
| 959 return destination(assembler); \ | 978 return destination(assembler); \ |
| 960 } \ | 979 } \ |
| 961 | 980 |
| 962 INTRINSIC_LIST(FIND_INTRINSICS); | 981 INTRINSIC_LIST(FIND_INTRINSICS); |
| 963 #undef FIND_INTRINSICS | 982 #undef FIND_INTRINSICS |
| 964 return false; | 983 return false; |
| 965 } | 984 } |
| 966 | 985 |
| 967 } // namespace dart | 986 } // namespace dart |
| 968 | 987 |
| 969 #endif // defined TARGET_ARCH_IA32 | 988 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |