Commit 404ef663 authored by Yuki Shiino's avatar Yuki Shiino Committed by Commit Bot

bind-gen: Remove unnecessary special casing of V8 context snapshot

There is no need to have a dedicated map from WrapperTypeInfo* to
v8::FunctionTemplate just only for V8 context snapshot.  Removes
the special casing only for V8 context snapshot.

Bug: 839389
Change-Id: Idacbf5290498098b13f63d6ea0e7f4203664adc8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2284517Reviewed-by: default avatarHitoshi Yoshida <peria@chromium.org>
Commit-Queue: Yuki Shiino <yukishiino@chromium.org>
Cr-Commit-Position: refs/heads/master@{#786171}
parent 998997d0
......@@ -48,13 +48,6 @@
namespace blink {
namespace {
constexpr char kInterfaceMapLabel[] =
"V8PerIsolateData::interface_template_map_for_v8_context_snapshot_";
} // namespace
// Function defined in third_party/blink/public/web/blink.h.
v8::Isolate* MainThreadIsolate() {
return V8PerIsolateData::MainThreadIsolate();
......@@ -81,8 +74,6 @@ V8PerIsolateData::V8PerIsolateData(
: gin::IsolateHolder::kAllowAtomicsWait,
IsMainThread() ? gin::IsolateHolder::IsolateType::kBlinkMainThread
: gin::IsolateHolder::IsolateType::kBlinkWorkerThread),
interface_template_map_for_v8_context_snapshot_(GetIsolate(),
kInterfaceMapLabel),
string_cache_(std::make_unique<StringCache>(GetIsolate())),
private_property_(std::make_unique<V8PrivateProperty>()),
constructor_mode_(ConstructorMode::kCreateNewObject),
......@@ -107,7 +98,6 @@ V8PerIsolateData::V8PerIsolateData()
gin::IsolateHolder::kAllowAtomicsWait,
gin::IsolateHolder::IsolateType::kBlinkMainThread,
gin::IsolateHolder::IsolateCreationMode::kCreateSnapshot),
interface_template_map_for_v8_context_snapshot_(GetIsolate()),
string_cache_(std::make_unique<StringCache>(GetIsolate())),
private_property_(std::make_unique<V8PrivateProperty>()),
constructor_mode_(ConstructorMode::kCreateNewObject),
......@@ -248,11 +238,6 @@ v8::Local<v8::FunctionTemplate> V8PerIsolateData::FindOrCreateOperationTemplate(
v8::Local<v8::FunctionTemplate> V8PerIsolateData::FindInterfaceTemplate(
const DOMWrapperWorld& world,
const void* key) {
if (GetV8ContextSnapshotMode() == V8ContextSnapshotMode::kTakeSnapshot) {
const WrapperTypeInfo* type = reinterpret_cast<const WrapperTypeInfo*>(key);
return interface_template_map_for_v8_context_snapshot_.Get(type);
}
auto& map = SelectInterfaceTemplateMap(world);
auto result = map.find(key);
if (result != map.end())
......@@ -264,18 +249,16 @@ void V8PerIsolateData::SetInterfaceTemplate(
const DOMWrapperWorld& world,
const void* key,
v8::Local<v8::FunctionTemplate> value) {
if (GetV8ContextSnapshotMode() == V8ContextSnapshotMode::kTakeSnapshot) {
auto& map = interface_template_map_for_v8_context_snapshot_;
const WrapperTypeInfo* type = reinterpret_cast<const WrapperTypeInfo*>(key);
map.Set(type, value);
} else {
auto& map = SelectInterfaceTemplateMap(world);
map.insert(key, v8::Eternal<v8::FunctionTemplate>(GetIsolate(), value));
}
auto& map = SelectInterfaceTemplateMap(world);
map.insert(key, v8::Eternal<v8::FunctionTemplate>(GetIsolate(), value));
}
void V8PerIsolateData::ClearPersistentsForV8ContextSnapshot() {
interface_template_map_for_v8_context_snapshot_.Clear();
interface_template_map_for_main_world_.clear();
interface_template_map_for_non_main_world_.clear();
operation_template_map_for_main_world_.clear();
operation_template_map_for_non_main_world_.clear();
eternal_name_cache_.clear();
private_property_.reset();
}
......
......@@ -266,12 +266,6 @@ class PLATFORM_EXPORT V8PerIsolateData {
// Contains lists of eternal names, such as dictionary keys.
HashMap<const void*, Vector<v8::Eternal<v8::Name>>> eternal_name_cache_;
// When taking a V8 context snapshot, we can't keep V8 objects with eternal
// handles. So we use a special interface map that doesn't use eternal handles
// instead of the default V8FunctionTemplateMap.
V8GlobalValueMap<const WrapperTypeInfo*, v8::FunctionTemplate>
interface_template_map_for_v8_context_snapshot_;
std::unique_ptr<StringCache> string_cache_;
std::unique_ptr<V8PrivateProperty> private_property_;
Persistent<ScriptState> script_regexp_script_state_;
......
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