Commit c66e1686 authored by Ryan Tseng's avatar Ryan Tseng Committed by Commit Bot

Use static mapping for Blink::ExecutionContext -> V8::Isolate

Bug: 889542
Change-Id: I59055c2ce9b6af9026ee8284dd3f943cc0d7d179
Reviewed-on: https://chromium-review.googlesource.com/c/1252625
Commit-Queue: Ryan Tseng <hinoka@chromium.org>
Reviewed-by: default avatarHayato Ito <hayato@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarYuki Shiino <yukishiino@chromium.org>
Cr-Commit-Position: refs/heads/master@{#611992}
parent c5ede287
......@@ -873,9 +873,15 @@ bool HasCallableIteratorSymbol(v8::Isolate* isolate,
}
v8::Isolate* ToIsolate(const ExecutionContext* context) {
if (!context)
return nullptr;
v8::Isolate* isolate;
if (context && context->IsDocument())
return V8PerIsolateData::MainThreadIsolate();
return v8::Isolate::GetCurrent();
isolate = V8PerIsolateData::MainThreadIsolate();
isolate = v8::Isolate::GetCurrent();
DCHECK(context->GetIsolate() == isolate);
return context->GetIsolate();
}
v8::Isolate* ToIsolate(const LocalFrame* frame) {
......
......@@ -597,6 +597,7 @@ Document::Document(const DocumentInit& initializer,
DocumentClassFlags document_classes)
: ContainerNode(nullptr, kCreateDocument),
TreeScope(*this),
ExecutionContext(V8PerIsolateData::MainThreadIsolate()),
has_nodes_with_placeholder_style_(false),
evaluate_media_queries_on_style_recalc_(false),
pending_sheet_layout_(kNoLayoutWithPendingSheets),
......
......@@ -45,8 +45,9 @@
namespace blink {
ExecutionContext::ExecutionContext()
: circular_sequential_id_(0),
ExecutionContext::ExecutionContext(v8::Isolate* isolate)
: isolate_(isolate),
circular_sequential_id_(0),
in_dispatch_error_event_(false),
is_context_paused_(false),
is_context_destroyed_(false),
......
......@@ -255,11 +255,15 @@ class CORE_EXPORT ExecutionContext : public ContextLifecycleNotifier,
InterfaceInvalidator* GetInterfaceInvalidator() { return invalidator_.get(); }
v8::Isolate* GetIsolate() const { return isolate_; }
protected:
ExecutionContext();
explicit ExecutionContext(v8::Isolate* isolate);
~ExecutionContext() override;
private:
v8::Isolate* const isolate_;
bool DispatchErrorEventInternal(ErrorEvent*, SanitizeScriptErrors);
unsigned circular_sequential_id_;
......
......@@ -13,7 +13,9 @@
namespace blink {
NullExecutionContext::NullExecutionContext()
: tasks_need_pause_(false), is_secure_context_(true) {}
: ExecutionContext(v8::Isolate::GetCurrent()),
tasks_need_pause_(false),
is_secure_context_(true) {}
void NullExecutionContext::SetIsSecureContext(bool is_secure_context) {
is_secure_context_ = is_secure_context;
......
......@@ -28,7 +28,8 @@ WorkerOrWorkletGlobalScope::WorkerOrWorkletGlobalScope(
WorkerClients* worker_clients,
scoped_refptr<WebWorkerFetchContext> web_worker_fetch_context,
WorkerReportingProxy& reporting_proxy)
: worker_clients_(worker_clients),
: ExecutionContext(isolate),
worker_clients_(worker_clients),
web_worker_fetch_context_(std::move(web_worker_fetch_context)),
script_controller_(
WorkerOrWorkletScriptController::Create(this, isolate)),
......
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