v8/src/wasm/wasm-engine.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

425 lines
18 KiB
C
Raw Normal View History

// Copyright 2017 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef V8_WASM_WASM_ENGINE_H_
#define V8_WASM_WASM_ENGINE_H_
Reland "Reland "[wasm] Cache streaming compilation result"" This is a reland of 9781aa076f333ca27094a4d92beb8194af0051a1 Original change's description: > Reland "[wasm] Cache streaming compilation result" > > This is a reland of 015f379aa1f90168fe07a1c078ff5aae43a7915a > > Original change's description: > > [wasm] Cache streaming compilation result > > > > Before compiling the code section, check whether the > > bytes received so far match a cached module. If they do, delay > > compilation until we receive the full bytes, since we are likely to find > > a cache entry for them. > > > > R=clemensb@chromium.org > > > > Bug: v8:6847 > > Change-Id: Ie5170d1274da3da6d52ff1b408abc7cb441bbe3c > > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2002823 > > Commit-Queue: Thibaud Michaud <thibaudm@chromium.org> > > Reviewed-by: Clemens Backes <clemensb@chromium.org> > > Cr-Commit-Position: refs/heads/master@{#66000} > > Bug: v8:6847 > Change-Id: I0b5acffa01aeb7dade3dc966392814383d900015 > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2022951 > Commit-Queue: Thibaud Michaud <thibaudm@chromium.org> > Reviewed-by: Clemens Backes <clemensb@chromium.org> > Cr-Commit-Position: refs/heads/master@{#66047} Bug: v8:6847 Change-Id: I272f56eee28010f34cc99df475164581c8b63036 Cq-Include-Trybots: luci.v8.try:v8_linux64_tsan_rel Cq-Include-Trybots: luci.v8.try:v8_linux64_msan_rel Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2030741 Commit-Queue: Thibaud Michaud <thibaudm@chromium.org> Reviewed-by: Clemens Backes <clemensb@chromium.org> Cr-Commit-Position: refs/heads/master@{#66081}
2020-02-03 12:13:26 +00:00
#include <algorithm>
#include <map>
#include <memory>
#include <unordered_map>
#include <unordered_set>
#include "src/base/platform/condition-variable.h"
#include "src/base/platform/mutex.h"
#include "src/tasks/cancelable-task.h"
#include "src/tasks/operations-barrier.h"
#include "src/wasm/wasm-code-manager.h"
#include "src/wasm/wasm-tier.h"
#include "src/zone/accounting-allocator.h"
namespace v8 {
namespace internal {
class AsmWasmData;
class CodeTracer;
class CompilationStatistics;
class HeapNumber;
class WasmInstanceObject;
class WasmModuleObject;
Reland x6 [arraybuffer] Rearchitect backing store ownership This reverts commit 9da3483136b5e71e830ed9a9c34802ad8d605e58 Original change's description: > "Reland x4 [arraybuffer] Rearchitect backing store ownership" > > This is a reland of bc33f5aeba9ceb13f8bfc401c5ba2521c2207ffb > > Contributed by titzer@chromium.org > > Original change's description: > > [arraybuffer] Rearchitect backing store ownership > > > > This CL completely rearchitects the ownership of array buffer backing stores, > > consolidating ownership into a {BackingStore} C++ object that is tracked > > throughout V8 using unique_ptr and shared_ptr where appropriate. > > > > Overall, lifetime management is simpler and more explicit. The numerous > > ways that array buffers were initialized have been streamlined to one > > Attach() method on JSArrayBuffer. The array buffer tracker in the > > GC implementation now manages std::shared_ptr<BackingStore> pointers, > > and the construction and destruction of the BackingStore object itself > > handles the underlying page or embedder-allocated memory. > > > > The embedder API remains unchanged for now. We use the > > v8::ArrayBuffer::Contents struct to hide an additional shared_ptr to > > keep the backing store alive properly, even in the case of aliases > > from live heap objects. Thus the embedder has a lower chance of making > > a mistake. Long-term, we should move the embedder to a model where they > > manage backing stores using shared_ptr to an opaque backing store object. > > TBR=yangguo@chromium.org > > BUG=v8:9380,v8:9221,chromium:986318 > > Change-Id: If671a4a9ca0476e8f084efae46e0d2bf99ed99ef > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1731005 > Commit-Queue: Ulan Degenbaev <ulan@chromium.org> > Reviewed-by: Clemens Hammacher <clemensh@chromium.org> > Reviewed-by: Michael Starzinger <mstarzinger@chromium.org> > Cr-Commit-Position: refs/heads/master@{#63041} TBR=yangguo@chromium.org Change-Id: I3cc4bb80081c662b1751234bc16a821c20e744be Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1792166 Commit-Queue: Ulan Degenbaev <ulan@chromium.org> Reviewed-by: Michael Starzinger <mstarzinger@chromium.org> Cr-Commit-Position: refs/heads/master@{#63617}
2019-09-09 10:19:34 +00:00
class JSArrayBuffer;
namespace wasm {
#ifdef V8_ENABLE_WASM_GDB_REMOTE_DEBUGGING
namespace gdb_server {
class GdbServer;
} // namespace gdb_server
#endif // V8_ENABLE_WASM_GDB_REMOTE_DEBUGGING
class AsyncCompileJob;
class ErrorThrower;
struct ModuleWireBytes;
class WasmFeatures;
class V8_EXPORT_PRIVATE CompilationResultResolver {
public:
virtual void OnCompilationSucceeded(Handle<WasmModuleObject> result) = 0;
virtual void OnCompilationFailed(Handle<Object> error_reason) = 0;
virtual ~CompilationResultResolver() = default;
};
class V8_EXPORT_PRIVATE InstantiationResultResolver {
public:
virtual void OnInstantiationSucceeded(Handle<WasmInstanceObject> result) = 0;
virtual void OnInstantiationFailed(Handle<Object> error_reason) = 0;
virtual ~InstantiationResultResolver() = default;
};
// Native modules cached by their wire bytes.
class NativeModuleCache {
public:
Reland "Reland "[wasm] Cache streaming compilation result"" This is a reland of 9781aa076f333ca27094a4d92beb8194af0051a1 Original change's description: > Reland "[wasm] Cache streaming compilation result" > > This is a reland of 015f379aa1f90168fe07a1c078ff5aae43a7915a > > Original change's description: > > [wasm] Cache streaming compilation result > > > > Before compiling the code section, check whether the > > bytes received so far match a cached module. If they do, delay > > compilation until we receive the full bytes, since we are likely to find > > a cache entry for them. > > > > R=clemensb@chromium.org > > > > Bug: v8:6847 > > Change-Id: Ie5170d1274da3da6d52ff1b408abc7cb441bbe3c > > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2002823 > > Commit-Queue: Thibaud Michaud <thibaudm@chromium.org> > > Reviewed-by: Clemens Backes <clemensb@chromium.org> > > Cr-Commit-Position: refs/heads/master@{#66000} > > Bug: v8:6847 > Change-Id: I0b5acffa01aeb7dade3dc966392814383d900015 > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2022951 > Commit-Queue: Thibaud Michaud <thibaudm@chromium.org> > Reviewed-by: Clemens Backes <clemensb@chromium.org> > Cr-Commit-Position: refs/heads/master@{#66047} Bug: v8:6847 Change-Id: I272f56eee28010f34cc99df475164581c8b63036 Cq-Include-Trybots: luci.v8.try:v8_linux64_tsan_rel Cq-Include-Trybots: luci.v8.try:v8_linux64_msan_rel Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2030741 Commit-Queue: Thibaud Michaud <thibaudm@chromium.org> Reviewed-by: Clemens Backes <clemensb@chromium.org> Cr-Commit-Position: refs/heads/master@{#66081}
2020-02-03 12:13:26 +00:00
struct Key {
// Store the prefix hash as part of the key for faster lookup, and to
// quickly check existing prefixes for streaming compilation.
size_t prefix_hash;
Vector<const uint8_t> bytes;
bool operator==(const Key& other) const {
bool eq = bytes == other.bytes;
DCHECK_IMPLIES(eq, prefix_hash == other.prefix_hash);
return eq;
}
bool operator<(const Key& other) const {
if (prefix_hash != other.prefix_hash) {
DCHECK_IMPLIES(!bytes.empty() && !other.bytes.empty(),
bytes != other.bytes);
Reland "Reland "[wasm] Cache streaming compilation result"" This is a reland of 9781aa076f333ca27094a4d92beb8194af0051a1 Original change's description: > Reland "[wasm] Cache streaming compilation result" > > This is a reland of 015f379aa1f90168fe07a1c078ff5aae43a7915a > > Original change's description: > > [wasm] Cache streaming compilation result > > > > Before compiling the code section, check whether the > > bytes received so far match a cached module. If they do, delay > > compilation until we receive the full bytes, since we are likely to find > > a cache entry for them. > > > > R=clemensb@chromium.org > > > > Bug: v8:6847 > > Change-Id: Ie5170d1274da3da6d52ff1b408abc7cb441bbe3c > > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2002823 > > Commit-Queue: Thibaud Michaud <thibaudm@chromium.org> > > Reviewed-by: Clemens Backes <clemensb@chromium.org> > > Cr-Commit-Position: refs/heads/master@{#66000} > > Bug: v8:6847 > Change-Id: I0b5acffa01aeb7dade3dc966392814383d900015 > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2022951 > Commit-Queue: Thibaud Michaud <thibaudm@chromium.org> > Reviewed-by: Clemens Backes <clemensb@chromium.org> > Cr-Commit-Position: refs/heads/master@{#66047} Bug: v8:6847 Change-Id: I272f56eee28010f34cc99df475164581c8b63036 Cq-Include-Trybots: luci.v8.try:v8_linux64_tsan_rel Cq-Include-Trybots: luci.v8.try:v8_linux64_msan_rel Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2030741 Commit-Queue: Thibaud Michaud <thibaudm@chromium.org> Reviewed-by: Clemens Backes <clemensb@chromium.org> Cr-Commit-Position: refs/heads/master@{#66081}
2020-02-03 12:13:26 +00:00
return prefix_hash < other.prefix_hash;
}
if (bytes.size() != other.bytes.size()) {
return bytes.size() < other.bytes.size();
}
// Fast path when the base pointers are the same.
// Also handles the {nullptr} case which would be UB for memcmp.
if (bytes.begin() == other.bytes.begin()) {
DCHECK_EQ(prefix_hash, other.prefix_hash);
return false;
}
DCHECK_NOT_NULL(bytes.begin());
DCHECK_NOT_NULL(other.bytes.begin());
return memcmp(bytes.begin(), other.bytes.begin(), bytes.size()) < 0;
Reland "Reland "[wasm] Cache streaming compilation result"" This is a reland of 9781aa076f333ca27094a4d92beb8194af0051a1 Original change's description: > Reland "[wasm] Cache streaming compilation result" > > This is a reland of 015f379aa1f90168fe07a1c078ff5aae43a7915a > > Original change's description: > > [wasm] Cache streaming compilation result > > > > Before compiling the code section, check whether the > > bytes received so far match a cached module. If they do, delay > > compilation until we receive the full bytes, since we are likely to find > > a cache entry for them. > > > > R=clemensb@chromium.org > > > > Bug: v8:6847 > > Change-Id: Ie5170d1274da3da6d52ff1b408abc7cb441bbe3c > > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2002823 > > Commit-Queue: Thibaud Michaud <thibaudm@chromium.org> > > Reviewed-by: Clemens Backes <clemensb@chromium.org> > > Cr-Commit-Position: refs/heads/master@{#66000} > > Bug: v8:6847 > Change-Id: I0b5acffa01aeb7dade3dc966392814383d900015 > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2022951 > Commit-Queue: Thibaud Michaud <thibaudm@chromium.org> > Reviewed-by: Clemens Backes <clemensb@chromium.org> > Cr-Commit-Position: refs/heads/master@{#66047} Bug: v8:6847 Change-Id: I272f56eee28010f34cc99df475164581c8b63036 Cq-Include-Trybots: luci.v8.try:v8_linux64_tsan_rel Cq-Include-Trybots: luci.v8.try:v8_linux64_msan_rel Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2030741 Commit-Queue: Thibaud Michaud <thibaudm@chromium.org> Reviewed-by: Clemens Backes <clemensb@chromium.org> Cr-Commit-Position: refs/heads/master@{#66081}
2020-02-03 12:13:26 +00:00
}
};
std::shared_ptr<NativeModule> MaybeGetNativeModule(
ModuleOrigin origin, Vector<const uint8_t> wire_bytes);
Reland "Reland "[wasm] Cache streaming compilation result"" This is a reland of 9781aa076f333ca27094a4d92beb8194af0051a1 Original change's description: > Reland "[wasm] Cache streaming compilation result" > > This is a reland of 015f379aa1f90168fe07a1c078ff5aae43a7915a > > Original change's description: > > [wasm] Cache streaming compilation result > > > > Before compiling the code section, check whether the > > bytes received so far match a cached module. If they do, delay > > compilation until we receive the full bytes, since we are likely to find > > a cache entry for them. > > > > R=clemensb@chromium.org > > > > Bug: v8:6847 > > Change-Id: Ie5170d1274da3da6d52ff1b408abc7cb441bbe3c > > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2002823 > > Commit-Queue: Thibaud Michaud <thibaudm@chromium.org> > > Reviewed-by: Clemens Backes <clemensb@chromium.org> > > Cr-Commit-Position: refs/heads/master@{#66000} > > Bug: v8:6847 > Change-Id: I0b5acffa01aeb7dade3dc966392814383d900015 > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2022951 > Commit-Queue: Thibaud Michaud <thibaudm@chromium.org> > Reviewed-by: Clemens Backes <clemensb@chromium.org> > Cr-Commit-Position: refs/heads/master@{#66047} Bug: v8:6847 Change-Id: I272f56eee28010f34cc99df475164581c8b63036 Cq-Include-Trybots: luci.v8.try:v8_linux64_tsan_rel Cq-Include-Trybots: luci.v8.try:v8_linux64_msan_rel Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2030741 Commit-Queue: Thibaud Michaud <thibaudm@chromium.org> Reviewed-by: Clemens Backes <clemensb@chromium.org> Cr-Commit-Position: refs/heads/master@{#66081}
2020-02-03 12:13:26 +00:00
bool GetStreamingCompilationOwnership(size_t prefix_hash);
void StreamingCompilationFailed(size_t prefix_hash);
std::shared_ptr<NativeModule> Update(
std::shared_ptr<NativeModule> native_module, bool error);
void Erase(NativeModule* native_module);
bool empty() { return map_.empty(); }
Reland "Reland "[wasm] Cache streaming compilation result"" This is a reland of 9781aa076f333ca27094a4d92beb8194af0051a1 Original change's description: > Reland "[wasm] Cache streaming compilation result" > > This is a reland of 015f379aa1f90168fe07a1c078ff5aae43a7915a > > Original change's description: > > [wasm] Cache streaming compilation result > > > > Before compiling the code section, check whether the > > bytes received so far match a cached module. If they do, delay > > compilation until we receive the full bytes, since we are likely to find > > a cache entry for them. > > > > R=clemensb@chromium.org > > > > Bug: v8:6847 > > Change-Id: Ie5170d1274da3da6d52ff1b408abc7cb441bbe3c > > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2002823 > > Commit-Queue: Thibaud Michaud <thibaudm@chromium.org> > > Reviewed-by: Clemens Backes <clemensb@chromium.org> > > Cr-Commit-Position: refs/heads/master@{#66000} > > Bug: v8:6847 > Change-Id: I0b5acffa01aeb7dade3dc966392814383d900015 > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2022951 > Commit-Queue: Thibaud Michaud <thibaudm@chromium.org> > Reviewed-by: Clemens Backes <clemensb@chromium.org> > Cr-Commit-Position: refs/heads/master@{#66047} Bug: v8:6847 Change-Id: I272f56eee28010f34cc99df475164581c8b63036 Cq-Include-Trybots: luci.v8.try:v8_linux64_tsan_rel Cq-Include-Trybots: luci.v8.try:v8_linux64_msan_rel Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2030741 Commit-Queue: Thibaud Michaud <thibaudm@chromium.org> Reviewed-by: Clemens Backes <clemensb@chromium.org> Cr-Commit-Position: refs/heads/master@{#66081}
2020-02-03 12:13:26 +00:00
static size_t WireBytesHash(Vector<const uint8_t> bytes);
// Hash the wire bytes up to the code section header. Used as a heuristic to
// avoid streaming compilation of modules that are likely already in the
// cache. See {GetStreamingCompilationOwnership}. Assumes that the bytes have
// already been validated.
static size_t PrefixHash(Vector<const uint8_t> wire_bytes);
private:
// Each key points to the corresponding native module's wire bytes, so they
// should always be valid as long as the native module is alive. When
// the native module dies, {FreeNativeModule} deletes the entry from the
// map, so that we do not leave any dangling key pointing to an expired
// weak_ptr. This also serves as a way to regularly clean up the map, which
// would otherwise accumulate expired entries.
// A {nullopt} value is inserted to indicate that this native module is
// currently being created in some thread, and that other threads should wait
// before trying to get it from the cache.
// By contrast, an expired {weak_ptr} indicates that the native module died
// and will soon be cleaned up from the cache.
Reland "Reland "[wasm] Cache streaming compilation result"" This is a reland of 9781aa076f333ca27094a4d92beb8194af0051a1 Original change's description: > Reland "[wasm] Cache streaming compilation result" > > This is a reland of 015f379aa1f90168fe07a1c078ff5aae43a7915a > > Original change's description: > > [wasm] Cache streaming compilation result > > > > Before compiling the code section, check whether the > > bytes received so far match a cached module. If they do, delay > > compilation until we receive the full bytes, since we are likely to find > > a cache entry for them. > > > > R=clemensb@chromium.org > > > > Bug: v8:6847 > > Change-Id: Ie5170d1274da3da6d52ff1b408abc7cb441bbe3c > > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2002823 > > Commit-Queue: Thibaud Michaud <thibaudm@chromium.org> > > Reviewed-by: Clemens Backes <clemensb@chromium.org> > > Cr-Commit-Position: refs/heads/master@{#66000} > > Bug: v8:6847 > Change-Id: I0b5acffa01aeb7dade3dc966392814383d900015 > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2022951 > Commit-Queue: Thibaud Michaud <thibaudm@chromium.org> > Reviewed-by: Clemens Backes <clemensb@chromium.org> > Cr-Commit-Position: refs/heads/master@{#66047} Bug: v8:6847 Change-Id: I272f56eee28010f34cc99df475164581c8b63036 Cq-Include-Trybots: luci.v8.try:v8_linux64_tsan_rel Cq-Include-Trybots: luci.v8.try:v8_linux64_msan_rel Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2030741 Commit-Queue: Thibaud Michaud <thibaudm@chromium.org> Reviewed-by: Clemens Backes <clemensb@chromium.org> Cr-Commit-Position: refs/heads/master@{#66081}
2020-02-03 12:13:26 +00:00
std::map<Key, base::Optional<std::weak_ptr<NativeModule>>> map_;
base::Mutex mutex_;
// This condition variable is used to synchronize threads compiling the same
// module. Only one thread will create the {NativeModule}. Other threads
// will wait on this variable until the first thread wakes them up.
base::ConditionVariable cache_cv_;
};
// The central data structure that represents an engine instance capable of
// loading, instantiating, and executing Wasm code.
class V8_EXPORT_PRIVATE WasmEngine {
public:
WasmEngine();
WasmEngine(const WasmEngine&) = delete;
WasmEngine& operator=(const WasmEngine&) = delete;
~WasmEngine();
// Synchronously validates the given bytes that represent an encoded Wasm
// module.
bool SyncValidate(Isolate* isolate, const WasmFeatures& enabled,
const ModuleWireBytes& bytes);
// Synchronously compiles the given bytes that represent a translated
// asm.js module.
MaybeHandle<AsmWasmData> SyncCompileTranslatedAsmJs(
Isolate* isolate, ErrorThrower* thrower, const ModuleWireBytes& bytes,
Vector<const byte> asm_js_offset_table_bytes,
Handle<HeapNumber> uses_bitset, LanguageMode language_mode);
Handle<WasmModuleObject> FinalizeTranslatedAsmJs(
Isolate* isolate, Handle<AsmWasmData> asm_wasm_data,
Handle<Script> script);
// Synchronously compiles the given bytes that represent an encoded Wasm
// module.
MaybeHandle<WasmModuleObject> SyncCompile(Isolate* isolate,
const WasmFeatures& enabled,
ErrorThrower* thrower,
const ModuleWireBytes& bytes);
// Synchronously instantiate the given Wasm module with the given imports.
// If the module represents an asm.js module, then the supplied {memory}
// should be used as the memory of the instance.
MaybeHandle<WasmInstanceObject> SyncInstantiate(
Isolate* isolate, ErrorThrower* thrower,
Handle<WasmModuleObject> module_object, MaybeHandle<JSReceiver> imports,
MaybeHandle<JSArrayBuffer> memory);
// Begin an asynchronous compilation of the given bytes that represent an
// encoded Wasm module.
// The {is_shared} flag indicates if the bytes backing the module could
// be shared across threads, i.e. could be concurrently modified.
void AsyncCompile(Isolate* isolate, const WasmFeatures& enabled,
std::shared_ptr<CompilationResultResolver> resolver,
const ModuleWireBytes& bytes, bool is_shared,
const char* api_method_name_for_errors);
// Begin an asynchronous instantiation of the given Wasm module.
void AsyncInstantiate(Isolate* isolate,
std::unique_ptr<InstantiationResultResolver> resolver,
Handle<WasmModuleObject> module_object,
MaybeHandle<JSReceiver> imports);
std::shared_ptr<StreamingDecoder> StartStreamingCompilation(
Isolate* isolate, const WasmFeatures& enabled, Handle<Context> context,
const char* api_method_name,
std::shared_ptr<CompilationResultResolver> resolver);
// Compiles the function with the given index at a specific compilation tier.
// Errors are stored internally in the CompilationState.
// This is mostly used for testing to force a function into a specific tier.
void CompileFunction(Isolate* isolate, NativeModule* native_module,
uint32_t function_index, ExecutionTier tier);
void TierDownAllModulesPerIsolate(Isolate* isolate);
void TierUpAllModulesPerIsolate(Isolate* isolate);
// Exports the sharable parts of the given module object so that they can be
// transferred to a different Context/Isolate using the same engine.
std::shared_ptr<NativeModule> ExportNativeModule(
Handle<WasmModuleObject> module_object);
// Imports the shared part of a module from a different Context/Isolate using
// the the same engine, recreating a full module object in the given Isolate.
Handle<WasmModuleObject> ImportNativeModule(
Isolate* isolate, std::shared_ptr<NativeModule> shared_module,
Vector<const char> source_url);
WasmCodeManager* code_manager() { return &code_manager_; }
AccountingAllocator* allocator() { return &allocator_; }
// Compilation statistics for TurboFan compilations.
CompilationStatistics* GetOrCreateTurboStatistics();
// Prints the gathered compilation statistics, then resets them.
void DumpAndResetTurboStatistics();
// Used to redirect tracing output from {stdout} to a file.
CodeTracer* GetCodeTracer();
// Remove {job} from the list of active compile jobs.
Revert "[wasm] Remove finisher task" This reverts commit ac2fb66b65053d1cac5d1bb430261979f4017f60. Reason for revert: Flakily crashes on several bots: https://ci.chromium.org/p/v8/builders/luci.v8.ci/V8%20Win32/18524 https://ci.chromium.org/p/v8/builders/luci.v8.ci/V8%20Win64%20-%20msvc/6824 https://ci.chromium.org/p/v8/builders/luci.v8.ci/V8%20Linux64%20-%20internal%20snapshot/19766 Original change's description: > [wasm] Remove finisher task > > This removes the finisher task and instead finishes compilation units > from the background. > It also changes ownership of the AsyncCompileJob to be shared among all > tasks that still operate on it. The AsyncCompileJob dies when the last > reference dies. > > R=​ahaas@chromium.org > CC=​​​mstarzinger@chromium.org > > Bug: v8:7921, v8:8423 > Change-Id: Id09378327dfc146459ef41bc97176a8716756ae4 > Cq-Include-Trybots: luci.v8.try:v8_linux64_tsan_rel > Reviewed-on: https://chromium-review.googlesource.com/c/1335553 > Reviewed-by: Andreas Haas <ahaas@chromium.org> > Commit-Queue: Clemens Hammacher <clemensh@chromium.org> > Cr-Commit-Position: refs/heads/master@{#58630} TBR=ahaas@chromium.org,clemensh@chromium.org Change-Id: I6b332b66adaec8f713fb31f4c8517cae7ebb4645 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: v8:7921, v8:8423 Cq-Include-Trybots: luci.v8.try:v8_linux64_tsan_rel Reviewed-on: https://chromium-review.googlesource.com/c/1400420 Reviewed-by: Michael Achenbach <machenbach@chromium.org> Commit-Queue: Michael Achenbach <machenbach@chromium.org> Cr-Commit-Position: refs/heads/master@{#58634}
2019-01-08 13:58:01 +00:00
std::unique_ptr<AsyncCompileJob> RemoveCompileJob(AsyncCompileJob* job);
// Returns true if at least one AsyncCompileJob that belongs to the given
// Isolate is currently running.
bool HasRunningCompileJob(Isolate* isolate);
// Deletes all AsyncCompileJobs that belong to the given context. All
// compilation is aborted, no more callbacks will be triggered. This is used
// when a context is disposed, e.g. because of browser navigation.
void DeleteCompileJobsOnContext(Handle<Context> context);
Revert "[wasm] Remove finisher task" This reverts commit ac2fb66b65053d1cac5d1bb430261979f4017f60. Reason for revert: Flakily crashes on several bots: https://ci.chromium.org/p/v8/builders/luci.v8.ci/V8%20Win32/18524 https://ci.chromium.org/p/v8/builders/luci.v8.ci/V8%20Win64%20-%20msvc/6824 https://ci.chromium.org/p/v8/builders/luci.v8.ci/V8%20Linux64%20-%20internal%20snapshot/19766 Original change's description: > [wasm] Remove finisher task > > This removes the finisher task and instead finishes compilation units > from the background. > It also changes ownership of the AsyncCompileJob to be shared among all > tasks that still operate on it. The AsyncCompileJob dies when the last > reference dies. > > R=​ahaas@chromium.org > CC=​​​mstarzinger@chromium.org > > Bug: v8:7921, v8:8423 > Change-Id: Id09378327dfc146459ef41bc97176a8716756ae4 > Cq-Include-Trybots: luci.v8.try:v8_linux64_tsan_rel > Reviewed-on: https://chromium-review.googlesource.com/c/1335553 > Reviewed-by: Andreas Haas <ahaas@chromium.org> > Commit-Queue: Clemens Hammacher <clemensh@chromium.org> > Cr-Commit-Position: refs/heads/master@{#58630} TBR=ahaas@chromium.org,clemensh@chromium.org Change-Id: I6b332b66adaec8f713fb31f4c8517cae7ebb4645 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: v8:7921, v8:8423 Cq-Include-Trybots: luci.v8.try:v8_linux64_tsan_rel Reviewed-on: https://chromium-review.googlesource.com/c/1400420 Reviewed-by: Michael Achenbach <machenbach@chromium.org> Commit-Queue: Michael Achenbach <machenbach@chromium.org> Cr-Commit-Position: refs/heads/master@{#58634}
2019-01-08 13:58:01 +00:00
// Deletes all AsyncCompileJobs that belong to the given Isolate. All
// compilation is aborted, no more callbacks will be triggered. This is used
// for tearing down an isolate, or to clean it up to be reused.
Revert "[wasm] Remove finisher task" This reverts commit ac2fb66b65053d1cac5d1bb430261979f4017f60. Reason for revert: Flakily crashes on several bots: https://ci.chromium.org/p/v8/builders/luci.v8.ci/V8%20Win32/18524 https://ci.chromium.org/p/v8/builders/luci.v8.ci/V8%20Win64%20-%20msvc/6824 https://ci.chromium.org/p/v8/builders/luci.v8.ci/V8%20Linux64%20-%20internal%20snapshot/19766 Original change's description: > [wasm] Remove finisher task > > This removes the finisher task and instead finishes compilation units > from the background. > It also changes ownership of the AsyncCompileJob to be shared among all > tasks that still operate on it. The AsyncCompileJob dies when the last > reference dies. > > R=​ahaas@chromium.org > CC=​​​mstarzinger@chromium.org > > Bug: v8:7921, v8:8423 > Change-Id: Id09378327dfc146459ef41bc97176a8716756ae4 > Cq-Include-Trybots: luci.v8.try:v8_linux64_tsan_rel > Reviewed-on: https://chromium-review.googlesource.com/c/1335553 > Reviewed-by: Andreas Haas <ahaas@chromium.org> > Commit-Queue: Clemens Hammacher <clemensh@chromium.org> > Cr-Commit-Position: refs/heads/master@{#58630} TBR=ahaas@chromium.org,clemensh@chromium.org Change-Id: I6b332b66adaec8f713fb31f4c8517cae7ebb4645 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: v8:7921, v8:8423 Cq-Include-Trybots: luci.v8.try:v8_linux64_tsan_rel Reviewed-on: https://chromium-review.googlesource.com/c/1400420 Reviewed-by: Michael Achenbach <machenbach@chromium.org> Commit-Queue: Michael Achenbach <machenbach@chromium.org> Cr-Commit-Position: refs/heads/master@{#58634}
2019-01-08 13:58:01 +00:00
void DeleteCompileJobsOnIsolate(Isolate* isolate);
// Manage the set of Isolates that use this WasmEngine.
void AddIsolate(Isolate* isolate);
void RemoveIsolate(Isolate* isolate);
// Trigger code logging for the given code objects in all Isolates which have
// access to the NativeModule containing this code. This method can be called
// from background threads.
void LogCode(Vector<WasmCode*>);
// Enable code logging for the given Isolate. Initially, code logging is
// enabled if {WasmCode::ShouldBeLogged(Isolate*)} returns true during
// {AddIsolate}.
void EnableCodeLogging(Isolate*);
// This is called from the foreground thread of the Isolate to log all
// outstanding code objects (added via {LogCode}).
void LogOutstandingCodesForIsolate(Isolate*);
// Create a new NativeModule. The caller is responsible for its
// lifetime. The native module will be given some memory for code,
// which will be page size aligned. The size of the initial memory
// is determined by {code_size_estimate}. The native module may later request
// more memory.
// TODO(wasm): isolate is only required here for CompilationState.
Reland "[wasm] Simplify module creation" Original CL: > [wasm] Simplify module creation > > This includes WasmEngine::NewNativeModule() and WasmModuleObject::New(). > The intent is to make the various ways of creating a module (sync, > async, deserialize, import) more similar. > > After this change, a NativeModule will always be created before a > WasmModuleObject. This will make it easier to look up a cached > NativeModule given its wire bytes. > > The following changes are made: > > * Use WasmCodeManager::EstimateNativeModuleCodeSize() to find the code > size estimate by default. A different code size estimate is only used in > tests. > * Change CompileJsToWasmWrappers() to allocate a new FixedArray instead of > assuming the array was created with the correct size. This simplifies > WasmModuleObject::New(), and matches what CompileToNativeModule() > does. > * Remove the WasmModuleObject::New() constructor that creates a > NativeModule. This case was only used in DeserializeNativeModule() and > in test code. > > Change-Id: I6bdfc425057f92de11abbbf702d052d40aa8267d > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1717497 > Commit-Queue: Ben Smith <binji@chromium.org> > Reviewed-by: Clemens Hammacher <clemensh@chromium.org> > Cr-Commit-Position: refs/heads/master@{#62925} R=ahaas@chromium.org, clemensh@chromium.org CC=binji@chromium.org Change-Id: I03aa901a1df65af28f864d9aabe2b134ea132e99 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1724213 Commit-Queue: Ben Smith <binji@chromium.org> Reviewed-by: Ben Smith <binji@chromium.org> Cr-Commit-Position: refs/heads/master@{#62996}
2019-07-30 14:58:41 +00:00
std::shared_ptr<NativeModule> NewNativeModule(
Isolate* isolate, const WasmFeatures& enabled_features,
std::shared_ptr<const WasmModule> module, size_t code_size_estimate);
Reland "Reland "[wasm] Cache streaming compilation result"" This is a reland of 9781aa076f333ca27094a4d92beb8194af0051a1 Original change's description: > Reland "[wasm] Cache streaming compilation result" > > This is a reland of 015f379aa1f90168fe07a1c078ff5aae43a7915a > > Original change's description: > > [wasm] Cache streaming compilation result > > > > Before compiling the code section, check whether the > > bytes received so far match a cached module. If they do, delay > > compilation until we receive the full bytes, since we are likely to find > > a cache entry for them. > > > > R=clemensb@chromium.org > > > > Bug: v8:6847 > > Change-Id: Ie5170d1274da3da6d52ff1b408abc7cb441bbe3c > > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2002823 > > Commit-Queue: Thibaud Michaud <thibaudm@chromium.org> > > Reviewed-by: Clemens Backes <clemensb@chromium.org> > > Cr-Commit-Position: refs/heads/master@{#66000} > > Bug: v8:6847 > Change-Id: I0b5acffa01aeb7dade3dc966392814383d900015 > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2022951 > Commit-Queue: Thibaud Michaud <thibaudm@chromium.org> > Reviewed-by: Clemens Backes <clemensb@chromium.org> > Cr-Commit-Position: refs/heads/master@{#66047} Bug: v8:6847 Change-Id: I272f56eee28010f34cc99df475164581c8b63036 Cq-Include-Trybots: luci.v8.try:v8_linux64_tsan_rel Cq-Include-Trybots: luci.v8.try:v8_linux64_msan_rel Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2030741 Commit-Queue: Thibaud Michaud <thibaudm@chromium.org> Reviewed-by: Clemens Backes <clemensb@chromium.org> Cr-Commit-Position: refs/heads/master@{#66081}
2020-02-03 12:13:26 +00:00
// Try getting a cached {NativeModule}, or get ownership for its creation.
// Return {nullptr} if no {NativeModule} exists for these bytes. In this case,
// a {nullopt} entry is added to let other threads know that a {NativeModule}
// for these bytes is currently being created. The caller should eventually
// call {UpdateNativeModuleCache} to update the entry and wake up other
// threads. The {wire_bytes}' underlying array should be valid at least until
// the call to {UpdateNativeModuleCache}.
std::shared_ptr<NativeModule> MaybeGetNativeModule(
ModuleOrigin origin, Vector<const uint8_t> wire_bytes, Isolate* isolate);
Reland "Reland "[wasm] Cache streaming compilation result"" This is a reland of 9781aa076f333ca27094a4d92beb8194af0051a1 Original change's description: > Reland "[wasm] Cache streaming compilation result" > > This is a reland of 015f379aa1f90168fe07a1c078ff5aae43a7915a > > Original change's description: > > [wasm] Cache streaming compilation result > > > > Before compiling the code section, check whether the > > bytes received so far match a cached module. If they do, delay > > compilation until we receive the full bytes, since we are likely to find > > a cache entry for them. > > > > R=clemensb@chromium.org > > > > Bug: v8:6847 > > Change-Id: Ie5170d1274da3da6d52ff1b408abc7cb441bbe3c > > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2002823 > > Commit-Queue: Thibaud Michaud <thibaudm@chromium.org> > > Reviewed-by: Clemens Backes <clemensb@chromium.org> > > Cr-Commit-Position: refs/heads/master@{#66000} > > Bug: v8:6847 > Change-Id: I0b5acffa01aeb7dade3dc966392814383d900015 > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2022951 > Commit-Queue: Thibaud Michaud <thibaudm@chromium.org> > Reviewed-by: Clemens Backes <clemensb@chromium.org> > Cr-Commit-Position: refs/heads/master@{#66047} Bug: v8:6847 Change-Id: I272f56eee28010f34cc99df475164581c8b63036 Cq-Include-Trybots: luci.v8.try:v8_linux64_tsan_rel Cq-Include-Trybots: luci.v8.try:v8_linux64_msan_rel Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2030741 Commit-Queue: Thibaud Michaud <thibaudm@chromium.org> Reviewed-by: Clemens Backes <clemensb@chromium.org> Cr-Commit-Position: refs/heads/master@{#66081}
2020-02-03 12:13:26 +00:00
// Replace the temporary {nullopt} with the new native module, or
// erase it if any error occurred. Wake up blocked threads waiting for this
// module.
Reland "Reland "[wasm] Cache streaming compilation result"" This is a reland of 9781aa076f333ca27094a4d92beb8194af0051a1 Original change's description: > Reland "[wasm] Cache streaming compilation result" > > This is a reland of 015f379aa1f90168fe07a1c078ff5aae43a7915a > > Original change's description: > > [wasm] Cache streaming compilation result > > > > Before compiling the code section, check whether the > > bytes received so far match a cached module. If they do, delay > > compilation until we receive the full bytes, since we are likely to find > > a cache entry for them. > > > > R=clemensb@chromium.org > > > > Bug: v8:6847 > > Change-Id: Ie5170d1274da3da6d52ff1b408abc7cb441bbe3c > > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2002823 > > Commit-Queue: Thibaud Michaud <thibaudm@chromium.org> > > Reviewed-by: Clemens Backes <clemensb@chromium.org> > > Cr-Commit-Position: refs/heads/master@{#66000} > > Bug: v8:6847 > Change-Id: I0b5acffa01aeb7dade3dc966392814383d900015 > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2022951 > Commit-Queue: Thibaud Michaud <thibaudm@chromium.org> > Reviewed-by: Clemens Backes <clemensb@chromium.org> > Cr-Commit-Position: refs/heads/master@{#66047} Bug: v8:6847 Change-Id: I272f56eee28010f34cc99df475164581c8b63036 Cq-Include-Trybots: luci.v8.try:v8_linux64_tsan_rel Cq-Include-Trybots: luci.v8.try:v8_linux64_msan_rel Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2030741 Commit-Queue: Thibaud Michaud <thibaudm@chromium.org> Reviewed-by: Clemens Backes <clemensb@chromium.org> Cr-Commit-Position: refs/heads/master@{#66081}
2020-02-03 12:13:26 +00:00
// To avoid a deadlock on the main thread between synchronous and streaming
// compilation, two compilation jobs might compile the same native module at
// the same time. In this case the first call to {UpdateNativeModuleCache}
// will insert the native module in the cache, and the last call will discard
// its {native_module} argument and replace it with the existing entry.
// Return true in the former case, and false in the latter.
bool UpdateNativeModuleCache(bool error,
std::shared_ptr<NativeModule>* native_module,
Isolate* isolate);
Reland "Reland "[wasm] Cache streaming compilation result"" This is a reland of 9781aa076f333ca27094a4d92beb8194af0051a1 Original change's description: > Reland "[wasm] Cache streaming compilation result" > > This is a reland of 015f379aa1f90168fe07a1c078ff5aae43a7915a > > Original change's description: > > [wasm] Cache streaming compilation result > > > > Before compiling the code section, check whether the > > bytes received so far match a cached module. If they do, delay > > compilation until we receive the full bytes, since we are likely to find > > a cache entry for them. > > > > R=clemensb@chromium.org > > > > Bug: v8:6847 > > Change-Id: Ie5170d1274da3da6d52ff1b408abc7cb441bbe3c > > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2002823 > > Commit-Queue: Thibaud Michaud <thibaudm@chromium.org> > > Reviewed-by: Clemens Backes <clemensb@chromium.org> > > Cr-Commit-Position: refs/heads/master@{#66000} > > Bug: v8:6847 > Change-Id: I0b5acffa01aeb7dade3dc966392814383d900015 > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2022951 > Commit-Queue: Thibaud Michaud <thibaudm@chromium.org> > Reviewed-by: Clemens Backes <clemensb@chromium.org> > Cr-Commit-Position: refs/heads/master@{#66047} Bug: v8:6847 Change-Id: I272f56eee28010f34cc99df475164581c8b63036 Cq-Include-Trybots: luci.v8.try:v8_linux64_tsan_rel Cq-Include-Trybots: luci.v8.try:v8_linux64_msan_rel Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2030741 Commit-Queue: Thibaud Michaud <thibaudm@chromium.org> Reviewed-by: Clemens Backes <clemensb@chromium.org> Cr-Commit-Position: refs/heads/master@{#66081}
2020-02-03 12:13:26 +00:00
// Register this prefix hash for a streaming compilation job.
// If the hash is not in the cache yet, the function returns true and the
// caller owns the compilation of this module.
// Otherwise another compilation job is currently preparing or has already
// prepared a module with the same prefix hash. The caller should wait until
// the stream is finished and call {MaybeGetNativeModule} to either get the
// module from the cache or get ownership for the compilation of these bytes.
bool GetStreamingCompilationOwnership(size_t prefix_hash);
// Remove the prefix hash from the cache when compilation failed. If
// compilation succeeded, {UpdateNativeModuleCache} should be called instead.
void StreamingCompilationFailed(size_t prefix_hash);
void FreeNativeModule(NativeModule*);
// Sample the code size of the given {NativeModule} in all isolates that have
// access to it. Call this after top-tier compilation finished.
// This will spawn foreground tasks that do *not* keep the NativeModule alive.
void SampleTopTierCodeSizeInAllIsolates(const std::shared_ptr<NativeModule>&);
// Called by each Isolate to report its live code for a GC cycle. First
// version reports an externally determined set of live code (might be empty),
// second version gets live code from the execution stack of that isolate.
void ReportLiveCodeForGC(Isolate*, Vector<WasmCode*>);
void ReportLiveCodeFromStackForGC(Isolate*);
// Add potentially dead code. The occurrence in the set of potentially dead
// code counts as a reference, and is decremented on the next GC.
// Returns {true} if the code was added to the set of potentially dead code,
// {false} if an entry already exists. The ref count is *unchanged* in any
// case.
V8_WARN_UNUSED_RESULT bool AddPotentiallyDeadCode(WasmCode*);
// Free dead code.
using DeadCodeMap = std::unordered_map<NativeModule*, std::vector<WasmCode*>>;
void FreeDeadCode(const DeadCodeMap&);
void FreeDeadCodeLocked(const DeadCodeMap&);
Handle<Script> GetOrCreateScript(Isolate*,
const std::shared_ptr<NativeModule>&,
Vector<const char> source_url = {});
// Returns a barrier allowing background compile operations if valid and
// preventing this object from being destroyed.
std::shared_ptr<OperationsBarrier> GetBarrierForBackgroundCompile();
2020-08-05 07:22:27 +00:00
// Call on process start and exit.
static void InitializeOncePerProcess();
static void GlobalTearDown();
// Returns a reference to the WasmEngine shared by the entire process. Try to
// use {Isolate::wasm_engine} instead if it is available, which encapsulates
// engine lifetime decisions during Isolate bootstrapping.
static std::shared_ptr<WasmEngine> GetWasmEngine();
private:
struct CurrentGCInfo;
struct IsolateInfo;
struct NativeModuleInfo;
Revert "[wasm] Remove finisher task" This reverts commit ac2fb66b65053d1cac5d1bb430261979f4017f60. Reason for revert: Flakily crashes on several bots: https://ci.chromium.org/p/v8/builders/luci.v8.ci/V8%20Win32/18524 https://ci.chromium.org/p/v8/builders/luci.v8.ci/V8%20Win64%20-%20msvc/6824 https://ci.chromium.org/p/v8/builders/luci.v8.ci/V8%20Linux64%20-%20internal%20snapshot/19766 Original change's description: > [wasm] Remove finisher task > > This removes the finisher task and instead finishes compilation units > from the background. > It also changes ownership of the AsyncCompileJob to be shared among all > tasks that still operate on it. The AsyncCompileJob dies when the last > reference dies. > > R=​ahaas@chromium.org > CC=​​​mstarzinger@chromium.org > > Bug: v8:7921, v8:8423 > Change-Id: Id09378327dfc146459ef41bc97176a8716756ae4 > Cq-Include-Trybots: luci.v8.try:v8_linux64_tsan_rel > Reviewed-on: https://chromium-review.googlesource.com/c/1335553 > Reviewed-by: Andreas Haas <ahaas@chromium.org> > Commit-Queue: Clemens Hammacher <clemensh@chromium.org> > Cr-Commit-Position: refs/heads/master@{#58630} TBR=ahaas@chromium.org,clemensh@chromium.org Change-Id: I6b332b66adaec8f713fb31f4c8517cae7ebb4645 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: v8:7921, v8:8423 Cq-Include-Trybots: luci.v8.try:v8_linux64_tsan_rel Reviewed-on: https://chromium-review.googlesource.com/c/1400420 Reviewed-by: Michael Achenbach <machenbach@chromium.org> Commit-Queue: Michael Achenbach <machenbach@chromium.org> Cr-Commit-Position: refs/heads/master@{#58634}
2019-01-08 13:58:01 +00:00
AsyncCompileJob* CreateAsyncCompileJob(
Isolate* isolate, const WasmFeatures& enabled,
std::unique_ptr<byte[]> bytes_copy, size_t length,
Handle<Context> context, const char* api_method_name,
std::shared_ptr<CompilationResultResolver> resolver);
void TriggerGC(int8_t gc_sequence_index);
// Remove an isolate from the outstanding isolates of the current GC. Returns
// true if the isolate was still outstanding, false otherwise. Hold {mutex_}
// when calling this method.
bool RemoveIsolateFromCurrentGC(Isolate*);
// Finish a GC if there are no more outstanding isolates. Hold {mutex_} when
// calling this method.
void PotentiallyFinishCurrentGC();
WasmCodeManager code_manager_;
AccountingAllocator allocator_;
Add initial support for Wasm debugging with LLDB: implements a GDB-remote stub This is the first piece of the wasm debugging prototype (besides the changes to add/remove breakpoints in WasmModuleObject made with https://chromium.googlesource.com/v8/v8.git/+/e699f39caed9a23f8e20bd3a0386a3236e272737). This changelist adds the infrastructure for a GDB-remote stub that will be used to manage debugging sessions via the gdb-remote protocol. It enables the creation and termination of debugging sessions over TCP connections that are managed in a separate thread. The logic to actually send, receive and decode GDB-remote packets will be part of a future changelist. Build with: v8_enable_wasm_gdb_remote_debugging = true Run with: --wasm-gdb-remote Enables Wasm debugging with LLDB (default: false) --wasm-gdb-remote-port TCP port to be used for debugging (default: 8765) --wasm-pause-waiting-for-debugger Pauses the execution of Wasm code waiting for a debugger (default: false) --trace-wasm-gdb-remote Enables tracing of Gdb-remote packets (default: false) Note that most of this code is "borrowed" from the code of the Chromium NaCL GDB-remote stub (located in Chromium in src\native_client\src\trusted\debug_stub). Implementation details: - class GdbServer acts as a singleton manager for the gdb-remote stub. It is instantiated as soon as the first Wasm module is loaded in the Wasm engine. - class GdbServerThread spawns the worker thread for the TCP connection. - class Transport manages the socket connection, in a portable way. - class Session represents a remote debugging session. - class Target represents a debugging target and it’s the place where the debugging packets will be processed and will implement the logic to debug a Wasm engine. Bug: chromium:1010467 Change-Id: Ib2324e5901f5ae1d855b96b99ef0995d407322b6 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1923407 Reviewed-by: Clemens Backes <clemensb@chromium.org> Reviewed-by: Benedikt Meurer <bmeurer@chromium.org> Reviewed-by: Michael Achenbach <machenbach@chromium.org> Commit-Queue: Paolo Severini <paolosev@microsoft.com> Cr-Commit-Position: refs/heads/master@{#66379}
2020-02-17 05:01:29 +00:00
#ifdef V8_ENABLE_WASM_GDB_REMOTE_DEBUGGING
// Implements a GDB-remote stub for WebAssembly debugging.
std::unique_ptr<gdb_server::GdbServer> gdb_server_;
#endif // V8_ENABLE_WASM_GDB_REMOTE_DEBUGGING
// This mutex protects all information which is mutated concurrently or
// fields that are initialized lazily on the first access.
base::Mutex mutex_;
//////////////////////////////////////////////////////////////////////////////
// Protected by {mutex_}:
Revert "[wasm] Remove finisher task" This reverts commit ac2fb66b65053d1cac5d1bb430261979f4017f60. Reason for revert: Flakily crashes on several bots: https://ci.chromium.org/p/v8/builders/luci.v8.ci/V8%20Win32/18524 https://ci.chromium.org/p/v8/builders/luci.v8.ci/V8%20Win64%20-%20msvc/6824 https://ci.chromium.org/p/v8/builders/luci.v8.ci/V8%20Linux64%20-%20internal%20snapshot/19766 Original change's description: > [wasm] Remove finisher task > > This removes the finisher task and instead finishes compilation units > from the background. > It also changes ownership of the AsyncCompileJob to be shared among all > tasks that still operate on it. The AsyncCompileJob dies when the last > reference dies. > > R=​ahaas@chromium.org > CC=​​​mstarzinger@chromium.org > > Bug: v8:7921, v8:8423 > Change-Id: Id09378327dfc146459ef41bc97176a8716756ae4 > Cq-Include-Trybots: luci.v8.try:v8_linux64_tsan_rel > Reviewed-on: https://chromium-review.googlesource.com/c/1335553 > Reviewed-by: Andreas Haas <ahaas@chromium.org> > Commit-Queue: Clemens Hammacher <clemensh@chromium.org> > Cr-Commit-Position: refs/heads/master@{#58630} TBR=ahaas@chromium.org,clemensh@chromium.org Change-Id: I6b332b66adaec8f713fb31f4c8517cae7ebb4645 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: v8:7921, v8:8423 Cq-Include-Trybots: luci.v8.try:v8_linux64_tsan_rel Reviewed-on: https://chromium-review.googlesource.com/c/1400420 Reviewed-by: Michael Achenbach <machenbach@chromium.org> Commit-Queue: Michael Achenbach <machenbach@chromium.org> Cr-Commit-Position: refs/heads/master@{#58634}
2019-01-08 13:58:01 +00:00
// We use an AsyncCompileJob as the key for itself so that we can delete the
// job from the map when it is finished.
std::unordered_map<AsyncCompileJob*, std::unique_ptr<AsyncCompileJob>>
async_compile_jobs_;
std::unique_ptr<CompilationStatistics> compilation_stats_;
std::unique_ptr<CodeTracer> code_tracer_;
// Set of isolates which use this WasmEngine.
std::unordered_map<Isolate*, std::unique_ptr<IsolateInfo>> isolates_;
// Set of native modules managed by this engine.
std::unordered_map<NativeModule*, std::unique_ptr<NativeModuleInfo>>
native_modules_;
std::shared_ptr<OperationsBarrier> operations_barrier_{
std::make_shared<OperationsBarrier>()};
2020-08-05 07:22:27 +00:00
// Size of code that became dead since the last GC. If this exceeds a certain
// threshold, a new GC is triggered.
size_t new_potentially_dead_code_size_ = 0;
// If an engine-wide GC is currently running, this pointer stores information
// about that.
std::unique_ptr<CurrentGCInfo> current_gc_info_;
NativeModuleCache native_module_cache_;
// End of fields protected by {mutex_}.
//////////////////////////////////////////////////////////////////////////////
};
} // namespace wasm
} // namespace internal
} // namespace v8
#endif // V8_WASM_WASM_ENGINE_H_