Bug 216685

Summary: Move some LLInt globals into JSC::Config.
Product: WebKit Reporter: Mark Lam <mark.lam>
Component: JavaScriptCoreAssignee: Mark Lam <mark.lam>
Status: RESOLVED FIXED    
Severity: Normal CC: benjamin, cdumez, cmarcelo, ews-watchlist, keith_miller, mmaxfield, msaboff, pmatos, saam, sam, tzagallo, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 216772    
Attachments:
Description Flags
proposed patch.
ews-feeder: commit-queue-
proposed patch.
ews-feeder: commit-queue-
proposed patch.
ews-feeder: commit-queue-
proposed patch.
ews-feeder: commit-queue-
proposed patch.
ews-feeder: commit-queue-
patch for EWS testing.
ews-feeder: commit-queue-
EWS test
ews-feeder: commit-queue-
EWS test.
ews-feeder: commit-queue-
EWS test.
ews-feeder: commit-queue-
EWS test.
ews-feeder: commit-queue-
EWS test.
ews-feeder: commit-queue-
EWS test
ews-feeder: commit-queue-
EWS test.
ews-feeder: commit-queue-
LowLevelInterpreterWin.asm without patch
none
LowLevelInterpreterWin.asm with patch
none
proposed patch.
ews-feeder: commit-queue-
proposed patch. keith_miller: review+

Description Mark Lam 2020-09-17 20:58:15 PDT
rdar://68964544
Comment 1 Mark Lam 2020-09-17 22:01:36 PDT
Created attachment 409103 [details]
proposed patch.
Comment 2 Mark Lam 2020-09-17 22:32:13 PDT
Created attachment 409105 [details]
proposed patch.
Comment 3 Mark Lam 2020-09-18 00:32:40 PDT
Created attachment 409108 [details]
proposed patch.
Comment 4 Mark Lam 2020-09-18 00:40:45 PDT
Created attachment 409109 [details]
proposed patch.
Comment 5 Mark Lam 2020-09-18 00:55:03 PDT
Created attachment 409112 [details]
proposed patch.
Comment 6 Mark Lam 2020-09-18 01:38:33 PDT
Created attachment 409113 [details]
patch for EWS testing.
Comment 7 Mark Lam 2020-09-18 01:50:50 PDT
Created attachment 409114 [details]
EWS test
Comment 8 Mark Lam 2020-09-18 01:54:26 PDT
Created attachment 409115 [details]
EWS test.
Comment 9 Mark Lam 2020-09-18 02:50:01 PDT
Created attachment 409121 [details]
EWS test.
Comment 10 Mark Lam 2020-09-18 11:33:27 PDT
Created attachment 409152 [details]
EWS test.
Comment 11 Mark Lam 2020-09-18 11:41:30 PDT
Created attachment 409155 [details]
EWS test.
Comment 12 Mark Lam 2020-09-18 12:35:43 PDT
Created attachment 409163 [details]
EWS test
Comment 13 Mark Lam 2020-09-18 13:08:00 PDT
Created attachment 409167 [details]
EWS test.
Comment 14 Myles C. Maxfield 2020-09-18 21:56:27 PDT
Created attachment 409194 [details]
LowLevelInterpreterWin.asm without patch
Comment 15 Myles C. Maxfield 2020-09-18 21:57:45 PDT
Created attachment 409195 [details]
LowLevelInterpreterWin.asm with patch
Comment 16 Mark Lam 2020-09-19 16:04:16 PDT
Created attachment 409212 [details]
proposed patch.
Comment 17 Mark Lam 2020-09-19 16:20:33 PDT
Created attachment 409213 [details]
proposed patch.
Comment 18 Mark Lam 2020-09-19 17:36:20 PDT
Comment on attachment 409213 [details]
proposed patch.

Ready for a review now.
Comment 19 Sam Weinig 2020-09-19 17:41:03 PDT
Comment on attachment 409213 [details]
proposed patch.

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

> Source/JavaScriptCore/ChangeLog:3
> +        Move some LLInt globals into JSC::Config.

What is the goal of doing this?
Comment 20 Mark Lam 2020-09-19 20:40:50 PDT
(In reply to Sam Weinig from comment #19)
> Comment on attachment 409213 [details]
> proposed patch.
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=409213&action=review
> 
> > Source/JavaScriptCore/ChangeLog:3
> > +        Move some LLInt globals into JSC::Config.
> 
> What is the goal of doing this?

The opcodeMaps are supposed to be functionally constant.  They are meant to be initialized once and never changed thereafter.  This change enforces that invariant.
Comment 21 Sam Weinig 2020-09-20 07:37:34 PDT
Comment on attachment 409213 [details]
proposed patch.

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

>>> Source/JavaScriptCore/ChangeLog:3
>>> +        Move some LLInt globals into JSC::Config.
>> 
>> What is the goal of doing this?
> 
> The opcodeMaps are supposed to be functionally constant.  They are meant to be initialized once and never changed thereafter.  This change enforces that invariant.

It feels like an oddly named place, "Config", for an opcode map. Perhaps either JSC::Config needs a new name, or these should go somewhere else that can enforce that invariant?
Comment 22 Mark Lam 2020-09-20 12:25:44 PDT
(In reply to Sam Weinig from comment #21)
> Comment on attachment 409213 [details]
> proposed patch.
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=409213&action=review
> 
> >>> Source/JavaScriptCore/ChangeLog:3
> >>> +        Move some LLInt globals into JSC::Config.
> >> 
> >> What is the goal of doing this?
> > 
> > The opcodeMaps are supposed to be functionally constant.  They are meant to be initialized once and never changed thereafter.  This change enforces that invariant.
> 
> It feels like an oddly named place, "Config", for an opcode map. Perhaps
> either JSC::Config needs a new name, or these should go somewhere else that
> can enforce that invariant?

It's not that odd.  In a sense, the opcode maps "configures" how the LLInt will behave (though this is a bit of a stretch).  But yeah, if we can come up with a better name for the Config, I would gladly adopt it.  No one has a better proposal yet.  When I first introduced it, I considered ConstData / ROData (for ReadOnlyData) but those are not accurate either (the data is only const/read-only after freezing, and not before).
Comment 23 Sam Weinig 2020-09-20 14:10:25 PDT
(In reply to Mark Lam from comment #22)
> (In reply to Sam Weinig from comment #21)
> > Comment on attachment 409213 [details]
> > proposed patch.
> > 
> > View in context:
> > https://bugs.webkit.org/attachment.cgi?id=409213&action=review
> > 
> > >>> Source/JavaScriptCore/ChangeLog:3
> > >>> +        Move some LLInt globals into JSC::Config.
> > >> 
> > >> What is the goal of doing this?
> > > 
> > > The opcodeMaps are supposed to be functionally constant.  They are meant to be initialized once and never changed thereafter.  This change enforces that invariant.
> > 
> > It feels like an oddly named place, "Config", for an opcode map. Perhaps
> > either JSC::Config needs a new name, or these should go somewhere else that
> > can enforce that invariant?
> 
> It's not that odd.  In a sense, the opcode maps "configures" how the LLInt
> will behave (though this is a bit of a stretch).  But yeah, if we can come
> up with a better name for the Config, I would gladly adopt it.  No one has a
> better proposal yet.  When I first introduced it, I considered ConstData /
> ROData (for ReadOnlyData) but those are not accurate either (the data is
> only const/read-only after freezing, and not before).

I see, makes sense. We should definitely rename JSC::Config (or make it a member of a new thing) at some point. Not needed for this change.
Comment 24 Keith Miller 2020-09-21 13:03:53 PDT
Comment on attachment 409213 [details]
proposed patch.

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

r=me with nits

> Source/JavaScriptCore/ChangeLog:18
> +        2. Add a LLIntInitializeAssertScope to be used in LLInt::initialize() to ensure
> +           that it is only called during primodial initialization time.

It seems like this is unnecessary, since we will crash once the data has been made read only anyway, right?

> Source/JavaScriptCore/llint/LLIntData.cpp:65
> +    LLIntInitializeAssertScope assertScope;

Nit: if you want to keep this assert, make it a ScopeExit, you're only using it once anyway.

> Source/JavaScriptCore/offlineasm/arm.rb:269
> +                        newList << Instruction.new(codeOrigin, "move", [Immediate.new(node.codeOrigin, labelRef.offset), tmp])
> +                        newList << Instruction.new(codeOrigin, "addp", [tmp, node.operands[1]])

Can you put a FIXME to implement the logic to figure out which immediates are encodable inline here?
Comment 25 Mark Lam 2020-09-21 14:25:41 PDT
Comment on attachment 409213 [details]
proposed patch.

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

>> Source/JavaScriptCore/ChangeLog:18
>> +           that it is only called during primodial initialization time.
> 
> It seems like this is unnecessary, since we will crash once the data has been made read only anyway, right?

After thinking about this some more, I agree that this is redundant.  I'll remove it.

>> Source/JavaScriptCore/llint/LLIntData.cpp:65
>> +    LLIntInitializeAssertScope assertScope;
> 
> Nit: if you want to keep this assert, make it a ScopeExit, you're only using it once anyway.

The scope asserts on function entry (via the constructor) and on exit (via the destructor).  The exit scope solution is not the same.  But anyway, this is moot since I'll remove this.

>> Source/JavaScriptCore/offlineasm/arm.rb:269
>> +                        newList << Instruction.new(codeOrigin, "addp", [tmp, node.operands[1]])
> 
> Can you put a FIXME to implement the logic to figure out which immediates are encodable inline here?

255 is the basic (covered here already), but traditional 32-bit ARM instruction set does allow for encoding of some larger immediate via rotation tricks.  Not too sure about Thumb2 though.  I'll have the a FIXME just say that we can explore other encodings of immediate that fit in the add instruction.
Comment 26 Mark Lam 2020-09-21 15:02:30 PDT
Thanks for the review.  Landed in r267371: <http://trac.webkit.org/r267371>.