summaryrefslogtreecommitdiff
path: root/ext
Commit message (Collapse)AuthorAgeFilesLines
* Free the message allocated by FormatMessageA (should have been in last commit).Charlie Savage2023-04-201-0/+3
|
* On Windows FormatMessageA can return a NULL message - for example when ↵Charlie Savage2023-04-191-2/+10
| | | | | | trying to load a 32bit dll from a 64 bit program (garbage.so in the test suite). Since the passed in buffer contains junk data the resulting error message full of garbage characters which makes it impossible to know what the problem is. This commit updates the message so that it at least returns the error code (in this case 193) which makes it possible to debug the problem.
* Merge pull request #1025 from peterzhu2118/pz-rarray-ptrLars Kanis2023-04-192-2/+2
|\ | | | | Remove use of RARRAY_PTR
| * Remove use of RARRAY_PTRPeter Zhu2023-04-182-2/+2
| | | | | | | | | | RARRAY_PTR is bad for GC performance as it exposes the internal buffer of the array meaning that the array becomes write barrier unprotected.
* | Remove old definitions in compat.h for Ruby 1.xPeter Zhu2023-04-181-23/+0
|/ | | | | These definitions all exist in all recent versions of Ruby, so it's dead code that we can remove.
* Remove unused FFI::SizeTypesLars Kanis2023-04-181-16/+13
| | | | It is not used in C or Ruby code.
* Merge pull request #1021 from larskanis/compactLars Kanis2023-04-1613-37/+197
|\ | | | | Make FFI classes GC.compact friendly
| * Make FFI classes GC.compact friendlyLars Kanis2023-04-1413-37/+197
| | | | | | | | | | | | This allows to relocate all FFI objects. Also remove marking of StructLayout->cache_row in favour of clearing it at GC.compact only.
* | Disable custom trampoline when using libffi closure allocationLars Kanis2023-04-141-1/+3
| | | | | | | | | | | | This is because libffi changed the way how closures are allocated to static trampolines. `codeloc` is an opaque pointer now, to the internal `struct tramp` struct - and not to executable code. The executable code of trampolines is static and no longer written or writable at runtime.
* | Update libffi to latest masterLars Kanis2023-04-141-0/+0
|/
* Merge pull request #1012 from larskanis/type-check-by-typed-dataLars Kanis2023-03-066-25/+20
|\ | | | | Use type checking by TypedData and remove duplocated check by rb_obj_is_kind_of
| * Use type checking by TypedData and remove duplocated check by rb_obj_is_kind_ofLars Kanis2023-03-066-25/+20
| | | | | | | | This is now possible with new typed data objects.
* | Merge pull request #1013 from larskanis/undef-abstractmem-newLars Kanis2023-03-061-12/+1
|\ \ | | | | | | Remove allocator of AbstractMemory
| * | Remove allocator of AbstractMemoryLars Kanis2023-03-061-12/+1
| |/ | | | | | | | | | | This disables AbstractMemory.new, which has no practical use. As discussed in #1010
* | Implement the last missing Write Barriers and dsizeJean Boussier2023-03-063-9/+36
|/ | | | | | | | | | | | | | Ref: https://github.com/ffi/ffi/pull/991 Write barrier protected objects are allowed to be promoted to the old generation, which means they only get marked on major GC. The downside is that the RB_BJ_WRITE macro MUST be used to set references, otherwise the referenced object may be garbaged collected. This commit also implement a `dsize` function so that these instance report a more relevant size in various memory profilers. It's not counting everything because some types are opaque right now, so a larger refactoring would be needed.
* Merge pull request #1010 from casperisfine/pointer-write-barrierLars Kanis2023-03-064-17/+78
|\ | | | | Implement Write Barrier and dsize for FFI::Pointer
| * Implement Write Barrier and dsize for FFI::PointerJean Boussier2023-03-064-17/+78
| | | | | | | | | | | | | | | | | | | | As well as FFI::MemoryPointer and FFI::AbstractMemory Write barrier protected objects are allowed to be promoted to the old generation, which means they only get marked on major GC. The downside is that the RB_BJ_WRITE macro MUST be used to set references, otherwise the referenced object may be garbaged collected. This commit also implement a dsize function so that these instance report a more relevant size in various memory profilers.
* | Merge branch 'struct-layout-write-barrier' of ↵Lars Kanis2023-03-063-14/+35
|\ \ | |/ |/| | | https://github.com/casperisfine/ffi into casperisfine-struct-layout-write-barrier
| * Implement Write Barrier and dsize for FFI::StructLayoutJean Boussier2023-03-063-14/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | And FFI::StructLayout::Field Write barrier protected objects are allowed to be promoted to the old generation, which means they only get marked on major GC. The downside is that the RB_BJ_WRITE macro MUST be used to set references, otherwise the referenced object may be garbaged collected. This commit also implement a `dsize` function so that these instance report a more relevant size in various memory profilers. I had to get rid of the `memset(0)` in `struct_layout_mark` has with Write Barriers it's not guaranteed that the layout will be marked before `fieldName` is moved. I don't think it was a good fix anyway, it's better to mark these VALUE so the GC pin them. I think we could go back to an `st_table` and mark only the keys with `rb_mark_set`. But I didn't want to go down this rabbit hole.
* | Merge pull request #1009 from casperisfine/struct-by-value-write-barrierLars Kanis2023-03-061-6/+15
|\ \ | | | | | | Implement Write Barrier and dsize for FFI::StructByValue
| * | Implement Write Barrier and dsize for FFI::StructByValueJean Boussier2023-03-061-6/+15
| | | | | | | | | | | | | | | | | | | | | | | | Write barrier protected objects are allowed to be promoted to the old generation, which means they only get marked on major GC. The downside is that the RB_BJ_WRITE macro MUST be used to set references, otherwise the referenced object may be garbaged collected. This commit also implement a `dsize` function so that these instance report a more relevant size in various memory profilers.
* | | Merge pull request #1008 from casperisfine/variadic-write-barrierLars Kanis2023-03-061-8/+17
|\ \ \ | | | | | | | | Implement Write Barrier and dsize for FFI::VariadicInvoker
| * | | Implement Write Barrier and dsize for FFI::VariadicInvokerJean Boussier2023-03-061-8/+17
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Write barrier protected objects are allowed to be promoted to the old generation, which means they only get marked on major GC. The downside is that the RB_BJ_WRITE macro MUST be used to set references, otherwise the referenced object may be garbaged collected. This commit also implement a `dsize` function so that these instance report a more relevant size in various memory profilers.
* | | Merge pull request #1007 from casperisfine/struct-write-barrierLars Kanis2023-03-061-29/+50
|\ \ \ | | | | | | | | Implement Write Barrier and dsize for FFI::Struct
| * | | Implement Write Barrier and dsize for FFI::StructJean Boussier2023-03-061-29/+50
| | |/ | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | And FFI::Struct::InlineArray. Write barrier protected objects are allowed to be promoted to the old generation, which means they only get marked on major GC. The downside is that the RB_BJ_WRITE macro MUST be used to set references, otherwise the referenced object may be garbaged collected. This commit also implement a `dsize` function so that these instance report a more relevant size in various memory profilers.
* | | Merge pull request #1005 from casperisfine/type-write-barrierLars Kanis2023-03-064-23/+40
|\ \ \ | |_|/ |/| | Implement Write Barrier and dsize for FFI::Type
| * | Implement Write Barrier and dsize for FFI::TypeJean Boussier2023-03-064-23/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Ref: https://github.com/ffi/ffi/pull/991 Write barrier protected objects are allowed to be promoted to the old generation, which means they only get marked on major GC. The downside is that the RB_BJ_WRITE macro MUST be used to set references, otherwise the referenced object may be garbaged collected. This commit also implement a `dsize` function so that these instance report a more relevant size in various memory profilers. While I was at it I removed the `strdup` of `BuiltinType.name`, I don't see why we wouldn't directly point at static memory, that saves copying type names, and makes freeing builtin types easier.
* | | Merge branch 'master' of github.com:ffi/ffiLars Kanis2023-03-061-10/+16
|\ \ \
| * \ \ Merge pull request #1004 from casperisfine/symbol-write-barrierLars Kanis2023-03-061-10/+16
| |\ \ \ | | | | | | | | | | Implement Write Barrier and dsize for FFI::DynamicLibrary
| | * | | Implement Write Barrier and dsize for FFI::DynamicLibraryJean Boussier2023-03-061-10/+16
| | |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | And FFI::DynamicLibrary::Symbol Ref: https://github.com/ffi/ffi/pull/991 Write barrier protected objects are allowed to be promoted to the old generation, which means they only get marked on major GC. The downside is that the RB_BJ_WRITE macro MUST be used to set references, otherwise the referenced object may be garbaged collected. This commit also implement a `dsize` function so that these instance report a more relevant size in various memory profilers. It's not counting everything because some types are opaque right now, so a larger refactoring would be needed. While I was at it, I moved `Symbol.library` into the unused `Symbol.base.rbParent` which seemed appropriate and saves a pointer.
* | | | Merge branch 'master' of github.com:ffi/ffiLars Kanis2023-03-061-8/+25
|\ \ \ \ | |/ / /
| * | | Merge pull request #1003 from casperisfine/function-write-barrier-2Lars Kanis2023-03-061-8/+25
| |\ \ \ | | |_|/ | |/| | Implement Write Barrier and dsize for FFI::Function
| | * | Implement Write Barrier and dsize for FFI::FunctionJean Boussier2023-03-061-8/+25
| | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Ref: https://github.com/ffi/ffi/pull/991 Write barrier protected objects are allowed to be promoted to the old generation, which means they only get marked on major GC. The downside is that the RB_BJ_WRITE macro MUST be used to set references, otherwise the referenced object may be garbaged collected. This commit also implement a `dsize` function so that these instance report a more relevant size in various memory profilers. It's not counting everything because some types are opaque right now, so a larger refactoring would be needed.
* | | Fix class name of Symbol#inspectLars Kanis2023-03-061-1/+1
|/ /
* | Increment callbackCount outside of the macro RB_OBJ_WRITELars Kanis2023-03-061-1/+2
|/ | | | .. to ensure it is called exactly once.
* Merge pull request #1002 from casperisfine/builtin-type-inspectLars Kanis2023-03-061-2/+2
|\ | | | | Fix `Type#inspect` to properly display the constant name
| * Fix `Type#inspect` to properly display the constant nameJean Boussier2023-03-061-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | before: ```ruby >> FFI::Type::Builtin::CHAR => #<FFI::Type::Builtin:INT8 size=1 alignment=1> ``` after: ```ruby >> FFI::Type::Builtin::CHAR => #<FFI::Type::Builtin::INT8 size=1 alignment=1> ```
* | Implement Write Barrier and dsize for FFI::FunctionTypeJean Boussier2023-03-061-15/+35
|/ | | | | | | | | | | Write barrier protected objects are allowed to be promoted to the old generation, which means they only get marked on major GC. The downside is that the RB_BJ_WRITE macro MUST be used to set references, otherwise the referenced object may be garbaged collected. This commit also implement a `dsize` function so that these instance report a more relevant size in various memory profilers.
* Convert FFI::DynamicLibrary to TypedDataLars Kanis2023-03-031-7/+19
| | | | | | | Ref: ffi#991 The old untyped DATA API is soft deprecated and this new one open the door to write barriers, compaction, memsize etc.
* Change remaining use of TypedData objectLars Kanis2023-03-031-5/+1
| | | | for completeness even if this code part is commented out
* Merge branch 'typed-data-struct' of https://github.com/casperisfine/ffi into ↵Lars Kanis2023-03-034-19/+37
|\ | | | | | | casperisfine-typed-data-struct
| * Convert FFI::Struct to TypedDataJean Boussier2023-03-025-37/+65
| | | | | | | | | | | | | | Ref: https://github.com/ffi/ffi/pull/991 The old untyped DATA API is soft deprecated and this new one open the door to write barriers, compaction, memsize etc.
* | Merge branch 'casperisfine-typed-data-abstract-memory'Lars Kanis2023-03-0311-87/+192
|\ \
| * | Convert FFI::AbstractMemory and descendants to TypedDataJean Boussier2023-03-0211-87/+192
| |/ | | | | | | | | | | | | Ref: https://github.com/ffi/ffi/pull/991 The old untyped DATA API is soft deprecated and this new one open the door to write barriers, compaction, memsize etc.
* | Merge pull request #997 from casperisfine/typed-data-inline-arrayLars Kanis2023-03-031-11/+22
|\ \ | | | | | | Convert FFI::Struct::InlineArray to TypedData
| * | Convert FFI::Struct::InlineArray to TypedDataJean Boussier2023-03-021-11/+22
| |/ | | | | | | | | | | | | Ref: https://github.com/ffi/ffi/pull/991 The old untyped DATA API is soft deprecated and this new one open the door to write barriers, compaction, memsize etc.
* | Merge pull request #995 from casperisfine/typed-data-typeLars Kanis2023-03-0316-103/+205
|\ \ | | | | | | Convert FFI::Type and descendants to TypedData
| * | Convert FFI::Type and descendants to TypedDataJean Boussier2023-03-0216-103/+205
| |/ | | | | | | | | | | | | Ref: https://github.com/ffi/ffi/pull/991 The old untyped DATA API is soft deprecated and this new one open the door to write barriers, compaction, memsize etc.
* | Merge pull request #996 from casperisfine/typed-data-thread-dataLars Kanis2023-03-031-6/+18
|\ \ | | | | | | Convert FFI::ThreadData to TypedData
| * | Convert FFI::ThreadData to TypedDataJean Boussier2023-03-021-6/+18
| |/ | | | | | | | | | | | | Ref: https://github.com/ffi/ffi/pull/991 The old untyped DATA API is soft deprecated and this new one open the door to write barriers, compaction, memsize etc.