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(_IntegerImplementation, _addFromInteger, Integer_addFromInteger, 726019207)\ | 19 V(_IntegerImplementation, _addFromInteger, Integer_addFromInteger, 726019207)\ |
20 V(_IntegerImplementation, +, Integer_add, 959303888) \ | 20 V(_IntegerImplementation, +, Integer_add, 25837296) \ |
21 V(_IntegerImplementation, _subFromInteger, Integer_subFromInteger, 726019207)\ | 21 V(_IntegerImplementation, _subFromInteger, Integer_subFromInteger, 726019207)\ |
22 V(_IntegerImplementation, -, Integer_sub, 483122878) \ | 22 V(_IntegerImplementation, -, Integer_sub, 1697139934) \ |
23 V(_IntegerImplementation, _mulFromInteger, Integer_mulFromInteger, 726019207)\ | 23 V(_IntegerImplementation, _mulFromInteger, Integer_mulFromInteger, 726019207)\ |
24 V(_IntegerImplementation, *, Integer_mul, 1043837343) \ | 24 V(_IntegerImplementation, *, Integer_mul, 110370751) \ |
25 V(_IntegerImplementation, %, Integer_modulo, 2027609817) \ | 25 V(_IntegerImplementation, %, Integer_modulo, 108639519) \ |
26 V(_IntegerImplementation, ~/, Integer_truncDivide, 958840900) \ | 26 V(_IntegerImplementation, ~/, Integer_truncDivide, 1187354250) \ |
27 V(_IntegerImplementation, unary-, Integer_negate, 678480358) \ | 27 V(_IntegerImplementation, unary-, Integer_negate, 675709702) \ |
28 V(_IntegerImplementation, _bitAndFromInteger, \ | 28 V(_IntegerImplementation, _bitAndFromInteger, \ |
29 Integer_bitAndFromInteger, 726019207) \ | 29 Integer_bitAndFromInteger, 726019207) \ |
30 V(_IntegerImplementation, &, Integer_bitAnd, 1692486097) \ | 30 V(_IntegerImplementation, &, Integer_bitAnd, 759019505) \ |
31 V(_IntegerImplementation, _bitOrFromInteger, \ | 31 V(_IntegerImplementation, _bitOrFromInteger, \ |
32 Integer_bitOrFromInteger, 726019207) \ | 32 Integer_bitOrFromInteger, 726019207) \ |
33 V(_IntegerImplementation, |, Integer_bitOr, 66350242) \ | 33 V(_IntegerImplementation, |, Integer_bitOr, 1280367298) \ |
34 V(_IntegerImplementation, _bitXorFromInteger, \ | 34 V(_IntegerImplementation, _bitXorFromInteger, \ |
35 Integer_bitXorFromInteger, 726019207) \ | 35 Integer_bitXorFromInteger, 726019207) \ |
36 V(_IntegerImplementation, ^, Integer_bitXor, 1620294403) \ | 36 V(_IntegerImplementation, ^, Integer_bitXor, 686827811) \ |
37 V(_IntegerImplementation, \ | 37 V(_IntegerImplementation, \ |
38 _greaterThanFromInteger, \ | 38 _greaterThanFromInteger, \ |
39 Integer_greaterThanFromInt, 79222670) \ | 39 Integer_greaterThanFromInt, 79222670) \ |
40 V(_IntegerImplementation, >, Integer_greaterThan, 1800453857) \ | 40 V(_IntegerImplementation, >, Integer_greaterThan, 866987265) \ |
41 V(_IntegerImplementation, ==, Integer_equal, 1540405784) \ | 41 V(_IntegerImplementation, ==, Integer_equal, 408178104) \ |
42 V(_IntegerImplementation, _equalToInteger, Integer_equalToInteger, 79222670) \ | 42 V(_IntegerImplementation, _equalToInteger, Integer_equalToInteger, 79222670) \ |
43 V(_IntegerImplementation, <, Integer_lessThan, 1426685575) \ | 43 V(_IntegerImplementation, <, Integer_lessThan, 1423914919) \ |
44 V(_IntegerImplementation, <=, Integer_lessEqualThan, 1065121761) \ | 44 V(_IntegerImplementation, <=, Integer_lessEqualThan, 890963352) \ |
45 V(_IntegerImplementation, >=, Integer_greaterEqualThan, 1065151552) \ | 45 V(_IntegerImplementation, >=, Integer_greaterEqualThan, 890993143) \ |
46 V(_IntegerImplementation, <<, Integer_shl, 386573125) \ | 46 V(_IntegerImplementation, <<, Integer_shl, 1600590181) \ |
47 V(_IntegerImplementation, >>, Integer_sar, 1170883039) \ | 47 V(_IntegerImplementation, >>, Integer_sar, 237416447) \ |
48 V(_Smi, ~, Smi_bitNegate, 882629793) \ | 48 V(_Smi, ~, Smi_bitNegate, 882629793) \ |
49 V(_Double, >, Double_greaterThan, 2056391997) \ | 49 V(_Double, >, Double_greaterThan, 498448864) \ |
50 V(_Double, >=, Double_greaterEqualThan, 1300634558) \ | 50 V(_Double, >=, Double_greaterEqualThan, 1126476149) \ |
51 V(_Double, <, Double_lessThan, 1598098437) \ | 51 V(_Double, <, Double_lessThan, 1595327781) \ |
52 V(_Double, <=, Double_lessEqualThan, 1300604767) \ | 52 V(_Double, <=, Double_lessEqualThan, 1126446358) \ |
53 V(_Double, ==, Double_equal, 1206706717) \ | 53 V(_Double, ==, Double_equal, 48480576) \ |
54 V(_Double, +, Double_add, 1965033293) \ | 54 V(_Double, +, Double_add, 407090160) \ |
55 V(_Double, -, Double_sub, 1212327731) \ | 55 V(_Double, -, Double_sub, 1801868246) \ |
56 V(_Double, *, Double_mul, 395243827) \ | 56 V(_Double, *, Double_mul, 984784342) \ |
57 V(_Double, /, Double_div, 809804402) \ | 57 V(_Double, /, Double_div, 1399344917) \ |
58 V(_Double, get:isNaN, Double_getIsNaN, 54462366) \ | 58 V(_Double, get:isNaN, Double_getIsNaN, 54462366) \ |
59 V(_Double, get:isNegative, Double_getIsNegative, 54462366) \ | 59 V(_Double, get:isNegative, Double_getIsNegative, 54462366) \ |
60 V(_Double, _mulFromInteger, Double_mulFromInteger, 815838159) \ | 60 V(_Double, _mulFromInteger, Double_mulFromInteger, 353781714) \ |
61 V(_Double, .fromInteger, Double_fromInteger, 842078193) \ | 61 V(_Double, .fromInteger, Double_fromInteger, 842078193) \ |
62 V(_Double, toInt, Double_toInt, 362666636) \ | 62 V(_Double, toInt, Double_toInt, 362666636) \ |
63 V(_ObjectArray, ., ObjectArray_Allocate, 97987288) \ | 63 V(_ObjectArray, ., ObjectArray_Allocate, 97987288) \ |
64 V(_ObjectArray, get:length, Array_getLength, 405297088) \ | 64 V(_ObjectArray, get:length, Array_getLength, 405297088) \ |
65 V(_ObjectArray, [], Array_getIndexed, 71937385) \ | 65 V(_ObjectArray, [], Array_getIndexed, 71937385) \ |
66 V(_ObjectArray, []=, Array_setIndexed, 255863719) \ | 66 V(_ObjectArray, []=, Array_setIndexed, 255863719) \ |
67 V(_GrowableObjectArray, .withData, GrowableArray_Allocate, 816132033) \ | 67 V(_GrowableObjectArray, .withData, GrowableArray_Allocate, 816132033) \ |
68 V(_GrowableObjectArray, get:length, GrowableArray_getLength, 725548050) \ | 68 V(_GrowableObjectArray, get:length, GrowableArray_getLength, 725548050) \ |
69 V(_GrowableObjectArray, get:_capacity, GrowableArray_getCapacity, 725548050) \ | 69 V(_GrowableObjectArray, get:_capacity, GrowableArray_getCapacity, 725548050) \ |
70 V(_GrowableObjectArray, [], GrowableArray_getIndexed, 581838973) \ | 70 V(_GrowableObjectArray, [], GrowableArray_getIndexed, 581838973) \ |
71 V(_GrowableObjectArray, []=, GrowableArray_setIndexed, 1048007636) \ | 71 V(_GrowableObjectArray, []=, GrowableArray_setIndexed, 1048007636) \ |
72 V(_GrowableObjectArray, _setLength, GrowableArray_setLength, 796709584) \ | 72 V(_GrowableObjectArray, _setLength, GrowableArray_setLength, 796709584) \ |
73 V(_GrowableObjectArray, _setData, GrowableArray_setData, 629110947) \ | 73 V(_GrowableObjectArray, _setData, GrowableArray_setData, 629110947) \ |
74 V(_GrowableObjectArray, add, GrowableArray_add, 1367698386) \ | 74 V(_GrowableObjectArray, add, GrowableArray_add, 2139340847) \ |
75 V(_ImmutableArray, [], ImmutableArray_getIndexed, 486821199) \ | 75 V(_ImmutableArray, [], ImmutableArray_getIndexed, 486821199) \ |
76 V(_ImmutableArray, get:length, ImmutableArray_getLength, 433698233) \ | 76 V(_ImmutableArray, get:length, ImmutableArray_getLength, 433698233) \ |
77 V(Object, ==, Object_equal, 2126956595) \ | 77 V(Object, ==, Object_equal, 2126867222) \ |
78 V(_StringBase, get:hashCode, String_getHashCode, 320803993) \ | 78 V(_StringBase, get:hashCode, String_getHashCode, 320803993) \ |
79 V(_StringBase, get:isEmpty, String_getIsEmpty, 711547329) \ | 79 V(_StringBase, get:isEmpty, String_getIsEmpty, 110632481) \ |
80 V(_StringBase, get:length, String_getLength, 320803993) \ | 80 V(_StringBase, get:length, String_getLength, 320803993) \ |
81 V(_StringBase, codeUnitAt, String_codeUnitAt, 984449525) \ | 81 V(_StringBase, codeUnitAt, String_codeUnitAt, 984449525) \ |
82 V(_OneByteString, get:hashCode, OneByteString_getHashCode, 682660413) \ | 82 V(_OneByteString, get:hashCode, OneByteString_getHashCode, 682660413) \ |
83 | 83 |
84 | 84 |
85 #define MATH_LIB_INTRINSIC_LIST(V) \ | 85 #define MATH_LIB_INTRINSIC_LIST(V) \ |
86 V(::, sqrt, Math_sqrt, 1662640002) \ | 86 V(::, sqrt, Math_sqrt, 1662640002) \ |
87 V(::, sin, Math_sin, 1273932041) \ | 87 V(::, sin, Math_sin, 1273932041) \ |
88 V(::, cos, Math_cos, 1749547468) \ | 88 V(::, cos, Math_cos, 1749547468) \ |
89 | 89 |
90 | 90 |
91 // Note that any intrinsified function is not inlined. Some optimizations | 91 // Note that any intrinsified function is not inlined. Some optimizations |
92 // rely on seeing the factories below instead of their inlined code. | 92 // rely on seeing the factories below instead of their inlined code. |
93 #define SCALARLIST_LIB_INTRINSIC_LIST(V) \ | 93 #define SCALARLIST_LIB_INTRINSIC_LIST(V) \ |
94 V(_ByteArrayBase, get:length, ByteArrayBase_getLength, 1098081765) \ | 94 V(_ByteArrayBase, get:length, ByteArrayBase_getLength, 1095311202) \ |
95 V(_Int64Array, [], Int64Array_getIndexed, 504894128) \ | 95 V(_Int64Array, [], Int64Array_getIndexed, 419006675) \ |
96 V(_Uint64Array, [], Uint64Array_getIndexed, 31272531) \ | 96 V(_Uint64Array, [], Uint64Array_getIndexed, 2092868726) \ |
97 V(_Int8Array, _new, Int8Array_new, 535958453) \ | 97 V(_Int8Array, _new, Int8Array_new, 535958453) \ |
98 V(_Uint8Array, _new, Uint8Array_new, 604355565) \ | 98 V(_Uint8Array, _new, Uint8Array_new, 604355565) \ |
99 V(_Uint8ClampedArray, _new, Uint8ClampedArray_new, 1070949952) \ | 99 V(_Uint8ClampedArray, _new, Uint8ClampedArray_new, 1070949952) \ |
100 V(_Int16Array, _new, Int16Array_new, 903723993) \ | 100 V(_Int16Array, _new, Int16Array_new, 903723993) \ |
101 V(_Uint16Array, _new, Uint16Array_new, 133542762) \ | 101 V(_Uint16Array, _new, Uint16Array_new, 133542762) \ |
102 V(_Int32Array, _new, Int32Array_new, 8218286) \ | 102 V(_Int32Array, _new, Int32Array_new, 8218286) \ |
103 V(_Uint32Array, _new, Uint32Array_new, 469402161) \ | 103 V(_Uint32Array, _new, Uint32Array_new, 469402161) \ |
104 V(_Int64Array, _new, Int64Array_new, 60605075) \ | 104 V(_Int64Array, _new, Int64Array_new, 60605075) \ |
105 V(_Uint64Array, _new, Uint64Array_new, 624354107) \ | 105 V(_Uint64Array, _new, Uint64Array_new, 624354107) \ |
106 V(_Float32Array, _new, Float32Array_new, 109944959) \ | 106 V(_Float32Array, _new, Float32Array_new, 109944959) \ |
107 V(_Float64Array, _new, Float64Array_new, 147668392) \ | 107 V(_Float64Array, _new, Float64Array_new, 147668392) \ |
108 V(Int8List, ., Int8Array_factory, 817410959) \ | 108 V(Int8List, ., Int8Array_factory, 216496111) \ |
109 V(Uint8List, ., Uint8Array_factory, 220896178) \ | 109 V(Uint8List, ., Uint8Array_factory, 1767464978) \ |
110 V(Uint8ClampedList, ., Uint8ClampedArray_factory, 422034060) \ | 110 V(Uint8ClampedList, ., Uint8ClampedArray_factory, 1968602860) \ |
111 V(Int16List, ., Int16Array_factory, 214246025) \ | 111 V(Int16List, ., Int16Array_factory, 1760814825) \ |
112 V(Uint16List, ., Uint16Array_factory, 137929963) \ | 112 V(Uint16List, ., Uint16Array_factory, 1684498763) \ |
113 V(Int32List, ., Int32Array_factory, 1977571010) \ | 113 V(Int32List, ., Int32Array_factory, 1376656162) \ |
114 V(Uint32List, ., Uint32Array_factory, 407638944) \ | 114 V(Uint32List, ., Uint32Array_factory, 1954207744) \ |
115 V(Int64List, ., Int64Array_factory, 885130273) \ | 115 V(Int64List, ., Int64Array_factory, 284215425) \ |
116 V(Uint64List, ., Uint64Array_factory, 1471017221) \ | 116 V(Uint64List, ., Uint64Array_factory, 870102373) \ |
117 V(Float32List, ., Float32Array_factory, 2035252095) \ | 117 V(Float32List, ., Float32Array_factory, 1434337247) \ |
118 V(Float64List, ., Float64Array_factory, 1037441059) \ | 118 V(Float64List, ., Float64Array_factory, 436526211) \ |
119 | 119 |
120 #define TYPEDDATA_LIB_INTRINSIC_LIST(V) \ | 120 #define TYPEDDATA_LIB_INTRINSIC_LIST(V) \ |
121 V(_TypedList, get:length, TypedData_getLength, 231908172) \ | 121 V(_TypedList, get:length, TypedData_getLength, 231908172) \ |
122 V(_Int8Array, _new, TypedData_Int8Array_new, 844274443) \ | 122 V(_Int8Array, _new, TypedData_Int8Array_new, 844274443) \ |
123 V(_Uint8Array, _new, TypedData_Uint8Array_new, 997951645) \ | 123 V(_Uint8Array, _new, TypedData_Uint8Array_new, 997951645) \ |
124 V(_Uint8ClampedArray, _new, TypedData_Uint8ClampedArray_new, 1025045044) \ | 124 V(_Uint8ClampedArray, _new, TypedData_Uint8ClampedArray_new, 1025045044) \ |
125 V(_Int16Array, _new, TypedData_Int16Array_new, 1064563368) \ | 125 V(_Int16Array, _new, TypedData_Int16Array_new, 1064563368) \ |
126 V(_Uint16Array, _new, TypedData_Uint16Array_new, 110927177) \ | 126 V(_Uint16Array, _new, TypedData_Uint16Array_new, 110927177) \ |
127 V(_Int32Array, _new, TypedData_Int32Array_new, 770802406) \ | 127 V(_Int32Array, _new, TypedData_Int32Array_new, 770802406) \ |
128 V(_Uint32Array, _new, TypedData_Uint32Array_new, 856841876) \ | 128 V(_Uint32Array, _new, TypedData_Uint32Array_new, 856841876) \ |
129 V(_Int64Array, _new, TypedData_Int64Array_new, 941769528) \ | 129 V(_Int64Array, _new, TypedData_Int64Array_new, 941769528) \ |
130 V(_Uint64Array, _new, TypedData_Uint64Array_new, 977566635) \ | 130 V(_Uint64Array, _new, TypedData_Uint64Array_new, 977566635) \ |
131 V(_Float32Array, _new, TypedData_Float32Array_new, 1053133615) \ | 131 V(_Float32Array, _new, TypedData_Float32Array_new, 1053133615) \ |
132 V(_Float64Array, _new, TypedData_Float64Array_new, 936673303) \ | 132 V(_Float64Array, _new, TypedData_Float64Array_new, 936673303) \ |
133 V(_Int8Array, ., TypedData_Int8Array_factory, 1852699666) \ | 133 V(_Int8Array, ., TypedData_Int8Array_factory, 632939448) \ |
134 V(_Uint8Array, ., TypedData_Uint8Array_factory, 1014667000) \ | 134 V(_Uint8Array, ., TypedData_Uint8Array_factory, 1942390430) \ |
135 V(_Uint8ClampedArray, ., TypedData_Uint8ClampedArray_factory, 519376744) \ | 135 V(_Uint8ClampedArray, ., TypedData_Uint8ClampedArray_factory, 1447100174) \ |
136 V(_Int16Array, ., TypedData_Int16Array_factory, 1069515268) \ | 136 V(_Int16Array, ., TypedData_Int16Array_factory, 1997238698) \ |
137 V(_Uint16Array, ., TypedData_Uint16Array_factory, 1892182763) \ | 137 V(_Uint16Array, ., TypedData_Uint16Array_factory, 672422545) \ |
138 V(_Int32Array, ., TypedData_Int32Array_factory, 1724127394) \ | 138 V(_Int32Array, ., TypedData_Int32Array_factory, 504367176) \ |
139 V(_Uint32Array, ., TypedData_Uint32Array_factory, 1251657079) \ | 139 V(_Uint32Array, ., TypedData_Uint32Array_factory, 31896861) \ |
140 V(_Int64Array, ., TypedData_Int64Array_factory, 1922050636) \ | 140 V(_Int64Array, ., TypedData_Int64Array_factory, 702290418) \ |
141 V(_Uint64Array, ., TypedData_Uint64Array_factory, 1279581075) \ | 141 V(_Uint64Array, ., TypedData_Uint64Array_factory, 59820857) \ |
142 V(_Float32Array, ., TypedData_Float32Array_factory, 112704438) \ | 142 V(_Float32Array, ., TypedData_Float32Array_factory, 1040427868) \ |
143 V(_Float64Array, ., TypedData_Float64Array_factory, 41426340) \ | 143 V(_Float64Array, ., TypedData_Float64Array_factory, 969149770) \ |
144 | 144 |
145 // TODO(srdjan): Implement _FixedSizeArrayIterator, get:current and | 145 // TODO(srdjan): Implement _FixedSizeArrayIterator, get:current and |
146 // _FixedSizeArrayIterator, moveNext. | 146 // _FixedSizeArrayIterator, moveNext. |
147 | 147 |
148 // Forward declarations. | 148 // Forward declarations. |
149 class Assembler; | 149 class Assembler; |
150 class Function; | 150 class Function; |
151 | 151 |
152 class Intrinsifier : public AllStatic { | 152 class Intrinsifier : public AllStatic { |
153 public: | 153 public: |
(...skipping 12 matching lines...) Expand all Loading... |
166 MATH_LIB_INTRINSIC_LIST(DECLARE_FUNCTION) | 166 MATH_LIB_INTRINSIC_LIST(DECLARE_FUNCTION) |
167 SCALARLIST_LIB_INTRINSIC_LIST(DECLARE_FUNCTION) | 167 SCALARLIST_LIB_INTRINSIC_LIST(DECLARE_FUNCTION) |
168 TYPEDDATA_LIB_INTRINSIC_LIST(DECLARE_FUNCTION) | 168 TYPEDDATA_LIB_INTRINSIC_LIST(DECLARE_FUNCTION) |
169 | 169 |
170 #undef DECLARE_FUNCTION | 170 #undef DECLARE_FUNCTION |
171 }; | 171 }; |
172 | 172 |
173 } // namespace dart | 173 } // namespace dart |
174 | 174 |
175 #endif // VM_INTRINSIFIER_H_ | 175 #endif // VM_INTRINSIFIER_H_ |
OLD | NEW |