Revert "[build] Make separate snapshot for trusted variant"

This reverts commit 40d66d8bf8.

Reason for revert:
https://build.chromium.org/p/client.v8/builders/V8%20Mac64/builds/20910

Original change's description:
> [build] Make separate snapshot for trusted variant
> 
> This enables side-by-side snapshots with and without untrusted-code
> mitigations. It'll be the default in all V8 stand-alone builds
> with external startup data. Internal snapshots are not supported.
> 
> The files snapshot_blob.bin and snapshot_blob_trusted.bin will be
> bundled with V8 on swarming and the correct file is loaded dependent
> on the --untrusted-code-mitigations runtime flag.
> 
> Likewise we embed two snapshots for builtins.
> 
> Side-by-side snapshots won't be supported in Chromium.
> 
> Bug: v8:7441
> Change-Id: I2949ddfd5773649946b1c8e74751d48ad1d9c524
> Reviewed-on: https://chromium-review.googlesource.com/960004
> Commit-Queue: Michael Achenbach <machenbach@chromium.org>
> Reviewed-by: Jakob Gruber <jgruber@chromium.org>
> Reviewed-by: Yang Guo <yangguo@chromium.org>
> Reviewed-by: Ross McIlroy <rmcilroy@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#52028}

TBR=rmcilroy@chromium.org,machenbach@chromium.org,yangguo@chromium.org,mstarzinger@chromium.org,jgruber@chromium.org

Change-Id: I5b18f7aff7c05a17842fc68d785bb617eeca4a41
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: v8:7441
Reviewed-on: https://chromium-review.googlesource.com/968622
Reviewed-by: Michael Achenbach <machenbach@chromium.org>
Commit-Queue: Michael Achenbach <machenbach@chromium.org>
Cr-Commit-Position: refs/heads/master@{#52029}
This commit is contained in:
Michael Achenbach 2018-03-19 13:56:24 +00:00 committed by Commit Bot
parent 40d66d8bf8
commit 7e7c04b677
10 changed files with 18 additions and 138 deletions

View File

@ -9,7 +9,6 @@ import("//build/config/host_byteorder.gni")
import("//build/config/jumbo.gni")
import("//build/config/mips.gni")
import("//build/config/sanitizers/sanitizers.gni")
import("//build_overrides/build.gni")
if (is_android) {
import("//build/config/android/rules.gni")
@ -327,9 +326,6 @@ config("features") {
if (v8_enable_embedded_builtins) {
defines += [ "V8_EMBEDDED_BUILTINS" ]
}
if (v8_use_multi_snapshots) {
defines += [ "V8_MULTI_SNAPSHOTS" ]
}
}
config("toolchain") {
@ -722,8 +718,6 @@ action("d8_js2c") {
if (is_android && enable_java_templates) {
android_assets("v8_external_startup_data_assets") {
if (v8_use_external_startup_data) {
# We don't support side-by-side snapshots on Android within Chromium.
assert(!v8_use_multi_snapshots)
deps = [
"//v8",
]
@ -811,24 +805,8 @@ action("postmortem-metadata") {
rebase_path(sources, root_build_dir)
}
# Template to generate different V8 snapshots based on different runtime flags.
# Can be invoked with run_mksnapshot(<name>). The target will resolve to
# run_mksnapshot_<name>. If <name> is "default", no file suffixes will be used.
# Otherwise files are suffixed, e.g. embedded_<name>.cc and
# snapshot_blob_<name>.bin.
#
# The template exposes the variables:
# args: additional flags for mksnapshots
# embedded_suffix: a camel case suffix for method names in the embedded
# snapshot.
template("run_mksnapshot") {
name = target_name
if (name == "default") {
suffix = ""
} else {
suffix = "_$name"
}
action("run_mksnapshot_" + name) {
if (v8_use_snapshot) {
action("run_mksnapshot") {
visibility = [ ":*" ] # Only targets in this file can depend on this.
deps = [
@ -848,20 +826,12 @@ template("run_mksnapshot") {
"--turbo_instruction_scheduling",
]
args += invoker.args
if (v8_enable_embedded_builtins) {
outputs += [ "$target_gen_dir/embedded${suffix}.cc" ]
outputs += [ "$target_gen_dir/embedded.cc" ]
args += [
"--embedded_src",
rebase_path("$target_gen_dir/embedded${suffix}.cc", root_build_dir),
rebase_path("$target_gen_dir/embedded.cc", root_build_dir),
]
if (invoker.embedded_suffix != "") {
args += [
"--embedded_suffix",
invoker.embedded_suffix,
]
}
}
if (v8_random_seed != "0") {
@ -883,16 +853,16 @@ template("run_mksnapshot") {
}
if (v8_use_external_startup_data) {
outputs += [ "$root_out_dir/snapshot_blob${suffix}.bin" ]
outputs += [ "$root_out_dir/snapshot_blob.bin" ]
args += [
"--startup_blob",
rebase_path("$root_out_dir/snapshot_blob${suffix}.bin", root_build_dir),
rebase_path("$root_out_dir/snapshot_blob.bin", root_build_dir),
]
} else {
outputs += [ "$target_gen_dir/snapshot${suffix}.cc" ]
outputs += [ "$target_gen_dir/snapshot.cc" ]
args += [
"--startup_src",
rebase_path("$target_gen_dir/snapshot${suffix}.cc", root_build_dir),
rebase_path("$target_gen_dir/snapshot.cc", root_build_dir),
]
}
@ -910,23 +880,6 @@ template("run_mksnapshot") {
}
}
if (v8_use_snapshot) {
run_mksnapshot("default") {
args = []
if (v8_enable_embedded_builtins) {
embedded_suffix = ""
}
}
if (v8_use_multi_snapshots) {
run_mksnapshot("trusted") {
args = [ "--no-untrusted-code-mitigations" ]
if (v8_enable_embedded_builtins) {
embedded_suffix = "Trusted"
}
}
}
}
action("v8_dump_build_config") {
script = "tools/testrunner/utils/dump_build_config.py"
outputs = [
@ -1032,7 +985,7 @@ if (v8_use_snapshot && !v8_use_external_startup_data) {
public_deps = [
# This should be public so downstream targets can declare the snapshot
# output file as their inputs.
":run_mksnapshot_default",
":run_mksnapshot",
]
sources = [
@ -1072,13 +1025,9 @@ if (v8_use_snapshot && v8_use_external_startup_data) {
]
public_deps = [
":natives_blob",
":run_mksnapshot_default",
":run_mksnapshot",
]
if (v8_use_multi_snapshots) {
public_deps += [ ":run_mksnapshot_trusted" ]
}
sources = [
"src/setup-isolate-deserialize.cc",
"src/snapshot/natives-external.cc",
@ -1087,9 +1036,6 @@ if (v8_use_snapshot && v8_use_external_startup_data) {
if (v8_enable_embedded_builtins) {
sources += [ "$target_gen_dir/embedded.cc" ]
if (v8_use_multi_snapshots) {
sources += [ "$target_gen_dir/embedded_trusted.cc" ]
}
}
configs = [ ":internal_config" ]

View File

@ -116,11 +116,6 @@ template("v8_isolate_run") {
} else {
use_snapshot = "false"
}
if (v8_use_multi_snapshots) {
multi_snapshots = "1"
} else {
multi_snapshots = "0"
}
if (v8_has_valgrind) {
has_valgrind = "1"
} else {
@ -180,8 +175,6 @@ template("v8_isolate_run") {
"--config-variable",
"ubsan_vptr=$ubsan_vptr",
"--config-variable",
"v8_use_multi_snapshots=$multi_snapshots",
"--config-variable",
"v8_use_external_startup_data=$use_external_startup_data",
"--config-variable",
"v8_use_snapshot=$use_snapshot",

View File

@ -37,9 +37,6 @@ declare_args() {
# https://803591
v8_use_snapshot = !(is_win && host_os != "win" && target_cpu == "x64")
# Enable several snapshots side-by-side (e.g. default and for trusted code).
v8_use_multi_snapshots = ""
# Use external files for startup data blobs:
# the JS builtins sources and the start snapshot.
v8_use_external_startup_data = ""
@ -61,10 +58,6 @@ if (v8_use_external_startup_data == "") {
v8_use_external_startup_data = v8_use_snapshot && !is_ios
}
if (v8_use_multi_snapshots == "") {
v8_use_multi_snapshots = v8_use_external_startup_data && !build_with_chromium
}
if (v8_enable_backtrace == "") {
v8_enable_backtrace = is_debug && !v8_optimized_debug
}

View File

@ -17,13 +17,6 @@
],
},
}],
['v8_use_snapshot=="true" and v8_use_external_startup_data==1 and v8_use_multi_snapshots==1', {
'variables': {
'files': [
'<(PRODUCT_DIR)/snapshot_blob_trusted.bin',
],
},
}],
['tsan==1', {
'variables': {
'files': [

View File

@ -1067,8 +1067,6 @@ DEFINE_INT(testing_prng_seed, 42, "Seed used for threading test randomness")
// mksnapshot.cc
DEFINE_STRING(embedded_src, nullptr,
"Path for the generated embedded data file. (mksnapshot only)")
DEFINE_STRING(embedded_suffix, nullptr,
"Symbol suffix in embedded data file. (mksnapshot only)")
DEFINE_STRING(startup_src, nullptr,
"Write V8 startup as C++ src. (mksnapshot only)")
DEFINE_STRING(startup_blob, nullptr,

View File

@ -70,11 +70,6 @@ base::Atomic32 ThreadId::highest_thread_id_ = 0;
extern const uint8_t* DefaultEmbeddedBlob();
extern uint32_t DefaultEmbeddedBlobSize();
#ifdef V8_MULTI_SNAPSHOTS
extern const uint8_t* DefaultEmbeddedBlobTrusted();
extern uint32_t DefaultEmbeddedBlobSizeTrusted();
#endif
const uint8_t* Isolate::embedded_blob() const { return embedded_blob_; }
uint32_t Isolate::embedded_blob_size() const { return embedded_blob_size_; }
#endif
@ -2944,18 +2939,8 @@ bool Isolate::Init(StartupDeserializer* des) {
new CompilerDispatcher(this, V8::GetCurrentPlatform(), FLAG_stack_size);
#ifdef V8_EMBEDDED_BUILTINS
#ifdef V8_MULTI_SNAPSHOTS
if (FLAG_untrusted_code_mitigations) {
embedded_blob_ = DefaultEmbeddedBlob();
embedded_blob_size_ = DefaultEmbeddedBlobSize();
} else {
embedded_blob_ = DefaultEmbeddedBlobTrusted();
embedded_blob_size_ = DefaultEmbeddedBlobSizeTrusted();
}
#else
embedded_blob_ = DefaultEmbeddedBlob();
embedded_blob_size_ = DefaultEmbeddedBlobSize();
#endif
#endif
// Enable logging before setting up the heap

View File

@ -12,12 +12,6 @@ namespace internal {
#ifdef V8_EMBEDDED_BUILTINS
const uint8_t* DefaultEmbeddedBlob() { return nullptr; }
uint32_t DefaultEmbeddedBlobSize() { return 0; }
#ifdef V8_MULTI_SNAPSHOTS
const uint8_t* DefaultEmbeddedBlobTrusted() { return nullptr; }
uint32_t DefaultEmbeddedBlobSizeTrusted() { return 0; }
#endif
#endif
} // namespace internal

View File

@ -26,10 +26,6 @@ class SnapshotWriter {
void SetEmbeddedFile(const char* embedded_cpp_file) {
embedded_cpp_path_ = embedded_cpp_file;
}
void SetEmbeddedSuffix(const char* embedded_suffix) {
embedded_suffix_ = embedded_suffix;
}
#endif
void SetSnapshotFile(const char* snapshot_cpp_file) {
@ -128,7 +124,7 @@ class SnapshotWriter {
WriteEmbeddedFilePrefix(fp);
WriteEmbeddedFileData(fp, blob);
WriteEmbeddedFileSuffix(fp, embedded_suffix_);
WriteEmbeddedFileSuffix(fp);
fclose(fp);
}
@ -142,16 +138,14 @@ class SnapshotWriter {
fprintf(fp, "namespace {\n\n");
}
static void WriteEmbeddedFileSuffix(FILE* fp, const char* symbol_suffix) {
static void WriteEmbeddedFileSuffix(FILE* fp) {
fprintf(fp, "} // namespace\n\n");
fprintf(
fp,
"const uint8_t* DefaultEmbeddedBlob() { return v8_embedded_blob_; }\n");
fprintf(fp,
"const uint8_t* DefaultEmbeddedBlob%s() { return "
"v8_embedded_blob_; }\n",
symbol_suffix);
fprintf(fp,
"uint32_t DefaultEmbeddedBlobSize%s() { return "
"v8_embedded_blob_size_; }\n\n",
symbol_suffix);
"uint32_t DefaultEmbeddedBlobSize() { return "
"v8_embedded_blob_size_; }\n\n");
fprintf(fp, "} // namespace internal\n");
fprintf(fp, "} // namespace v8\n");
}
@ -217,7 +211,6 @@ class SnapshotWriter {
#ifdef V8_EMBEDDED_BUILTINS
const char* embedded_cpp_path_ = nullptr;
const char* embedded_suffix_ = "";
#endif
const char* snapshot_cpp_path_;
const char* snapshot_blob_path_;
@ -383,8 +376,6 @@ int main(int argc, char** argv) {
if (i::FLAG_startup_blob) writer.SetStartupBlobFile(i::FLAG_startup_blob);
#ifdef V8_EMBEDDED_BUILTINS
if (i::FLAG_embedded_src) writer.SetEmbeddedFile(i::FLAG_embedded_src);
if (i::FLAG_embedded_suffix)
writer.SetEmbeddedSuffix(i::FLAG_embedded_suffix);
#endif
std::unique_ptr<char> embed_script(

View File

@ -10,7 +10,6 @@
#include "src/base/file-utils.h"
#include "src/base/logging.h"
#include "src/base/platform/platform.h"
#include "src/flags.h"
#include "src/utils.h"
@ -87,15 +86,9 @@ void InitializeExternalStartupData(const char* directory_path) {
#ifdef V8_USE_EXTERNAL_STARTUP_DATA
char* natives;
char* snapshot;
const char* snapshot_name = "snapshot_blob.bin";
#ifdef V8_MULTI_SNAPSHOTS
if (!FLAG_untrusted_code_mitigations) {
snapshot_name = "snapshot_blob_trusted.bin";
}
#endif
LoadFromFiles(
base::RelativePath(&natives, directory_path, "natives_blob.bin"),
base::RelativePath(&snapshot, directory_path, snapshot_name));
base::RelativePath(&snapshot, directory_path, "snapshot_blob.bin"));
free(natives);
free(snapshot);
#endif // V8_USE_EXTERNAL_STARTUP_DATA

View File

@ -793,12 +793,6 @@ class AndroidPlatform(Platform): # pragma: no cover
target_dir,
skip_if_missing=True,
)
self._PushFile(
shell_dir,
"snapshot_blob_trusted.bin",
target_dir,
skip_if_missing=True,
)
self._PushFile(
shell_dir,
"icudtl.dat",