From 7ab7de1853e436a282c6a261b4616d48e96cb1e8 Mon Sep 17 00:00:00 2001 From: Piotr Sikora Date: Fri, 30 Oct 2020 08:31:49 -0700 Subject: [PATCH] wasm: update V8 to v8.7.220.10. (#13568) Signed-off-by: Piotr Sikora --- bazel/external/wee8.BUILD | 11 +++++++---- bazel/external/wee8.patch | 19 ++++++++++++++++--- bazel/repository_locations.bzl | 6 +++--- test/tools/wee8_compile/wee8_compile.cc | 12 ++++++++---- tools/code_format/check_format.py | 2 +- 5 files changed, 35 insertions(+), 15 deletions(-) diff --git a/bazel/external/wee8.BUILD b/bazel/external/wee8.BUILD index 3a62ecd9ebf4..ce16c32af799 100644 --- a/bazel/external/wee8.BUILD +++ b/bazel/external/wee8.BUILD @@ -9,15 +9,18 @@ cc_library( srcs = [ "libwee8.a", ], - hdrs = [ - "wee8/include/v8-version.h", - "wee8/third_party/wasm-api/wasm.hh", - ], + hdrs = + glob([ + "wee8/include/**/*.h", + "wee8/src/**/*.h", + "wee8/third_party/wasm-api/wasm.hh", + ]), copts = [ "-Wno-range-loop-analysis", ], defines = ["ENVOY_WASM_V8"], includes = [ + "wee8", "wee8/include", "wee8/third_party", ], diff --git a/bazel/external/wee8.patch b/bazel/external/wee8.patch index cce3eecde614..50255793070e 100644 --- a/bazel/external/wee8.patch +++ b/bazel/external/wee8.patch @@ -1,9 +1,10 @@ # 1. Fix linking with unbundled toolchain on macOS. # 2. Increase VSZ limit to 4TiB (allows us to start up to 409 VMs). # 3. Fix MSAN linking. +# 4. Fix Wasm module deserialization (http://crbug.com/v8/11024). --- wee8/build/toolchain/gcc_toolchain.gni +++ wee8/build/toolchain/gcc_toolchain.gni -@@ -329,6 +329,8 @@ template("gcc_toolchain") { +@@ -348,6 +348,8 @@ template("gcc_toolchain") { # AIX does not support either -D (deterministic output) or response # files. command = "$ar -X64 {{arflags}} -r -c -s {{output}} {{inputs}}" @@ -12,7 +13,7 @@ } else { rspfile = "{{output}}.rsp" rspfile_content = "{{inputs}}" -@@ -507,7 +509,7 @@ template("gcc_toolchain") { +@@ -543,7 +545,7 @@ template("gcc_toolchain") { start_group_flag = "" end_group_flag = "" @@ -51,5 +52,17 @@ - is_msan && (msan_track_origins == 0 || msan_track_origins == 2) +prebuilt_instrumented_libraries_available = false - if (use_libfuzzer && is_linux) { + if (use_libfuzzer && (is_linux || is_chromeos)) { if (is_asan) { +--- wee8/src/wasm/module-compiler.cc ++++ wee8/src/wasm/module-compiler.cc +@@ -2901,6 +2901,9 @@ void CompilationStateImpl::InitializeCompilationProgressAfterDeserialization() { + RequiredBaselineTierField::encode(ExecutionTier::kTurbofan) | + RequiredTopTierField::encode(ExecutionTier::kTurbofan) | + ReachedTierField::encode(ExecutionTier::kTurbofan); ++ finished_events_.Add(CompilationEvent::kFinishedExportWrappers); ++ finished_events_.Add(CompilationEvent::kFinishedBaselineCompilation); ++ finished_events_.Add(CompilationEvent::kFinishedTopTierCompilation); + compilation_progress_.assign(module->num_declared_functions, + kProgressAfterDeserialization); + } diff --git a/bazel/repository_locations.bzl b/bazel/repository_locations.bzl index c9a3dbd343c9..974c9deea62b 100644 --- a/bazel/repository_locations.bzl +++ b/bazel/repository_locations.bzl @@ -651,10 +651,10 @@ REPOSITORY_LOCATIONS_SPEC = dict( project_name = "V8", project_desc = "Google’s open source high-performance JavaScript and WebAssembly engine, written in C++", project_url = "https://v8.dev", - version = "8.5.210.20", + version = "8.7.220.10", # This archive was created using https://storage.googleapis.com/envoyproxy-wee8/wee8-archive.sh # and contains complete checkout of V8 with all dependencies necessary to build wee8. - sha256 = "ef404643d7da6854b76b9fb9950a79a1acbd037b7a26f02c585ac379b0f7dee1", + sha256 = "f22734640e0515bc34d1ca3772513aef24374fafa44d0489d3a9a57cadec69fb", urls = ["https://storage.googleapis.com/envoyproxy-wee8/wee8-{version}.tar.gz"], use_category = ["dataplane_ext"], extensions = [ @@ -664,7 +664,7 @@ REPOSITORY_LOCATIONS_SPEC = dict( "envoy.filters.network.wasm", "envoy.stat_sinks.wasm", ], - release_date = "2020-08-17", + release_date = "2020-10-27", cpe = "cpe:2.3:a:google:v8:*", ), com_googlesource_quiche = dict( diff --git a/test/tools/wee8_compile/wee8_compile.cc b/test/tools/wee8_compile/wee8_compile.cc index a1b2906ab281..fe257a95e1a6 100644 --- a/test/tools/wee8_compile/wee8_compile.cc +++ b/test/tools/wee8_compile/wee8_compile.cc @@ -1,12 +1,13 @@ // NOLINT(namespace-envoy) -#include - +#include #include #include #include +#include #include +#include "src/wasm/c-api.h" #include "v8-version.h" #include "wasm-api/wasm.hh" @@ -166,8 +167,11 @@ wasm::vec serializeWasmModule(const char* path, const wasm::vec& return wasm::vec::invalid(); } - // TODO(PiotrSikora): figure out how to hook the completion callback. - sleep(3); + wasm::StoreImpl* store_impl = reinterpret_cast(store.get()); + auto isolate = store_impl->isolate(); + while (isolate->HasPendingBackgroundTasks()) { + std::this_thread::sleep_for(std::chrono::milliseconds(50)); + } return module->serialize(); } diff --git a/tools/code_format/check_format.py b/tools/code_format/check_format.py index bb25f20cba44..ebe10e9ba133 100755 --- a/tools/code_format/check_format.py +++ b/tools/code_format/check_format.py @@ -58,7 +58,7 @@ "./test/test_common/simulated_time_system.cc", "./test/test_common/simulated_time_system.h", "./test/test_common/test_time.cc", "./test/test_common/test_time.h", "./test/test_common/utility.cc", "./test/test_common/utility.h", - "./test/integration/integration.h") + "./test/integration/integration.h", "./test/tools/wee8_compile/wee8_compile.cc") # Tests in these paths may make use of the Registry::RegisterFactory constructor or the # REGISTER_FACTORY macro. Other locations should use the InjectFactory helper class to