wickwirew / Runtime

A Swift Runtime library for viewing type info, and the dynamic getting and setting of properties.
MIT License
1.08k stars 94 forks source link

why class is 4096? not 2047 #15

Closed luoqisheng closed 6 years ago

luoqisheng commented 6 years ago

just a questoin! ref: https://github.com/apple/swift/blob/6a9e1f2b3e3ea27121a939140d4d6615ce78f1bb/include/swift/ABI/MetadataValues.h

wickwirew commented 6 years ago

Checkout Type Metadata. Specifically the Class Metadata where it talks about the kind

luoqisheng commented 6 years ago

Thanks!. Given a pointer ,how to tell which type it blongs to. i.e: class or just malloc block.

wickwirew commented 6 years ago

Thats not entirely possible. No metadata is stored with an object. A class will have an isa pointer however

luoqisheng commented 6 years ago

Thanks , I am trying to figure out how does the memory debugger works. And I found what you did was so cool. Anyway, thanks again.