[vm/ffi] Change internal loads and stores to take byteOffesets

Change-Id: Iaff7aa9f158b3b168ccf2d7014a43b08afaa448e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/136182
Reviewed-by: Martin Kustermann <kustermann@google.com>
This commit is contained in:
Daco Harkes 2020-02-18 12:16:16 +00:00
parent 493779a0e0
commit 01f4479372
5 changed files with 146 additions and 134 deletions

View file

@ -103,13 +103,10 @@ DEFINE_NATIVE_ENTRY(Ffi_address, 0, 1) {
static RawObject* LoadValueNumeric(Zone* zone,
const Pointer& target,
classid_t type_cid,
const Integer& index) {
const Integer& offset) {
// TODO(36370): Make representation consistent with kUnboxedFfiIntPtr.
const size_t address =
target.NativeAddress() +
static_cast<intptr_t>(index.AsInt64Value()) *
compiler::ffi::NativeType::FromTypedDataClassId(type_cid, zone)
.SizeInBytes();
target.NativeAddress() + static_cast<intptr_t>(offset.AsInt64Value());
switch (type_cid) {
case kFfiInt8Cid:
return Integer::New(*reinterpret_cast<int8_t*>(address));
@ -141,15 +138,15 @@ static RawObject* LoadValueNumeric(Zone* zone,
#define DEFINE_NATIVE_ENTRY_LOAD(type) \
DEFINE_NATIVE_ENTRY(Ffi_load##type, 0, 2) { \
GET_NON_NULL_NATIVE_ARGUMENT(Pointer, pointer, arguments->NativeArgAt(0)); \
GET_NON_NULL_NATIVE_ARGUMENT(Integer, index, arguments->NativeArgAt(1)); \
return LoadValueNumeric(zone, pointer, kFfi##type##Cid, index); \
GET_NON_NULL_NATIVE_ARGUMENT(Integer, offset, arguments->NativeArgAt(1)); \
return LoadValueNumeric(zone, pointer, kFfi##type##Cid, offset); \
}
CLASS_LIST_FFI_NUMERIC(DEFINE_NATIVE_ENTRY_LOAD)
#undef DEFINE_NATIVE_ENTRY_LOAD
DEFINE_NATIVE_ENTRY(Ffi_loadPointer, 1, 2) {
GET_NON_NULL_NATIVE_ARGUMENT(Pointer, pointer, arguments->NativeArgAt(0));
GET_NON_NULL_NATIVE_ARGUMENT(Integer, index, arguments->NativeArgAt(1));
GET_NON_NULL_NATIVE_ARGUMENT(Integer, offset, arguments->NativeArgAt(1));
const auto& pointer_type_arg =
AbstractType::Handle(zone, pointer.type_argument());
@ -159,8 +156,7 @@ DEFINE_NATIVE_ENTRY(Ffi_loadPointer, 1, 2) {
// TODO(36370): Make representation consistent with kUnboxedFfiIntPtr.
const size_t address =
pointer.NativeAddress() + static_cast<intptr_t>(index.AsInt64Value()) *
SizeOf(pointer_type_arg, zone);
pointer.NativeAddress() + static_cast<intptr_t>(offset.AsInt64Value());
return Pointer::New(type_arg, *reinterpret_cast<uword*>(address));
}
@ -209,14 +205,11 @@ DEFINE_NATIVE_ENTRY(Ffi_loadStruct, 0, 2) {
static void StoreValueNumeric(Zone* zone,
const Pointer& pointer,
classid_t type_cid,
const Integer& index,
const Integer& offset,
const Instance& new_value) {
// TODO(36370): Make representation consistent with kUnboxedFfiIntPtr.
const size_t address =
pointer.NativeAddress() +
static_cast<intptr_t>(index.AsInt64Value()) *
compiler::ffi::NativeType::FromTypedDataClassId(type_cid, zone)
.SizeInBytes();
pointer.NativeAddress() + static_cast<intptr_t>(offset.AsInt64Value());
switch (type_cid) {
case kFfiInt8Cid:
*reinterpret_cast<int8_t*>(address) = AsInteger(new_value).AsInt64Value();
@ -267,9 +260,9 @@ static void StoreValueNumeric(Zone* zone,
#define DEFINE_NATIVE_ENTRY_STORE(type) \
DEFINE_NATIVE_ENTRY(Ffi_store##type, 0, 3) { \
GET_NON_NULL_NATIVE_ARGUMENT(Pointer, pointer, arguments->NativeArgAt(0)); \
GET_NON_NULL_NATIVE_ARGUMENT(Integer, index, arguments->NativeArgAt(1)); \
GET_NON_NULL_NATIVE_ARGUMENT(Integer, offset, arguments->NativeArgAt(1)); \
GET_NON_NULL_NATIVE_ARGUMENT(Instance, value, arguments->NativeArgAt(2)); \
StoreValueNumeric(zone, pointer, kFfi##type##Cid, index, value); \
StoreValueNumeric(zone, pointer, kFfi##type##Cid, offset, value); \
return Object::null(); \
}
CLASS_LIST_FFI_NUMERIC(DEFINE_NATIVE_ENTRY_STORE)
@ -277,7 +270,7 @@ CLASS_LIST_FFI_NUMERIC(DEFINE_NATIVE_ENTRY_STORE)
DEFINE_NATIVE_ENTRY(Ffi_storePointer, 0, 3) {
GET_NON_NULL_NATIVE_ARGUMENT(Pointer, pointer, arguments->NativeArgAt(0));
GET_NON_NULL_NATIVE_ARGUMENT(Integer, index, arguments->NativeArgAt(1));
GET_NON_NULL_NATIVE_ARGUMENT(Integer, offset, arguments->NativeArgAt(1));
GET_NON_NULL_NATIVE_ARGUMENT(Pointer, new_value, arguments->NativeArgAt(2));
AbstractType& pointer_type_arg =
AbstractType::Handle(pointer.type_argument());
@ -296,8 +289,7 @@ DEFINE_NATIVE_ENTRY(Ffi_storePointer, 0, 3) {
ASSERT(IsPointerType(pointer_type_arg));
// TODO(36370): Make representation consistent with kUnboxedFfiIntPtr.
const size_t address =
pointer.NativeAddress() + static_cast<intptr_t>(index.AsInt64Value()) *
SizeOf(pointer_type_arg, zone);
pointer.NativeAddress() + static_cast<intptr_t>(offset.AsInt64Value());
*reinterpret_cast<uword*>(address) = new_value.NativeAddress();
return Object::null();
}

View file

@ -196,6 +196,10 @@ void generatePatchExtension(StringBuffer buffer, Config config) {
final nativeType = config.nativeType;
final dartType = config.dartType;
final typedListType = config.typedListType;
final elementSize = config.elementSize;
final sizeTimes =
elementSize != 1 ? '${sizeOfIntPtrSize(elementSize)} * ' : '';
final asTypedList = typedListType == kDoNotEmit
? ""
@ -213,10 +217,10 @@ extension ${nativeType}Pointer on Pointer<$nativeType> {
set value($dartType value) => _store$nativeType(this, 0, value);
@patch
$dartType operator [](int index) => _load$nativeType(this, index);
$dartType operator [](int index) => _load$nativeType(this, ${sizeTimes}index);
@patch
operator []=(int index, $dartType value) => _store$nativeType(this, index, value);
operator []=(int index, $dartType value) => _store$nativeType(this, ${sizeTimes}index, value);
$asTypedList
}
@ -259,6 +263,15 @@ String sizeOfBits(int size) {
}
}
String sizeOfIntPtrSize(int size) {
switch (size) {
case kIntPtrElementSize:
return "_intPtrSize";
default:
return "$size";
}
}
String bracketOr(String input) {
if (input.contains("or")) {
return "($input)";

View file

@ -1219,22 +1219,18 @@ FlowGraph* FlowGraphBuilder::BuildGraphOfRecognizedMethod(
ASSERT(ffi_type_arg_cid == type_arg.type_class_id());
ASSERT(function.NumParameters() == 2);
body += LoadLocal(parsed_function_->RawParameterVariable(0)); // Pointer.
LocalVariable* arg_pointer = parsed_function_->RawParameterVariable(0);
LocalVariable* arg_offset = parsed_function_->RawParameterVariable(1);
body += LoadLocal(arg_pointer);
body += CheckNullOptimized(TokenPosition::kNoSource,
String::ZoneHandle(Z, function.name()));
body += LoadNativeField(Slot::Pointer_c_memory_address());
body += UnboxTruncate(kUnboxedFfiIntPtr);
// We do Pointer.address + index * sizeOf<T> manually because LoadIndexed
// does not support Mint index arguments.
body += LoadLocal(parsed_function_->RawParameterVariable(1)); // Index.
body += LoadLocal(arg_offset);
body += CheckNullOptimized(TokenPosition::kNoSource,
String::ZoneHandle(Z, function.name()));
body += UnboxTruncate(kUnboxedFfiIntPtr);
body += IntConstant(native_rep.SizeInBytes());
body += UnboxTruncate(kUnboxedIntPtr);
// TODO(38831): Implement Shift for Uint32, and use that instead.
body +=
BinaryIntegerOp(Token::kMUL, kUnboxedFfiIntPtr, /* truncate= */ true);
body +=
BinaryIntegerOp(Token::kADD, kUnboxedFfiIntPtr, /* truncate= */ true);
body += ConvertIntptrToUntagged();
@ -1309,7 +1305,7 @@ FlowGraph* FlowGraphBuilder::BuildGraphOfRecognizedMethod(
ASSERT(ffi_type_arg_cid == type_arg.type_class_id());
LocalVariable* arg_pointer = parsed_function_->RawParameterVariable(0);
LocalVariable* arg_index = parsed_function_->RawParameterVariable(1);
LocalVariable* arg_offset = parsed_function_->RawParameterVariable(1);
LocalVariable* arg_value = parsed_function_->RawParameterVariable(2);
if (kind == MethodRecognizer::kFfiStorePointer) {
@ -1356,17 +1352,10 @@ FlowGraph* FlowGraphBuilder::BuildGraphOfRecognizedMethod(
String::ZoneHandle(Z, function.name()));
body += LoadNativeField(Slot::Pointer_c_memory_address());
body += UnboxTruncate(kUnboxedFfiIntPtr);
// We do Pointer.address + index * sizeOf<T> manually because LoadIndexed
// does not support Mint index arguments.
body += LoadLocal(arg_index); // Index.
body += LoadLocal(arg_offset); // Offset.
body += CheckNullOptimized(TokenPosition::kNoSource,
String::ZoneHandle(Z, function.name()));
body += UnboxTruncate(kUnboxedFfiIntPtr);
body += IntConstant(native_rep.SizeInBytes());
body += UnboxTruncate(kUnboxedFfiIntPtr);
// TODO(38831): Implement Shift for Uint32, and use that instead.
body +=
BinaryIntegerOp(Token::kMUL, kUnboxedFfiIntPtr, /* truncate= */ true);
body +=
BinaryIntegerOp(Token::kADD, kUnboxedFfiIntPtr, /* truncate= */ true);
body += ConvertIntptrToUntagged();

View file

@ -122,71 +122,79 @@ int _abi()
// allocating a Pointer with in elementAt/offsetBy. Allocating these pointers
// and GCing new spaces takes a lot of the benchmark time. The next speedup is
// getting rid of these allocations by inlining these functions.
//
// TODO(37773): Change _loadInt8 etc to take an index.
int _loadInt8(Pointer<Int8> pointer, int index) native "Ffi_loadInt8";
int _loadInt8(Pointer<Int8> pointer, int offsetInBytes) native "Ffi_loadInt8";
int _loadInt16(Pointer<Int16> pointer, int index) native "Ffi_loadInt16";
int _loadInt16(Pointer<Int16> pointer, int offsetInBytes)
native "Ffi_loadInt16";
int _loadInt32(Pointer<Int32> pointer, int index) native "Ffi_loadInt32";
int _loadInt32(Pointer<Int32> pointer, int offsetInBytes)
native "Ffi_loadInt32";
int _loadInt64(Pointer<Int64> pointer, int index) native "Ffi_loadInt64";
int _loadInt64(Pointer<Int64> pointer, int offsetInBytes)
native "Ffi_loadInt64";
int _loadUint8(Pointer<Uint8> pointer, int index) native "Ffi_loadUint8";
int _loadUint8(Pointer<Uint8> pointer, int offsetInBytes)
native "Ffi_loadUint8";
int _loadUint16(Pointer<Uint16> pointer, int index) native "Ffi_loadUint16";
int _loadUint16(Pointer<Uint16> pointer, int offsetInBytes)
native "Ffi_loadUint16";
int _loadUint32(Pointer<Uint32> pointer, int index) native "Ffi_loadUint32";
int _loadUint32(Pointer<Uint32> pointer, int offsetInBytes)
native "Ffi_loadUint32";
int _loadUint64(Pointer<Uint64> pointer, int index) native "Ffi_loadUint64";
int _loadUint64(Pointer<Uint64> pointer, int offsetInBytes)
native "Ffi_loadUint64";
int _loadIntPtr(Pointer<IntPtr> pointer, int index) native "Ffi_loadIntPtr";
int _loadIntPtr(Pointer<IntPtr> pointer, int offsetInBytes)
native "Ffi_loadIntPtr";
double _loadFloat(Pointer<Float> pointer, int index) native "Ffi_loadFloat";
double _loadFloat(Pointer<Float> pointer, int offsetInBytes)
native "Ffi_loadFloat";
double _loadDouble(Pointer<Double> pointer, int index) native "Ffi_loadDouble";
double _loadDouble(Pointer<Double> pointer, int offsetInBytes)
native "Ffi_loadDouble";
Pointer<S> _loadPointer<S extends NativeType>(
Pointer<Pointer<S>> pointer, int index) native "Ffi_loadPointer";
Pointer<Pointer<S>> pointer, int offsetInBytes) native "Ffi_loadPointer";
S _loadStruct<S extends Struct>(Pointer<S> pointer, int index)
native "Ffi_loadStruct";
void _storeInt8(Pointer<Int8> pointer, int index, int value)
void _storeInt8(Pointer<Int8> pointer, int offsetInBytes, int value)
native "Ffi_storeInt8";
void _storeInt16(Pointer<Int16> pointer, int index, int value)
void _storeInt16(Pointer<Int16> pointer, int offsetInBytes, int value)
native "Ffi_storeInt16";
void _storeInt32(Pointer<Int32> pointer, int index, int value)
void _storeInt32(Pointer<Int32> pointer, int offsetInBytes, int value)
native "Ffi_storeInt32";
void _storeInt64(Pointer<Int64> pointer, int index, int value)
void _storeInt64(Pointer<Int64> pointer, int offsetInBytes, int value)
native "Ffi_storeInt64";
void _storeUint8(Pointer<Uint8> pointer, int index, int value)
void _storeUint8(Pointer<Uint8> pointer, int offsetInBytes, int value)
native "Ffi_storeUint8";
void _storeUint16(Pointer<Uint16> pointer, int index, int value)
void _storeUint16(Pointer<Uint16> pointer, int offsetInBytes, int value)
native "Ffi_storeUint16";
void _storeUint32(Pointer<Uint32> pointer, int index, int value)
void _storeUint32(Pointer<Uint32> pointer, int offsetInBytes, int value)
native "Ffi_storeUint32";
void _storeUint64(Pointer<Uint64> pointer, int index, int value)
void _storeUint64(Pointer<Uint64> pointer, int offsetInBytes, int value)
native "Ffi_storeUint64";
void _storeIntPtr(Pointer<IntPtr> pointer, int index, int value)
void _storeIntPtr(Pointer<IntPtr> pointer, int offsetInBytes, int value)
native "Ffi_storeIntPtr";
void _storeFloat(Pointer<Float> pointer, int index, double value)
void _storeFloat(Pointer<Float> pointer, int offsetInBytes, double value)
native "Ffi_storeFloat";
void _storeDouble(Pointer<Double> pointer, int index, double value)
void _storeDouble(Pointer<Double> pointer, int offsetInBytes, double value)
native "Ffi_storeDouble";
void _storePointer<S extends NativeType>(Pointer<Pointer<S>> pointer, int index,
Pointer<S> value) native "Ffi_storePointer";
void _storePointer<S extends NativeType>(Pointer<Pointer<S>> pointer,
int offsetInBytes, Pointer<S> value) native "Ffi_storePointer";
Pointer<Int8> _elementAtInt8(Pointer<Int8> pointer, int index) =>
Pointer.fromAddress(pointer.address + 1 * index);
@ -263,10 +271,10 @@ extension Int16Pointer on Pointer<Int16> {
set value(int value) => _storeInt16(this, 0, value);
@patch
int operator [](int index) => _loadInt16(this, index);
int operator [](int index) => _loadInt16(this, 2 * index);
@patch
operator []=(int index, int value) => _storeInt16(this, index, value);
operator []=(int index, int value) => _storeInt16(this, 2 * index, value);
@patch
Int16List asTypedList(int elements) => _asExternalTypedData(this, elements);
@ -280,10 +288,10 @@ extension Int32Pointer on Pointer<Int32> {
set value(int value) => _storeInt32(this, 0, value);
@patch
int operator [](int index) => _loadInt32(this, index);
int operator [](int index) => _loadInt32(this, 4 * index);
@patch
operator []=(int index, int value) => _storeInt32(this, index, value);
operator []=(int index, int value) => _storeInt32(this, 4 * index, value);
@patch
Int32List asTypedList(int elements) => _asExternalTypedData(this, elements);
@ -297,10 +305,10 @@ extension Int64Pointer on Pointer<Int64> {
set value(int value) => _storeInt64(this, 0, value);
@patch
int operator [](int index) => _loadInt64(this, index);
int operator [](int index) => _loadInt64(this, 8 * index);
@patch
operator []=(int index, int value) => _storeInt64(this, index, value);
operator []=(int index, int value) => _storeInt64(this, 8 * index, value);
@patch
Int64List asTypedList(int elements) => _asExternalTypedData(this, elements);
@ -331,10 +339,10 @@ extension Uint16Pointer on Pointer<Uint16> {
set value(int value) => _storeUint16(this, 0, value);
@patch
int operator [](int index) => _loadUint16(this, index);
int operator [](int index) => _loadUint16(this, 2 * index);
@patch
operator []=(int index, int value) => _storeUint16(this, index, value);
operator []=(int index, int value) => _storeUint16(this, 2 * index, value);
@patch
Uint16List asTypedList(int elements) => _asExternalTypedData(this, elements);
@ -348,10 +356,10 @@ extension Uint32Pointer on Pointer<Uint32> {
set value(int value) => _storeUint32(this, 0, value);
@patch
int operator [](int index) => _loadUint32(this, index);
int operator [](int index) => _loadUint32(this, 4 * index);
@patch
operator []=(int index, int value) => _storeUint32(this, index, value);
operator []=(int index, int value) => _storeUint32(this, 4 * index, value);
@patch
Uint32List asTypedList(int elements) => _asExternalTypedData(this, elements);
@ -365,10 +373,10 @@ extension Uint64Pointer on Pointer<Uint64> {
set value(int value) => _storeUint64(this, 0, value);
@patch
int operator [](int index) => _loadUint64(this, index);
int operator [](int index) => _loadUint64(this, 8 * index);
@patch
operator []=(int index, int value) => _storeUint64(this, index, value);
operator []=(int index, int value) => _storeUint64(this, 8 * index, value);
@patch
Uint64List asTypedList(int elements) => _asExternalTypedData(this, elements);
@ -382,10 +390,11 @@ extension IntPtrPointer on Pointer<IntPtr> {
set value(int value) => _storeIntPtr(this, 0, value);
@patch
int operator [](int index) => _loadIntPtr(this, index);
int operator [](int index) => _loadIntPtr(this, _intPtrSize * index);
@patch
operator []=(int index, int value) => _storeIntPtr(this, index, value);
operator []=(int index, int value) =>
_storeIntPtr(this, _intPtrSize * index, value);
}
extension FloatPointer on Pointer<Float> {
@ -396,10 +405,10 @@ extension FloatPointer on Pointer<Float> {
set value(double value) => _storeFloat(this, 0, value);
@patch
double operator [](int index) => _loadFloat(this, index);
double operator [](int index) => _loadFloat(this, 4 * index);
@patch
operator []=(int index, double value) => _storeFloat(this, index, value);
operator []=(int index, double value) => _storeFloat(this, 4 * index, value);
@patch
Float32List asTypedList(int elements) => _asExternalTypedData(this, elements);
@ -413,10 +422,10 @@ extension DoublePointer on Pointer<Double> {
set value(double value) => _storeDouble(this, 0, value);
@patch
double operator [](int index) => _loadDouble(this, index);
double operator [](int index) => _loadDouble(this, 8 * index);
@patch
operator []=(int index, double value) => _storeDouble(this, index, value);
operator []=(int index, double value) => _storeDouble(this, 8 * index, value);
@patch
Float64List asTypedList(int elements) => _asExternalTypedData(this, elements);
@ -434,11 +443,11 @@ extension PointerPointer<T extends NativeType> on Pointer<Pointer<T>> {
set value(Pointer<T> value) => _storePointer(this, 0, value);
@patch
Pointer<T> operator [](int index) => _loadPointer(this, index);
Pointer<T> operator [](int index) => _loadPointer(this, _intPtrSize * index);
@patch
operator []=(int index, Pointer<T> value) =>
_storePointer(this, index, value);
_storePointer(this, _intPtrSize * index, value);
}
extension StructPointer<T extends Struct> on Pointer<T> {

View file

@ -120,71 +120,79 @@ int _abi()
// allocating a Pointer with in elementAt/offsetBy. Allocating these pointers
// and GCing new spaces takes a lot of the benchmark time. The next speedup is
// getting rid of these allocations by inlining these functions.
//
// TODO(37773): Change _loadInt8 etc to take an index.
int _loadInt8(Pointer<Int8> pointer, int index) native "Ffi_loadInt8";
int _loadInt8(Pointer<Int8> pointer, int offsetInBytes) native "Ffi_loadInt8";
int _loadInt16(Pointer<Int16> pointer, int index) native "Ffi_loadInt16";
int _loadInt16(Pointer<Int16> pointer, int offsetInBytes)
native "Ffi_loadInt16";
int _loadInt32(Pointer<Int32> pointer, int index) native "Ffi_loadInt32";
int _loadInt32(Pointer<Int32> pointer, int offsetInBytes)
native "Ffi_loadInt32";
int _loadInt64(Pointer<Int64> pointer, int index) native "Ffi_loadInt64";
int _loadInt64(Pointer<Int64> pointer, int offsetInBytes)
native "Ffi_loadInt64";
int _loadUint8(Pointer<Uint8> pointer, int index) native "Ffi_loadUint8";
int _loadUint8(Pointer<Uint8> pointer, int offsetInBytes)
native "Ffi_loadUint8";
int _loadUint16(Pointer<Uint16> pointer, int index) native "Ffi_loadUint16";
int _loadUint16(Pointer<Uint16> pointer, int offsetInBytes)
native "Ffi_loadUint16";
int _loadUint32(Pointer<Uint32> pointer, int index) native "Ffi_loadUint32";
int _loadUint32(Pointer<Uint32> pointer, int offsetInBytes)
native "Ffi_loadUint32";
int _loadUint64(Pointer<Uint64> pointer, int index) native "Ffi_loadUint64";
int _loadUint64(Pointer<Uint64> pointer, int offsetInBytes)
native "Ffi_loadUint64";
int _loadIntPtr(Pointer<IntPtr> pointer, int index) native "Ffi_loadIntPtr";
int _loadIntPtr(Pointer<IntPtr> pointer, int offsetInBytes)
native "Ffi_loadIntPtr";
double _loadFloat(Pointer<Float> pointer, int index) native "Ffi_loadFloat";
double _loadFloat(Pointer<Float> pointer, int offsetInBytes)
native "Ffi_loadFloat";
double _loadDouble(Pointer<Double> pointer, int index) native "Ffi_loadDouble";
double _loadDouble(Pointer<Double> pointer, int offsetInBytes)
native "Ffi_loadDouble";
Pointer<S> _loadPointer<S extends NativeType>(
Pointer<Pointer<S>> pointer, int index) native "Ffi_loadPointer";
Pointer<Pointer<S>> pointer, int offsetInBytes) native "Ffi_loadPointer";
S _loadStruct<S extends Struct>(Pointer<S> pointer, int index)
native "Ffi_loadStruct";
void _storeInt8(Pointer<Int8> pointer, int index, int value)
void _storeInt8(Pointer<Int8> pointer, int offsetInBytes, int value)
native "Ffi_storeInt8";
void _storeInt16(Pointer<Int16> pointer, int index, int value)
void _storeInt16(Pointer<Int16> pointer, int offsetInBytes, int value)
native "Ffi_storeInt16";
void _storeInt32(Pointer<Int32> pointer, int index, int value)
void _storeInt32(Pointer<Int32> pointer, int offsetInBytes, int value)
native "Ffi_storeInt32";
void _storeInt64(Pointer<Int64> pointer, int index, int value)
void _storeInt64(Pointer<Int64> pointer, int offsetInBytes, int value)
native "Ffi_storeInt64";
void _storeUint8(Pointer<Uint8> pointer, int index, int value)
void _storeUint8(Pointer<Uint8> pointer, int offsetInBytes, int value)
native "Ffi_storeUint8";
void _storeUint16(Pointer<Uint16> pointer, int index, int value)
void _storeUint16(Pointer<Uint16> pointer, int offsetInBytes, int value)
native "Ffi_storeUint16";
void _storeUint32(Pointer<Uint32> pointer, int index, int value)
void _storeUint32(Pointer<Uint32> pointer, int offsetInBytes, int value)
native "Ffi_storeUint32";
void _storeUint64(Pointer<Uint64> pointer, int index, int value)
void _storeUint64(Pointer<Uint64> pointer, int offsetInBytes, int value)
native "Ffi_storeUint64";
void _storeIntPtr(Pointer<IntPtr> pointer, int index, int value)
void _storeIntPtr(Pointer<IntPtr> pointer, int offsetInBytes, int value)
native "Ffi_storeIntPtr";
void _storeFloat(Pointer<Float> pointer, int index, double value)
void _storeFloat(Pointer<Float> pointer, int offsetInBytes, double value)
native "Ffi_storeFloat";
void _storeDouble(Pointer<Double> pointer, int index, double value)
void _storeDouble(Pointer<Double> pointer, int offsetInBytes, double value)
native "Ffi_storeDouble";
void _storePointer<S extends NativeType>(Pointer<Pointer<S>> pointer, int index,
Pointer<S> value) native "Ffi_storePointer";
void _storePointer<S extends NativeType>(Pointer<Pointer<S>> pointer,
int offsetInBytes, Pointer<S> value) native "Ffi_storePointer";
Pointer<Int8> _elementAtInt8(Pointer<Int8> pointer, int index) =>
Pointer.fromAddress(pointer.address + 1 * index);
@ -261,10 +269,10 @@ extension Int16Pointer on Pointer<Int16> {
set value(int value) => _storeInt16(this, 0, value);
@patch
int operator [](int index) => _loadInt16(this, index);
int operator [](int index) => _loadInt16(this, 2 * index);
@patch
operator []=(int index, int value) => _storeInt16(this, index, value);
operator []=(int index, int value) => _storeInt16(this, 2 * index, value);
@patch
Int16List asTypedList(int elements) => _asExternalTypedData(this, elements);
@ -278,10 +286,10 @@ extension Int32Pointer on Pointer<Int32> {
set value(int value) => _storeInt32(this, 0, value);
@patch
int operator [](int index) => _loadInt32(this, index);
int operator [](int index) => _loadInt32(this, 4 * index);
@patch
operator []=(int index, int value) => _storeInt32(this, index, value);
operator []=(int index, int value) => _storeInt32(this, 4 * index, value);
@patch
Int32List asTypedList(int elements) => _asExternalTypedData(this, elements);
@ -295,10 +303,10 @@ extension Int64Pointer on Pointer<Int64> {
set value(int value) => _storeInt64(this, 0, value);
@patch
int operator [](int index) => _loadInt64(this, index);
int operator [](int index) => _loadInt64(this, 8 * index);
@patch
operator []=(int index, int value) => _storeInt64(this, index, value);
operator []=(int index, int value) => _storeInt64(this, 8 * index, value);
@patch
Int64List asTypedList(int elements) => _asExternalTypedData(this, elements);
@ -329,10 +337,10 @@ extension Uint16Pointer on Pointer<Uint16> {
set value(int value) => _storeUint16(this, 0, value);
@patch
int operator [](int index) => _loadUint16(this, index);
int operator [](int index) => _loadUint16(this, 2 * index);
@patch
operator []=(int index, int value) => _storeUint16(this, index, value);
operator []=(int index, int value) => _storeUint16(this, 2 * index, value);
@patch
Uint16List asTypedList(int elements) => _asExternalTypedData(this, elements);
@ -346,10 +354,10 @@ extension Uint32Pointer on Pointer<Uint32> {
set value(int value) => _storeUint32(this, 0, value);
@patch
int operator [](int index) => _loadUint32(this, index);
int operator [](int index) => _loadUint32(this, 4 * index);
@patch
operator []=(int index, int value) => _storeUint32(this, index, value);
operator []=(int index, int value) => _storeUint32(this, 4 * index, value);
@patch
Uint32List asTypedList(int elements) => _asExternalTypedData(this, elements);
@ -363,10 +371,10 @@ extension Uint64Pointer on Pointer<Uint64> {
set value(int value) => _storeUint64(this, 0, value);
@patch
int operator [](int index) => _loadUint64(this, index);
int operator [](int index) => _loadUint64(this, 8 * index);
@patch
operator []=(int index, int value) => _storeUint64(this, index, value);
operator []=(int index, int value) => _storeUint64(this, 8 * index, value);
@patch
Uint64List asTypedList(int elements) => _asExternalTypedData(this, elements);
@ -380,10 +388,11 @@ extension IntPtrPointer on Pointer<IntPtr> {
set value(int value) => _storeIntPtr(this, 0, value);
@patch
int operator [](int index) => _loadIntPtr(this, index);
int operator [](int index) => _loadIntPtr(this, _intPtrSize * index);
@patch
operator []=(int index, int value) => _storeIntPtr(this, index, value);
operator []=(int index, int value) =>
_storeIntPtr(this, _intPtrSize * index, value);
}
extension FloatPointer on Pointer<Float> {
@ -394,10 +403,10 @@ extension FloatPointer on Pointer<Float> {
set value(double value) => _storeFloat(this, 0, value);
@patch
double operator [](int index) => _loadFloat(this, index);
double operator [](int index) => _loadFloat(this, 4 * index);
@patch
operator []=(int index, double value) => _storeFloat(this, index, value);
operator []=(int index, double value) => _storeFloat(this, 4 * index, value);
@patch
Float32List asTypedList(int elements) => _asExternalTypedData(this, elements);
@ -411,10 +420,10 @@ extension DoublePointer on Pointer<Double> {
set value(double value) => _storeDouble(this, 0, value);
@patch
double operator [](int index) => _loadDouble(this, index);
double operator [](int index) => _loadDouble(this, 8 * index);
@patch
operator []=(int index, double value) => _storeDouble(this, index, value);
operator []=(int index, double value) => _storeDouble(this, 8 * index, value);
@patch
Float64List asTypedList(int elements) => _asExternalTypedData(this, elements);
@ -432,11 +441,11 @@ extension PointerPointer<T extends NativeType> on Pointer<Pointer<T>> {
set value(Pointer<T> value) => _storePointer(this, 0, value);
@patch
Pointer<T> operator [](int index) => _loadPointer(this, index);
Pointer<T> operator [](int index) => _loadPointer(this, _intPtrSize * index);
@patch
operator []=(int index, Pointer<T> value) =>
_storePointer(this, index, value);
_storePointer(this, _intPtrSize * index, value);
}
extension StructPointer<T extends Struct> on Pointer<T> {