| 28 | |
| 29 | #ifndef HERMESVM_LEAN |
| 30 | Shared<hermes::hbc::BCProvider> HermesJavaScriptCompiler::compile(const std::string& script, |
| 31 | const std::string_view& sourceFilename, |
| 32 | JSExceptionTracker& exceptionTracker) { |
| 33 | std::lock_guard<Mutex> lock(_mutex); |
| 34 | auto entry = _cache.find(script); |
| 35 | if (entry != _cache.end()) { |
| 36 | return entry->value(); |
| 37 | } |
| 38 | |
| 39 | auto compiledBytecode = compileToBytecode(script, |
| 40 | sourceFilename, |
| 41 | hermes::OutputFormatKind::Execute, |
| 42 | {}, |
| 43 | hermes::BytecodeGenerationOptions::defaults(), |
| 44 | exceptionTracker); |
| 45 | |
| 46 | if (!exceptionTracker) { |
| 47 | return nullptr; |
| 48 | } |
| 49 | |
| 50 | _cache.insert(script, compiledBytecode); |
| 51 | |
| 52 | return compiledBytecode; |
| 53 | } |
| 54 | |
| 55 | BytesView HermesJavaScriptCompiler::compileToSerializedBytecode(const std::string& script, |
| 56 | const std::string_view& sourceFilename, |
no test coverage detected