Bug 245925

Summary: [JSC] Optimization for class static block
Product: WebKit Reporter: Yijia Huang <yijia_huang>
Component: JavaScriptCoreAssignee: Yijia Huang <yijia_huang>
Status: NEW    
Severity: Normal CC: webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   

Yijia Huang
Reported 2022-10-01 00:42:45 PDT
There are two possible optimizations in current implementation. Given the JS program: ``` class C { static { } static { } } ``` The corresponding emitted bytecode for evaluating class field initializations and static blocks. ``` bb#1 Predecessors: [ ] [ 0] enter [ 1] get_scope dst:loc4 [ 3] mov dst:loc5, src:loc4 [ 6] check_traps [ 7] get_by_id dst:loc6, base:callee, property:0 [ 12] new_func_exp dst:loc7, scope:loc4, functionDecl:0 [ 16] put_by_id base:loc7, property:0, value:loc6, flags:Strict [ 22] mov dst:loc8, src:this [ 25] call dst:loc7, callee:loc7, argc:1, argv:14 [ 31] get_by_id dst:loc6, base:callee, property:0 [ 36] new_func_exp dst:loc7, scope:loc4, functionDecl:1 [ 40] put_by_id base:loc7, property:0, value:loc6, flags:Strict [ 46] mov dst:loc8, src:this [ 49] call dst:loc7, callee:loc7, argc:1, argv:14 [ 55] ret value:Undefined(const0) Successors: [ ] Identifiers: id0 = PrivateSymbol.homeObject Constants: k0 = Undefined ``` where `[ 7] get_by_id dst:loc6, base:callee, property:0` and `[ 31] get_by_id dst:loc6, base:callee, property:0` are redundant. And if the static block is empty, we should not emit the function call bytecode. Maybe we can do these optimizations in another path.
Attachments
Radar WebKit Bug Importer
Comment 1 2022-10-08 00:43:16 PDT
Note You need to log in before you can comment on or make changes to this bug.