Bug 197910 - [JSC] UnlinkedMetadataTable's offset table should be small
Summary: [JSC] UnlinkedMetadataTable's offset table should be small
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Yusuke Suzuki
URL:
Keywords: InRadar
Depends on:
Blocks: 197940
  Show dependency treegraph
 
Reported: 2019-05-15 02:31 PDT by Yusuke Suzuki
Modified: 2019-05-22 18:48 PDT (History)
7 users (show)

See Also:


Attachments
Patch (21.31 KB, patch)
2019-05-17 19:31 PDT, Yusuke Suzuki
no flags Details | Formatted Diff | Diff
Patch (23.24 KB, patch)
2019-05-17 21:45 PDT, Yusuke Suzuki
no flags Details | Formatted Diff | Diff
Patch (26.50 KB, patch)
2019-05-18 03:03 PDT, Yusuke Suzuki
no flags Details | Formatted Diff | Diff
Patch (26.13 KB, patch)
2019-05-18 03:10 PDT, Yusuke Suzuki
saam: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Yusuke Suzuki 2019-05-15 02:31:00 PDT
Each one takes 208 bytes for now.
Comment 1 Yusuke Suzuki 2019-05-17 19:31:23 PDT
Created attachment 370177 [details]
Patch

WIP
Comment 2 Yusuke Suzuki 2019-05-17 21:45:57 PDT
Created attachment 370185 [details]
Patch

WIP
Comment 3 Yusuke Suzuki 2019-05-18 00:49:05 PDT
16bit thing can cover almost all the thing. But 8bit version cannot cover things even if we leverage 4byte alignment. So, we should use 16bit offset table.
Comment 4 Yusuke Suzuki 2019-05-18 03:03:29 PDT
Created attachment 370189 [details]
Patch
Comment 5 Yusuke Suzuki 2019-05-18 03:10:05 PDT
Created attachment 370190 [details]
Patch
Comment 6 Tadeu Zagallo 2019-05-18 04:02:44 PDT
This looks great! I wonder what percentage of the UnlinkedMetadataTables in gmail fit in the 16-bit offset table.
Comment 7 Yusuke Suzuki 2019-05-18 16:33:57 PDT
(In reply to Tadeu Zagallo from comment #6)
> This looks great! I wonder what percentage of the UnlinkedMetadataTables in
> gmail fit in the 16-bit offset table.

I don't remember the exact number of that, but when I logged the 32bit UnlinkedMetadataTable in Gmail to see it is actually used and works, it is < 100, super limited. So, it is less than 0.4% of all the UnlinkedMetadataTable in Gmail :)
Comment 8 Yusuke Suzuki 2019-05-18 18:47:48 PDT
(In reply to Yusuke Suzuki from comment #7)
> (In reply to Tadeu Zagallo from comment #6)
> > This looks great! I wonder what percentage of the UnlinkedMetadataTables in
> > gmail fit in the 16-bit offset table.
> 
> I don't remember the exact number of that, but when I logged the 32bit
> UnlinkedMetadataTable in Gmail to see it is actually used and works, it is <
> 100, super limited. So, it is less than 0.4% of all the
> UnlinkedMetadataTable in Gmail :)

On the other hand, 8bit version does not cover the existing MetadataTable well. When I inserted the log, it seems sooooo many MetadataTable in Gmail exceeds 1024 bytes (log does not stop...) => even if we use 4byte alignment information, this exceeds 8bit range. This makes me decide picking 16bit offset table here.
Comment 9 Saam Barati 2019-05-22 13:54:31 PDT
Comment on attachment 370190 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=370190&action=review

r=me

> Source/JavaScriptCore/bytecode/UnlinkedMetadataTable.cpp:61
> +            offset = roundUpToMultipleOf(metadataAlignment(static_cast<OpcodeID>(i)), offset);

maybe also ASSERT metadataAlignment <= s_maxMetadataAlignment?

> Source/JavaScriptCore/bytecode/UnlinkedMetadataTable.cpp:69
> +    if (m_is32Bit) {

Please make sure we have tests for this code in our regression test suite.

> Source/JavaScriptCore/bytecode/UnlinkedMetadataTable.h:106
> +    Offset16* offsetTable16() const { return bitwise_cast<Offset16*>(m_rawBuffer + sizeof(LinkingData)); }

nit: ASSERT(!m_is32bit)?

> Source/JavaScriptCore/bytecode/UnlinkedMetadataTable.h:107
> +    Offset32* offsetTable32() const { return bitwise_cast<Offset32*>(m_rawBuffer + sizeof(LinkingData) + s_offset16TableSize); }

nit: ASSERT(m_is32bit)?

> Source/JavaScriptCore/llint/LowLevelInterpreter.asm:185
> +const MetadataOffsetTable16 = 0
> +const MetadataOffsetTable32 = constexpr UnlinkedMetadataTable::s_offset16TableSize

I think these names should have "Offset" at the end of them.
Comment 10 Yusuke Suzuki 2019-05-22 17:07:17 PDT
Comment on attachment 370190 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=370190&action=review

Thanks!

>> Source/JavaScriptCore/bytecode/UnlinkedMetadataTable.cpp:61
>> +            offset = roundUpToMultipleOf(metadataAlignment(static_cast<OpcodeID>(i)), offset);
> 
> maybe also ASSERT metadataAlignment <= s_maxMetadataAlignment?

Sounds nice. Fixed.

>> Source/JavaScriptCore/bytecode/UnlinkedMetadataTable.cpp:69
>> +    if (m_is32Bit) {
> 
> Please make sure we have tests for this code in our regression test suite.

Thanks, added.

>> Source/JavaScriptCore/bytecode/UnlinkedMetadataTable.h:106
>> +    Offset16* offsetTable16() const { return bitwise_cast<Offset16*>(m_rawBuffer + sizeof(LinkingData)); }
> 
> nit: ASSERT(!m_is32bit)?

Nice, added.

>> Source/JavaScriptCore/bytecode/UnlinkedMetadataTable.h:107
>> +    Offset32* offsetTable32() const { return bitwise_cast<Offset32*>(m_rawBuffer + sizeof(LinkingData) + s_offset16TableSize); }
> 
> nit: ASSERT(m_is32bit)?

Ditto.

>> Source/JavaScriptCore/llint/LowLevelInterpreter.asm:185
>> +const MetadataOffsetTable32 = constexpr UnlinkedMetadataTable::s_offset16TableSize
> 
> I think these names should have "Offset" at the end of them.

Added. Nice.
Comment 11 Yusuke Suzuki 2019-05-22 18:47:36 PDT
Committed r245669: <https://trac.webkit.org/changeset/245669>
Comment 12 Radar WebKit Bug Importer 2019-05-22 18:48:19 PDT
<rdar://problem/51051682>