ObjFW  Check-in [55001dba24]

Overview
Comment:runtime: Document functions for tagged pointers
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | tagged-pointers
Files: files | file ages | folders
SHA3-256: 55001dba247b77096a086302fdb039e6ac2d4c3bb61d9dd77134fdb918591981
User & Date: js on 2020-09-26 19:13:14
Other Links: branch diff | manifest | tags
Context
2020-09-29
21:36
Merge support for tagged pointers check-in: b4039f9a85 user: js tags: trunk
2020-09-26
19:13
runtime: Document functions for tagged pointers Closed-Leaf check-in: 55001dba24 user: js tags: tagged-pointers
2020-09-04
18:03
OFNumber: Fix missing #ifdefs check-in: 81469669ae user: js tags: tagged-pointers
Changes

Modified src/runtime/ObjFWRT.h from [b42f831278] to [fc5b9a4b31].

240
241
242
243
244
245
246







247







248















249







250








251
252
253
254
255
256
257
    objc_enumeration_mutation_handler_t _Nullable handler);
extern id _Nullable objc_constructInstance(Class _Nullable class_,
    void *_Nullable bytes);
extern void *_Nullable objc_destructInstance(id _Nullable object);
extern void *_Null_unspecified objc_autoreleasePoolPush(void);
extern void objc_autoreleasePoolPop(void *_Null_unspecified pool);
extern id _Nullable _objc_rootAutorelease(id _Nullable object);







extern void objc_setTaggedPointerSecret(uintptr_t secret);







extern int objc_registerTaggedPointerClass(Class _Nonnull class);















extern Class _Nullable object_getTaggedPointerClass(id _Nonnull object);







extern uintptr_t object_getTaggedPointerValue(id _Nonnull object);








extern id _Nullable objc_createTaggedPointer(int class, uintptr_t value);

/*
 * Used by the compiler, but can also be called manually.
 *
 * These declarations are also required to prevent Clang's implicit
 * declarations which include __declspec(dllimport) on Windows.







>
>
>
>
>
>
>

>
>
>
>
>
>
>

>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

>
>
>
>
>
>
>

>
>
>
>
>
>
>
>







240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
    objc_enumeration_mutation_handler_t _Nullable handler);
extern id _Nullable objc_constructInstance(Class _Nullable class_,
    void *_Nullable bytes);
extern void *_Nullable objc_destructInstance(id _Nullable object);
extern void *_Null_unspecified objc_autoreleasePoolPush(void);
extern void objc_autoreleasePoolPop(void *_Null_unspecified pool);
extern id _Nullable _objc_rootAutorelease(id _Nullable object);

/*!
 * @brief Sets the tagged pointer secret.
 *
 * @param secret A secret, random value that will be used to XOR all tagged
 *		 pointers with
 */
extern void objc_setTaggedPointerSecret(uintptr_t secret);

/*!
 * @brief Registers a class for tagged pointers.
 *
 * @param class The class to register for tagged pointers
 * @return The tagged pointer ID for the registered class
 */
extern int objc_registerTaggedPointerClass(Class _Nonnull class);

/*!
 * @brief Returns whether the specified object is a tagged pointer.
 *
 * @param object The object to inspect
 * @return Whether the specified object is a tagged pointer
 */
static inline bool
object_isTaggedPointer(id _Nullable object)
{
	uintptr_t pointer = (uintptr_t)object;

	return pointer & 1;
}

extern Class _Nullable object_getTaggedPointerClass(id _Nonnull object);

/*!
 * @brief Returns the value of the specified tagged pointer.
 *
 * @param object The object whose tagged pointer value should be returned
 * @return The tagged pointer value of the object
 */
extern uintptr_t object_getTaggedPointerValue(id _Nonnull object);

/*!
 * @brief Creates a new tagged pointer.
 *
 * @param class The tag ID for the tagged pointer class to use
 * @param value The value the tagged pointer should have
 * @return A tagged pointer, or `nil` if it could not be created
 */
extern id _Nullable objc_createTaggedPointer(int class, uintptr_t value);

/*
 * Used by the compiler, but can also be called manually.
 *
 * These declarations are also required to prevent Clang's implicit
 * declarations which include __declspec(dllimport) on Windows.

Modified src/runtime/private.h from [e3fff27493] to [82de8c2339].

332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
	uint8_t i = idx >> 8;
	uint8_t j = idx;

	return dtable->buckets[i]->buckets[j];
#endif
}

static inline bool
object_isTaggedPointer(id _Nullable object)
{
	uintptr_t pointer = (uintptr_t)object;

	return pointer & 1;
}

#if defined(OF_ELF)
# if defined(OF_X86_64) || defined(OF_X86) || defined(OF_POWERPC) || \
    defined(OF_ARM64) || defined(OF_ARM) || \
    defined(OF_MIPS64_N64) || defined(OF_MIPS) || \
    defined(OF_SPARC64) || defined(OF_SPARC)
#  define OF_ASM_LOOKUP
# endif







<
<
<
<
<
<
<
<







332
333
334
335
336
337
338








339
340
341
342
343
344
345
	uint8_t i = idx >> 8;
	uint8_t j = idx;

	return dtable->buckets[i]->buckets[j];
#endif
}









#if defined(OF_ELF)
# if defined(OF_X86_64) || defined(OF_X86) || defined(OF_POWERPC) || \
    defined(OF_ARM64) || defined(OF_ARM) || \
    defined(OF_MIPS64_N64) || defined(OF_MIPS) || \
    defined(OF_SPARC64) || defined(OF_SPARC)
#  define OF_ASM_LOOKUP
# endif