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

Side by Side Diff: src/runtime.js

Issue 771483002: Implement ES6 @@isConcatSpreadable (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Move implementation to C++ to fix speed issue Created 6 years 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 // 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' and 9 // ALL CAPS. The compiled code passes the first argument in 'this' and
10 // it does not push the function onto the stack. This means that you 10 // it does not push the function onto the stack. This means that you
(...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 // Returns if the given x is a primitive value - not an object or a 607 // Returns if the given x is a primitive value - not an object or a
608 // function. 608 // function.
609 function IsPrimitive(x) { 609 function IsPrimitive(x) {
610 // Even though the type of null is "object", null is still 610 // Even though the type of null is "object", null is still
611 // considered a primitive value. IS_SPEC_OBJECT handles this correctly 611 // considered a primitive value. IS_SPEC_OBJECT handles this correctly
612 // (i.e., it will return false if x is null). 612 // (i.e., it will return false if x is null).
613 return !IS_SPEC_OBJECT(x); 613 return !IS_SPEC_OBJECT(x);
614 } 614 }
615 615
616 616
617 // ES6, draft 10-14-14, section 22.1.3.1.1
618 function IsConcatSpreadable(O) {
619 if (!IS_SPEC_OBJECT(O)) return false;
620 var spreadable = O[symbolIsConcatSpreadable];
621 if (IS_UNDEFINED(spreadable)) return IS_ARRAY(O);
622 return ToBoolean(spreadable);
623 }
624
625
617 // ECMA-262, section 8.6.2.6, page 28. 626 // ECMA-262, section 8.6.2.6, page 28.
618 function DefaultNumber(x) { 627 function DefaultNumber(x) {
619 if (!IS_SYMBOL_WRAPPER(x)) { 628 if (!IS_SYMBOL_WRAPPER(x)) {
620 var valueOf = x.valueOf; 629 var valueOf = x.valueOf;
621 if (IS_SPEC_FUNCTION(valueOf)) { 630 if (IS_SPEC_FUNCTION(valueOf)) {
622 var v = %_CallFunction(x, valueOf); 631 var v = %_CallFunction(x, valueOf);
623 if (%IsPrimitive(v)) return v; 632 if (%IsPrimitive(v)) return v;
624 } 633 }
625 634
626 var toString = x.toString; 635 var toString = x.toString;
(...skipping 29 matching lines...) Expand all
656 return i; 665 return i;
657 } 666 }
658 667
659 668
660 // NOTE: Setting the prototype for Array must take place as early as 669 // NOTE: Setting the prototype for Array must take place as early as
661 // possible due to code generation for array literals. When 670 // possible due to code generation for array literals. When
662 // generating code for a array literal a boilerplate array is created 671 // generating code for a array literal a boilerplate array is created
663 // that is cloned when running the code. It is essential that the 672 // that is cloned when running the code. It is essential that the
664 // boilerplate gets the right prototype. 673 // boilerplate gets the right prototype.
665 %FunctionSetPrototype($Array, new $Array(0)); 674 %FunctionSetPrototype($Array, new $Array(0));
OLDNEW
« no previous file with comments | « src/harmony-array.js ('k') | src/runtime/runtime-array.cc » ('j') | src/runtime/runtime-array.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698