Appendix
Examples, explanations and suggestions for v8 bailout reasons. Help alinode
users optimize according to CPU-Profiler prompts.
Index
Bailout reasons
Assignment to parameter in arguments object
Simple example
Why
Only occurs when reassigning parameters in a function.
Advices
You cannot reassign variable a.
It is better to use strict mode.
V8's latest TurboFan will have optimizations #1.
Bad value context for arguments value
Simple example
Why
Requires further specification of the
arguments
array.
Advices
You can read: https://github.com/petkaantonov/bluebird/wiki/Optimization-killers#3-managing-arguments
You can loop through
arguments
to create a new array Unsupported phi use of argumentsV8's latest TurboFan will have optimizations #1.
External links
https://github.com/bevry/taskgroup/issues/12
ForInStatement with non-local each variable
Simple example
Why
https://github.com/yjhjstz/v8-git-mirror/blob/master/src/hydrogen.cc#L5254
Advices
Only pure local variables can be used in for...in.
https://github.com/petkaantonov/bluebird/wiki/Optimization-killers#5-for-in
External links
https://github.com/mbostock/d3/pull/2686
Object literal with complex property
Simple example
Why
Advices
Simplify the Object.
ForInStatement is not fast case
Simple example
Why
Too much code in the for loop.
Advices
Extract the code in the for loop into a function.
Reference to a variable which requires dynamic lookup
Simple example
Why
Compilation fails to locate the variable at compile time, and Crankshaft needs to dynamically look it up again. #3
Advices
TurboFan can optimize.
TryCatchStatement
Simple example
Why
try/catch makes the control flow unstable and difficult to optimize at runtime.
Advices
Do not use try/catch in heavily loaded functions.
Can be refactored as
try { func() } catch
TryFinallyStatement
Simple example
Why
Advices
Unsupported phi use of arguments
简单例子
Why
Crankshaft cannot determine whether
_arguments
is an object or an array.
Advices
It is best to operate on a copy of
arguments
.TurboFan can optimize #1.
Why
Generator state preservation and restoration is achieved by copying function stack frames, which is not suitable for optimized compilers.
Advices
Currently, there is no need to consider this issue. TurboFan can optimize.
External links:
https://groups.google.com/forum/#!topic/v8-users/KnnUb-u4rA8
Resources
Last updated