You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Start use DynamicLibrary.invoke() but not only DynamicLibrary.invokeEx() #4
The method invoke() not much slower than invokeEx()
But it are more intellectual way and it will be improved further.
Improved performance of the DynamicLibrary.invoke() with a variable parameters through the precompilation of the commonly used binary types (bool, char, char *,int, double)
This has effect also when you use strings but not only with variadic functions.
Also I plan implement propogating null's (converting) to appropriate pointers.
Code fragment of invoke().
if (argument isString) {
if (parameter isPointerType) {
var valueType = parameter.type;
if (valueType.kind == basicTypes.charType.kind) {
if (strings ==null) {
strings =<BinaryObject>[];
}
var string = valueType.array(argument.length +1).alloc(argument.codeUnits);
strings.add(string);
newArguments[i] = string;
} else {
thrownewArgumentError("Unable to allocate string object for parameter $i: $parameter");
}
}
} elseif (argument ==null) {
// TODO: "Promoting NULL values not implemented yet"thrownewUnimplementedError("Promoting NULL values not implemented yet");
}
As you can see it automatically perform the following tasks.
Converts the String (allocates them without invoke the helper.allocString())
Creates the heap for them
Promoting NULL values (will be added soon)
P.S.
Also I plan to add segmentation fault handler into unsafe extension for the graceful exits with a Dart stack trace (instead of only exit code 139 "post mortem").
After that I implement "auto NULL pointer promoting" (if SEGFAULT will work with a success in Dart VM).
As for me second looks (and works) better than first.
Activity
azenla commentedon Mar 25, 2015
Thanks! @mezoni Let me know when you make the changes to unsafe_extension, I'll recompile for ya :)
mezoni commentedon Mar 26, 2015
It works!
Update instruction.
unsafe_extensioncompiled/X86/macos/libunsafe_extension.dylib)lib/srctool/setup.dartIf you want repeat a recompilation then you should repeat steps everything from step 2
Last step:
5. Delete any binaries in
lib/srcP.S.
This binary already compiled
X86/linux/libunsafe_extension.soI will recompile other later today (Windows 32/64, Linux 64)
Temporary test file can be found here
test/test_sigsegv.dart