| 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 // Class for intrinsifying functions. | 4 // Class for intrinsifying functions. |
| 5 | 5 |
| 6 #ifndef VM_INTRINSIFIER_H_ | 6 #ifndef VM_INTRINSIFIER_H_ |
| 7 #define VM_INTRINSIFIER_H_ | 7 #define VM_INTRINSIFIER_H_ |
| 8 | 8 |
| 9 #include "vm/allocation.h" | 9 #include "vm/allocation.h" |
| 10 | 10 |
| 11 namespace dart { | 11 namespace dart { |
| 12 | 12 |
| 13 // List of intrinsics: | 13 // List of intrinsics: |
| 14 // (class-name, function-name, intrinsification method, fingerprint). | 14 // (class-name, function-name, intrinsification method, fingerprint). |
| 15 // | 15 // |
| 16 // When adding a new function for intrinsification add a 0 as fingerprint, | 16 // When adding a new function for intrinsification add a 0 as fingerprint, |
| 17 // build and run to get the correct fingerprint from the mismatch error. | 17 // build and run to get the correct fingerprint from the mismatch error. |
| 18 #define CORE_LIB_INTRINSIC_LIST(V) \ | 18 #define CORE_LIB_INTRINSIC_LIST(V) \ |
| 19 V(_Smi, ~, Smi_bitNegate, 882629793) \ | 19 V(_Smi, ~, Smi_bitNegate, 882629793) \ |
| 20 V(_Double, >, Double_greaterThan, 301935359) \ | 20 V(_Double, >, Double_greaterThan, 498448864) \ |
| 21 V(_Double, >=, Double_greaterEqualThan, 1184528952) \ | 21 V(_Double, >=, Double_greaterEqualThan, 1322959863) \ |
| 22 V(_Double, <, Double_lessThan, 1596251333) \ | 22 V(_Double, <, Double_lessThan, 1595326820) \ |
| 23 V(_Double, <=, Double_lessEqualThan, 1184499161) \ | 23 V(_Double, <=, Double_lessEqualThan, 1322930072) \ |
| 24 V(_Double, ==, Double_equal, 1706047712) \ | 24 V(_Double, ==, Double_equal, 1012968674) \ |
| 25 V(_Double, +, Double_add, 210576655) \ | 25 V(_Double, +, Double_add, 407090160) \ |
| 26 V(_Double, -, Double_sub, 1605354741) \ | 26 V(_Double, -, Double_sub, 1801868246) \ |
| 27 V(_Double, *, Double_mul, 788270837) \ | 27 V(_Double, *, Double_mul, 984784342) \ |
| 28 V(_Double, /, Double_div, 1202831412) \ | 28 V(_Double, /, Double_div, 1399344917) \ |
| 29 V(_Double, get:isNaN, Double_getIsNaN, 54462366) \ | 29 V(_Double, get:isNaN, Double_getIsNaN, 54462366) \ |
| 30 V(_Double, get:isNegative, Double_getIsNegative, 54462366) \ | 30 V(_Double, get:isNegative, Double_getIsNegative, 54462366) \ |
| 31 V(_Double, _mulFromInteger, Double_mulFromInteger, 704314034) \ | 31 V(_Double, _mulFromInteger, Double_mulFromInteger, 550294258) \ |
| 32 V(_Double, .fromInteger, Double_fromInteger, 842078193) \ | 32 V(_Double, .fromInteger, Double_fromInteger, 842078193) \ |
| 33 V(_ObjectArray, ., ObjectArray_Allocate, 97987288) \ | 33 V(_ObjectArray, ., ObjectArray_Allocate, 97987288) \ |
| 34 V(_ObjectArray, get:length, Array_getLength, 405297088) \ | 34 V(_ObjectArray, get:length, Array_getLength, 405297088) \ |
| 35 V(_ObjectArray, [], Array_getIndexed, 71937385) \ | 35 V(_ObjectArray, [], Array_getIndexed, 71937385) \ |
| 36 V(_ObjectArray, []=, Array_setIndexed, 255863719) \ | 36 V(_ObjectArray, []=, Array_setIndexed, 255863719) \ |
| 37 V(_GrowableObjectArray, .withData, GrowableArray_Allocate, 816132033) \ | 37 V(_GrowableObjectArray, .withData, GrowableArray_Allocate, 816132033) \ |
| 38 V(_GrowableObjectArray, get:length, GrowableArray_getLength, 725548050) \ | 38 V(_GrowableObjectArray, get:length, GrowableArray_getLength, 725548050) \ |
| 39 V(_GrowableObjectArray, get:_capacity, GrowableArray_getCapacity, 725548050) \ | 39 V(_GrowableObjectArray, get:_capacity, GrowableArray_getCapacity, 725548050) \ |
| 40 V(_GrowableObjectArray, [], GrowableArray_getIndexed, 581838973) \ | 40 V(_GrowableObjectArray, [], GrowableArray_getIndexed, 581838973) \ |
| 41 V(_GrowableObjectArray, []=, GrowableArray_setIndexed, 1048007636) \ | 41 V(_GrowableObjectArray, []=, GrowableArray_setIndexed, 1048007636) \ |
| 42 V(_GrowableObjectArray, _setLength, GrowableArray_setLength, 796709584) \ | 42 V(_GrowableObjectArray, _setLength, GrowableArray_setLength, 796709584) \ |
| 43 V(_GrowableObjectArray, _setData, GrowableArray_setData, 629110947) \ | 43 V(_GrowableObjectArray, _setData, GrowableArray_setData, 629110947) \ |
| 44 V(_GrowableObjectArray, add, GrowableArray_add, 1904852879) \ | 44 V(_GrowableObjectArray, add, GrowableArray_add, 112207566) \ |
| 45 V(_ImmutableArray, [], ImmutableArray_getIndexed, 486821199) \ | 45 V(_ImmutableArray, [], ImmutableArray_getIndexed, 486821199) \ |
| 46 V(_ImmutableArray, get:length, ImmutableArray_getLength, 433698233) \ | 46 V(_ImmutableArray, get:length, ImmutableArray_getLength, 433698233) \ |
| 47 V(Object, ==, Object_equal, 2126897013) \ | 47 V(Object, ==, Object_equal, 2126867222) \ |
| 48 V(_StringBase, get:hashCode, String_getHashCode, 320803993) \ | 48 V(_StringBase, get:hashCode, String_getHashCode, 320803993) \ |
| 49 V(_StringBase, get:isEmpty, String_getIsEmpty, 1026765313) \ | 49 V(_StringBase, get:isEmpty, String_getIsEmpty, 110631520) \ |
| 50 V(_StringBase, get:length, String_getLength, 320803993) \ | 50 V(_StringBase, get:length, String_getLength, 320803993) \ |
| 51 V(_StringBase, codeUnitAt, String_codeUnitAt, 984449525) \ | 51 V(_StringBase, codeUnitAt, String_codeUnitAt, 984449525) \ |
| 52 V(_OneByteString, get:hashCode, OneByteString_getHashCode, 682660413) \ | 52 V(_OneByteString, get:hashCode, OneByteString_getHashCode, 682660413) \ |
| 53 V(_OneByteString, _substringUncheckedNative, \ | 53 V(_OneByteString, _substringUncheckedNative, \ |
| 54 OneByteString_substringUnchecked, 713121438) \ | 54 OneByteString_substringUnchecked, 713121438) \ |
| 55 V(_OneByteString, _setAt, OneByteString_setAt, 342452817) \ | 55 V(_OneByteString, _setAt, OneByteString_setAt, 342452817) \ |
| 56 V(_OneByteString, _allocate, OneByteString_allocate, 510754908) \ | 56 V(_OneByteString, _allocate, OneByteString_allocate, 510754908) \ |
| 57 | 57 |
| 58 #define CORE_INTEGER_LIB_INTRINSIC_LIST(V) \ | 58 #define CORE_INTEGER_LIB_INTRINSIC_LIST(V) \ |
| 59 V(_IntegerImplementation, _addFromInteger, Integer_addFromInteger, 726019207)\ | 59 V(_IntegerImplementation, _addFromInteger, Integer_addFromInteger, 726019207)\ |
| 60 V(_IntegerImplementation, +, Integer_add, 1768648592) \ | 60 V(_IntegerImplementation, +, Integer_add, 25837296) \ |
| 61 V(_IntegerImplementation, _subFromInteger, Integer_subFromInteger, 726019207)\ | 61 V(_IntegerImplementation, _subFromInteger, Integer_subFromInteger, 726019207)\ |
| 62 V(_IntegerImplementation, -, Integer_sub, 1292467582) \ | 62 V(_IntegerImplementation, -, Integer_sub, 1697139934) \ |
| 63 V(_IntegerImplementation, _mulFromInteger, Integer_mulFromInteger, 726019207)\ | 63 V(_IntegerImplementation, _mulFromInteger, Integer_mulFromInteger, 726019207)\ |
| 64 V(_IntegerImplementation, *, Integer_mul, 1853182047) \ | 64 V(_IntegerImplementation, *, Integer_mul, 110370751) \ |
| 65 V(_IntegerImplementation, %, Integer_modulo, 1211518976) \ | 65 V(_IntegerImplementation, %, Integer_modulo, 980686435) \ |
| 66 V(_IntegerImplementation, remainder, Integer_remainder, 1131753683) \ | 66 V(_IntegerImplementation, remainder, Integer_remainder, 1536426035) \ |
| 67 V(_IntegerImplementation, ~/, Integer_truncDivide, 142750059) \ | 67 V(_IntegerImplementation, ~/, Integer_truncDivide, 2059401166) \ |
| 68 V(_IntegerImplementation, unary-, Integer_negate, 676633254) \ | 68 V(_IntegerImplementation, unary-, Integer_negate, 675709702) \ |
| 69 V(_IntegerImplementation, _bitAndFromInteger, \ | 69 V(_IntegerImplementation, _bitAndFromInteger, \ |
| 70 Integer_bitAndFromInteger, 726019207) \ | 70 Integer_bitAndFromInteger, 726019207) \ |
| 71 V(_IntegerImplementation, &, Integer_bitAnd, 354347153) \ | 71 V(_IntegerImplementation, &, Integer_bitAnd, 759019505) \ |
| 72 V(_IntegerImplementation, _bitOrFromInteger, \ | 72 V(_IntegerImplementation, _bitOrFromInteger, \ |
| 73 Integer_bitOrFromInteger, 726019207) \ | 73 Integer_bitOrFromInteger, 726019207) \ |
| 74 V(_IntegerImplementation, |, Integer_bitOr, 875694946) \ | 74 V(_IntegerImplementation, |, Integer_bitOr, 1280367298) \ |
| 75 V(_IntegerImplementation, _bitXorFromInteger, \ | 75 V(_IntegerImplementation, _bitXorFromInteger, \ |
| 76 Integer_bitXorFromInteger, 726019207) \ | 76 Integer_bitXorFromInteger, 726019207) \ |
| 77 V(_IntegerImplementation, ^, Integer_bitXor, 282155459) \ | 77 V(_IntegerImplementation, ^, Integer_bitXor, 686827811) \ |
| 78 V(_IntegerImplementation, \ | 78 V(_IntegerImplementation, \ |
| 79 _greaterThanFromInteger, \ | 79 _greaterThanFromInteger, \ |
| 80 Integer_greaterThanFromInt, 79222670) \ | 80 Integer_greaterThanFromInt, 79222670) \ |
| 81 V(_IntegerImplementation, >, Integer_greaterThan, 462314913) \ | 81 V(_IntegerImplementation, >, Integer_greaterThan, 866987265) \ |
| 82 V(_IntegerImplementation, ==, Integer_equal, 1424765465) \ | 82 V(_IntegerImplementation, ==, Integer_equal, 1763184121) \ |
| 83 V(_IntegerImplementation, _equalToInteger, Integer_equalToInteger, 79222670) \ | 83 V(_IntegerImplementation, _equalToInteger, Integer_equalToInteger, 79222670) \ |
| 84 V(_IntegerImplementation, <, Integer_lessThan, 1424838471) \ | 84 V(_IntegerImplementation, <, Integer_lessThan, 1423913958) \ |
| 85 V(_IntegerImplementation, <=, Integer_lessEqualThan, 949016155) \ | 85 V(_IntegerImplementation, <=, Integer_lessEqualThan, 1087447066) \ |
| 86 V(_IntegerImplementation, >=, Integer_greaterEqualThan, 949045946) \ | 86 V(_IntegerImplementation, >=, Integer_greaterEqualThan, 1087476857) \ |
| 87 V(_IntegerImplementation, <<, Integer_shl, 1195917829) \ | 87 V(_IntegerImplementation, <<, Integer_shl, 1600590181) \ |
| 88 V(_IntegerImplementation, >>, Integer_sar, 1980227743) \ | 88 V(_IntegerImplementation, >>, Integer_sar, 237416447) \ |
| 89 V(_Double, toInt, Double_toInt, 362666636) | 89 V(_Double, toInt, Double_toInt, 362666636) |
| 90 | 90 |
| 91 | 91 |
| 92 #define MATH_LIB_INTRINSIC_LIST(V) \ | 92 #define MATH_LIB_INTRINSIC_LIST(V) \ |
| 93 V(::, sqrt, Math_sqrt, 1662640002) \ | 93 V(::, sqrt, Math_sqrt, 1662640002) \ |
| 94 V(::, sin, Math_sin, 1273932041) \ | 94 V(::, sin, Math_sin, 1273932041) \ |
| 95 V(::, cos, Math_cos, 1749547468) \ | 95 V(::, cos, Math_cos, 1749547468) \ |
| 96 V(_Random, _nextState, Random_nextState, 77315414) \ | 96 V(_Random, _nextState, Random_nextState, 287494804) \ |
| 97 | 97 |
| 98 | 98 |
| 99 #define TYPED_DATA_LIB_INTRINSIC_LIST(V) \ | 99 #define TYPED_DATA_LIB_INTRINSIC_LIST(V) \ |
| 100 V(_TypedList, get:length, TypedData_getLength, 1004567191) \ | 100 V(_TypedList, get:length, TypedData_getLength, 1004567191) \ |
| 101 V(_Int8Array, _new, TypedData_Int8Array_new, 48970297) \ | 101 V(_Int8Array, _new, TypedData_Int8Array_new, 48970297) \ |
| 102 V(_Uint8Array, _new, TypedData_Uint8Array_new, 389788863) \ | 102 V(_Uint8Array, _new, TypedData_Uint8Array_new, 389788863) \ |
| 103 V(_Uint8ClampedArray, _new, TypedData_Uint8ClampedArray_new, 59021935) \ | 103 V(_Uint8ClampedArray, _new, TypedData_Uint8ClampedArray_new, 59021935) \ |
| 104 V(_Int16Array, _new, TypedData_Int16Array_new, 465688649) \ | 104 V(_Int16Array, _new, TypedData_Int16Array_new, 465688649) \ |
| 105 V(_Uint16Array, _new, TypedData_Uint16Array_new, 169304657) \ | 105 V(_Uint16Array, _new, TypedData_Uint16Array_new, 169304657) \ |
| 106 V(_Int32Array, _new, TypedData_Int32Array_new, 947562951) \ | 106 V(_Int32Array, _new, TypedData_Int32Array_new, 947562951) \ |
| 107 V(_Uint32Array, _new, TypedData_Uint32Array_new, 85066537) \ | 107 V(_Uint32Array, _new, TypedData_Uint32Array_new, 85066537) \ |
| 108 V(_Int64Array, _new, TypedData_Int64Array_new, 775415132) \ | 108 V(_Int64Array, _new, TypedData_Int64Array_new, 775415132) \ |
| 109 V(_Uint64Array, _new, TypedData_Uint64Array_new, 536384146) \ | 109 V(_Uint64Array, _new, TypedData_Uint64Array_new, 536384146) \ |
| 110 V(_Float32Array, _new, TypedData_Float32Array_new, 723829075) \ | 110 V(_Float32Array, _new, TypedData_Float32Array_new, 723829075) \ |
| 111 V(_Float64Array, _new, TypedData_Float64Array_new, 111654177) \ | 111 V(_Float64Array, _new, TypedData_Float64Array_new, 111654177) \ |
| 112 V(_Float32x4Array, _new, TypedData_Float32x4Array_new, 984763738) \ | 112 V(_Float32x4Array, _new, TypedData_Float32x4Array_new, 984763738) \ |
| 113 V(_Int8Array, ., TypedData_Int8Array_factory, 1168404493) \ | 113 V(_Int8Array, ., TypedData_Int8Array_factory, 1139775342) \ |
| 114 V(_Uint8Array, ., TypedData_Uint8Array_factory, 2094565809) \ | 114 V(_Uint8Array, ., TypedData_Uint8Array_factory, 2065936658) \ |
| 115 V(_Uint8ClampedArray, ., TypedData_Uint8ClampedArray_factory, 1449285088) \ | 115 V(_Uint8ClampedArray, ., TypedData_Uint8ClampedArray_factory, 1420655937) \ |
| 116 V(_Int16Array, ., TypedData_Int16Array_factory, 1430476167) \ | 116 V(_Int16Array, ., TypedData_Int16Array_factory, 1401847016) \ |
| 117 V(_Uint16Array, ., TypedData_Uint16Array_factory, 996241892) \ | 117 V(_Uint16Array, ., TypedData_Uint16Array_factory, 967612741) \ |
| 118 V(_Int32Array, ., TypedData_Int32Array_factory, 360797715) \ | 118 V(_Int32Array, ., TypedData_Int32Array_factory, 332168564) \ |
| 119 V(_Uint32Array, ., TypedData_Uint32Array_factory, 995053409) \ | 119 V(_Uint32Array, ., TypedData_Uint32Array_factory, 966424258) \ |
| 120 V(_Int64Array, ., TypedData_Int64Array_factory, 570248142) \ | 120 V(_Int64Array, ., TypedData_Int64Array_factory, 541618991) \ |
| 121 V(_Uint64Array, ., TypedData_Uint64Array_factory, 1114332856) \ | 121 V(_Uint64Array, ., TypedData_Uint64Array_factory, 1085703705) \ |
| 122 V(_Float32Array, ., TypedData_Float32Array_factory, 1719636031) \ | 122 V(_Float32Array, ., TypedData_Float32Array_factory, 1691006880) \ |
| 123 V(_Float64Array, ., TypedData_Float64Array_factory, 1896334311) \ | 123 V(_Float64Array, ., TypedData_Float64Array_factory, 1867705160) \ |
| 124 V(_Float32x4Array, ., TypedData_Float32x4Array_factory, 1768466392) \ | 124 V(_Float32x4Array, ., TypedData_Float32x4Array_factory, 1739837241) \ |
| 125 | 125 |
| 126 // TODO(srdjan): Implement _FixedSizeArrayIterator, get:current and | 126 // TODO(srdjan): Implement _FixedSizeArrayIterator, get:current and |
| 127 // _FixedSizeArrayIterator, moveNext. | 127 // _FixedSizeArrayIterator, moveNext. |
| 128 | 128 |
| 129 // Forward declarations. | 129 // Forward declarations. |
| 130 class Assembler; | 130 class Assembler; |
| 131 class Function; | 131 class Function; |
| 132 | 132 |
| 133 class Intrinsifier : public AllStatic { | 133 class Intrinsifier : public AllStatic { |
| 134 public: | 134 public: |
| (...skipping 12 matching lines...) Expand all Loading... |
| 147 CORE_INTEGER_LIB_INTRINSIC_LIST(DECLARE_FUNCTION) | 147 CORE_INTEGER_LIB_INTRINSIC_LIST(DECLARE_FUNCTION) |
| 148 MATH_LIB_INTRINSIC_LIST(DECLARE_FUNCTION) | 148 MATH_LIB_INTRINSIC_LIST(DECLARE_FUNCTION) |
| 149 TYPED_DATA_LIB_INTRINSIC_LIST(DECLARE_FUNCTION) | 149 TYPED_DATA_LIB_INTRINSIC_LIST(DECLARE_FUNCTION) |
| 150 | 150 |
| 151 #undef DECLARE_FUNCTION | 151 #undef DECLARE_FUNCTION |
| 152 }; | 152 }; |
| 153 | 153 |
| 154 } // namespace dart | 154 } // namespace dart |
| 155 | 155 |
| 156 #endif // VM_INTRINSIFIER_H_ | 156 #endif // VM_INTRINSIFIER_H_ |
| OLD | NEW |