Skip to content

Commit

Permalink
Add a "Debug Build" flag to HermesInternal.getRuntimeProperties()
Browse files Browse the repository at this point in the history
Summary:
This diff adds a "Debug Build" key to the RuntimeProperties to easily
determine whether the VM was built with `-DNDEBUG` or `-UNDEBUG`.

Reviewed By: tmikov

Differential Revision: D22004322

fbshipit-source-id: 9a12e681b758a95f9eebb5f7e1198aa66e3f131c
  • Loading branch information
willholen authored and facebook-github-bot committed Jun 11, 2020
1 parent e318806 commit 064e4a0
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions lib/VM/JSLib/HermesInternal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,24 @@ hermesInternalGetRuntimeProperties(void *, Runtime *runtime, NativeArgs args) {
return ExecutionStatus::EXCEPTION;
}

const char buildMode[] =
#ifdef HERMES_SLOW_DEBUG
"SlowDebug"
#elif !defined(NDEBUG)
"Debug"
#else
"Release"
#endif
;
auto buildModeVal = StringPrimitive::create(
runtime, ASCIIRef(buildMode, sizeof(buildMode) - 1));
if (LLVM_UNLIKELY(
buildModeVal == ExecutionStatus::EXCEPTION ||
addProperty(runtime->makeHandle(*buildModeVal), "Build") ==
ExecutionStatus::EXCEPTION)) {
return ExecutionStatus::EXCEPTION;
}

return resultHandle.getHermesValue();
}

Expand Down

0 comments on commit 064e4a0

Please sign in to comment.