Monday, January 2, 2012

System.arraycopy limits and Function.prototype.apply

Hi all,

I have this silly example (which is actually quite common in regular
Java):

private static int testArraycopy(int size)
{
double[] src = new double[size];
double[] dest = new double[size + 1];

System.arraycopy(src,0,dest,0,src.length);

return size;
}

After compiling this to Javascript I get various errors if the array
sizes are large:

Chrome 16; size=99999:
RangeError: Maximum call stack size exceeded

Firefox 8; size=491519:
RangeError: arguments array passed to Function.prototype.apply is too
large

So the problem is invoking a varargs function (in our case
Array.splice) with the content of the src array as individual function
arguments.

Why is System.arraycopy() implemented like this? Is this a known
limitation? Are there recommended workarounds?
(another place that fails the String(char[]) constructor that does a
similar thing)

Kind regards,
Csaba


--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment