Differences From Artifact [3ba8d16fba]:
- File src/runtime/tagged-pointer.m — part of check-in [577564693c] at 2020-06-29 23:24:20 on branch tagged-pointers — lookup-asm-x86_64-elf.S: Support tagged pointers (user: js, size: 1807) [annotate] [blame] [check-ins using]
To Artifact [1f64e311ce]:
- File
src/runtime/tagged-pointer.m
— part of check-in
[943cf97843]
at
2020-07-04 00:24:54
on branch tagged-pointers
— Only use 4 bits to classify tagged pointers
This leaves 28/60 bits for the value. (user: js, size: 1915) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
15 16 17 18 19 20 21 | * file. */ #import "ObjFWRT.h" #import "private.h" | > | | 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | * file. */ #import "ObjFWRT.h" #import "private.h" #define TAGGED_POINTER_BITS 4 #define NUM_TAGGED_POINTER_CLASSES (1 << (TAGGED_POINTER_BITS - 1)) Class objc_tagged_pointer_classes[NUM_TAGGED_POINTER_CLASSES]; static uint_fast8_t taggedPointerClassesCount; int_fast8_t objc_registerTaggedPointerClass(Class class) { |
︙ | ︙ | |||
45 46 47 48 49 50 51 | } Class object_getTaggedPointerClass(id object) { uintptr_t pointer = (uintptr_t)object; | | < | | | | 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | } Class object_getTaggedPointerClass(id object) { uintptr_t pointer = (uintptr_t)object; pointer &= (1 << TAGGED_POINTER_BITS) - 1; pointer >>= 1; if (pointer >= NUM_TAGGED_POINTER_CLASSES) return Nil; return objc_tagged_pointer_classes[pointer]; } uintptr_t object_getTaggedPointerValue(id object) { uintptr_t pointer = (uintptr_t)object; pointer >>= TAGGED_POINTER_BITS; return pointer; } id objc_createTaggedPointer(uint_fast8_t class, uintptr_t value) { uintptr_t pointer; if (class >= NUM_TAGGED_POINTER_CLASSES) return nil; if (value > (UINTPTR_MAX >> TAGGED_POINTER_BITS)) return nil; pointer = (class << 1) | 1; pointer |= (value << TAGGED_POINTER_BITS); return (id)pointer; } |