Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(178)

Side by Side Diff: src/runtime.js

Issue 519061: Improve performance of Array.prototype.join and String.prototype.substring... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 10 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 // First check whether length is a positive Smi and args is an 420 // First check whether length is a positive Smi and args is an
421 // array. This is the fast case. If this fails, we do the slow case 421 // array. This is the fast case. If this fails, we do the slow case
422 // that takes care of more eventualities. 422 // that takes care of more eventualities.
423 if (IS_ARRAY(args)) { 423 if (IS_ARRAY(args)) {
424 length = args.length; 424 length = args.length;
425 if (%_IsSmi(length) && length >= 0 && length < 0x800000 && IS_FUNCTION(this) ) { 425 if (%_IsSmi(length) && length >= 0 && length < 0x800000 && IS_FUNCTION(this) ) {
426 return length; 426 return length;
427 } 427 }
428 } 428 }
429 429
430 length = (args == null) ? 0 : %ToUint32(args.length); 430 length = (args == null) ? 0 : TO_UINT32(args.length);
431 431
432 // We can handle any number of apply arguments if the stack is 432 // We can handle any number of apply arguments if the stack is
433 // big enough, but sanity check the value to avoid overflow when 433 // big enough, but sanity check the value to avoid overflow when
434 // multiplying with pointer size. 434 // multiplying with pointer size.
435 if (length > 0x800000) { 435 if (length > 0x800000) {
436 throw %MakeRangeError('apply_overflow', [length]); 436 throw %MakeRangeError('apply_overflow', [length]);
437 } 437 }
438 438
439 if (!IS_FUNCTION(this)) { 439 if (!IS_FUNCTION(this)) {
440 throw %MakeTypeError('apply_non_function', [ %ToString(this), typeof this ]) ; 440 throw %MakeTypeError('apply_non_function', [ %ToString(this), typeof this ]) ;
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
603 throw %MakeTypeError('cannot_convert_to_primitive', []); 603 throw %MakeTypeError('cannot_convert_to_primitive', []);
604 } 604 }
605 605
606 606
607 // NOTE: Setting the prototype for Array must take place as early as 607 // NOTE: Setting the prototype for Array must take place as early as
608 // possible due to code generation for array literals. When 608 // possible due to code generation for array literals. When
609 // generating code for a array literal a boilerplate array is created 609 // generating code for a array literal a boilerplate array is created
610 // that is cloned when running the code. It is essiential that the 610 // that is cloned when running the code. It is essiential that the
611 // boilerplate gets the right prototype. 611 // boilerplate gets the right prototype.
612 %FunctionSetPrototype($Array, new $Array(0)); 612 %FunctionSetPrototype($Array, new $Array(0));
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698