@@ -168,28 +168,13 @@ disabled where we dynamically detect that they probably won't be used. See the
168
168
169
169
## C Extension Compatibility
170
170
171
- #### Storing Ruby objects in native structures and arrays
171
+ #### ` VALUE ` is a pointer
172
172
173
- You cannot store a Ruby object in a structure or array that has been natively
174
- allocated, such as on the stack, or in a heap-allocated structure or array.
175
-
176
- Simple local variables of type ` VALUE ` , and locals arrays that are defined such
177
- as ` VALUE array[n] ` are an exception and are supported, provided their address
178
- is not taken and passed to a function that is not inlined.
179
-
180
- ` void *rb_tr_handle_for_managed(VALUE managed) ` and `VALUE
181
- rb_tr_managed_from_handle(void * native)` may help you work around this
182
- limitation. Use ` void* rb_tr_handle_for_managed_leaking(VALUE managed) ` if you
183
- don't yet know where to put a corresponding call to `void
184
- * rb_tr_release_handle(void * native)` . Use ` VALUE
185
- rb_tr_managed_from_handle_or_null(void * native)` if the handle may be ` NULL`.
186
-
187
- #### Mixing native and managed in C global variables
188
-
189
- C global variables can contain native data or they can contain managed data,
190
- but they cannot contain both in the same program run. If you have a global you
191
- assign ` NULL ` to (` NULL ` being just ` 0 ` and so a native address) you cannot
192
- then assign managed data to this variable.
173
+ In TruffleRuby ` VALUE ` is a pointer type (` void * ` ) rather than a
174
+ integer type (` long ` ). This means that ` switch ` statements cannot be
175
+ done using a raw ` VALUE ` as they can with MRI. You can normally
176
+ replace any ` switch ` statement with ` if ` statements with little
177
+ difficulty if required.
193
178
194
179
#### Identifiers may be macros or functions
195
180
@@ -200,34 +185,18 @@ address of it, assigning to a function pointer variable and using defined() to
200
185
check if a macro exists). These issues should all be considered bugs and be
201
186
fixed, please report these cases.
202
187
203
- #### Variadic functions
204
-
205
- Variadic arguments of type ` VALUE ` that hold Ruby objects can be used, but they
206
- cannot be accessed with ` va_start ` etc. You can use
207
- ` void *polyglot_get_arg(int i) ` instead.
208
-
209
- #### Pointers to ` VALUE ` locals and variadic functions
210
-
211
- Pointers to local variables that have the type ` VALUE ` and hold Ruby objects can
212
- only be passed as function arguments if the function is inlined. LLVM will never
213
- inline variadic functions so pointers to local variables that hold Ruby objects
214
- cannot be passed as variadic arguments.
215
-
216
- ` rb_scan_args ` is an exception and is supported.
217
-
218
188
#### ` rb_scan_args `
219
189
220
190
` rb_scan_args ` only supports up to ten pointers.
221
191
222
192
#### ` RDATA `
223
193
224
- The ` mark ` function of ` RDATA ` and ` RTYPEDDATA ` is never called.
225
-
226
- #### Ruby objects and truthiness in C
227
-
228
- All Ruby objects are truthy in C, except for ` Qfalse ` , the ` Integer ` value ` 0 ` ,
229
- and the ` Float ` value ` 0.0 ` . The last two are incompatible with MRI, which would
230
- also see these values as truthy.
194
+ The ` mark ` function of ` RDATA ` and ` RTYPEDDATA ` is not called during
195
+ garbage collection. Instead we simulate this by caching information
196
+ about objects as they are assigned to structs, and periodically run
197
+ all mark functions when the cache has become full to represent those
198
+ object relationships in a way that the our garbage collector will
199
+ understand. The process should behave identically to MRI.
231
200
232
201
## Compatibility with JRuby
233
202
0 commit comments