Skip to content

Commit f34b914

Browse files
willholenfacebook-github-bot
authored andcommitted
Make the preemptive compilation threshold configurable
Summary: This diff allows specifying the preemptive compilation threshold via CompileFlags. Users get a toggle in CLI and RuntimeConfig that allows choosing between 1. fully eager, 2. fully lazy, 3. use default thresholds ("smart"). The default is microsoft#3. However, since we use `-O` by default, it overrides any lazy compilation when using the `hermes` binary. ChangeLog: [Internal] Inspector updated to use new RuntimeConfig laziness control Reviewed By: tmikov Differential Revision: D23356463 fbshipit-source-id: 508b7b2e6a218346c69acfec97e7891e388f0e9b
1 parent 300df59 commit f34b914

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed

ReactCommon/hermes/inspector/chrome/tests/AsyncHermesRuntime.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,17 @@ namespace chrome {
2020

2121
namespace detail = facebook::hermes::inspector::detail;
2222

23-
AsyncHermesRuntime::AsyncHermesRuntime()
24-
: runtime_(facebook::hermes::makeHermesRuntime()),
25-
executor_(
23+
AsyncHermesRuntime::AsyncHermesRuntime(bool veryLazy)
24+
: executor_(
2625
std::make_unique<detail::SerialExecutor>("async-hermes-runtime")) {
2726
using namespace std::placeholders;
2827

28+
auto builder = ::hermes::vm::RuntimeConfig::Builder();
29+
if (veryLazy) {
30+
builder.withCompilationMode(::hermes::vm::ForceLazyCompilation);
31+
}
32+
runtime_ = facebook::hermes::makeHermesRuntime(builder.build());
33+
2934
runtime_->global().setProperty(
3035
*runtime_,
3136
"shouldStop",

ReactCommon/hermes/inspector/chrome/tests/AsyncHermesRuntime.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ namespace chrome {
2727
*/
2828
class AsyncHermesRuntime {
2929
public:
30-
AsyncHermesRuntime();
30+
// Create a runtime. If veryLazy, configure the runtime to use completely
31+
// lazy compilation.
32+
AsyncHermesRuntime(bool veryLazy = false);
3133
~AsyncHermesRuntime();
3234

3335
std::shared_ptr<HermesRuntime> runtime() {

ReactCommon/hermes/inspector/chrome/tests/ConnectionTests.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ namespace {
4444
// the already-deallocated connection.
4545
class TestContext {
4646
public:
47-
TestContext(bool waitForDebugger = false)
48-
: conn_(runtime_.runtime(), waitForDebugger) {}
47+
TestContext(bool waitForDebugger = false, bool veryLazy = false)
48+
: runtime_(veryLazy), conn_(runtime_.runtime(), waitForDebugger) {}
4949
~TestContext() {
5050
runtime_.wait();
5151
}
@@ -860,9 +860,6 @@ TEST(ConnectionTests, testSetLazyBreakpoint) {
860860
SyncConnection &conn = context.conn();
861861
int msgId = 1;
862862

863-
facebook::hermes::HermesRuntime::DebugFlags flags{};
864-
flags.lazy = true;
865-
866863
asyncRuntime.executeScriptAsync(
867864
R"(
868865
var a = 1 + 2;
@@ -879,8 +876,7 @@ TEST(ConnectionTests, testSetLazyBreakpoint) {
879876
880877
foo();
881878
)",
882-
"url",
883-
flags);
879+
"url");
884880

885881
send<m::debugger::EnableRequest>(conn, msgId++);
886882
expectExecutionContextCreated(conn);

0 commit comments

Comments
 (0)