Commit f3f4cd72 authored by Marina Sakai's avatar Marina Sakai Committed by Commit Bot

Prevent GetSymbol() using SymbolKey from being inlined

Function inlining of the GetSymbol function using SymbolKey instance as a key is not negligible because that might bloat out code size especially with the Android compiler.

This CL prevents function inlining of the GetSymbol function by defining it in v8_private_property.cc.

Bug: 715418
Change-Id: I73aa068ee71802ed4b0ebf001d846520ae13be08
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1880900Reviewed-by: default avatarYuki Shiino <yukishiino@chromium.org>
Reviewed-by: default avatarHitoshi Yoshida <peria@chromium.org>
Commit-Queue: Marina Sakai <marinasakai@google.com>
Cr-Commit-Position: refs/heads/master@{#709856}
parent 98d72c40
...@@ -18,6 +18,23 @@ v8::MaybeLocal<v8::Value> V8PrivateProperty::Symbol::GetFromMainWorld( ...@@ -18,6 +18,23 @@ v8::MaybeLocal<v8::Value> V8PrivateProperty::Symbol::GetFromMainWorld(
: GetOrUndefined(wrapper); : GetOrUndefined(wrapper);
} }
V8PrivateProperty::Symbol V8PrivateProperty::GetSymbol(
v8::Isolate* isolate,
const V8PrivateProperty::SymbolKey& key) {
V8PrivateProperty* private_prop =
V8PerIsolateData::From(isolate)->PrivateProperty();
auto& symbol_map = private_prop->symbol_map_;
auto iter = symbol_map.find(&key);
v8::Local<v8::Private> v8_private;
if (UNLIKELY(iter == symbol_map.end())) {
v8_private = CreateV8Private(isolate, key.GetDescription());
symbol_map.insert(&key, v8::Eternal<v8::Private>(isolate, v8_private));
} else {
v8_private = iter->value.Get(isolate);
}
return Symbol(isolate, v8_private);
}
v8::Local<v8::Private> V8PrivateProperty::CreateV8Private(v8::Isolate* isolate, v8::Local<v8::Private> V8PrivateProperty::CreateV8Private(v8::Isolate* isolate,
const char* symbol) { const char* symbol) {
return v8::Private::New(isolate, V8String(isolate, symbol)); return v8::Private::New(isolate, V8String(isolate, symbol));
......
...@@ -135,7 +135,7 @@ class PLATFORM_EXPORT V8PrivateProperty { ...@@ -135,7 +135,7 @@ class PLATFORM_EXPORT V8PrivateProperty {
// //
// We can improve ability of tracking private properties by using an instance // We can improve ability of tracking private properties by using an instance
// of this class. |desc_| is a description of the private property. // of this class. |desc_| is a description of the private property.
class PLATFORM_EXPORT SymbolKey { class PLATFORM_EXPORT SymbolKey final {
public: public:
// Note that, unlike a string class, the lifetime of |desc| must be longer // Note that, unlike a string class, the lifetime of |desc| must be longer
// than this SymbolKey, i.e. this SymbolKey does not copy |desc| nor have // than this SymbolKey, i.e. this SymbolKey does not copy |desc| nor have
...@@ -220,20 +220,7 @@ class PLATFORM_EXPORT V8PrivateProperty { ...@@ -220,20 +220,7 @@ class PLATFORM_EXPORT V8PrivateProperty {
// Returns a Symbol to access a private property. Symbol instances from same // Returns a Symbol to access a private property. Symbol instances from same
// |key| are guaranteed to access the same property. // |key| are guaranteed to access the same property.
static Symbol GetSymbol(v8::Isolate* isolate, const SymbolKey& key) { static Symbol GetSymbol(v8::Isolate* isolate, const SymbolKey& key);
V8PrivateProperty* private_prop =
V8PerIsolateData::From(isolate)->PrivateProperty();
auto& symbol_map = private_prop->symbol_map_;
auto iter = symbol_map.find(&key);
v8::Local<v8::Private> v8_private;
if (UNLIKELY(iter == symbol_map.end())) {
v8_private = CreateV8Private(isolate, key.GetDescription());
symbol_map.insert(&key, v8::Eternal<v8::Private>(isolate, v8_private));
} else {
v8_private = iter->value.Get(isolate);
}
return Symbol(isolate, v8_private);
}
// This function is always called after NOTREACHED(). The Symbol returned from // This function is always called after NOTREACHED(). The Symbol returned from
// this function must not be used. // this function must not be used.
......
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