Commit f65251be authored by Adithya Srinivasan's avatar Adithya Srinivasan Committed by Commit Bot

Add JSSpecialApiObjectType to fast path

HTMLCollection and NodeList have InstanceType
JS_SPECIAL_API_OBJECT_TYPE, and therefore always run the slow case
of GetAlignedPropertyFromInternalField. This slows down the performance
of indexedPropertyGetter for both types, which are very commonly used
in websites.

Bug: 
Cq-Include-Trybots: master.tryserver.chromium.linux:linux_chromium_rel_ng
Change-Id: I36bd2cd7d9bbc19149e15174f6868b8a1f1658c8
Reviewed-on: https://chromium-review.googlesource.com/726529Reviewed-by: 's avatarCamillo Bruni <cbruni@chromium.org>
Commit-Queue: Adithya Srinivasan <adithyas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#48760}
parent 789298d8
...@@ -9116,6 +9116,7 @@ class Internals { ...@@ -9116,6 +9116,7 @@ class Internals {
static const int kFirstNonstringType = 0x80; static const int kFirstNonstringType = 0x80;
static const int kOddballType = 0x83; static const int kOddballType = 0x83;
static const int kForeignType = 0x87; static const int kForeignType = 0x87;
static const int kJSSpecialApiObjectType = 0xbb;
static const int kJSApiObjectType = 0xbf; static const int kJSApiObjectType = 0xbf;
static const int kJSObjectType = 0xc0; static const int kJSObjectType = 0xc0;
...@@ -9723,7 +9724,8 @@ Local<Value> Object::GetInternalField(int index) { ...@@ -9723,7 +9724,8 @@ Local<Value> Object::GetInternalField(int index) {
// know where to find the internal fields and can return the value directly. // know where to find the internal fields and can return the value directly.
auto instance_type = I::GetInstanceType(obj); auto instance_type = I::GetInstanceType(obj);
if (instance_type == I::kJSObjectType || if (instance_type == I::kJSObjectType ||
instance_type == I::kJSApiObjectType) { instance_type == I::kJSApiObjectType ||
instance_type == I::kJSSpecialApiObjectType) {
int offset = I::kJSObjectHeaderSize + (internal::kApiPointerSize * index); int offset = I::kJSObjectHeaderSize + (internal::kApiPointerSize * index);
O* value = I::ReadField<O*>(obj, offset); O* value = I::ReadField<O*>(obj, offset);
O** result = HandleScope::CreateHandle(reinterpret_cast<HO*>(obj), value); O** result = HandleScope::CreateHandle(reinterpret_cast<HO*>(obj), value);
...@@ -9743,7 +9745,8 @@ void* Object::GetAlignedPointerFromInternalField(int index) { ...@@ -9743,7 +9745,8 @@ void* Object::GetAlignedPointerFromInternalField(int index) {
// know where to find the internal fields and can return the value directly. // know where to find the internal fields and can return the value directly.
auto instance_type = I::GetInstanceType(obj); auto instance_type = I::GetInstanceType(obj);
if (V8_LIKELY(instance_type == I::kJSObjectType || if (V8_LIKELY(instance_type == I::kJSObjectType ||
instance_type == I::kJSApiObjectType)) { instance_type == I::kJSApiObjectType ||
instance_type == I::kJSSpecialApiObjectType)) {
int offset = I::kJSObjectHeaderSize + (internal::kApiPointerSize * index); int offset = I::kJSObjectHeaderSize + (internal::kApiPointerSize * index);
return I::ReadField<void*>(obj, offset); return I::ReadField<void*>(obj, offset);
} }
......
...@@ -837,6 +837,7 @@ enum InstanceType : uint8_t { ...@@ -837,6 +837,7 @@ enum InstanceType : uint8_t {
STATIC_ASSERT(JS_OBJECT_TYPE == Internals::kJSObjectType); STATIC_ASSERT(JS_OBJECT_TYPE == Internals::kJSObjectType);
STATIC_ASSERT(JS_API_OBJECT_TYPE == Internals::kJSApiObjectType); STATIC_ASSERT(JS_API_OBJECT_TYPE == Internals::kJSApiObjectType);
STATIC_ASSERT(JS_SPECIAL_API_OBJECT_TYPE == Internals::kJSSpecialApiObjectType);
STATIC_ASSERT(FIRST_NONSTRING_TYPE == Internals::kFirstNonstringType); STATIC_ASSERT(FIRST_NONSTRING_TYPE == Internals::kFirstNonstringType);
STATIC_ASSERT(ODDBALL_TYPE == Internals::kOddballType); STATIC_ASSERT(ODDBALL_TYPE == Internals::kOddballType);
STATIC_ASSERT(FOREIGN_TYPE == Internals::kForeignType); STATIC_ASSERT(FOREIGN_TYPE == Internals::kForeignType);
......
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