Hacker News new | ask | show | jobs
by mraleph 4220 days ago
> I work on integrating into Dart ecosysem "foreign functions interface" (ffi).

Truly efficient FFI has to be part of the VM, you can't implement efficient FFI from outside.

> - I access data (by physical address) allocated externally

Do you really mean "physical address" here?

External data is created precisely to efficiently access data allocated externally, because it allows direct raw access to a given region of memory (sans bounds checking).

2 comments

>> Do you really mean "physical address" here?

>> External data is created precisely to efficiently access data allocated externally, because it allows direct raw access to a given region of memory (sans bounds checking).

Serach in code "Unsafe." and you understand what means "physical address" as a base and offset.

Eg.

  Unsafe.memorySet(base, offset, 0, size);
  Unsafe.memoryAllocate(size);
  Unsafe.writeInt8(base, offset, value);
https://gist.github.com/mezoni/f85b04bf19dab8333abf
>> Truly efficient FFI has to be part of the VM, you can not implement efficient FFI from outside.

Evil of the "Truly efficient FFI" in that the it in many cases does not exists as such.

Benefit of "NOT Truly efficient FFI" in that the it in many cases it may be considered as acceptable in many cases (and exist in reality).

>> Do you really mean "physical address" here?

See here.

https://gist.github.com/mezoni/f85b04bf19dab8333abf