-
Notifications
You must be signed in to change notification settings - Fork 10.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dynamic function replacement #20333
Dynamic function replacement #20333
Commits on Nov 6, 2018
-
Allow dynamic without @objc in -swift-version 5
Dynamic functions will allow replacement of their implementation at runtime.
Configuration menu - View commit details
-
Copy full SHA for c158106 - Browse repository at this point
Copy the full SHA c158106View commit details -
Add [dynamically_replacable] to SILFunctions
'dynamic' functions are marked as [dynamically_replaceable].
Configuration menu - View commit details
-
Copy full SHA for 5f4e183 - Browse repository at this point
Copy the full SHA 5f4e183View commit details -
IRGen: Add implementation for dynamically replaceable functions
A dynamically replaceable function calls through a global variable that holds the function pointer. struct ChainEntry { void *(funPtr)(); struct ChainEntry *next; } ChainEntry dynamicallyReplaceableVar; void dynamicallyReplaceableFunction() { dynamicallyReplaceableVar.funPtr() } dynamic replacements will be chainable so the global variable also functions as the root entry in the chain of replacements. A dynamic replacement functions can call the previous implementation by going through its chain entry. ChainEntry chainEntryOf_dynamic_replacement_for_foo; void dynamic_replacement_for_foo() { // call the previous (original) implementation. chainEntryOf_dynamic_replacement_for_foo.funPtr(); }
Configuration menu - View commit details
-
Copy full SHA for ebbe3ae - Browse repository at this point
Copy the full SHA ebbe3aeView commit details -
Add new SIL instruction for calling dynamically_replaceable funtions
%0 = dynamic_function_ref @dynamically_replaceable_function apply %0() Calls a [dynamically_replaceable] function. %0 = prev_dynamic_function_ref @dynamic_replacement_function apply %0 Calls the previous implementation that dynamic_replacement_function replaced.
Configuration menu - View commit details
-
Copy full SHA for 7e32c68 - Browse repository at this point
Copy the full SHA 7e32c68View commit details -
Configuration menu - View commit details
-
Copy full SHA for 52c1903 - Browse repository at this point
Copy the full SHA 52c1903View commit details -
Parser/Sema/SILGen changes for @_dynamicReplacement(for:)
Dynamic replacements are currently written in extensions as extension ExtendedType { @_dynamicReplacement(for: replacedFun()) func replacement() { } } The runtime implementation allows an implementation in the future where dynamic replacements are gather in a scope and can be dynamically enabled and disabled. For example: dynamic_extension_scope CollectionOfReplacements { extension ExtentedType { func replacedFun() {} } extension ExtentedType2 { func replacedFun() {} } } CollectionOfReplacements.enable() CollectionOfReplacements.disable()
Configuration menu - View commit details
-
Copy full SHA for b102c7f - Browse repository at this point
Copy the full SHA b102c7fView commit details -
Configuration menu - View commit details
-
Copy full SHA for 152e8db - Browse repository at this point
Copy the full SHA 152e8dbView commit details -
Configuration menu - View commit details
-
Copy full SHA for 89e1969 - Browse repository at this point
Copy the full SHA 89e1969View commit details -
Configuration menu - View commit details
-
Copy full SHA for f1b53eb - Browse repository at this point
Copy the full SHA f1b53ebView commit details -
Configuration menu - View commit details
-
Copy full SHA for c77da02 - Browse repository at this point
Copy the full SHA c77da02View commit details -
Configuration menu - View commit details
-
Copy full SHA for cf2eb21 - Browse repository at this point
Copy the full SHA cf2eb21View commit details
Commits on Nov 7, 2018
-
Configuration menu - View commit details
-
Copy full SHA for fff1333 - Browse repository at this point
Copy the full SHA fff1333View commit details