diff --git a/include/v8.h b/include/v8.h index 29566f4303..07a500f7ff 100644 --- a/include/v8.h +++ b/include/v8.h @@ -1578,6 +1578,9 @@ class V8_EXPORT ScriptCompiler { * This will return nullptr if the script cannot be serialized. The * CachedData returned by this function should be owned by the caller. */ + static CachedData* CreateCodeCache(Local unbound_script); + + // Deprecated. static CachedData* CreateCodeCache(Local unbound_script, Local source); @@ -1587,6 +1590,9 @@ class V8_EXPORT ScriptCompiler { * This will return nullptr if the script cannot be serialized. The * CachedData returned by this function should be owned by the caller. */ + static CachedData* CreateCodeCacheForFunction(Local function); + + // Deprecated. static CachedData* CreateCodeCacheForFunction(Local function, Local source); diff --git a/src/api.cc b/src/api.cc index 27e7598bfa..61b1be1401 100644 --- a/src/api.cc +++ b/src/api.cc @@ -2628,21 +2628,29 @@ uint32_t ScriptCompiler::CachedDataVersionTag() { ScriptCompiler::CachedData* ScriptCompiler::CreateCodeCache( Local unbound_script, Local source) { + return CreateCodeCache(unbound_script); +} + +ScriptCompiler::CachedData* ScriptCompiler::CreateCodeCache( + Local unbound_script) { i::Handle shared = i::Handle::cast( Utils::OpenHandle(*unbound_script)); - i::Handle source_str = Utils::OpenHandle(*source); DCHECK(shared->is_toplevel()); - return i::CodeSerializer::Serialize(shared, source_str); + return i::CodeSerializer::Serialize(shared); } ScriptCompiler::CachedData* ScriptCompiler::CreateCodeCacheForFunction( Local function, Local source) { + return CreateCodeCacheForFunction(function); +} + +ScriptCompiler::CachedData* ScriptCompiler::CreateCodeCacheForFunction( + Local function) { i::Handle shared( i::Handle::cast(Utils::OpenHandle(*function))->shared()); - i::Handle source_str = Utils::OpenHandle(*source); CHECK(shared->is_wrapped()); - return i::CodeSerializer::Serialize(shared, source_str); + return i::CodeSerializer::Serialize(shared); } MaybeLocal