From 5405aeb2a3f700d3c937396fdd54dc2a968bc2cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Gregorczyk?= Date: Thu, 4 Aug 2016 15:42:56 -0700 Subject: [PATCH] First step to boot rn apps with hot bytecode cache Reviewed By: tadeuzagallo Differential Revision: D3561565 fbshipit-source-id: dc1cf580d7b31f30939b180aec38d9b8d0dd0f58 --- .../facebook/react/cxxbridge/UnpackingJSBundleLoader.java | 8 +++++++- ReactCommon/cxxreact/Executor.h | 1 + ReactCommon/cxxreact/JSCExecutor.cpp | 4 ++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/cxxbridge/UnpackingJSBundleLoader.java b/ReactAndroid/src/main/java/com/facebook/react/cxxbridge/UnpackingJSBundleLoader.java index e4cf13628..0b4f7d232 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/cxxbridge/UnpackingJSBundleLoader.java +++ b/ReactAndroid/src/main/java/com/facebook/react/cxxbridge/UnpackingJSBundleLoader.java @@ -40,10 +40,16 @@ public class UnpackingJSBundleLoader extends JSBundleLoader { /** * Flag passed to loadScriptFromOptimizedBundle to let the bridge know that - * the unpacked unpacked js source file. + * the unpacker unpacked js source file. */ public static final int UNPACKED_JS_SOURCE = (1 << 0); + /** + * Flag passed to loadScriptFromOptimizedBundle to let the bridge know that + * the unpacker unpacked bytecode cache files. + */ + public static final int UNPACKED_BC_CACHE = (1 << 1); + /** * Name of the lock files. Multiple processes can be spawned off the same app * and we need to guarantee that at most one unpacks files at any time. To diff --git a/ReactCommon/cxxreact/Executor.h b/ReactCommon/cxxreact/Executor.h index 62b2004c5..d1e55ba97 100644 --- a/ReactCommon/cxxreact/Executor.h +++ b/ReactCommon/cxxreact/Executor.h @@ -21,6 +21,7 @@ namespace react { enum { UNPACKED_JS_SOURCE = (1 << 0), + UNPACKED_BC_CACHE = (1 << 1), }; class JSExecutor; diff --git a/ReactCommon/cxxreact/JSCExecutor.cpp b/ReactCommon/cxxreact/JSCExecutor.cpp index b2b50fdc6..a86617e17 100644 --- a/ReactCommon/cxxreact/JSCExecutor.cpp +++ b/ReactCommon/cxxreact/JSCExecutor.cpp @@ -275,6 +275,10 @@ void JSCExecutor::loadApplicationScript( return loadApplicationScript(std::move(jsScriptBigString), sourceURL); } + if (flags & UNPACKED_BC_CACHE) { + configureJSCBCCache(m_context, bundlePath); + } + String jsSourceURL(sourceURL.c_str()); JSSourceCodeRef sourceCode = JSCreateSourceCode( jsScriptBigString->fd(),