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

Side by Side Diff: src/runtime.js

Issue 178223011: Reset trunk to 3.24.35.4 (Closed) Base URL: https://v8.googlecode.com/svn/trunk
Patch Set: Created 6 years, 9 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
« no previous file with comments | « src/runtime.cc ('k') | src/sampler.cc » ('j') | 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 // 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 } else if (IS_STRING(x)) { 68 } else if (IS_STRING(x)) {
69 while (true) { 69 while (true) {
70 if (IS_STRING(y)) return %StringEquals(x, y); 70 if (IS_STRING(y)) return %StringEquals(x, y);
71 if (IS_SYMBOL(y)) return 1; // not equal 71 if (IS_SYMBOL(y)) return 1; // not equal
72 if (IS_NUMBER(y)) return %NumberEquals(%ToNumber(x), y); 72 if (IS_NUMBER(y)) return %NumberEquals(%ToNumber(x), y);
73 if (IS_BOOLEAN(y)) return %NumberEquals(%ToNumber(x), %ToNumber(y)); 73 if (IS_BOOLEAN(y)) return %NumberEquals(%ToNumber(x), %ToNumber(y));
74 if (IS_NULL_OR_UNDEFINED(y)) return 1; // not equal 74 if (IS_NULL_OR_UNDEFINED(y)) return 1; // not equal
75 y = %ToPrimitive(y, NO_HINT); 75 y = %ToPrimitive(y, NO_HINT);
76 } 76 }
77 } else if (IS_SYMBOL(x)) { 77 } else if (IS_SYMBOL(x)) {
78 if (IS_SYMBOL(y)) return %_ObjectEquals(x, y) ? 0 : 1; 78 while (true) {
79 return 1; // not equal 79 if (IS_SYMBOL(y)) return %_ObjectEquals(x, y) ? 0 : 1;
80 if (!IS_SPEC_OBJECT(y)) return 1; // not equal
81 y = %ToPrimitive(y, NO_HINT);
82 }
80 } else if (IS_BOOLEAN(x)) { 83 } else if (IS_BOOLEAN(x)) {
81 if (IS_BOOLEAN(y)) return %_ObjectEquals(x, y) ? 0 : 1; 84 if (IS_BOOLEAN(y)) return %_ObjectEquals(x, y) ? 0 : 1;
82 if (IS_NULL_OR_UNDEFINED(y)) return 1; 85 if (IS_NULL_OR_UNDEFINED(y)) return 1;
83 if (IS_NUMBER(y)) return %NumberEquals(%ToNumber(x), y); 86 if (IS_NUMBER(y)) return %NumberEquals(%ToNumber(x), y);
84 if (IS_STRING(y)) return %NumberEquals(%ToNumber(x), %ToNumber(y)); 87 if (IS_STRING(y)) return %NumberEquals(%ToNumber(x), %ToNumber(y));
85 if (IS_SYMBOL(y)) return 1; // not equal 88 if (IS_SYMBOL(y)) return 1; // not equal
86 // y is object. 89 // y is object.
87 x = %ToNumber(x); 90 x = %ToNumber(x);
88 y = %ToPrimitive(y, NO_HINT); 91 y = %ToPrimitive(y, NO_HINT);
89 } else if (IS_NULL_OR_UNDEFINED(x)) { 92 } else if (IS_NULL_OR_UNDEFINED(x)) {
90 return IS_NULL_OR_UNDEFINED(y) ? 0 : 1; 93 return IS_NULL_OR_UNDEFINED(y) ? 0 : 1;
91 } else { 94 } else {
92 // x is an object. 95 // x is an object.
93 if (IS_SPEC_OBJECT(y)) { 96 if (IS_SPEC_OBJECT(y)) {
94 return %_ObjectEquals(x, y) ? 0 : 1; 97 return %_ObjectEquals(x, y) ? 0 : 1;
95 } 98 }
96 if (IS_NULL_OR_UNDEFINED(y)) return 1; // not equal 99 if (IS_NULL_OR_UNDEFINED(y)) return 1; // not equal
97 if (IS_SYMBOL(y)) return 1; // not equal
98 if (IS_BOOLEAN(y)) y = %ToNumber(y); 100 if (IS_BOOLEAN(y)) y = %ToNumber(y);
99 x = %ToPrimitive(x, NO_HINT); 101 x = %ToPrimitive(x, NO_HINT);
100 } 102 }
101 } 103 }
102 } 104 }
103 105
104 // ECMA-262, section 11.9.4, page 56. 106 // ECMA-262, section 11.9.4, page 56.
105 function STRICT_EQUALS(x) { 107 function STRICT_EQUALS(x) {
106 if (IS_STRING(this)) { 108 if (IS_STRING(this)) {
107 if (!IS_STRING(x)) return 1; // not equal 109 if (!IS_STRING(x)) return 1; // not equal
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 ------------------------------------- 494 -------------------------------------
493 */ 495 */
494 496
495 // ECMA-262, section 9.1, page 30. Use null/undefined for no hint, 497 // ECMA-262, section 9.1, page 30. Use null/undefined for no hint,
496 // (1) for number hint, and (2) for string hint. 498 // (1) for number hint, and (2) for string hint.
497 function ToPrimitive(x, hint) { 499 function ToPrimitive(x, hint) {
498 // Fast case check. 500 // Fast case check.
499 if (IS_STRING(x)) return x; 501 if (IS_STRING(x)) return x;
500 // Normal behavior. 502 // Normal behavior.
501 if (!IS_SPEC_OBJECT(x)) return x; 503 if (!IS_SPEC_OBJECT(x)) return x;
502 if (IS_SYMBOL_WRAPPER(x)) throw MakeTypeError('symbol_to_primitive', []); 504 if (IS_SYMBOL_WRAPPER(x)) return %_ValueOf(x);
503 if (hint == NO_HINT) hint = (IS_DATE(x)) ? STRING_HINT : NUMBER_HINT; 505 if (hint == NO_HINT) hint = (IS_DATE(x)) ? STRING_HINT : NUMBER_HINT;
504 return (hint == NUMBER_HINT) ? %DefaultNumber(x) : %DefaultString(x); 506 return (hint == NUMBER_HINT) ? %DefaultNumber(x) : %DefaultString(x);
505 } 507 }
506 508
507 509
508 // ECMA-262, section 9.2, page 30 510 // ECMA-262, section 9.2, page 30
509 function ToBoolean(x) { 511 function ToBoolean(x) {
510 if (IS_BOOLEAN(x)) return x; 512 if (IS_BOOLEAN(x)) return x;
511 if (IS_STRING(x)) return x.length != 0; 513 if (IS_STRING(x)) return x.length != 0;
512 if (x == null) return false; 514 if (x == null) return false;
(...skipping 26 matching lines...) Expand all
539 return (IS_NULL(x)) ? 0 : ToNumber(%DefaultNumber(x)); 541 return (IS_NULL(x)) ? 0 : ToNumber(%DefaultNumber(x));
540 } 542 }
541 543
542 544
543 // ECMA-262, section 9.8, page 35. 545 // ECMA-262, section 9.8, page 35.
544 function ToString(x) { 546 function ToString(x) {
545 if (IS_STRING(x)) return x; 547 if (IS_STRING(x)) return x;
546 if (IS_NUMBER(x)) return %_NumberToString(x); 548 if (IS_NUMBER(x)) return %_NumberToString(x);
547 if (IS_BOOLEAN(x)) return x ? 'true' : 'false'; 549 if (IS_BOOLEAN(x)) return x ? 'true' : 'false';
548 if (IS_UNDEFINED(x)) return 'undefined'; 550 if (IS_UNDEFINED(x)) return 'undefined';
549 if (IS_SYMBOL(x)) throw %MakeTypeError('symbol_to_string', []);
550 return (IS_NULL(x)) ? 'null' : %ToString(%DefaultString(x)); 551 return (IS_NULL(x)) ? 'null' : %ToString(%DefaultString(x));
551 } 552 }
552 553
553 function NonStringToString(x) { 554 function NonStringToString(x) {
554 if (IS_NUMBER(x)) return %_NumberToString(x); 555 if (IS_NUMBER(x)) return %_NumberToString(x);
555 if (IS_BOOLEAN(x)) return x ? 'true' : 'false'; 556 if (IS_BOOLEAN(x)) return x ? 'true' : 'false';
556 if (IS_UNDEFINED(x)) return 'undefined'; 557 if (IS_UNDEFINED(x)) return 'undefined';
557 if (IS_SYMBOL(x)) throw %MakeTypeError('symbol_to_string', []);
558 return (IS_NULL(x)) ? 'null' : %ToString(%DefaultString(x)); 558 return (IS_NULL(x)) ? 'null' : %ToString(%DefaultString(x));
559 } 559 }
560 560
561 561
562 // ES6 symbols 562 // ES6 symbols
563 function ToName(x) { 563 function ToName(x) {
564 return IS_SYMBOL(x) ? x : %ToString(x); 564 return IS_SYMBOL(x) ? x : %ToString(x);
565 } 565 }
566 566
567 567
568 // ECMA-262, section 9.9, page 36. 568 // ECMA-262, section 9.9, page 36.
569 function ToObject(x) { 569 function ToObject(x) {
570 if (IS_STRING(x)) return new $String(x); 570 if (IS_STRING(x)) return new $String(x);
571 if (IS_SYMBOL(x)) return new $Symbol(x);
571 if (IS_NUMBER(x)) return new $Number(x); 572 if (IS_NUMBER(x)) return new $Number(x);
572 if (IS_BOOLEAN(x)) return new $Boolean(x); 573 if (IS_BOOLEAN(x)) return new $Boolean(x);
573 if (IS_SYMBOL(x)) return %NewSymbolWrapper(x);
574 if (IS_NULL_OR_UNDEFINED(x) && !IS_UNDETECTABLE(x)) { 574 if (IS_NULL_OR_UNDEFINED(x) && !IS_UNDETECTABLE(x)) {
575 throw %MakeTypeError('undefined_or_null_to_object', []); 575 throw %MakeTypeError('undefined_or_null_to_object', []);
576 } 576 }
577 return x; 577 return x;
578 } 578 }
579 579
580 580
581 // ECMA-262, section 9.4, page 34. 581 // ECMA-262, section 9.4, page 34.
582 function ToInteger(x) { 582 function ToInteger(x) {
583 if (%_IsSmi(x)) return x; 583 if (%_IsSmi(x)) return x;
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
668 return i; 668 return i;
669 } 669 }
670 670
671 671
672 // NOTE: Setting the prototype for Array must take place as early as 672 // NOTE: Setting the prototype for Array must take place as early as
673 // possible due to code generation for array literals. When 673 // possible due to code generation for array literals. When
674 // generating code for a array literal a boilerplate array is created 674 // generating code for a array literal a boilerplate array is created
675 // that is cloned when running the code. It is essential that the 675 // that is cloned when running the code. It is essential that the
676 // boilerplate gets the right prototype. 676 // boilerplate gets the right prototype.
677 %FunctionSetPrototype($Array, new $Array(0)); 677 %FunctionSetPrototype($Array, new $Array(0));
OLDNEW
« no previous file with comments | « src/runtime.cc ('k') | src/sampler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698