Bug 203276 - BytecodeIndex should be a proper C++ class
Summary: BytecodeIndex should be a proper C++ class
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Keith Miller
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2019-10-22 14:48 PDT by Keith Miller
Modified: 2019-10-24 08:33 PDT (History)
13 users (show)

See Also:


Attachments
Patch (333.29 KB, patch)
2019-10-22 15:02 PDT, Keith Miller
no flags Details | Formatted Diff | Diff
Patch (325.78 KB, patch)
2019-10-22 15:07 PDT, Keith Miller
no flags Details | Formatted Diff | Diff
Patch (325.75 KB, patch)
2019-10-22 15:11 PDT, Keith Miller
no flags Details | Formatted Diff | Diff
Patch (325.76 KB, patch)
2019-10-22 15:17 PDT, Keith Miller
no flags Details | Formatted Diff | Diff
Patch for landing (326.28 KB, patch)
2019-10-22 15:55 PDT, Keith Miller
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Keith Miller 2019-10-22 14:48:08 PDT
BytecodeIndex should be a proper C++ class
Comment 1 Keith Miller 2019-10-22 15:02:07 PDT
Created attachment 381615 [details]
Patch
Comment 2 Keith Miller 2019-10-22 15:07:25 PDT
Created attachment 381616 [details]
Patch
Comment 3 Keith Miller 2019-10-22 15:11:11 PDT
Created attachment 381617 [details]
Patch
Comment 4 Keith Miller 2019-10-22 15:17:04 PDT
Created attachment 381618 [details]
Patch
Comment 5 Mark Lam 2019-10-22 15:40:20 PDT
Comment on attachment 381618 [details]
Patch

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

r=me with fixes.

> Source/JavaScriptCore/bytecode/BytecodeIndex.h:53
> +    explicit operator bool() const { return m_offset != std::numeric_limits<uint32_t>::max(); }

Can you use a "static constexpr InvalidOffset = std::numeric_limits<uint32_t>::max();" and use InvalidOffset here instead?  I think it will read better.

> Source/JavaScriptCore/bytecode/BytecodeIndex.h:66
> +    uint32_t m_offset { std::numeric_limits<uint32_t>::max() };

Ditto.  Use InvalidOffset here.

> Source/JavaScriptCore/bytecode/InstructionStream.h:80
> +        inline Offset offset() const { return m_index; }

Rename m_index to m_offset?  This cross-mixed naming is going to be a source of confusion.  You can do this in a follow up patch.

> Source/JavaScriptCore/bytecode/LazyOperandValueProfile.h:48
> -        : m_bytecodeOffset(0) // 0 = empty value
> +        : m_bytecodeIndex(0) // 0 = empty value
>          , m_operand(VirtualRegister()) // not a valid operand index in our current scheme
>      {
>      }
>      
>      LazyOperandValueProfileKey(WTF::HashTableDeletedValueType)
> -        : m_bytecodeOffset(1) // 1 = deleted value
> +        : m_bytecodeIndex(1) // 1 = deleted value

These feels like they deserve a comment as to why you can't use the default empty and deleted value instead of 0 and 1.  I presume the default values will cause problems?  The comment will prevent someone naive (like myself) coming along in the future and changing them thus.

> Source/JavaScriptCore/dfg/DFGOSREntrypointCreationPhase.cpp:55
> +        RELEASE_ASSERT(bytecodeIndex.offset());

Shouldn't this be RELEASE_ASSERT(bytecodeIndex)?
Comment 6 Keith Miller 2019-10-22 15:55:59 PDT
Created attachment 381622 [details]
Patch for landing
Comment 7 Keith Miller 2019-10-22 15:56:21 PDT
Comment on attachment 381618 [details]
Patch

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

>> Source/JavaScriptCore/bytecode/BytecodeIndex.h:53
>> +    explicit operator bool() const { return m_offset != std::numeric_limits<uint32_t>::max(); }
> 
> Can you use a "static constexpr InvalidOffset = std::numeric_limits<uint32_t>::max();" and use InvalidOffset here instead?  I think it will read better.

Done.

>> Source/JavaScriptCore/bytecode/InstructionStream.h:80
>> +        inline Offset offset() const { return m_index; }
> 
> Rename m_index to m_offset?  This cross-mixed naming is going to be a source of confusion.  You can do this in a follow up patch.

Sure.

>> Source/JavaScriptCore/bytecode/LazyOperandValueProfile.h:48
>> +        : m_bytecodeIndex(1) // 1 = deleted value
> 
> These feels like they deserve a comment as to why you can't use the default empty and deleted value instead of 0 and 1.  I presume the default values will cause problems?  The comment will prevent someone naive (like myself) coming along in the future and changing them thus.

I think I just left it because that's how it was before. I don't think it will cause any problems. I can change it.

>> Source/JavaScriptCore/dfg/DFGOSREntrypointCreationPhase.cpp:55
>> +        RELEASE_ASSERT(bytecodeIndex.offset());
> 
> Shouldn't this be RELEASE_ASSERT(bytecodeIndex)?

No, the old line above now covers the != UINT_MAX case. This covers the bytecodeIndex.offset() == 0 case.
Comment 8 Mark Lam 2019-10-22 15:59:35 PDT
Comment on attachment 381618 [details]
Patch

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

>>> Source/JavaScriptCore/dfg/DFGOSREntrypointCreationPhase.cpp:55
>>> +        RELEASE_ASSERT(bytecodeIndex.offset());
>> 
>> Shouldn't this be RELEASE_ASSERT(bytecodeIndex)?
> 
> No, the old line above now covers the != UINT_MAX case. This covers the bytecodeIndex.offset() == 0 case.

Oh, I see.
Comment 9 Keith Miller 2019-10-22 17:55:45 PDT
Committed r251468: <https://trac.webkit.org/changeset/251468>
Comment 10 Radar WebKit Bug Importer 2019-10-22 17:56:21 PDT
<rdar://problem/56523782>
Comment 11 Yusuke Suzuki 2019-10-22 20:06:34 PDT
Committed r251471: <https://trac.webkit.org/changeset/251471>
Comment 12 Keith Miller 2019-10-22 20:10:38 PDT
(In reply to Yusuke Suzuki from comment #11)
> Committed r251471: <https://trac.webkit.org/changeset/251471>

Ah, thanks. Unfortunately, the WinCairo EWS wasn't working.
Comment 13 Yusuke Suzuki 2019-10-22 20:14:27 PDT
(In reply to Keith Miller from comment #12)
> (In reply to Yusuke Suzuki from comment #11)
> > Committed r251471: <https://trac.webkit.org/changeset/251471>
> 
> Ah, thanks. Unfortunately, the WinCairo EWS wasn't working.

And, maybe, we also need to update 32bit things (but EWS is not working, sad :().
32bit had different implementation of CallSiteIndex. We should remove this difference I think.
Comment 14 Jonathan Bedard 2019-10-24 07:40:52 PDT
Just an FYI, this change broke a bunch of our Windows testers, Zan fixed it in <https://trac.webkit.org/changeset/251534>