Commit 602dd76b authored by Bill Budge's avatar Bill Budge Committed by Commit Bot

[wasm code caching] Eliminate weak reference to Context

- Removes context_ field on WasmStreamingClient, which held a weak
  reference to the Context. This isn't used, and isn't thread-safe.
- Removes unused isolate parameter too.

Bug: chromium:1018029
Change-Id: Iab4cbab2a710716860ab8931a7561239970051d0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1901592
Commit-Queue: Bill Budge <bbudge@chromium.org>
Reviewed-by: default avatarAndreas Haas <ahaas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#713140}
parent 228ade38
......@@ -234,24 +234,15 @@ RawResource* GetRawResource(ScriptState* script_state,
class WasmStreamingClient : public v8::WasmStreaming::Client {
public:
WasmStreamingClient(const String& response_url,
const base::Time& response_time,
v8::Isolate* isolate,
v8::Local<v8::Context> context)
const base::Time& response_time)
: response_url_(response_url.IsolatedCopy()),
response_time_(response_time),
context_(isolate, context) {
context_.SetWeak();
}
response_time_(response_time) {}
void OnModuleCompiled(v8::CompiledWasmModule compiled_module) override {
TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"),
"v8.wasm.compiledModule", TRACE_EVENT_SCOPE_THREAD,
"url", response_url_.Utf8());
// Don't cache if Context has been destroyed.
if (context_.IsEmpty())
return;
v8::MemorySpan<const uint8_t> wire_bytes =
compiled_module.GetWireBytesRef();
// Our heuristic for whether it's worthwhile to cache is that the module
......@@ -294,7 +285,6 @@ class WasmStreamingClient : public v8::WasmStreaming::Client {
private:
String response_url_;
base::Time response_time_;
v8::Global<v8::Context> context_;
scoped_refptr<CachedMetadata> cached_module_;
DISALLOW_COPY_AND_ASSIGN(WasmStreamingClient);
......@@ -367,8 +357,7 @@ void StreamFromResponseCallback(
raw_resource->ScriptCacheHandler();
if (cache_handler) {
auto client = std::make_shared<WasmStreamingClient>(
url, raw_resource->GetResponse().ResponseTime(), args.GetIsolate(),
script_state->GetContext());
url, raw_resource->GetResponse().ResponseTime());
streaming->SetClient(client);
scoped_refptr<CachedMetadata> cached_module =
cache_handler->GetCachedMetadata(kWasmModuleTag);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment