Skip to content

MyzTyn/tiny-objc-runtime

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tiny Objective-C Runtime

This repo is a small Objective-C runtime for arm64 macOS. It keeps the scope intentionally narrow so the code stays readable and useful for learning how Clang-emitted Objective-C metadata connects to message dispatch.

What It Supports

  • Class-method dispatch only
  • Basic parameters and return values
  • Normal Objective-C call syntax such as [Math addA:15 b:20]
  • A tiny objc_msgSend bridge plus readable lookup logic in C

What It Does Not Support

  • Instance allocation or instance methods
  • ARC integration
  • Method caches
  • Categories, protocols, ivars, or full runtime APIs
  • Platforms other than arm64 macOS

How It Works

The project is split into two small pieces:

  • runtime.c: walks Clang-emitted class metadata, finds a selector, and returns an IMP
  • objc_msgSend.s: a tiny arm64 ABI bridge that preserves argument registers, resolves the method, and jumps to the implementation

The key idea is that method lookup is easy to explain in C, while objc_msgSend still needs a small assembly wrapper because Objective-C syntax expects ABI-correct argument forwarding.

Project Layout

Build And Run

make run

Example output:

Hello from the mini runtime.

15 + 20 = 35
abs(-7) = 7

About

Show how Objective-C Runtime works (Very simple)

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors