Merge V8 5.3.332.45.  DO NOT MERGE

Test: Manual

FPIIM-449

Change-Id: Id3254828b068abdea3cb10442e0172a8c9a98e03
(cherry picked from commit 13e2dadd00298019ed862f2b2fc5068bba730bcf)
diff --git a/BUILD.gn b/BUILD.gn
index eec472f..3121dce 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -4,6 +4,7 @@
 
 import("//build/config/android/config.gni")
 import("//build/config/arm.gni")
+import("//build/config/dcheck_always_on.gni")
 import("//build/config/mips.gni")
 import("//build/config/sanitizers/sanitizers.gni")
 
@@ -11,25 +12,13 @@
   import("//build/config/android/rules.gni")
 }
 
-# Because standalone V8 builds are not supported, assume this is part of a
-# Chromium build.
+import("gni/v8.gni")
+import("gni/isolate.gni")
 import("//build_overrides/v8.gni")
 
 import("snapshot_toolchain.gni")
 
 declare_args() {
-  # Use ICU data file (icudtl.dat) if true or library (shared on windows,
-  # static otherwise).
-  icu_use_data_file_flag = true
-
-  # Enable the snapshot feature, for fast context creation.
-  # http://v8project.blogspot.com/2015/09/custom-startup-snapshots.html
-  v8_use_snapshot = true
-
-  # Use external files for startup data blobs:
-  # the JS builtins sources and the start snapshot.
-  v8_use_external_startup_data = true
-
   # Sets -DVERIFY_HEAP.
   v8_enable_verify_heap = false
 
@@ -52,6 +41,9 @@
   # add a dependency on the ICU library.
   v8_enable_i18n_support = true
 
+  # Enable slow dchecks.
+  v8_enable_slow_dchecks = false
+
   # Interpreted regexp engine exists as platform-independent alternative
   # based where the regular expression is compiled to a bytecode.
   v8_interpreted_regexp = false
@@ -74,24 +66,6 @@
 v8_random_seed = "314159265"
 v8_toolset_for_shell = "host"
 
-if (is_msan) {
-  # Running the V8-generated code on an ARM simulator is a powerful hack that
-  # allows the tool to see the memory accesses from JITted code. Without this
-  # flag, JS code causes false positive reports from MSan.
-  v8_target_arch = "arm64"
-} else {
-  v8_target_arch = target_cpu
-}
-
-if (v8_use_snapshot && v8_use_external_startup_data) {
-  snapshot_target = ":v8_external_snapshot"
-} else if (v8_use_snapshot) {
-  snapshot_target = ":v8_snapshot"
-} else {
-  assert(!v8_use_external_startup_data)
-  snapshot_target = ":v8_nosnapshot"
-}
-
 ###############################################################################
 # Configurations
 #
@@ -119,6 +93,11 @@
   include_dirs = [ "include" ]
 }
 
+# This config should be applied to code using the libsampler.
+config("libsampler_config") {
+  include_dirs = [ "include" ]
+}
+
 # This config should only be applied to code using V8 and not any V8 code
 # itself.
 config("external_config") {
@@ -185,8 +164,9 @@
 
   defines = []
   cflags = []
+  ldflags = []
 
-  if (v8_target_arch == "arm") {
+  if (v8_target_cpu == "arm") {
     defines += [ "V8_TARGET_ARCH_ARM" ]
     if (arm_version == 7) {
       defines += [ "CAN_USE_ARMV7_INSTRUCTIONS" ]
@@ -217,12 +197,12 @@
       }
     }
   }
-  if (v8_target_arch == "arm64") {
+  if (v8_target_cpu == "arm64") {
     defines += [ "V8_TARGET_ARCH_ARM64" ]
   }
 
   # TODO(jochen): Add support for mips.
-  if (v8_target_arch == "mipsel") {
+  if (v8_target_cpu == "mipsel") {
     defines += [ "V8_TARGET_ARCH_MIPS" ]
     if (v8_can_use_fpu_instructions) {
       defines += [ "CAN_USE_FPU_INSTRUCTIONS" ]
@@ -257,7 +237,7 @@
   }
 
   # TODO(jochen): Add support for mips64.
-  if (v8_target_arch == "mips64el") {
+  if (v8_target_cpu == "mips64el") {
     defines += [ "V8_TARGET_ARCH_MIPS64" ]
     if (v8_can_use_fpu_instructions) {
       defines += [ "CAN_USE_FPU_INSTRUCTIONS" ]
@@ -279,27 +259,33 @@
       defines += [ "_MIPS_ARCH_MIPS64R2" ]
     }
   }
-  if (v8_target_arch == "s390") {
+  if (v8_target_cpu == "s390" || v8_target_cpu == "s390x") {
     defines += [ "V8_TARGET_ARCH_S390" ]
+    if (v8_target_cpu == "s390x") {
+      defines += [ "V8_TARGET_ARCH_S390X" ]
+    }
+    if (host_cpu == "x64" || host_cpu == "x86") {
+      defines += [ "V8_TARGET_ARCH_S390_LE_SIM" ]
+    }
   }
-  if (v8_target_arch == "s390x") {
-    defines += [
-      "V8_TARGET_ARCH_S390",
-      "V8_TARGET_ARCH_S390X",
-    ]
-  }
-  if (v8_target_arch == "x86") {
+  if (v8_target_cpu == "x86") {
     defines += [ "V8_TARGET_ARCH_IA32" ]
+    if (is_win) {
+      # Ensure no surprising artifacts from 80bit double math with x86.
+      cflags += [ "/arch:SSE2" ]
+    }
   }
-  if (v8_target_arch == "x64") {
+  if (v8_target_cpu == "x64") {
     defines += [ "V8_TARGET_ARCH_X64" ]
+    if (is_win) {
+      # Increase the initial stack size. The default is 1MB, this is 2MB. This
+      # applies only to executables and shared libraries produced by V8 since
+      # ldflags are not pushed to dependants.
+      ldflags += [ "/STACK:2097152" ]
+    }
   }
 
-  if (is_win) {
-    defines += [ "WIN32" ]
-    # TODO(jochen): Support v8_enable_prof.
-  }
-
+  # TODO(jochen): Support v8_enable_prof on Windows.
   # TODO(jochen): Add support for compiling with simulators.
 
   if (is_debug) {
@@ -312,31 +298,11 @@
       "DEBUG",
       "TRACE_MAPS",
     ]
-    if (!v8_optimized_debug) {
+    if (v8_enable_slow_dchecks) {
       defines += [ "ENABLE_SLOW_DCHECKS" ]
     }
-  }
-}
-
-###############################################################################
-# Templates
-#
-
-template("v8_source_set") {
-  source_set(target_name) {
-    forward_variables_from(invoker, "*", [ "configs" ])
-    configs += invoker.configs
-    configs -= [ "//build/config/compiler:chromium_code" ]
-    configs += [ "//build/config/compiler:no_chromium_code" ]
-    configs += [
-      ":features",
-      ":toolchain",
-    ]
-
-    if (!is_debug || v8_optimized_debug) {
-      configs -= [ "//build/config/compiler:default_optimization" ]
-      configs += [ "//build/config/compiler:optimize_max" ]
-    }
+  } else if (dcheck_always_on) {
+    defines += [ "DEBUG" ]
   }
 }
 
@@ -365,7 +331,6 @@
     "src/js/symbol.js",
     "src/js/array.js",
     "src/js/string.js",
-    "src/js/uri.js",
     "src/js/math.js",
     "src/third_party/fdlibm/fdlibm.js",
     "src/js/regexp.js",
@@ -377,7 +342,6 @@
     "src/js/collection-iterator.js",
     "src/js/promise.js",
     "src/js/messages.js",
-    "src/js/json.js",
     "src/js/array-iterator.js",
     "src/js/string-iterator.js",
     "src/js/templates.js",
@@ -427,11 +391,8 @@
     "src/messages.h",
     "src/js/harmony-async-await.js",
     "src/js/harmony-atomics.js",
-    "src/js/harmony-regexp-exec.js",
     "src/js/harmony-sharedarraybuffer.js",
     "src/js/harmony-simd.js",
-    "src/js/harmony-species.js",
-    "src/js/harmony-unicode-regexps.js",
     "src/js/harmony-string-padding.js",
     "src/js/promise-extra.js",
   ]
@@ -551,8 +512,16 @@
       deps = [
         "//v8",
       ]
-      renaming_sources = v8_external_startup_data_renaming_sources
-      renaming_destinations = v8_external_startup_data_renaming_destinations
+      sources = [
+        "$root_out_dir/natives_blob.bin",
+      ]
+      renaming_sources = [ "$root_out_dir/snapshot_blob.bin" ]
+      if (current_cpu == "arm" || current_cpu == "x86" ||
+          current_cpu == "mipsel") {
+        renaming_destinations = [ "snapshot_blob_32.bin" ]
+      } else {
+        renaming_destinations = [ "snapshot_blob_64.bin" ]
+      }
       disable_compression = true
     }
   }
@@ -615,7 +584,7 @@
   visibility = [ ":*" ]  # Only targets in this file can depend on this.
 
   deps = [
-    ":mksnapshot($snapshot_toolchain)",
+    ":mksnapshot($v8_snapshot_toolchain)",
   ]
 
   script = "tools/run.py"
@@ -625,7 +594,7 @@
   ]
 
   args = [
-    "./" + rebase_path(get_label_info(":mksnapshot($snapshot_toolchain)",
+    "./" + rebase_path(get_label_info(":mksnapshot($v8_snapshot_toolchain)",
                                       "root_out_dir") + "/mksnapshot",
                        root_build_dir),
     "--startup_src",
@@ -652,6 +621,23 @@
 # Source Sets (aka static libraries)
 #
 
+source_set("v8_maybe_snapshot") {
+  if (v8_use_snapshot && v8_use_external_startup_data) {
+    public_deps = [
+      ":v8_external_snapshot",
+    ]
+  } else if (v8_use_snapshot) {
+    public_deps = [
+      ":v8_snapshot",
+    ]
+  } else {
+    assert(!v8_use_external_startup_data)
+    public_deps = [
+      ":v8_nosnapshot",
+    ]
+  }
+}
+
 v8_source_set("v8_nosnapshot") {
   visibility = [ ":*" ]  # Only targets in this file can depend on this.
 
@@ -735,8 +721,7 @@
   visibility = [ ":*" ]  # Only targets in this file can depend on this.
 
   sources = [
-    # TODO(fmeawad): This needs to be updated to support standalone V8 builds.
-    "../base/trace_event/common/trace_event_common.h",
+    "//base/trace_event/common/trace_event_common.h",
     "include/v8-debug.h",
     "include/v8-experimental.h",
     "include/v8-platform.h",
@@ -754,6 +739,7 @@
     "src/allocation-site-scopes.h",
     "src/allocation.cc",
     "src/allocation.h",
+    "src/api-arguments-inl.h",
     "src/api-arguments.cc",
     "src/api-arguments.h",
     "src/api-experimental.cc",
@@ -815,6 +801,7 @@
     "src/char-predicates.cc",
     "src/char-predicates.h",
     "src/checks.h",
+    "src/code-events.h",
     "src/code-factory.cc",
     "src/code-factory.h",
     "src/code-stub-assembler.cc",
@@ -852,8 +839,8 @@
     "src/compiler/bytecode-graph-builder.cc",
     "src/compiler/bytecode-graph-builder.h",
     "src/compiler/c-linkage.cc",
-    "src/compiler/coalesced-live-ranges.cc",
-    "src/compiler/coalesced-live-ranges.h",
+    "src/compiler/checkpoint-elimination.cc",
+    "src/compiler/checkpoint-elimination.h",
     "src/compiler/code-assembler.cc",
     "src/compiler/code-assembler.h",
     "src/compiler/code-generator-impl.h",
@@ -898,8 +885,6 @@
     "src/compiler/graph-visualizer.h",
     "src/compiler/graph.cc",
     "src/compiler/graph.h",
-    "src/compiler/greedy-allocator.cc",
-    "src/compiler/greedy-allocator.h",
     "src/compiler/instruction-codes.h",
     "src/compiler/instruction-scheduler.cc",
     "src/compiler/instruction-scheduler.h",
@@ -972,6 +957,8 @@
     "src/compiler/node.h",
     "src/compiler/opcodes.cc",
     "src/compiler/opcodes.h",
+    "src/compiler/operation-typer.cc",
+    "src/compiler/operation-typer.h",
     "src/compiler/operator-properties.cc",
     "src/compiler/operator-properties.h",
     "src/compiler/operator.cc",
@@ -984,6 +971,8 @@
     "src/compiler/pipeline.h",
     "src/compiler/raw-machine-assembler.cc",
     "src/compiler/raw-machine-assembler.h",
+    "src/compiler/redundancy-elimination.cc",
+    "src/compiler/redundancy-elimination.h",
     "src/compiler/register-allocator-verifier.cc",
     "src/compiler/register-allocator-verifier.h",
     "src/compiler/register-allocator.cc",
@@ -1006,6 +995,8 @@
     "src/compiler/source-position.h",
     "src/compiler/state-values-utils.cc",
     "src/compiler/state-values-utils.h",
+    "src/compiler/store-store-elimination.cc",
+    "src/compiler/store-store-elimination.h",
     "src/compiler/tail-call-optimization.cc",
     "src/compiler/tail-call-optimization.h",
     "src/compiler/type-hint-analyzer.cc",
@@ -1122,6 +1113,8 @@
     "src/dtoa.cc",
     "src/dtoa.h",
     "src/effects.h",
+    "src/eh-frame.cc",
+    "src/eh-frame.h",
     "src/elements-kind.cc",
     "src/elements-kind.h",
     "src/elements.cc",
@@ -1172,8 +1165,8 @@
     "src/handles-inl.h",
     "src/handles.cc",
     "src/handles.h",
-    "src/hashmap.h",
     "src/heap-symbols.h",
+    "src/heap/array-buffer-tracker-inl.h",
     "src/heap/array-buffer-tracker.cc",
     "src/heap/array-buffer-tracker.h",
     "src/heap/gc-idle-time-handler.cc",
@@ -1240,14 +1233,19 @@
     "src/interpreter/bytecode-array-iterator.h",
     "src/interpreter/bytecode-array-writer.cc",
     "src/interpreter/bytecode-array-writer.h",
+    "src/interpreter/bytecode-dead-code-optimizer.cc",
+    "src/interpreter/bytecode-dead-code-optimizer.h",
     "src/interpreter/bytecode-generator.cc",
     "src/interpreter/bytecode-generator.h",
+    "src/interpreter/bytecode-label.h",
     "src/interpreter/bytecode-peephole-optimizer.cc",
     "src/interpreter/bytecode-peephole-optimizer.h",
     "src/interpreter/bytecode-pipeline.cc",
     "src/interpreter/bytecode-pipeline.h",
     "src/interpreter/bytecode-register-allocator.cc",
     "src/interpreter/bytecode-register-allocator.h",
+    "src/interpreter/bytecode-register-optimizer.cc",
+    "src/interpreter/bytecode-register-optimizer.h",
     "src/interpreter/bytecode-traits.h",
     "src/interpreter/bytecodes.cc",
     "src/interpreter/bytecodes.h",
@@ -1268,7 +1266,9 @@
     "src/isolate-inl.h",
     "src/isolate.cc",
     "src/isolate.h",
+    "src/json-parser.cc",
     "src/json-parser.h",
+    "src/json-stringifier.cc",
     "src/json-stringifier.h",
     "src/keys.cc",
     "src/keys.h",
@@ -1342,8 +1342,8 @@
     "src/profiler/profile-generator-inl.h",
     "src/profiler/profile-generator.cc",
     "src/profiler/profile-generator.h",
-    "src/profiler/sampler.cc",
-    "src/profiler/sampler.h",
+    "src/profiler/profiler-listener.cc",
+    "src/profiler/profiler-listener.h",
     "src/profiler/sampling-heap-profiler.cc",
     "src/profiler/sampling-heap-profiler.h",
     "src/profiler/strings-storage.cc",
@@ -1395,7 +1395,6 @@
     "src/runtime/runtime-i18n.cc",
     "src/runtime/runtime-internal.cc",
     "src/runtime/runtime-interpreter.cc",
-    "src/runtime/runtime-json.cc",
     "src/runtime/runtime-literals.cc",
     "src/runtime/runtime-liveedit.cc",
     "src/runtime/runtime-maths.cc",
@@ -1410,7 +1409,6 @@
     "src/runtime/runtime-symbol.cc",
     "src/runtime/runtime-test.cc",
     "src/runtime/runtime-typedarray.cc",
-    "src/runtime/runtime-uri.cc",
     "src/runtime/runtime-utils.h",
     "src/runtime/runtime.cc",
     "src/runtime/runtime.h",
@@ -1449,8 +1447,6 @@
     "src/string-stream.h",
     "src/strtod.cc",
     "src/strtod.h",
-    "src/third_party/fdlibm/fdlibm.cc",
-    "src/third_party/fdlibm/fdlibm.h",
     "src/tracing/trace-event.cc",
     "src/tracing/trace-event.h",
     "src/transitions-inl.h",
@@ -1488,6 +1484,8 @@
     "src/version.h",
     "src/vm-state-inl.h",
     "src/vm-state.h",
+    "src/wasm/asm-types.cc",
+    "src/wasm/asm-types.h",
     "src/wasm/asm-wasm-builder.cc",
     "src/wasm/asm-wasm-builder.h",
     "src/wasm/ast-decoder.cc",
@@ -1500,10 +1498,14 @@
     "src/wasm/module-decoder.h",
     "src/wasm/switch-logic.cc",
     "src/wasm/switch-logic.h",
+    "src/wasm/wasm-debug.cc",
+    "src/wasm/wasm-debug.h",
     "src/wasm/wasm-external-refs.cc",
     "src/wasm/wasm-external-refs.h",
     "src/wasm/wasm-function-name-table.cc",
     "src/wasm/wasm-function-name-table.h",
+    "src/wasm/wasm-interpreter.cc",
+    "src/wasm/wasm-interpreter.h",
     "src/wasm/wasm-js.cc",
     "src/wasm/wasm-js.h",
     "src/wasm/wasm-macro-gen.h",
@@ -1519,7 +1521,7 @@
     "src/zone.h",
   ]
 
-  if (v8_target_arch == "x86") {
+  if (v8_target_cpu == "x86") {
     sources += [
       "src/compiler/ia32/code-generator-ia32.cc",
       "src/compiler/ia32/instruction-codes-ia32.h",
@@ -1557,7 +1559,7 @@
       "src/regexp/ia32/regexp-macro-assembler-ia32.cc",
       "src/regexp/ia32/regexp-macro-assembler-ia32.h",
     ]
-  } else if (v8_target_arch == "x64") {
+  } else if (v8_target_cpu == "x64") {
     sources += [
       "src/compiler/x64/code-generator-x64.cc",
       "src/compiler/x64/instruction-codes-x64.h",
@@ -1595,7 +1597,7 @@
       "src/x64/macro-assembler-x64.cc",
       "src/x64/macro-assembler-x64.h",
     ]
-  } else if (v8_target_arch == "arm") {
+  } else if (v8_target_cpu == "arm") {
     sources += [
       "src/arm/assembler-arm-inl.h",
       "src/arm/assembler-arm.cc",
@@ -1638,7 +1640,7 @@
       "src/regexp/arm/regexp-macro-assembler-arm.cc",
       "src/regexp/arm/regexp-macro-assembler-arm.h",
     ]
-  } else if (v8_target_arch == "arm64") {
+  } else if (v8_target_cpu == "arm64") {
     sources += [
       "src/arm64/assembler-arm64-inl.h",
       "src/arm64/assembler-arm64.cc",
@@ -1694,7 +1696,7 @@
       "src/regexp/arm64/regexp-macro-assembler-arm64.cc",
       "src/regexp/arm64/regexp-macro-assembler-arm64.h",
     ]
-  } else if (v8_target_arch == "mipsel") {
+  } else if (v8_target_cpu == "mipsel") {
     sources += [
       "src/compiler/mips/code-generator-mips.cc",
       "src/compiler/mips/instruction-codes-mips.h",
@@ -1736,7 +1738,7 @@
       "src/regexp/mips/regexp-macro-assembler-mips.cc",
       "src/regexp/mips/regexp-macro-assembler-mips.h",
     ]
-  } else if (v8_target_arch == "mips64el") {
+  } else if (v8_target_cpu == "mips64el") {
     sources += [
       "src/compiler/mips64/code-generator-mips64.cc",
       "src/compiler/mips64/instruction-codes-mips64.h",
@@ -1778,7 +1780,7 @@
       "src/regexp/mips64/regexp-macro-assembler-mips64.cc",
       "src/regexp/mips64/regexp-macro-assembler-mips64.h",
     ]
-  } else if (v8_target_arch == "s390" || v8_target_arch == "s390x") {
+  } else if (v8_target_cpu == "s390" || v8_target_cpu == "s390x") {
     sources += [
       "src/compiler/s390/code-generator-s390.cc",
       "src/compiler/s390/instruction-codes-s390.h",
@@ -1827,6 +1829,7 @@
   defines = []
   deps = [
     ":v8_libbase",
+    ":v8_libsampler",
   ]
 
   if (is_win) {
@@ -1839,14 +1842,6 @@
     if (is_win) {
       deps += [ "//third_party/icu:icudata" ]
     }
-
-    if (icu_use_data_file_flag) {
-      defines += [ "ICU_UTIL_DATA_IMPL=ICU_UTIL_DATA_FILE" ]
-    } else if (is_win) {
-      defines += [ "ICU_UTIL_DATA_IMPL=ICU_UTIL_DATA_SHARED" ]
-    } else {
-      defines += [ "ICU_UTIL_DATA_IMPL=ICU_UTIL_DATA_STATIC" ]
-    }
   } else {
     sources -= [
       "src/i18n.cc",
@@ -1888,10 +1883,15 @@
     "src/base/cpu.h",
     "src/base/division-by-constant.cc",
     "src/base/division-by-constant.h",
+    "src/base/file-utils.cc",
+    "src/base/file-utils.h",
     "src/base/flags.h",
     "src/base/format-macros.h",
     "src/base/functional.cc",
     "src/base/functional.h",
+    "src/base/hashmap.h",
+    "src/base/ieee754.cc",
+    "src/base/ieee754.h",
     "src/base/iterator.h",
     "src/base/lazy-instance.h",
     "src/base/logging.cc",
@@ -1989,6 +1989,21 @@
   ]
 }
 
+v8_source_set("v8_libsampler") {
+  sources = [
+    "src/libsampler/v8-sampler.cc",
+    "src/libsampler/v8-sampler.h",
+  ]
+
+  configs = [ ":internal_config_base" ]
+
+  public_configs = [ ":libsampler_config" ]
+
+  deps = [
+    ":v8_libbase",
+  ]
+}
+
 v8_source_set("fuzzer_support") {
   visibility = [ ":*" ]  # Only targets in this file can depend on this.
 
@@ -2000,7 +2015,7 @@
   configs = [ ":internal_config_base" ]
 
   deps = [
-    snapshot_target,
+    ":v8_maybe_snapshot",
   ]
 
   public_deps = [
@@ -2008,25 +2023,27 @@
   ]
 }
 
+v8_source_set("simple_fuzzer") {
+  sources = [
+    "test/fuzzer/fuzzer.cc",
+  ]
+
+  configs = [ ":internal_config_base" ]
+}
+
 ###############################################################################
 # Executables
 #
 
-if (current_toolchain == snapshot_toolchain) {
-  executable("mksnapshot") {
+if (current_toolchain == v8_snapshot_toolchain) {
+  v8_executable("mksnapshot") {
     visibility = [ ":*" ]  # Only targets in this file can depend on this.
 
     sources = [
       "src/snapshot/mksnapshot.cc",
     ]
 
-    configs -= [ "//build/config/compiler:chromium_code" ]
-    configs += [ "//build/config/compiler:no_chromium_code" ]
-    configs += [
-      ":internal_config",
-      ":features",
-      ":toolchain",
-    ]
+    configs = [ ":internal_config" ]
 
     deps = [
       ":v8_base",
@@ -2042,24 +2059,50 @@
 # Public targets
 #
 
+want_v8_shell =
+    (current_toolchain == host_toolchain && v8_toolset_for_shell == "host") ||
+    (current_toolchain == v8_snapshot_toolchain &&
+     v8_toolset_for_shell == "host") ||
+    (current_toolchain != host_toolchain && v8_toolset_for_shell == "target")
+
+group("gn_all") {
+  testonly = true
+
+  deps = [
+    ":d8",
+    ":v8_hello_world",
+    ":v8_parser_shell",
+    ":v8_sample_process",
+    ":v8_simple_json_fuzzer",
+    ":v8_simple_parser_fuzzer",
+    ":v8_simple_regexp_fuzzer",
+    ":v8_simple_wasm_asmjs_fuzzer",
+    ":v8_simple_wasm_fuzzer",
+    "test:gn_all",
+    "tools:gn_all",
+  ]
+
+  if (want_v8_shell) {
+    deps += [ ":v8_shell" ]
+  }
+
+  if (v8_test_isolation_mode != "noop") {
+    deps += [ ":d8_run" ]
+  }
+}
+
 if (is_component_build) {
-  component("v8") {
+  v8_component("v8") {
     sources = [
       "src/v8dll-main.cc",
     ]
 
     public_deps = [
       ":v8_base",
-      snapshot_target,
+      ":v8_maybe_snapshot",
     ]
 
-    configs -= [ "//build/config/compiler:chromium_code" ]
-    configs += [ "//build/config/compiler:no_chromium_code" ]
-    configs += [
-      ":internal_config",
-      ":features",
-      ":toolchain",
-    ]
+    configs = [ ":internal_config" ]
 
     public_configs = [ ":external_config" ]
   }
@@ -2067,27 +2110,23 @@
   group("v8") {
     public_deps = [
       ":v8_base",
-      snapshot_target,
+      ":v8_maybe_snapshot",
     ]
     public_configs = [ ":external_config" ]
   }
 }
 
-executable("d8") {
+v8_executable("d8") {
   sources = [
     "src/d8.cc",
     "src/d8.h",
   ]
 
-  configs -= [ "//build/config/compiler:chromium_code" ]
-  configs += [ "//build/config/compiler:no_chromium_code" ]
-  configs += [
+  configs = [
     # Note: don't use :internal_config here because this target will get
     # the :external_config applied to it by virtue of depending on :v8, and
     # you can't have both applied to the same target.
     ":internal_config_base",
-    ":features",
-    ":toolchain",
   ]
 
   deps = [
@@ -2114,21 +2153,103 @@
   }
 }
 
-if ((current_toolchain == host_toolchain && v8_toolset_for_shell == "host") || (current_toolchain == snapshot_toolchain && v8_toolset_for_shell == "host") || (current_toolchain != host_toolchain && v8_toolset_for_shell == "target")) {
-  executable("v8_shell") {
+v8_isolate_run("d8") {
+  deps = [
+    ":d8",
+  ]
+
+  isolate = "//src/d8.isolate"
+}
+
+v8_executable("v8_hello_world") {
+  sources = [
+    "samples/hello-world.cc",
+  ]
+
+  configs = [
+    # Note: don't use :internal_config here because this target will get
+    # the :external_config applied to it by virtue of depending on :v8, and
+    # you can't have both applied to the same target.
+    ":internal_config_base",
+  ]
+
+  deps = [
+    ":v8",
+    ":v8_libplatform",
+    "//build/config/sanitizers:deps",
+    "//build/win:default_exe_manifest",
+  ]
+
+  if (v8_enable_i18n_support) {
+    deps += [ "//third_party/icu" ]
+  }
+}
+
+v8_executable("v8_sample_process") {
+  sources = [
+    "samples/process.cc",
+  ]
+
+  configs = [
+    # Note: don't use :internal_config here because this target will get
+    # the :external_config applied to it by virtue of depending on :v8, and
+    # you can't have both applied to the same target.
+    ":internal_config_base",
+  ]
+
+  deps = [
+    ":v8",
+    ":v8_libplatform",
+    "//build/config/sanitizers:deps",
+    "//build/win:default_exe_manifest",
+  ]
+
+  if (v8_enable_i18n_support) {
+    deps += [ "//third_party/icu" ]
+  }
+}
+
+v8_executable("v8_parser_shell") {
+  sources = [
+    "tools/parser-shell.cc",
+    "tools/shell-utils.h",
+  ]
+
+  configs = [
+    ":external_config",
+    ":internal_config_base",
+  ]
+
+  deps = [
+    ":v8_libplatform",
+    "//build/config/sanitizers:deps",
+    "//build/win:default_exe_manifest",
+  ]
+
+  if (is_component_build) {
+    # v8_parser_shell can't be built against a shared library, so we
+    # need to depend on the underlying static target in that case.
+    deps += [ ":v8_maybe_snapshot" ]
+  } else {
+    deps += [ ":v8" ]
+  }
+
+  if (v8_enable_i18n_support) {
+    deps += [ "//third_party/icu" ]
+  }
+}
+
+if (want_v8_shell) {
+  v8_executable("v8_shell") {
     sources = [
       "samples/shell.cc",
     ]
 
-    configs -= [ "//build/config/compiler:chromium_code" ]
-    configs += [ "//build/config/compiler:no_chromium_code" ]
-    configs += [
+    configs = [
       # Note: don't use :internal_config here because this target will get
       # the :external_config applied to it by virtue of depending on :v8, and
       # you can't have both applied to the same target.
       ":internal_config_base",
-      ":features",
-      ":toolchain",
     ]
 
     deps = [
@@ -2144,6 +2265,20 @@
   }
 }
 
+template("v8_fuzzer") {
+  name = target_name
+  forward_variables_from(invoker, "*")
+  v8_executable("v8_simple_" + name) {
+    deps = [
+      ":" + name,
+      ":simple_fuzzer",
+      "//build/win:default_exe_manifest",
+    ]
+
+    configs = [ ":external_config" ]
+  }
+}
+
 v8_source_set("json_fuzzer") {
   sources = [
     "test/fuzzer/json.cc",
@@ -2156,6 +2291,9 @@
   configs = [ ":internal_config" ]
 }
 
+v8_fuzzer("json_fuzzer") {
+}
+
 v8_source_set("parser_fuzzer") {
   sources = [
     "test/fuzzer/parser.cc",
@@ -2168,6 +2306,9 @@
   configs = [ ":internal_config" ]
 }
 
+v8_fuzzer("parser_fuzzer") {
+}
+
 v8_source_set("regexp_fuzzer") {
   sources = [
     "test/fuzzer/regexp.cc",
@@ -2180,6 +2321,9 @@
   configs = [ ":internal_config" ]
 }
 
+v8_fuzzer("regexp_fuzzer") {
+}
+
 v8_source_set("wasm_fuzzer") {
   sources = [
     "test/fuzzer/wasm.cc",
@@ -2192,6 +2336,9 @@
   configs = [ ":internal_config" ]
 }
 
+v8_fuzzer("wasm_fuzzer") {
+}
+
 v8_source_set("wasm_asmjs_fuzzer") {
   sources = [
     "test/fuzzer/wasm-asmjs.cc",
@@ -2203,3 +2350,6 @@
 
   configs = [ ":internal_config" ]
 }
+
+v8_fuzzer("wasm_asmjs_fuzzer") {
+}