OLD | NEW |
1 // Copyright (c) 2011, 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: (class-name, function-name, intrinsification method). |
| 14 #define INTRINSIC_LIST(V) \ |
| 15 V(IntegerImplementation, addFromInteger, Integer_addFromInteger) \ |
| 16 V(IntegerImplementation, +, Integer_add) \ |
| 17 V(IntegerImplementation, subFromInteger, Integer_subFromInteger) \ |
| 18 V(IntegerImplementation, -, Integer_sub) \ |
| 19 V(IntegerImplementation, mulFromInteger, Integer_mulFromInteger) \ |
| 20 V(IntegerImplementation, *, Integer_mul) \ |
| 21 V(IntegerImplementation, %, Integer_modulo) \ |
| 22 V(IntegerImplementation, ~/, Integer_truncDivide) \ |
| 23 V(IntegerImplementation, negate, Integer_negate) \ |
| 24 V(IntegerImplementation, bitAndFromInteger, Integer_bitAndFromInteger) \ |
| 25 V(IntegerImplementation, &, Integer_bitAnd) \ |
| 26 V(IntegerImplementation, bitOrFromInteger, Integer_bitOrFromInteger) \ |
| 27 V(IntegerImplementation, |, Integer_bitOr) \ |
| 28 V(IntegerImplementation, bitXorFromInteger, Integer_bitXorFromInteger) \ |
| 29 V(IntegerImplementation, ^, Integer_bitXor) \ |
| 30 V(IntegerImplementation, greaterThanFromInteger, Integer_greaterThanFromInt) \ |
| 31 V(IntegerImplementation, >, Integer_greaterThan) \ |
| 32 V(IntegerImplementation, ==, Integer_equal) \ |
| 33 V(IntegerImplementation, equalToInteger, Integer_equalToInteger) \ |
| 34 V(IntegerImplementation, <, Integer_lessThan) \ |
| 35 V(IntegerImplementation, <=, Integer_lessEqualThan) \ |
| 36 V(IntegerImplementation, >=, Integer_greaterEqualThan) \ |
| 37 V(IntegerImplementation, <<, Integer_shl) \ |
| 38 V(IntegerImplementation, >>, Integer_sar) \ |
| 39 V(Smi, ~, Smi_bitNegate) \ |
| 40 V(Double, >, Double_greaterThan) \ |
| 41 V(Double, >=, Double_greaterEqualThan) \ |
| 42 V(Double, <, Double_lessThan) \ |
| 43 V(Double, <=, Double_lessEqualThan) \ |
| 44 V(Double, ==, Double_equal) \ |
| 45 V(Double, +, Double_add) \ |
| 46 V(Double, -, Double_sub) \ |
| 47 V(Double, *, Double_mul) \ |
| 48 V(Double, /, Double_div) \ |
| 49 V(Double, toDouble, Double_toDouble) \ |
| 50 V(Double, mulFromInteger, Double_mulFromInteger) \ |
| 51 V(Double, Double.fromInteger, Double_fromInteger) \ |
| 52 V(Double, isNaN, Double_isNaN) \ |
| 53 V(Double, isNegative, Double_isNegative) \ |
| 54 V(ObjectArray, ObjectArray., ObjectArray_Allocate) \ |
| 55 V(ObjectArray, get:length, Array_getLength) \ |
| 56 V(ObjectArray, [], Array_getIndexed) \ |
| 57 V(ObjectArray, []=, Array_setIndexed) \ |
| 58 V(GrowableObjectArray, GrowableObjectArray.fromObjectArray, GArray_Allocate) \ |
| 59 V(GrowableObjectArray, get:length, GrowableArray_getLength) \ |
| 60 V(GrowableObjectArray, get:capacity, GrowableArray_getCapacity) \ |
| 61 V(GrowableObjectArray, [], GrowableArray_getIndexed) \ |
| 62 V(GrowableObjectArray, []=, GrowableArray_setIndexed) \ |
| 63 V(GrowableObjectArray, _setLength, GrowableArray_setLength) \ |
| 64 V(GrowableObjectArray, set:data, GrowableArray_setData) \ |
| 65 V(_ByteArrayBase, get:length, ByteArrayBase_getLength) \ |
| 66 V(_ByteArrayBase, [], ByteArrayBase_getIndexed) \ |
| 67 V(ImmutableArray, [], ImmutableArray_getIndexed) \ |
| 68 V(ImmutableArray, get:length, ImmutableArray_getLength) \ |
| 69 V(Math, sqrt, Math_sqrt) \ |
| 70 V(Math, sin, Math_sin) \ |
| 71 V(Math, cos, Math_cos) \ |
| 72 V(Object, ==, Object_equal) \ |
| 73 V(FixedSizeArrayIterator, next, FixedSizeArrayIterator_next) \ |
| 74 V(FixedSizeArrayIterator, hasNext, FixedSizeArrayIterator_hasNext) \ |
| 75 V(StringBase, get:length, String_getLength) \ |
| 76 V(StringBase, charCodeAt, String_charCodeAt) \ |
| 77 V(StringBase, hashCode, String_hashCode) \ |
| 78 V(StringBase, isEmpty, String_isEmpty) \ |
| 79 |
13 // Forward declarations. | 80 // Forward declarations. |
14 class Assembler; | 81 class Assembler; |
15 class Function; | 82 class Function; |
16 | 83 |
17 class Intrinsifier : public AllStatic { | 84 class Intrinsifier : public AllStatic { |
18 public: | 85 public: |
19 // Try to intrinsify 'function'. Returns true if the function intrinsified | 86 // Try to intrinsify 'function'. Returns true if the function intrinsified |
20 // completely and the code does not need to be generated (i.e., no slow | 87 // completely and the code does not need to be generated (i.e., no slow |
21 // path possible). | 88 // path possible). |
22 static bool Intrinsify(const Function& function, Assembler* assembler); | 89 static bool Intrinsify(const Function& function, Assembler* assembler); |
| 90 |
| 91 private: |
| 92 #define DECLARE_FUNCTION(test_class_name, test_function_name, destination) \ |
| 93 static bool destination(Assembler* assembler); |
| 94 |
| 95 INTRINSIC_LIST(DECLARE_FUNCTION) |
| 96 #undef DECLARE_FUNCTION |
23 }; | 97 }; |
24 | 98 |
25 } // namespace dart | 99 } // namespace dart |
26 | 100 |
27 #endif // VM_INTRINSIFIER_H_ | 101 #endif // VM_INTRINSIFIER_H_ |
OLD | NEW |