Skip to content

Commit

Permalink
Prevent GetSymbol() using SymbolKey from being inlined
Browse files Browse the repository at this point in the history
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/+/1880900
Reviewed-by: Yuki Shiino <yukishiino@chromium.org>
Reviewed-by: Hitoshi Yoshida <peria@chromium.org>
Commit-Queue: Marina Sakai <marinasakai@google.com>
Cr-Commit-Position: refs/heads/master@{#709856}
  • Loading branch information
Marina Sakai authored and Commit Bot committed Oct 28, 2019
1 parent 98d72c4 commit f3f4cd7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,23 @@ v8::MaybeLocal<v8::Value> V8PrivateProperty::Symbol::GetFromMainWorld(
: 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,
const char* symbol) {
return v8::Private::New(isolate, V8String(isolate, symbol));
Expand Down
17 changes: 2 additions & 15 deletions third_party/blink/renderer/platform/bindings/v8_private_property.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class PLATFORM_EXPORT V8PrivateProperty {
//
// We can improve ability of tracking private properties by using an instance
// of this class. |desc_| is a description of the private property.
class PLATFORM_EXPORT SymbolKey {
class PLATFORM_EXPORT SymbolKey final {
public:
// 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
Expand Down Expand Up @@ -220,20 +220,7 @@ class PLATFORM_EXPORT V8PrivateProperty {

// Returns a Symbol to access a private property. Symbol instances from same
// |key| are guaranteed to access the same property.
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);
}
static Symbol GetSymbol(v8::Isolate* isolate, const SymbolKey& key);

// This function is always called after NOTREACHED(). The Symbol returned from
// this function must not be used.
Expand Down

0 comments on commit f3f4cd7

Please sign in to comment.