Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
recognized_method.cc
Go to the documentation of this file.
1// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
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.
4
6
7#include "vm/symbols.h"
8
9namespace dart {
10
11namespace compiler {
12
13namespace ffi {
14
16 switch (class_id) {
17 case kFfiInt8Cid:
18 return kTypedDataInt8ArrayCid;
19 case kFfiUint8Cid:
20 return kTypedDataUint8ArrayCid;
21 case kFfiInt16Cid:
22 return kTypedDataInt16ArrayCid;
23 case kFfiUint16Cid:
24 return kTypedDataUint16ArrayCid;
25 case kFfiInt32Cid:
26 return kTypedDataInt32ArrayCid;
27 case kFfiUint32Cid:
28 return kTypedDataUint32ArrayCid;
29 case kFfiInt64Cid:
30 return kTypedDataInt64ArrayCid;
31 case kFfiUint64Cid:
32 return kTypedDataUint64ArrayCid;
33 case kPointerCid:
34 return target::kWordSize == 4 ? kTypedDataUint32ArrayCid
35 : kTypedDataUint64ArrayCid;
36 case kFfiFloatCid:
37 return kTypedDataFloat32ArrayCid;
38 case kFfiDoubleCid:
39 return kTypedDataFloat64ArrayCid;
40 default:
42 }
43}
44
46 switch (class_id) {
47 case kFfiInt8Cid:
48 return kExternalTypedDataInt8ArrayCid;
49 case kFfiUint8Cid:
50 return kExternalTypedDataUint8ArrayCid;
51 case kFfiInt16Cid:
52 return kExternalTypedDataInt16ArrayCid;
53 case kFfiUint16Cid:
54 return kExternalTypedDataUint16ArrayCid;
55 case kFfiInt32Cid:
56 return kExternalTypedDataInt32ArrayCid;
57 case kFfiUint32Cid:
58 return kExternalTypedDataUint32ArrayCid;
59 case kFfiInt64Cid:
60 return kExternalTypedDataInt64ArrayCid;
61 case kFfiUint64Cid:
62 return kExternalTypedDataUint64ArrayCid;
63 case kFfiFloatCid:
64 return kExternalTypedDataFloat32ArrayCid;
65 case kFfiDoubleCid:
66 return kExternalTypedDataFloat64ArrayCid;
67 default:
69 }
70}
71
73 switch (kind) {
74#define LOAD_STORE(type) \
75 case MethodRecognizer::kFfiLoad##type: \
76 case MethodRecognizer::kFfiStore##type: \
77 return kFfi##type##Cid;
79#undef LOAD_STORE
80 case MethodRecognizer::kFfiLoadFloatUnaligned:
81 case MethodRecognizer::kFfiStoreFloatUnaligned:
82 return kFfiFloatCid;
83 case MethodRecognizer::kFfiLoadDoubleUnaligned:
84 case MethodRecognizer::kFfiStoreDoubleUnaligned:
85 return kFfiDoubleCid;
86 case MethodRecognizer::kFfiLoadPointer:
87 case MethodRecognizer::kFfiStorePointer:
88 return kPointerCid;
89#define AS_EXTERNAL_TYPED_DATA(type) \
90 case MethodRecognizer::kFfiAsExternalTypedData##type: \
91 return kFfi##type##Cid;
93#undef AS_EXTERNAL_TYPED_DATA
94 default:
96 }
97}
98
100 switch (kind) {
101#define LOAD_STORE(type) \
102 case MethodRecognizer::kFfiLoad##type: \
103 case MethodRecognizer::kFfiStore##type: \
104 return kAlignedAccess;
107#undef LOAD_STORE
108 case MethodRecognizer::kFfiLoadFloatUnaligned:
109 case MethodRecognizer::kFfiStoreFloatUnaligned:
110 case MethodRecognizer::kFfiLoadDoubleUnaligned:
111 case MethodRecognizer::kFfiStoreDoubleUnaligned:
112 return kUnalignedAccess;
113 default:
114 UNREACHABLE();
115 }
116}
117
119 if (native_type.IsPrimitive()) {
120 switch (native_type.AsPrimitive().representation()) {
121#define CASE(type) \
122 case k##type: \
123 return MethodRecognizer::kFfiLoad##type;
125#undef CASE
126 default:
127 break;
128 }
129 }
131}
132
134 if (native_type.IsPrimitive()) {
135 switch (native_type.AsPrimitive().representation()) {
136#define CASE(type) \
137 case k##type: \
138 return MethodRecognizer::kFfiStore##type;
140#undef CASE
141 default:
142 break;
143 }
144 }
146}
147
148} // namespace ffi
149
150} // namespace compiler
151
152} // namespace dart
#define UNREACHABLE()
Definition assert.h:248
#define CLASS_LIST_FFI_NUMERIC_FIXED_SIZE(V)
Definition class_id.h:153
const NativePrimitiveType & AsPrimitive() const
virtual bool IsPrimitive() const
Definition native_type.h:80
#define UNIMPLEMENTED
#define CASE(Arity, Mask, Name, Args, Result)
MethodRecognizer::Kind FfiStore(const NativeType &native_type)
AlignmentType RecognizedMethodAlignment(MethodRecognizer::Kind kind)
classid_t RecognizedMethodTypeArgCid(MethodRecognizer::Kind kind)
MethodRecognizer::Kind FfiLoad(const NativeType &native_type)
classid_t ElementExternalTypedDataCid(classid_t class_id)
classid_t ElementTypedDataCid(classid_t class_id)
int32_t classid_t
Definition globals.h:524
AlignmentType
Definition il.h:6720
@ kUnalignedAccess
Definition il.h:6721
#define AS_EXTERNAL_TYPED_DATA(type)
#define LOAD_STORE(type)