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

Side by Side Diff: src/runtime.js

Issue 1278873007: [runtime] Remove premature optimization from ToPrimitive. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 4 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // This files contains runtime support implemented in JavaScript. 5 // This files contains runtime support implemented in JavaScript.
6 6
7 // CAUTION: Some of the functions specified in this file are called 7 // CAUTION: Some of the functions specified in this file are called
8 // directly from compiled code. These are the functions with names in 8 // directly from compiled code. These are the functions with names in
9 // ALL CAPS. The compiled code passes the first argument in 'this'. 9 // ALL CAPS. The compiled code passes the first argument in 'this'.
10 10
(...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after
745 745
746 746
747 /* ------------------------------------- 747 /* -------------------------------------
748 - - - C o n v e r s i o n s - - - 748 - - - C o n v e r s i o n s - - -
749 ------------------------------------- 749 -------------------------------------
750 */ 750 */
751 751
752 // ECMA-262, section 9.1, page 30. Use null/undefined for no hint, 752 // ECMA-262, section 9.1, page 30. Use null/undefined for no hint,
753 // (1) for number hint, and (2) for string hint. 753 // (1) for number hint, and (2) for string hint.
754 function ToPrimitive(x, hint) { 754 function ToPrimitive(x, hint) {
755 // Fast case check.
756 if (IS_STRING(x)) return x;
757 // Normal behavior.
758 if (!IS_SPEC_OBJECT(x)) return x; 755 if (!IS_SPEC_OBJECT(x)) return x;
759 if (IS_SIMD_VALUE(x)) return x;
760 if (hint == NO_HINT) hint = (IS_DATE(x)) ? STRING_HINT : NUMBER_HINT; 756 if (hint == NO_HINT) hint = (IS_DATE(x)) ? STRING_HINT : NUMBER_HINT;
761 return (hint == NUMBER_HINT) ? DefaultNumber(x) : DefaultString(x); 757 return (hint == NUMBER_HINT) ? DefaultNumber(x) : DefaultString(x);
762 } 758 }
763 759
764 760
765 // ECMA-262, section 9.2, page 30 761 // ECMA-262, section 9.2, page 30
766 function ToBoolean(x) { 762 function ToBoolean(x) {
767 if (IS_BOOLEAN(x)) return x; 763 if (IS_BOOLEAN(x)) return x;
768 if (IS_STRING(x)) return x.length != 0; 764 if (IS_STRING(x)) return x.length != 0;
769 if (x == null) return false; 765 if (x == null) return false;
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
977 $toInteger = ToInteger; 973 $toInteger = ToInteger;
978 $toLength = ToLength; 974 $toLength = ToLength;
979 $toName = ToName; 975 $toName = ToName;
980 $toNumber = ToNumber; 976 $toNumber = ToNumber;
981 $toPositiveInteger = ToPositiveInteger; 977 $toPositiveInteger = ToPositiveInteger;
982 $toPrimitive = ToPrimitive; 978 $toPrimitive = ToPrimitive;
983 $toString = ToString; 979 $toString = ToString;
984 $toUint32 = ToUint32; 980 $toUint32 = ToUint32;
985 981
986 }) 982 })
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698