[webkit-reviews] review requested: [Bug 209716] [ESNext] Implement logical assignment operators : [Attachment 396486] Patch

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Tue Apr 14 18:06:42 PDT 2020


Devin Rousso <drousso at apple.com> has asked  for review:
Bug 209716: [ESNext] Implement logical assignment operators
https://bugs.webkit.org/show_bug.cgi?id=209716

Attachment 396486: Patch

https://bugs.webkit.org/attachment.cgi?id=396486&action=review




--- Comment #26 from Devin Rousso <drousso at apple.com> ---
Created attachment 396486

  --> https://bugs.webkit.org/attachment.cgi?id=396486&action=review

Patch

After talking with @Ross Kirsling a bit more offline, it looks like the logic
we have is correct.

A simple test is to compare the dumped bytecodes for `a ??= b` and `a ?? (a =
b)`.

>>> x ?? (x = 42)
[   0] enter		  
[   1] get_scope	  loc4
[   3] mov		  loc5, loc4
[   6] check_traps	  
[   7] mov		  loc6, Undefined(const0)
[  10] mov		  loc6, Undefined(const0)
[  13] resolve_scope	  loc6, loc4, 0, GlobalProperty, 0
[  20] get_from_scope	  loc7, loc6, 0,
2048<ThrowIfNotFound|GlobalProperty|NotInitialization|NotStrictMode>, 0, 0
[  28] mov		  loc6, loc7
[  31] profile_type	  loc6, 0, ProfileTypeBytecodeClosureVar, 0,
GlobalProperty
[  38] jnundefined_or_null loc6, 28(->66)
[  41] resolve_scope	  loc7, loc4, 0, GlobalProperty, 0
[  48] mov		  loc6, Int32: 42(const1)
[  51] put_to_scope	  loc7, 0, loc6,
1050624<DoNotThrowIfNotFound|GlobalProperty|NotInitialization|NotStrictMode>,
0, 0
[  59] profile_type	  loc6, 0, ProfileTypeBytecodeClosureVar, 0,
GlobalProperty
[  66] end		  loc6

>>> x ??= 42
[   0] enter		  
[   1] get_scope	  loc4
[   3] mov		  loc5, loc4
[   6] check_traps	  
[   7] mov		  loc6, Undefined(const0)
[  10] mov		  loc6, Undefined(const0)
[  13] resolve_scope	  loc7, loc4, 0, GlobalProperty, 0
[  20] get_from_scope	  loc6, loc7, 0,
2048<ThrowIfNotFound|GlobalProperty|NotInitialization|NotStrictMode>, 0, 0
[  28] jnundefined_or_null loc6, 21(->49)
[  31] mov		  loc6, Int32: 42(const1)
[  34] put_to_scope	  loc7, 0, loc6,
2048<ThrowIfNotFound|GlobalProperty|NotInitialization|NotStrictMode>, 0, 0
[  42] profile_type	  loc6, 0, ProfileTypeBytecodeClosureVar, 0,
GlobalProperty
[  49] end		  loc6

As we can see, we emit the same things other than
 - the `mov` (28) and `profile_type` (31) from the lhs `x` in `x ?? (x = 42)`
 - the second `resolve_scope` (41) from the rhs `x` in `x ?? (x = 42)`
both of which are expected and a benefit of the short circuiting.


More information about the webkit-reviews mailing list