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

Side by Side Diff: src/runtime.js

Issue 596122: Some string optimizations: (Closed)
Patch Set: Undo unnecessary optimizations. Created 10 years, 10 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
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 511 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 522
523 // ECMA-262, section 9.8, page 35. 523 // ECMA-262, section 9.8, page 35.
524 function ToString(x) { 524 function ToString(x) {
525 if (IS_STRING(x)) return x; 525 if (IS_STRING(x)) return x;
526 if (IS_NUMBER(x)) return %_NumberToString(x); 526 if (IS_NUMBER(x)) return %_NumberToString(x);
527 if (IS_BOOLEAN(x)) return x ? 'true' : 'false'; 527 if (IS_BOOLEAN(x)) return x ? 'true' : 'false';
528 if (IS_UNDEFINED(x)) return 'undefined'; 528 if (IS_UNDEFINED(x)) return 'undefined';
529 return (IS_NULL(x)) ? 'null' : %ToString(%DefaultString(x)); 529 return (IS_NULL(x)) ? 'null' : %ToString(%DefaultString(x));
530 } 530 }
531 531
532 function NonStringToString(x) {
533 if (IS_NUMBER(x)) return %NumberToString(x);
534 if (IS_BOOLEAN(x)) return x ? 'true' : 'false';
535 if (IS_UNDEFINED(x)) return 'undefined';
536 return (IS_NULL(x)) ? 'null' : %ToString(%DefaultString(x));
537 }
538
532 539
533 // ECMA-262, section 9.9, page 36. 540 // ECMA-262, section 9.9, page 36.
534 function ToObject(x) { 541 function ToObject(x) {
535 if (IS_STRING(x)) return new $String(x); 542 if (IS_STRING(x)) return new $String(x);
536 if (IS_NUMBER(x)) return new $Number(x); 543 if (IS_NUMBER(x)) return new $Number(x);
537 if (IS_BOOLEAN(x)) return new $Boolean(x); 544 if (IS_BOOLEAN(x)) return new $Boolean(x);
538 if (IS_NULL_OR_UNDEFINED(x) && !IS_UNDETECTABLE(x)) { 545 if (IS_NULL_OR_UNDEFINED(x) && !IS_UNDETECTABLE(x)) {
539 throw %MakeTypeError('null_to_object', []); 546 throw %MakeTypeError('null_to_object', []);
540 } 547 }
541 return x; 548 return x;
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
632 throw %MakeTypeError('cannot_convert_to_primitive', []); 639 throw %MakeTypeError('cannot_convert_to_primitive', []);
633 } 640 }
634 641
635 642
636 // NOTE: Setting the prototype for Array must take place as early as 643 // NOTE: Setting the prototype for Array must take place as early as
637 // possible due to code generation for array literals. When 644 // possible due to code generation for array literals. When
638 // generating code for a array literal a boilerplate array is created 645 // generating code for a array literal a boilerplate array is created
639 // that is cloned when running the code. It is essiential that the 646 // that is cloned when running the code. It is essiential that the
640 // boilerplate gets the right prototype. 647 // boilerplate gets the right prototype.
641 %FunctionSetPrototype($Array, new $Array(0)); 648 %FunctionSetPrototype($Array, new $Array(0));
OLDNEW
« src/macros.py ('K') | « src/runtime.cc ('k') | src/string.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698