I try to create a codeCache via V8. Use ScriptCompiler::CreateCodeCache function.
ScriptCompiler::CachedData* CreateCachedData(Local<String> sourceContent, Local<String> sourceName) {
ScriptOrigin* scriptOriginPtr = nullptr;
scriptOriginPtr = new ScriptOrigin(
String::NewFromTwoByte(isolate_, sourceName, NewStringType::kNormal).ToLocalChecked(),
Integer::New(isolate_, 0), Integer::New(isolate_, 0));
ScriptCompiler::Source* source = nullptr;
source = new ScriptCompiler::Source(sourceContent, *scriptOriginPtr);
Local<Script> script;
ScriptCompiler::Compile(context_, source, ScriptCompiler::CompileOptions::kEagerCompile).ToLocal(&script);
ScriptCompiler::CachedData* data = ScriptCompiler::CreateCodeCache(script->GetUnboundScript());
return data;
}
When I use these code, the value of data is nullptr.
function A() {
"use asm"
function R() {}
return R
}
When I use these code, the value of data isn’t nullptr.
function A() {
"use asm"
function R() {};
return R
}
What’s the difference between these two JS codes in V8 or in JS?