-
-
Notifications
You must be signed in to change notification settings - Fork 208
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
perf: avoid unnecessary operation for improve performance #698
Conversation
Why closed? |
@Uzlopak I thought you don't want to merge anymore :D |
I want to check the V8 bytecode to see if a switch typeof uses string comparison or not, |
The problem is, that we have always maendering interests, so it is kind of hard to always get things done in a timely manner. So just dont think we are not interested, we are just busy, like you ;). |
Seems like I cannot get the const a = (b) => {
if (typeof b === "function") {
return b;
}
}; [generated bytecode for function: a (0x328e80b5b9f1 <SharedFunctionInfo a>)]
Bytecode length: 11
Parameter count 2
Register count 0
Frame size 0
Bytecode age: 0
3174 S> 0x328e80b5ccae @ 0 : 0b 03 Ldar a0
0x328e80b5ccb0 @ 2 : 20 06 TestTypeOf #6
0x328e80b5ccb2 @ 4 : 99 05 JumpIfFalse [5] (0x328e80b5ccb7 @ 9)
3209 S> 0x328e80b5ccb4 @ 6 : 0b 03 Ldar a0
3218 S> 0x328e80b5ccb6 @ 8 : a9 Return
0x328e80b5ccb7 @ 9 : 0e LdaUndefined
3223 S> 0x328e80b5ccb8 @ 10 : a9 Return
Constant pool (size = 0)
Handler Table (size = 0)
Source Position Table (size = 12)
0x328e80b5ccc1 <ByteArray[12]> const a = (b) => {
switch (typeof b) {
case "function":
return b;
}
}; [generated bytecode for function: a (0x1ded2941b9f1 <SharedFunctionInfo a>)]
Bytecode length: 18
Parameter count 2
Register count 1
Frame size 8
Bytecode age: 0
3174 S> 0x1ded2941ccc6 @ 0 : 0b 03 Ldar a0
0x1ded2941ccc8 @ 2 : 56 TypeOf
0x1ded2941ccc9 @ 3 : c4 Star0
0x1ded2941ccca @ 4 : 13 00 LdaConstant [0]
0x1ded2941cccc @ 6 : 6c fa 00 TestEqualStrict r0, [0]
0x1ded2941cccf @ 9 : 98 04 JumpIfTrue [4] (0x1ded2941ccd3 @ 13)
0x1ded2941ccd1 @ 11 : 8a 05 Jump [5] (0x1ded2941ccd6 @ 16)
3221 S> 0x1ded2941ccd3 @ 13 : 0b 03 Ldar a0
3230 S> 0x1ded2941ccd5 @ 15 : a9 Return
0x1ded2941ccd6 @ 16 : 0e LdaUndefined
3235 S> 0x1ded2941ccd7 @ 17 : a9 Return
Constant pool (size = 1)
0x1ded2941cc79: [FixedArray] in OldSpace
- map: 0x0624cc240211 <Map(FIXED_ARRAY_TYPE)>
- length: 1
0: 0x0624cc246351 <String[8]: #function>
Handler Table (size = 0)
Source Position Table (size = 12)
0x1ded2941ccd9 <ByteArray[12]> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rest of the PR (Number
-> +
, isFinite
-> !== Infinity || !== -Infinity
) LGTM
Signed-off-by: francesco <[email protected]>
Signed-off-by: francesco <[email protected]>
Signed-off-by: francesco <[email protected]>
@gurgunday done
MASTER
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
@ivan-tymoshenko ptal |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
@mcollina seem all "ok" for the merge! |
This PR has some microptimization for reduce the overhead of function call that can replaced with more faster inline control
Side note: the code become a bit ugly but seems more faster
PS. someone can run benchmark on github (master vs PR)? I have noticed my PC is a bit unstable on benchmark results
Master
PR
Checklist
npm run test
andnpm run benchmark
and the Code of conduct