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

Side by Side Diff: src/js/v8natives.js

Issue 1517963002: Move Object.assign implementation to C++ (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebased Created 5 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
« no previous file with comments | « src/js/prologue.js ('k') | test/mjsunit/harmony/proxies-object-assign.js » ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 (function(global, utils) { 5 (function(global, utils) {
6 6
7 %CheckIsBootstrapping(); 7 %CheckIsBootstrapping();
8 8
9 // ---------------------------------------------------------------------------- 9 // ----------------------------------------------------------------------------
10 // Imports 10 // Imports
(...skipping 786 matching lines...) Expand 10 before | Expand all | Expand 10 after
797 return obj; 797 return obj;
798 } 798 }
799 799
800 800
801 // ES6 section 19.1.2.6 801 // ES6 section 19.1.2.6
802 function ObjectGetOwnPropertyDescriptor(obj, p) { 802 function ObjectGetOwnPropertyDescriptor(obj, p) {
803 return %GetOwnProperty(obj, p); 803 return %GetOwnProperty(obj, p);
804 } 804 }
805 805
806 806
807 // ES6 section 9.1.12 / 9.5.12
808 function OwnPropertyKeys(obj) {
809 return %GetOwnPropertyKeys(obj, PROPERTY_FILTER_NONE);
810 }
811
812
813 // ES5 section 15.2.3.4. 807 // ES5 section 15.2.3.4.
814 function ObjectGetOwnPropertyNames(obj) { 808 function ObjectGetOwnPropertyNames(obj) {
815 obj = TO_OBJECT(obj); 809 obj = TO_OBJECT(obj);
816 return %GetOwnPropertyKeys(obj, PROPERTY_FILTER_SKIP_SYMBOLS); 810 return %GetOwnPropertyKeys(obj, PROPERTY_FILTER_SKIP_SYMBOLS);
817 } 811 }
818 812
819 813
820 // ES5 section 15.2.3.5. 814 // ES5 section 15.2.3.5.
821 function ObjectCreate(proto, properties) { 815 function ObjectCreate(proto, properties) {
822 if (!IS_SPEC_OBJECT(proto) && proto !== null) { 816 if (!IS_SPEC_OBJECT(proto) && proto !== null) {
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
909 } 903 }
910 904
911 905
912 // ES6 19.1.2.11 906 // ES6 19.1.2.11
913 function ObjectIsExtensible(obj) { 907 function ObjectIsExtensible(obj) {
914 if (!IS_SPEC_OBJECT(obj)) return false; 908 if (!IS_SPEC_OBJECT(obj)) return false;
915 return %IsExtensible(obj); 909 return %IsExtensible(obj);
916 } 910 }
917 911
918 912
919 // ES6 19.1.2.1
920 function ObjectAssign(target, sources) {
921 // TODO(bmeurer): Move this to toplevel.
922 "use strict";
923 var to = TO_OBJECT(target);
924 var argsLen = %_ArgumentsLength();
925 if (argsLen < 2) return to;
926
927 for (var i = 1; i < argsLen; ++i) {
928 var nextSource = %_Arguments(i);
929 if (IS_NULL_OR_UNDEFINED(nextSource)) {
930 continue;
931 }
932
933 var from = TO_OBJECT(nextSource);
934 var keys = OwnPropertyKeys(from);
935 var len = keys.length;
936
937 for (var j = 0; j < len; ++j) {
938 var key = keys[j];
939 if (%PropertyIsEnumerable(from, key)) {
940 var propValue = from[key];
941 to[key] = propValue;
942 }
943 }
944 }
945 return to;
946 }
947
948
949 // ES6 B.2.2.1.1 913 // ES6 B.2.2.1.1
950 function ObjectGetProto() { 914 function ObjectGetProto() {
951 return %_GetPrototype(TO_OBJECT(this)); 915 return %_GetPrototype(TO_OBJECT(this));
952 } 916 }
953 917
954 918
955 // ES6 B.2.2.1.2 919 // ES6 B.2.2.1.2
956 function ObjectSetProto(proto) { 920 function ObjectSetProto(proto) {
957 CHECK_OBJECT_COERCIBLE(this, "Object.prototype.__proto__"); 921 CHECK_OBJECT_COERCIBLE(this, "Object.prototype.__proto__");
958 922
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
992 "__defineGetter__", ObjectDefineGetter, 956 "__defineGetter__", ObjectDefineGetter,
993 "__lookupGetter__", ObjectLookupGetter, 957 "__lookupGetter__", ObjectLookupGetter,
994 "__defineSetter__", ObjectDefineSetter, 958 "__defineSetter__", ObjectDefineSetter,
995 "__lookupSetter__", ObjectLookupSetter 959 "__lookupSetter__", ObjectLookupSetter
996 ]); 960 ]);
997 utils.InstallGetterSetter(GlobalObject.prototype, "__proto__", ObjectGetProto, 961 utils.InstallGetterSetter(GlobalObject.prototype, "__proto__", ObjectGetProto,
998 ObjectSetProto); 962 ObjectSetProto);
999 963
1000 // Set up non-enumerable functions in the Object object. 964 // Set up non-enumerable functions in the Object object.
1001 utils.InstallFunctions(GlobalObject, DONT_ENUM, [ 965 utils.InstallFunctions(GlobalObject, DONT_ENUM, [
1002 "assign", ObjectAssign, 966 // assign is added in bootstrapper.cc.
1003 "keys", ObjectKeys, 967 "keys", ObjectKeys,
1004 "create", ObjectCreate, 968 "create", ObjectCreate,
1005 "defineProperty", ObjectDefineProperty, 969 "defineProperty", ObjectDefineProperty,
1006 "defineProperties", ObjectDefineProperties, 970 "defineProperties", ObjectDefineProperties,
1007 "freeze", ObjectFreezeJS, 971 "freeze", ObjectFreezeJS,
1008 "getPrototypeOf", ObjectGetPrototypeOf, 972 "getPrototypeOf", ObjectGetPrototypeOf,
1009 "setPrototypeOf", ObjectSetPrototypeOf, 973 "setPrototypeOf", ObjectSetPrototypeOf,
1010 "getOwnPropertyDescriptor", ObjectGetOwnPropertyDescriptor, 974 "getOwnPropertyDescriptor", ObjectGetOwnPropertyDescriptor,
1011 "getOwnPropertyNames", ObjectGetOwnPropertyNames, 975 "getOwnPropertyNames", ObjectGetOwnPropertyNames,
1012 // getOwnPropertySymbols is added in symbol.js. 976 // getOwnPropertySymbols is added in symbol.js.
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after
1490 to.ObjectIsSealed = ObjectIsSealed; 1454 to.ObjectIsSealed = ObjectIsSealed;
1491 to.ObjectKeys = ObjectKeys; 1455 to.ObjectKeys = ObjectKeys;
1492 }); 1456 });
1493 1457
1494 %InstallToContext([ 1458 %InstallToContext([
1495 "global_eval_fun", GlobalEval, 1459 "global_eval_fun", GlobalEval,
1496 "object_value_of", ObjectValueOf, 1460 "object_value_of", ObjectValueOf,
1497 ]); 1461 ]);
1498 1462
1499 }) 1463 })
OLDNEW
« no previous file with comments | « src/js/prologue.js ('k') | test/mjsunit/harmony/proxies-object-assign.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698