|
11 | 11 | #include "vm/bootstrap_natives.h"
|
12 | 12 | #include "vm/class_finalizer.h"
|
13 | 13 | #include "vm/class_id.h"
|
14 |
| -#include "vm/compiler/ffi/native_type.h" |
15 | 14 | #include "vm/exceptions.h"
|
16 | 15 | #include "vm/flags.h"
|
17 | 16 | #include "vm/log.h"
|
|
30 | 29 |
|
31 | 30 | namespace dart {
|
32 | 31 |
|
33 |
| -// The following functions are runtime checks on type arguments. |
34 |
| -// Some checks are also performed in kernel transformation, these are asserts. |
35 |
| -// Some checks are only performed at runtime to allow for generic code, these |
36 |
| -// throw ArgumentExceptions. |
37 |
| - |
38 |
| -static void CheckSized(const AbstractType& type_arg) { |
39 |
| - const classid_t type_cid = type_arg.type_class_id(); |
40 |
| - if (IsFfiNativeTypeTypeClassId(type_cid) || IsFfiTypeVoidClassId(type_cid) || |
41 |
| - IsFfiTypeNativeFunctionClassId(type_cid)) { |
42 |
| - const String& error = String::Handle(String::NewFormatted( |
43 |
| - "%s does not have a predefined size (@unsized). " |
44 |
| - "Unsized NativeTypes do not support [sizeOf] because their size " |
45 |
| - "is unknown. " |
46 |
| - "Consequently, [allocate], [Pointer.load], [Pointer.store], and " |
47 |
| - "[Pointer.elementAt] are not available.", |
48 |
| - String::Handle(type_arg.UserVisibleName()).ToCString())); |
49 |
| - Exceptions::ThrowArgumentError(error); |
50 |
| - } |
51 |
| -} |
52 |
| - |
53 |
| -// Calculate the size of a native type. |
54 |
| -// |
55 |
| -// You must check [IsConcreteNativeType] and [CheckSized] first to verify that |
56 |
| -// this type has a defined size. |
57 |
| -static size_t SizeOf(Zone* zone, const AbstractType& type) { |
58 |
| - if (IsFfiTypeClassId(type.type_class_id())) { |
59 |
| - return compiler::ffi::NativeType::FromAbstractType(zone, type) |
60 |
| - .SizeInBytes(); |
61 |
| - } else { |
62 |
| - Class& struct_class = Class::Handle(type.type_class()); |
63 |
| - Object& result = Object::Handle( |
64 |
| - struct_class.InvokeGetter(Symbols::SizeOfStructField(), |
65 |
| - /*throw_nsm_if_absent=*/false, |
66 |
| - /*respect_reflectable=*/false)); |
67 |
| - ASSERT(!result.IsNull() && result.IsInteger()); |
68 |
| - return Integer::Cast(result).AsInt64Value(); |
69 |
| - } |
70 |
| -} |
71 |
| - |
72 | 32 | // The remainder of this file implements the dart:ffi native methods.
|
73 | 33 |
|
74 | 34 | DEFINE_NATIVE_ENTRY(Ffi_fromAddress, 1, 1) {
|
@@ -101,13 +61,6 @@ DEFINE_NATIVE_ENTRY(Ffi_storePointer, 0, 3) {
|
101 | 61 | UNREACHABLE();
|
102 | 62 | }
|
103 | 63 |
|
104 |
| -DEFINE_NATIVE_ENTRY(Ffi_sizeOf, 1, 0) { |
105 |
| - GET_NATIVE_TYPE_ARGUMENT(type_arg, arguments->NativeTypeArgAt(0)); |
106 |
| - CheckSized(type_arg); |
107 |
| - |
108 |
| - return Integer::New(SizeOf(zone, type_arg)); |
109 |
| -} |
110 |
| - |
111 | 64 | // Static invocations to this method are translated directly in streaming FGB.
|
112 | 65 | DEFINE_NATIVE_ENTRY(Ffi_asFunctionInternal, 2, 1) {
|
113 | 66 | UNREACHABLE();
|
|
0 commit comments