From 1e18fc46b045f70267b089856526796b7a2b61a9 Mon Sep 17 00:00:00 2001 From: Yang Guo Date: Wed, 30 May 2018 09:08:12 +0200 Subject: [PATCH 1/3] deps: V8: cherry-pick a440efb27f from upstream Original commit message: [api] do not require source string for producing code cache. The embedder should not need to keep track of the source string. R=jgruber@chromium.org Cq-Include-Trybots: luci.chromium.try:linux_chromium_rel_ng Change-Id: Ie27df755a22fbcae7b6e87a435419d2d8f545558 Reviewed-on: https://chromium-review.googlesource.com/1013482 Reviewed-by: Jakob Gruber Commit-Queue: Yang Guo Cr-Commit-Position: refs/heads/master@{#52614} --- deps/v8/include/v8.h | 6 ++++++ deps/v8/src/api.cc | 14 ++++++++++++-- deps/v8/src/d8.cc | 4 ++-- deps/v8/src/snapshot/code-serializer.cc | 14 ++++++++------ deps/v8/src/snapshot/code-serializer.h | 5 ++--- deps/v8/test/cctest/test-api.cc | 3 +-- deps/v8/test/cctest/test-serialize.cc | 11 +++++------ 7 files changed, 36 insertions(+), 21 deletions(-) diff --git a/deps/v8/include/v8.h b/deps/v8/include/v8.h index ed1a6d4af1ac02..6fb5e50dbeed90 100644 --- a/deps/v8/include/v8.h +++ b/deps/v8/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/deps/v8/src/api.cc b/deps/v8/src/api.cc index 25506d3930868d..d78899347b7dd8 100644 --- a/deps/v8/src/api.cc +++ b/deps/v8/src/api.cc @@ -2626,21 +2626,31 @@ 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