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

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

Issue 1553043002: [builtins] Migrate a bunch of Object builtins to C++. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 11 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 | « src/js/templates.js ('k') | src/runtime/runtime.h » ('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 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 } 532 }
533 } 533 }
534 return true; 534 return true;
535 } 535 }
536 536
537 537
538 // ES6 9.1.6 [[DefineOwnProperty]](P, Desc) 538 // ES6 9.1.6 [[DefineOwnProperty]](P, Desc)
539 function DefineObjectProperty(obj, p, desc, should_throw) { 539 function DefineObjectProperty(obj, p, desc, should_throw) {
540 var current_array = %GetOwnProperty_Legacy(obj, TO_NAME(p)); 540 var current_array = %GetOwnProperty_Legacy(obj, TO_NAME(p));
541 var current = ConvertDescriptorArrayToDescriptor(current_array); 541 var current = ConvertDescriptorArrayToDescriptor(current_array);
542 var extensible = %IsExtensible(obj); 542 var extensible = %object_is_extensible(obj);
543 543
544 if (IS_UNDEFINED(current) && !extensible) { 544 if (IS_UNDEFINED(current) && !extensible) {
545 if (should_throw) { 545 if (should_throw) {
546 throw MakeTypeError(kDefineDisallowed, p); 546 throw MakeTypeError(kDefineDisallowed, p);
547 } else { 547 } else {
548 return false; 548 return false;
549 } 549 }
550 } 550 }
551 551
552 if (!IS_UNDEFINED(current)) { 552 if (!IS_UNDEFINED(current)) {
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
831 } 831 }
832 for (var i = 0; i < names.length; i++) { 832 for (var i = 0; i < names.length; i++) {
833 DefineOwnProperty(obj, names[i], descriptors[i], true); 833 DefineOwnProperty(obj, names[i], descriptors[i], true);
834 } 834 }
835 return obj; 835 return obj;
836 } 836 }
837 return %ObjectDefineProperties(obj, properties); 837 return %ObjectDefineProperties(obj, properties);
838 } 838 }
839 839
840 840
841 // ES6 19.1.2.17
842 function ObjectSealJS(obj) {
843 if (!IS_RECEIVER(obj)) return obj;
844 return %ObjectSeal(obj);
845 }
846
847
848 // ES6 19.1.2.5
849 function ObjectFreezeJS(obj) {
850 if (!IS_RECEIVER(obj)) return obj;
851 return %ObjectFreeze(obj);
852 }
853
854
855 // ES6 19.1.2.15
856 function ObjectPreventExtension(obj) {
857 if (!IS_RECEIVER(obj)) return obj;
858 return %PreventExtensions(obj);
859 }
860
861
862 // ES6 19.1.2.13
863 function ObjectIsSealed(obj) {
864 if (!IS_RECEIVER(obj)) return true;
865 return %ObjectIsSealed(obj);
866 }
867
868
869 // ES6 19.1.2.12
870 function ObjectIsFrozen(obj) {
871 if (!IS_RECEIVER(obj)) return true;
872 return %ObjectIsFrozen(obj);
873 }
874
875
876 // ES6 19.1.2.11
877 function ObjectIsExtensible(obj) {
878 if (!IS_RECEIVER(obj)) return false;
879 return %IsExtensible(obj);
880 }
881
882
883 // ES6 B.2.2.1.1 841 // ES6 B.2.2.1.1
884 function ObjectGetProto() { 842 function ObjectGetProto() {
885 return %_GetPrototype(TO_OBJECT(this)); 843 return %_GetPrototype(TO_OBJECT(this));
886 } 844 }
887 845
888 846
889 // ES6 B.2.2.1.2 847 // ES6 B.2.2.1.2
890 function ObjectSetProto(proto) { 848 function ObjectSetProto(proto) {
891 CHECK_OBJECT_COERCIBLE(this, "Object.prototype.__proto__"); 849 CHECK_OBJECT_COERCIBLE(this, "Object.prototype.__proto__");
892 850
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
930 ]); 888 ]);
931 utils.InstallGetterSetter(GlobalObject.prototype, "__proto__", ObjectGetProto, 889 utils.InstallGetterSetter(GlobalObject.prototype, "__proto__", ObjectGetProto,
932 ObjectSetProto); 890 ObjectSetProto);
933 891
934 // Set up non-enumerable functions in the Object object. 892 // Set up non-enumerable functions in the Object object.
935 utils.InstallFunctions(GlobalObject, DONT_ENUM, [ 893 utils.InstallFunctions(GlobalObject, DONT_ENUM, [
936 // assign is added in bootstrapper.cc. 894 // assign is added in bootstrapper.cc.
937 "keys", ObjectKeys, 895 "keys", ObjectKeys,
938 "defineProperty", ObjectDefineProperty, 896 "defineProperty", ObjectDefineProperty,
939 "defineProperties", ObjectDefineProperties, 897 "defineProperties", ObjectDefineProperties,
940 "freeze", ObjectFreezeJS,
941 "getPrototypeOf", ObjectGetPrototypeOf, 898 "getPrototypeOf", ObjectGetPrototypeOf,
942 "setPrototypeOf", ObjectSetPrototypeOf, 899 "setPrototypeOf", ObjectSetPrototypeOf,
943 "getOwnPropertyDescriptor", ObjectGetOwnPropertyDescriptor, 900 "getOwnPropertyDescriptor", ObjectGetOwnPropertyDescriptor,
944 "getOwnPropertyNames", ObjectGetOwnPropertyNames, 901 "getOwnPropertyNames", ObjectGetOwnPropertyNames,
945 // getOwnPropertySymbols is added in symbol.js. 902 // getOwnPropertySymbols is added in symbol.js.
946 "is", SameValue, // ECMA-262, Edition 6, section 19.1.2.10 903 "is", SameValue, // ECMA-262, Edition 6, section 19.1.2.10
947 "isExtensible", ObjectIsExtensible,
948 "isFrozen", ObjectIsFrozen,
949 "isSealed", ObjectIsSealed,
950 "preventExtensions", ObjectPreventExtension,
951 "seal", ObjectSealJS
952 // deliverChangeRecords, getNotifier, observe and unobserve are added 904 // deliverChangeRecords, getNotifier, observe and unobserve are added
953 // in object-observe.js. 905 // in object-observe.js.
954 ]); 906 ]);
955 907
956 908
957 // ---------------------------------------------------------------------------- 909 // ----------------------------------------------------------------------------
958 // Boolean 910 // Boolean
959 911
960 function BooleanConstructor(x) { 912 function BooleanConstructor(x) {
961 // TODO(bmeurer): Move this to toplevel. 913 // TODO(bmeurer): Move this to toplevel.
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
1250 // Exports 1202 // Exports
1251 1203
1252 utils.Export(function(to) { 1204 utils.Export(function(to) {
1253 to.GetIterator = GetIterator; 1205 to.GetIterator = GetIterator;
1254 to.GetMethod = GetMethod; 1206 to.GetMethod = GetMethod;
1255 to.IsFinite = GlobalIsFinite; 1207 to.IsFinite = GlobalIsFinite;
1256 to.IsNaN = GlobalIsNaN; 1208 to.IsNaN = GlobalIsNaN;
1257 to.NumberIsNaN = NumberIsNaN; 1209 to.NumberIsNaN = NumberIsNaN;
1258 to.ObjectDefineProperties = ObjectDefineProperties; 1210 to.ObjectDefineProperties = ObjectDefineProperties;
1259 to.ObjectDefineProperty = ObjectDefineProperty; 1211 to.ObjectDefineProperty = ObjectDefineProperty;
1260 to.ObjectFreeze = ObjectFreezeJS;
1261 to.ObjectHasOwnProperty = ObjectHasOwnProperty; 1212 to.ObjectHasOwnProperty = ObjectHasOwnProperty;
1262 to.ObjectIsFrozen = ObjectIsFrozen;
1263 to.ObjectIsSealed = ObjectIsSealed;
1264 to.ObjectKeys = ObjectKeys; 1213 to.ObjectKeys = ObjectKeys;
1265 }); 1214 });
1266 1215
1267 %InstallToContext([ 1216 %InstallToContext([
1268 "object_value_of", ObjectValueOf, 1217 "object_value_of", ObjectValueOf,
1269 ]); 1218 ]);
1270 1219
1271 }) 1220 })
OLDNEW
« no previous file with comments | « src/js/templates.js ('k') | src/runtime/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698