Experiment with HostFunction caching in TurboModules

Summary:
Enables two new experiments (and the current behaviour as default) to speed up access to TurboModule methods from JS.

1) HostObject - Current behaviour
2) Prototype - Connect the TM HostObject via `__proto__`, and cache any methods accessed on the wrapper object.
3) Eager - Eagerly store all methods on the wrapper object, do not expose the HostObject to JS at all (TurboModules no longer need to be HostObjects in this scenario)

Changelog: [Internal]

Reviewed By: JoshuaGross, rubennorte, mdvacca

Differential Revision: D36590018

fbshipit-source-id: c9565eb239eb6aeee0f06b581ff8cd72a92073fc
This commit is contained in:
Pieter De Baets
2022-05-25 07:46:21 -07:00
committed by Facebook GitHub Bot
parent d5045252f8
commit 5ae53cc051
7 changed files with 104 additions and 15 deletions
@@ -116,4 +116,15 @@ public class ReactFeatureFlags {
/** Feature Flag to control RN Android scrollEventThrottle prop. */
public static boolean enableScrollEventThrottle = false;
/**
* Feature flag that controls how turbo modules are exposed to JS
*
* <ul>
* <li>0 = as a HostObject
* <li>1 = as a plain object, backed with a HostObject as prototype
* <li>2 = as a plain object, with all methods eagerly configured
* </ul>
*/
public static int turboModuleBindingMode = 0;
}