#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "third_party/blink/renderer/platform/bindings/v8_per_isolate_data.h"
#include <memory>
#include <utility>
#include "base/debug/crash_logging.h"
#include "base/feature_list.h"
#include "base/metrics/histogram_macros.h"
#include "base/ranges/algorithm.h"
#include "base/task/single_thread_task_runner.h"
#include "base/time/default_tick_clock.h"
#include "base/trace_event/trace_event.h"
#include "gin/public/v8_idle_task_runner.h"
#include "partition_alloc/oom.h"
#include "third_party/blink/public/platform/platform.h"
#include "third_party/blink/public/web/blink.h"
#include "third_party/blink/renderer/platform/bindings/active_script_wrappable_base.h"
#include "third_party/blink/renderer/platform/bindings/dom_data_store.h"
#include "third_party/blink/renderer/platform/bindings/script_forbidden_scope.h"
#include "third_party/blink/renderer/platform/bindings/script_regexp.h"
#include "third_party/blink/renderer/platform/bindings/script_state.h"
#include "third_party/blink/renderer/platform/bindings/thread_debugger.h"
#include "third_party/blink/renderer/platform/bindings/v8_binding.h"
#include "third_party/blink/renderer/platform/bindings/v8_histogram_accumulator.h"
#include "third_party/blink/renderer/platform/bindings/v8_object_constructor.h"
#include "third_party/blink/renderer/platform/bindings/v8_private_property.h"
#include "third_party/blink/renderer/platform/bindings/v8_value_cache.h"
#include "third_party/blink/renderer/platform/heap/garbage_collected.h"
#include "third_party/blink/renderer/platform/heap/thread_state_scopes.h"
#include "third_party/blink/renderer/platform/scheduler/public/task_attribution_tracker.h"
#include "third_party/blink/renderer/platform/scheduler/public/thread.h"
#include "third_party/blink/renderer/platform/wtf/leak_annotations.h"
namespace blink {
BASE_FEATURE(…);
namespace {
void AddCrashKey(v8::CrashKeyId id, const std::string& value) { … }
V8PerIsolateData::TaskAttributionTrackerFactoryPtr
task_attribution_tracker_factory = …;
}
static void BeforeCallEnteredCallback(v8::Isolate* isolate) { … }
static bool AllowAtomicWaits(
V8PerIsolateData::V8ContextSnapshotMode v8_context_snapshot_mode) { … }
V8PerIsolateData::V8PerIsolateData(
scoped_refptr<base::SingleThreadTaskRunner> task_runner,
scoped_refptr<base::SingleThreadTaskRunner> low_priority_task_runner,
V8ContextSnapshotMode v8_context_snapshot_mode,
v8::CreateHistogramCallback create_histogram_callback,
v8::AddHistogramSampleCallback add_histogram_sample_callback)
: … { … }
V8PerIsolateData::~V8PerIsolateData() = default;
v8::Isolate* V8PerIsolateData::Initialize(
scoped_refptr<base::SingleThreadTaskRunner> task_runner,
scoped_refptr<base::SingleThreadTaskRunner> low_priority_task_runner,
V8ContextSnapshotMode context_mode,
v8::CreateHistogramCallback create_histogram_callback,
v8::AddHistogramSampleCallback add_histogram_sample_callback) { … }
void V8PerIsolateData::EnableIdleTasks(
v8::Isolate* isolate,
std::unique_ptr<gin::V8IdleTaskRunner> task_runner) { … }
void V8PerIsolateData::WillBeDestroyed(v8::Isolate* isolate) { … }
void V8PerIsolateData::SetGCCallbacks(
v8::Isolate* isolate,
v8::Isolate::GCCallback prologue_callback,
v8::Isolate::GCCallback epilogue_callback) { … }
void V8PerIsolateData::Destroy(v8::Isolate* isolate) { … }
v8::Local<v8::Template> V8PerIsolateData::FindV8Template(
const DOMWrapperWorld& world,
const void* key) { … }
void V8PerIsolateData::AddV8Template(const DOMWrapperWorld& world,
const void* key,
v8::Local<v8::Template> value) { … }
v8::MaybeLocal<v8::DictionaryTemplate>
V8PerIsolateData::FindV8DictionaryTemplate(const void* key) { … }
void V8PerIsolateData::AddV8DictionaryTemplate(
const void* key,
v8::Local<v8::DictionaryTemplate> value) { … }
bool V8PerIsolateData::HasInstance(const WrapperTypeInfo* wrapper_type_info,
v8::Local<v8::Value> untrusted_value) { … }
bool V8PerIsolateData::HasInstance(const WrapperTypeInfo* wrapper_type_info,
v8::Local<v8::Value> untrusted_value,
const V8TemplateMap& map) { … }
bool V8PerIsolateData::HasInstanceOfUntrustedType(
const WrapperTypeInfo* untrusted_wrapper_type_info,
v8::Local<v8::Value> untrusted_value) { … }
bool V8PerIsolateData::HasInstanceOfUntrustedType(
const WrapperTypeInfo* untrusted_wrapper_type_info,
v8::Local<v8::Value> untrusted_value,
const V8TemplateMap& map) { … }
V8PerIsolateData::V8TemplateMap& V8PerIsolateData::SelectV8TemplateMap(
const DOMWrapperWorld& world) { … }
void V8PerIsolateData::ClearPersistentsForV8ContextSnapshot() { … }
const base::span<const v8::Eternal<v8::Name>>
V8PerIsolateData::FindOrCreateEternalNameCache(
const void* lookup_key,
base::span<const std::string_view> names) { … }
v8::Local<v8::Context> V8PerIsolateData::EnsureScriptRegexpContext() { … }
void V8PerIsolateData::ClearScriptRegexpContext() { … }
void V8PerIsolateData::SetThreadDebugger(
std::unique_ptr<ThreadDebugger> thread_debugger) { … }
void V8PerIsolateData::SetPasswordRegexp(ScriptRegexp* password_regexp) { … }
ScriptRegexp* V8PerIsolateData::GetPasswordRegexp() { … }
void V8PerIsolateData::SetTaskAttributionTrackerFactory(
TaskAttributionTrackerFactoryPtr factory) { … }
void* CreateHistogram(const char* name, int min, int max, size_t buckets) { … }
void AddHistogramSample(void* hist, int sample) { … }
}