Add specialized Vector4.translate methods based on argument types #345
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Matrix4.translate
is used by Flutter and it often appears as an overhead whenprofiling Flutter apps compiled to Wasm.
The function currently takes a
dynamic
argument and takes different codepaths based on the type.
This is inefficient when the call site already knows the argument's type.
In general, when we have a performance-critical generic function that checks
types of the arguments, it makes sense to introduce specialized versions of the
function based on precise argument types that it handles, so that callers can
call the more efficient specialized versions and avoid the type test overheads.
This PR introduces such functions for
Vector4.translate
based on argument types:Vector4.translateByDouble(double x, double y, double z)
Vector4.translateByVector3(Vector3 v3)
Vector4.translateByVector4(Vector4 v4)
Once these functions are released, we can update Flutter to call these to
improve performance.
dart2wasm benchmarks:
dart2js benchmarks:
AOT benchmarks:
JIT benchmarks: