MCPcopy Create free account
hub / github.com/Snapchat/Valdi / preCompile

Method preCompile

valdi/src/valdi/hermes/HermesJavaScriptContext.cpp:252–271  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

250}
251
252BytesView HermesJavaScriptContext::preCompile(const std::string_view& script,
253 const std::string_view& sourceFilename,
254 JSExceptionTracker& exceptionTracker) {
255#ifdef HERMESVM_LEAN
256 exceptionTracker.onError("Hermes not compiled with compilation enabled");
257 return BytesView();
258#else
259 hermes::vm::GCScope gcScope(*_runtime);
260 auto formattedScript = Valdi::formatJsModule(script);
261
262 auto serializedBytecode =
263 HermesJavaScriptCompiler::get()->compileToSerializedBytecode(formattedScript, sourceFilename, exceptionTracker);
264
265 if (!exceptionTracker) {
266 return BytesView();
267 }
268
269 return Valdi::makePreCompiledJsModule(serializedBytecode.data(), serializedBytecode.size());
270#endif
271}
272
273JSValueRef HermesJavaScriptContext::evaluatePreCompiled(const BytesView& script,
274 const std::string_view& sourceFilename,

Callers

nothing calls this directly

Calls 8

formatJsModuleFunction · 0.85
makePreCompiledJsModuleFunction · 0.85
onErrorMethod · 0.65
BytesViewClass · 0.50
getFunction · 0.50
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected