WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED CONFIGURATION CHANGED
203604
codeBlock->expressionRangeForBytecodeIndex() returns wrong range for op_bitxor, op_bitand, op_bitor (and op_bitnot)
https://bugs.webkit.org/show_bug.cgi?id=203604
Summary
codeBlock->expressionRangeForBytecodeIndex() returns wrong range for op_bitxo...
Tuomas Karkkainen
Reported
2019-10-30 03:53:22 PDT
Created
attachment 382294
[details]
repro case for the JavaScript:
> function foo() { > let i = 0; > let j = 0; > let k = 0; > i ^ j; > j ^ k; > i ^ j ^ k; > } > > foo(); > foo();
the bytecode is:
> foo#CWMAwU:[0x1157a0140->0x1157c7b80, NoneFunctionCall, 47]: 15 instructions (0 16-bit instructions, 0 32-bit instructions, 4 instructions with metadata); 155 bytes (108 metadata bytes); 1 parameter(s); 10 callee register(s); 6 variable(s); scope at loc4 > [ 0] enter > [ 1] get_scope loc4 > [ 3] mov loc5, loc4 > [ 6] check_traps > [ 7] mov loc6, <JSValue()>(const0) > [ 10] mov loc7, <JSValue()>(const0) > [ 13] mov loc8, <JSValue()>(const0) > [ 16] mov loc6, Int32: 0(const1) > [ 19] mov loc8, Int32: 0(const1) > [ 22] mov loc7, Int32: 0(const1) > [ 25] bitxor loc9, loc6, loc8 > [ 30] bitxor loc9, loc8, loc7 > [ 35] bitxor loc9, loc6, loc8 > [ 40] bitxor loc9, loc9, loc7 > [ 45] ret Undefined(const2) > > Constants: > k0 = <JSValue()> > k1 = Int32: 0: in source as integer > k2 = Undefined
output of codeBlock->unlinkedCodeBlock()->dumpExpressionRangeInfo() is:
> UnlinkedCodeBlock 0x115798000 expressionRangeInfo[4] { > [0] pc 25 @ line 4 col 2 : op_bitxor > [1] pc 30 @ line 5 col 2 : op_bitxor > [2] pc 35 @ line 6 col 2 : op_bitxor > [3] pc 40 @ line 6 col 2 : op_bitxor > }
for the op_bitxors, codeBlock->expressionRangeForBytecodeIndex returns startOffset and endOffset of zero for all four and the divots are at the beginning of each line, specifically bytecodes #35 and #40 are both targeting the beginning of the line "i ^ j ^ k" nb. expressionRangeInfo points specifically to the op_bitxor bytecodes. my expectations for the source ranges for the op_bitxor bytecodes are:
> #25 "i ^ j" > divot--^ > #30 "j ^ k" > divot--^ > #35 "j ^ k" > divot--^ > #40 "i ^ j ^ k" > divot--^
the opcodes op_bitxor, op_bitand, op_bitor are all similarly affected.
Attachments
repro case
(104 bytes, application/x-javascript)
2019-10-30 03:53 PDT
,
Tuomas Karkkainen
no flags
Details
View All
Add attachment
proposed patch, testcase, etc.
Tuomas Karkkainen
Comment 1
2019-10-30 04:08:02 PDT
for the JavaScript:
> function bar() {} > > function foo() > { > let i = 0; > i ^= 0; > i &= 0; > i |= 0; > bar(); > } > > foo(); > foo();
the bytecode is:
> foo#BAHEl0:[0x108aa0140->0x108ac7c00, NoneFunctionCall, 51]: 13 instructions (0 16-bit instructions, 0 32-bit instructions, 6 instructions with metadata); 159 bytes (108 metadata bytes); 1 parameter(s); 14 callee register(s); 6 variable(s); scope at loc4 > [ 0] enter > [ 1] get_scope loc4 > [ 3] mov loc5, loc4 > [ 6] check_traps > [ 7] mov loc6, <JSValue()>(const0) > [ 10] mov loc6, Int32: 0(const1) > [ 13] bitxor loc6, loc6, Int32: 0(const1) > [ 18] bitand loc6, loc6, Int32: 0(const1) > [ 23] bitor loc6, loc6, Int32: 0(const1) > [ 28] resolve_scope loc8, loc4, 0, GlobalProperty, 0 > [ 35] get_from_scope loc7, loc8, 0, 2048<ThrowIfNotFound|GlobalProperty|NotInitialization>, 0, 0 > [ 43] call loc7, loc7, 1, 14 > [ 49] ret Undefined(const2) > > Identifiers: > id0 = bar > > Constants: > k0 = <JSValue()> > k1 = Int32: 0: in source as integer > k2 = Undefined
output of codeBlock->unlinkedCodeBlock()->dumpExpressionRangeInfo() is:
> UnlinkedCodeBlock 0x108a98000 expressionRangeInfo[2] { > [0] pc 28 @ line 6 col 5 : op_resolve_scope > [1] pc 43 @ line 6 col 5 : op_call > }
codeBlock->expressionRangeForBytecodeIndex() for bitxor, bitand and bitor all return a range that reads "bar"
Yusuke Suzuki
Comment 2
2023-07-28 23:17:23 PDT
These bytecodes no longer have ValueProfile.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug