brought up in #3525 and https://github.com/processing/p5.js/pull/3531#issuecomment-466808663
such use of the
argumentsarray causes deoptimization in many js jits
alternate implementation proposed by @Spongman :
p5.prototype.square = function(x, y, s, tl, tr, br, bl) {
this.rect(x, y, s, s, tl, tr, br, bl);
};
this should be more performant than the current implementation (which uses arguments).
just to expand on this: in general whenever the arguments object is mutated, or passed to a method (except as the 2nd argument of function.apply) the runtime has to copy the stack-allocated arguments object to a heap-allocated, garbage collected temporary proxy object. additionally, the added complexity of this often can result in the method no longer being eligible for native code generation.
I'd like to work on this
Most helpful comment
just to expand on this: in general whenever the
argumentsobject is mutated, or passed to a method (except as the 2nd argument offunction.apply) the runtime has to copy the stack-allocatedargumentsobject to a heap-allocated, garbage collected temporary proxy object. additionally, the added complexity of this often can result in the method no longer being eligible for native code generation.