Skip to content

Commit

Permalink
[vm/ffi] Change type of typedDataBase parameter for load and store
Browse files Browse the repository at this point in the history
So that it can be invoked from `CArray` which has a backing store
that is either TypedData or Pointer.

Bug: #35763

TEST=tests/ffi(_2)/*

Change-Id: I30bb0c1e848f2ac4f47919009106d5428ed66453
Cq-Include-Trybots: luci.dart.try:vm-kernel-linux-debug-x64-try,vm-kernel-precomp-nnbd-linux-debug-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/183683
Commit-Queue: Daco Harkes <[email protected]>
Reviewed-by: Aske Simon Christensen <[email protected]>
  • Loading branch information
dcharkes authored and [email protected] committed Feb 9, 2021
1 parent b60e0aa commit aa2a6f8
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 49 deletions.
48 changes: 24 additions & 24 deletions runtime/vm/compiler/recognized_methods_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,30 +166,30 @@ namespace dart {
V(::, _abi, FfiAbi, 0x7c4ab775) \
V(::, _asFunctionInternal, FfiAsFunctionInternal, 0xbbcb235a) \
V(::, _nativeCallbackFunction, FfiNativeCallbackFunction, 0x3ff5ae9c) \
V(::, _loadInt8, FfiLoadInt8, 0xa54bed8c) \
V(::, _loadInt16, FfiLoadInt16, 0x828b3ee3) \
V(::, _loadInt32, FfiLoadInt32, 0x84694d79) \
V(::, _loadInt64, FfiLoadInt64, 0x7536cd59) \
V(::, _loadUint8, FfiLoadUint8, 0x77952a87) \
V(::, _loadUint16, FfiLoadUint16, 0xa31d6aa0) \
V(::, _loadUint32, FfiLoadUint32, 0x8cb59e0b) \
V(::, _loadUint64, FfiLoadUint64, 0x9b4d0b82) \
V(::, _loadIntPtr, FfiLoadIntPtr, 0x8220c1f4) \
V(::, _loadFloat, FfiLoadFloat, 0x8f209213) \
V(::, _loadDouble, FfiLoadDouble, 0x8d53d3cf) \
V(::, _loadPointer, FfiLoadPointer, 0xc50e1486) \
V(::, _storeInt8, FfiStoreInt8, 0x000b2742) \
V(::, _storeInt16, FfiStoreInt16, 0xf9086b68) \
V(::, _storeInt32, FfiStoreInt32, 0x1ca0a493) \
V(::, _storeInt64, FfiStoreInt64, 0x128e85b0) \
V(::, _storeUint8, FfiStoreUint8, 0x26284b2c) \
V(::, _storeUint16, FfiStoreUint16, 0x03b82314) \
V(::, _storeUint32, FfiStoreUint32, 0x069260fb) \
V(::, _storeUint64, FfiStoreUint64, 0x0393aa6f) \
V(::, _storeIntPtr, FfiStoreIntPtr, 0x28bcdede) \
V(::, _storeFloat, FfiStoreFloat, 0x853f68b4) \
V(::, _storeDouble, FfiStoreDouble, 0x6354049a) \
V(::, _storePointer, FfiStorePointer, 0x0cfd005b) \
V(::, _loadInt8, FfiLoadInt8, 0x0f04dfd6) \
V(::, _loadInt16, FfiLoadInt16, 0xec44312d) \
V(::, _loadInt32, FfiLoadInt32, 0xee223fc3) \
V(::, _loadInt64, FfiLoadInt64, 0xdeefbfa3) \
V(::, _loadUint8, FfiLoadUint8, 0xe14e1cd1) \
V(::, _loadUint16, FfiLoadUint16, 0x0cd65cea) \
V(::, _loadUint32, FfiLoadUint32, 0xf66e9055) \
V(::, _loadUint64, FfiLoadUint64, 0x0505fdcc) \
V(::, _loadIntPtr, FfiLoadIntPtr, 0xebd9b43e) \
V(::, _loadFloat, FfiLoadFloat, 0xf8d9845d) \
V(::, _loadDouble, FfiLoadDouble, 0xf70cc619) \
V(::, _loadPointer, FfiLoadPointer, 0x4e79d0fc) \
V(::, _storeInt8, FfiStoreInt8, 0xdf50af0c) \
V(::, _storeInt16, FfiStoreInt16, 0xd84df332) \
V(::, _storeInt32, FfiStoreInt32, 0xfbe62c5d) \
V(::, _storeInt64, FfiStoreInt64, 0xf1d40d7a) \
V(::, _storeUint8, FfiStoreUint8, 0x056dd2f6) \
V(::, _storeUint16, FfiStoreUint16, 0xe2fdaade) \
V(::, _storeUint32, FfiStoreUint32, 0xe5d7e8c5) \
V(::, _storeUint64, FfiStoreUint64, 0xe2d93239) \
V(::, _storeIntPtr, FfiStoreIntPtr, 0x080266a8) \
V(::, _storeFloat, FfiStoreFloat, 0x6484f07e) \
V(::, _storeDouble, FfiStoreDouble, 0x42998c64) \
V(::, _storePointer, FfiStorePointer, 0xea6b7751) \
V(::, _fromAddress, FfiFromAddress, 0xfd8cb1cc) \
V(Pointer, get:address, FfiGetAddress, 0x7cde87be) \
V(::, reachabilityFence, ReachabilityFence, 0x619235c1) \
Expand Down
56 changes: 31 additions & 25 deletions sdk/lib/_internal/vm/lib/ffi_patch.dart
Original file line number Diff line number Diff line change
Expand Up @@ -168,89 +168,95 @@ void _memCopy(Object target, int targetOffsetInBytes, Object source,
// and GCing new spaces takes a lot of the benchmark time. The next speedup is
// getting rid of these allocations by inlining these functions.
@pragma("vm:recognized", "other")
int _loadInt8(Pointer pointer, int offsetInBytes) native "Ffi_loadInt8";
int _loadInt8(Object typedDataBase, int offsetInBytes) native "Ffi_loadInt8";

@pragma("vm:recognized", "other")
int _loadInt16(Pointer pointer, int offsetInBytes) native "Ffi_loadInt16";
int _loadInt16(Object typedDataBase, int offsetInBytes) native "Ffi_loadInt16";

@pragma("vm:recognized", "other")
int _loadInt32(Pointer pointer, int offsetInBytes) native "Ffi_loadInt32";
int _loadInt32(Object typedDataBase, int offsetInBytes) native "Ffi_loadInt32";

@pragma("vm:recognized", "other")
int _loadInt64(Pointer pointer, int offsetInBytes) native "Ffi_loadInt64";
int _loadInt64(Object typedDataBase, int offsetInBytes) native "Ffi_loadInt64";

@pragma("vm:recognized", "other")
int _loadUint8(Pointer pointer, int offsetInBytes) native "Ffi_loadUint8";
int _loadUint8(Object typedDataBase, int offsetInBytes) native "Ffi_loadUint8";

@pragma("vm:recognized", "other")
int _loadUint16(Pointer pointer, int offsetInBytes) native "Ffi_loadUint16";
int _loadUint16(Object typedDataBase, int offsetInBytes)
native "Ffi_loadUint16";

@pragma("vm:recognized", "other")
int _loadUint32(Pointer pointer, int offsetInBytes) native "Ffi_loadUint32";
int _loadUint32(Object typedDataBase, int offsetInBytes)
native "Ffi_loadUint32";

@pragma("vm:recognized", "other")
int _loadUint64(Pointer pointer, int offsetInBytes) native "Ffi_loadUint64";
int _loadUint64(Object typedDataBase, int offsetInBytes)
native "Ffi_loadUint64";

@pragma("vm:recognized", "other")
int _loadIntPtr(Pointer pointer, int offsetInBytes) native "Ffi_loadIntPtr";
int _loadIntPtr(Object typedDataBase, int offsetInBytes)
native "Ffi_loadIntPtr";

@pragma("vm:recognized", "other")
double _loadFloat(Pointer pointer, int offsetInBytes) native "Ffi_loadFloat";
double _loadFloat(Object typedDataBase, int offsetInBytes)
native "Ffi_loadFloat";

@pragma("vm:recognized", "other")
double _loadDouble(Pointer pointer, int offsetInBytes) native "Ffi_loadDouble";
double _loadDouble(Object typedDataBase, int offsetInBytes)
native "Ffi_loadDouble";

@pragma("vm:recognized", "other")
Pointer<S> _loadPointer<S extends NativeType>(
Pointer pointer, int offsetInBytes) native "Ffi_loadPointer";
Object typedDataBase, int offsetInBytes) native "Ffi_loadPointer";

@pragma("vm:recognized", "other")
void _storeInt8(Pointer pointer, int offsetInBytes, int value)
void _storeInt8(Object typedDataBase, int offsetInBytes, int value)
native "Ffi_storeInt8";

@pragma("vm:recognized", "other")
void _storeInt16(Pointer pointer, int offsetInBytes, int value)
void _storeInt16(Object typedDataBase, int offsetInBytes, int value)
native "Ffi_storeInt16";

@pragma("vm:recognized", "other")
void _storeInt32(Pointer pointer, int offsetInBytes, int value)
void _storeInt32(Object typedDataBase, int offsetInBytes, int value)
native "Ffi_storeInt32";

@pragma("vm:recognized", "other")
void _storeInt64(Pointer pointer, int offsetInBytes, int value)
void _storeInt64(Object typedDataBase, int offsetInBytes, int value)
native "Ffi_storeInt64";

@pragma("vm:recognized", "other")
void _storeUint8(Pointer pointer, int offsetInBytes, int value)
void _storeUint8(Object typedDataBase, int offsetInBytes, int value)
native "Ffi_storeUint8";

@pragma("vm:recognized", "other")
void _storeUint16(Pointer pointer, int offsetInBytes, int value)
void _storeUint16(Object typedDataBase, int offsetInBytes, int value)
native "Ffi_storeUint16";

@pragma("vm:recognized", "other")
void _storeUint32(Pointer pointer, int offsetInBytes, int value)
void _storeUint32(Object typedDataBase, int offsetInBytes, int value)
native "Ffi_storeUint32";

@pragma("vm:recognized", "other")
void _storeUint64(Pointer pointer, int offsetInBytes, int value)
void _storeUint64(Object typedDataBase, int offsetInBytes, int value)
native "Ffi_storeUint64";

@pragma("vm:recognized", "other")
void _storeIntPtr(Pointer pointer, int offsetInBytes, int value)
void _storeIntPtr(Object typedDataBase, int offsetInBytes, int value)
native "Ffi_storeIntPtr";

@pragma("vm:recognized", "other")
void _storeFloat(Pointer pointer, int offsetInBytes, double value)
void _storeFloat(Object typedDataBase, int offsetInBytes, double value)
native "Ffi_storeFloat";

@pragma("vm:recognized", "other")
void _storeDouble(Pointer pointer, int offsetInBytes, double value)
void _storeDouble(Object typedDataBase, int offsetInBytes, double value)
native "Ffi_storeDouble";

@pragma("vm:recognized", "other")
void _storePointer<S extends NativeType>(Pointer pointer, int offsetInBytes,
Pointer<S> value) native "Ffi_storePointer";
void _storePointer<S extends NativeType>(Object typedDataBase,
int offsetInBytes, Pointer<S> value) native "Ffi_storePointer";

Pointer<Int8> _elementAtInt8(Pointer<Int8> pointer, int index) =>
Pointer.fromAddress(pointer.address + 1 * index);
Expand Down

0 comments on commit aa2a6f8

Please sign in to comment.