Bug 210019 - [JSC] JSWrapperObject should use JSInternalFieldObjectImpl
Summary: [JSC] JSWrapperObject should use JSInternalFieldObjectImpl
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: Yusuke Suzuki
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-04-05 00:39 PDT by Yusuke Suzuki
Modified: 2020-04-07 10:40 PDT (History)
7 users (show)

See Also:


Attachments
Patch (15.50 KB, patch)
2020-04-05 00:42 PDT, Yusuke Suzuki
no flags Details | Formatted Diff | Diff
Patch (15.53 KB, patch)
2020-04-05 00:47 PDT, Yusuke Suzuki
no flags Details | Formatted Diff | Diff
Patch (17.03 KB, patch)
2020-04-05 00:55 PDT, Yusuke Suzuki
mark.lam: 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 2020-04-05 00:39:56 PDT
[JSC] JSWrapperObject should use JSInternalFieldObjectImpl
Comment 1 Yusuke Suzuki 2020-04-05 00:42:59 PDT
Created attachment 395490 [details]
Patch
Comment 2 Yusuke Suzuki 2020-04-05 00:44:13 PDT
Comment on attachment 395490 [details]
Patch

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

> Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp:-9866
> -    m_jit.storePtr(
> -        TrustedImmPtr(StringObject::info()),
> -        JITCompiler::Address(resultGPR, JSDestructibleObject::classInfoOffset()));

This was wrong :P

> Source/JavaScriptCore/dfg/DFGSpeculativeJIT.h:-1533
> -    template<typename ClassType>
> -    void emitAllocateDestructibleObject(GPRReg resultGPR, RegisteredStructure structure, 
> -        GPRReg scratchGPR1, GPRReg scratchGPR2, MacroAssembler::JumpList& slowPath)
> -    {
> -        m_jit.emitAllocateDestructibleObject<ClassType>(vm(), resultGPR, structure.get(), scratchGPR1, scratchGPR2, slowPath);
> -    }

We are no longer using this.

> Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp:-6404
> -        m_out.storePtr(m_out.constIntPtr(StringObject::info()), fastResultValue, m_heaps.JSDestructibleObject_classInfo);

Ditto :P
Comment 3 Yusuke Suzuki 2020-04-05 00:47:37 PDT
Created attachment 395491 [details]
Patch
Comment 4 Yusuke Suzuki 2020-04-05 00:55:34 PDT
Created attachment 395492 [details]
Patch
Comment 5 Mark Lam 2020-04-05 22:42:21 PDT
Comment on attachment 395492 [details]
Patch

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

r=me with suggestion.

> Source/JavaScriptCore/runtime/JSWrapperObject.cpp:37
>  void JSWrapperObject::visitChildren(JSCell* cell, SlotVisitor& visitor)
>  {
> -    JSWrapperObject* thisObject = jsCast<JSWrapperObject*>(cell);
> +    auto* thisObject = jsCast<JSWrapperObject*>(cell);
>      ASSERT_GC_OBJECT_INHERITS(thisObject, info());
> -    JSObject::visitChildren(thisObject, visitor);
> -    visitor.append(thisObject->m_internalValue);
> +    Base::visitChildren(thisObject, visitor);
>  }

This no longer adds much value.  Can we just get rid of it and use the Base visitChildren()?  

The only thing done here that is not done by the Base is the ASSERT_GC_OBJECT_INHERITS.  How much value is there in keeping that?  If we want to keep this assert, can / should we make this function conditional on ASSERT_ENABLED?
Comment 6 Saam Barati 2020-04-06 15:07:05 PDT
Comment on attachment 395492 [details]
Patch

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

> Source/JavaScriptCore/ChangeLog:16
> +        We remove this wrong store.

I feel like all of the c++ code emitting these stores should come along with a static_assert
Comment 7 Yusuke Suzuki 2020-04-07 10:30:59 PDT
Comment on attachment 395492 [details]
Patch

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

>> Source/JavaScriptCore/runtime/JSWrapperObject.cpp:37
>>  }
> 
> This no longer adds much value.  Can we just get rid of it and use the Base visitChildren()?  
> 
> The only thing done here that is not done by the Base is the ASSERT_GC_OBJECT_INHERITS.  How much value is there in keeping that?  If we want to keep this assert, can / should we make this function conditional on ASSERT_ENABLED?

To avoid bothering about template-weak-symbol related linking problems (template weak symbols which is only referenced as a pointer), I think defining this is harmless and easy to make it manageable. For now, I'll just use this.
Comment 8 Yusuke Suzuki 2020-04-07 10:31:59 PDT
Comment on attachment 395492 [details]
Patch

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

>> Source/JavaScriptCore/ChangeLog:16
>> +        We remove this wrong store.
> 
> I feel like all of the c++ code emitting these stores should come along with a static_assert

I think we should eventually put more and more static_assert in FTL / DFG side to ensure that FTL / DFG's class hierarchy assumption is kept.
Comment 9 Yusuke Suzuki 2020-04-07 10:39:34 PDT
Committed r259645: <https://trac.webkit.org/changeset/259645>
Comment 10 Radar WebKit Bug Importer 2020-04-07 10:40:20 PDT
<rdar://problem/61399515>