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 #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
This commit is contained in:
Will Holen 2020-09-14 12:37:37 -07:00 коммит произвёл Facebook GitHub Bot
Родитель 300df59c77
Коммит f34b914c8d
3 изменённых файлов: 14 добавлений и 11 удалений

Просмотреть файл

@ -20,12 +20,17 @@ namespace chrome {
namespace detail = facebook::hermes::inspector::detail;
AsyncHermesRuntime::AsyncHermesRuntime()
: runtime_(facebook::hermes::makeHermesRuntime()),
executor_(
AsyncHermesRuntime::AsyncHermesRuntime(bool veryLazy)
: executor_(
std::make_unique<detail::SerialExecutor>("async-hermes-runtime")) {
using namespace std::placeholders;
auto builder = ::hermes::vm::RuntimeConfig::Builder();
if (veryLazy) {
builder.withCompilationMode(::hermes::vm::ForceLazyCompilation);
}
runtime_ = facebook::hermes::makeHermesRuntime(builder.build());
runtime_->global().setProperty(
*runtime_,
"shouldStop",

Просмотреть файл

@ -27,7 +27,9 @@ namespace chrome {
*/
class AsyncHermesRuntime {
public:
AsyncHermesRuntime();
// Create a runtime. If veryLazy, configure the runtime to use completely
// lazy compilation.
AsyncHermesRuntime(bool veryLazy = false);
~AsyncHermesRuntime();
std::shared_ptr<HermesRuntime> runtime() {

Просмотреть файл

@ -44,8 +44,8 @@ namespace {
// the already-deallocated connection.
class TestContext {
public:
TestContext(bool waitForDebugger = false)
: conn_(runtime_.runtime(), waitForDebugger) {}
TestContext(bool waitForDebugger = false, bool veryLazy = false)
: runtime_(veryLazy), conn_(runtime_.runtime(), waitForDebugger) {}
~TestContext() {
runtime_.wait();
}
@ -860,9 +860,6 @@ TEST(ConnectionTests, testSetLazyBreakpoint) {
SyncConnection &conn = context.conn();
int msgId = 1;
facebook::hermes::HermesRuntime::DebugFlags flags{};
flags.lazy = true;
asyncRuntime.executeScriptAsync(
R"(
var a = 1 + 2;
@ -879,8 +876,7 @@ TEST(ConnectionTests, testSetLazyBreakpoint) {
foo();
)",
"url",
flags);
"url");
send<m::debugger::EnableRequest>(conn, msgId++);
expectExecutionContextCreated(conn);