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

Side by Side Diff: src/v8natives.js

Issue 7535004: Merge bleeding edge up to 8774 into the GC branch. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/gc/
Patch Set: Created 9 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 | Annotate | Revision Log
« no previous file with comments | « src/v8globals.h ('k') | src/v8utils.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 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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 155
156 return %_CallFunction(receiver, f); 156 return %_CallFunction(receiver, f);
157 } 157 }
158 158
159 159
160 // ---------------------------------------------------------------------------- 160 // ----------------------------------------------------------------------------
161 161
162 162
163 function SetupGlobal() { 163 function SetupGlobal() {
164 // ECMA 262 - 15.1.1.1. 164 // ECMA 262 - 15.1.1.1.
165 %SetProperty(global, "NaN", $NaN, DONT_ENUM | DONT_DELETE); 165 %SetProperty(global, "NaN", $NaN, DONT_ENUM | DONT_DELETE | READ_ONLY);
166 166
167 // ECMA-262 - 15.1.1.2. 167 // ECMA-262 - 15.1.1.2.
168 %SetProperty(global, "Infinity", 1/0, DONT_ENUM | DONT_DELETE); 168 %SetProperty(global, "Infinity", 1/0, DONT_ENUM | DONT_DELETE | READ_ONLY);
169 169
170 // ECMA-262 - 15.1.1.3. 170 // ECMA-262 - 15.1.1.3.
171 %SetProperty(global, "undefined", void 0, DONT_ENUM | DONT_DELETE); 171 %SetProperty(global, "undefined", void 0,
172 DONT_ENUM | DONT_DELETE | READ_ONLY);
172 173
173 // Setup non-enumerable function on the global object. 174 // Setup non-enumerable function on the global object.
174 InstallFunctions(global, DONT_ENUM, $Array( 175 InstallFunctions(global, DONT_ENUM, $Array(
175 "isNaN", GlobalIsNaN, 176 "isNaN", GlobalIsNaN,
176 "isFinite", GlobalIsFinite, 177 "isFinite", GlobalIsFinite,
177 "parseInt", GlobalParseInt, 178 "parseInt", GlobalParseInt,
178 "parseFloat", GlobalParseFloat, 179 "parseFloat", GlobalParseFloat,
179 "eval", GlobalEval 180 "eval", GlobalEval
180 )); 181 ));
181 } 182 }
(...skipping 20 matching lines...) Expand all
202 // ---------------------------------------------------------------------------- 203 // ----------------------------------------------------------------------------
203 // Object 204 // Object
204 205
205 $Object.prototype.constructor = $Object; 206 $Object.prototype.constructor = $Object;
206 207
207 // ECMA-262 - 15.2.4.2 208 // ECMA-262 - 15.2.4.2
208 function ObjectToString() { 209 function ObjectToString() {
209 if (IS_UNDEFINED(this) && !IS_UNDETECTABLE(this)) { 210 if (IS_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
210 return '[object Undefined]'; 211 return '[object Undefined]';
211 } 212 }
212 if (IS_NULL(this)) return '[object Null]'; 213 if (IS_NULL(this)) return '[object Null]';
213 return "[object " + %_ClassOf(ToObject(this)) + "]"; 214 return "[object " + %_ClassOf(ToObject(this)) + "]";
214 } 215 }
215 216
216 217
217 // ECMA-262 - 15.2.4.3 218 // ECMA-262 - 15.2.4.3
218 function ObjectToLocaleString() { 219 function ObjectToLocaleString() {
219 if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) { 220 if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
220 throw MakeTypeError("called_on_null_or_undefined", 221 throw MakeTypeError("called_on_null_or_undefined",
221 ["Object.prototype.toLocaleString"]); 222 ["Object.prototype.toLocaleString"]);
222 } 223 }
223 return this.toString(); 224 return this.toString();
224 } 225 }
225 226
226 227
227 // ECMA-262 - 15.2.4.4 228 // ECMA-262 - 15.2.4.4
228 function ObjectValueOf() { 229 function ObjectValueOf() {
229 return ToObject(this); 230 return ToObject(this);
230 } 231 }
231 232
232 233
233 // ECMA-262 - 15.2.4.5 234 // ECMA-262 - 15.2.4.5
234 function ObjectHasOwnProperty(V) { 235 function ObjectHasOwnProperty(V) {
236 if (%IsJSProxy(this)) {
237 var handler = %GetHandler(this);
238 return CallTrap1(handler, "hasOwn", DerivedHasOwnTrap, TO_STRING_INLINE(V));
239 }
235 return %HasLocalProperty(TO_OBJECT_INLINE(this), TO_STRING_INLINE(V)); 240 return %HasLocalProperty(TO_OBJECT_INLINE(this), TO_STRING_INLINE(V));
236 } 241 }
237 242
238 243
239 // ECMA-262 - 15.2.4.6 244 // ECMA-262 - 15.2.4.6
240 function ObjectIsPrototypeOf(V) { 245 function ObjectIsPrototypeOf(V) {
241 if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) { 246 if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
242 throw MakeTypeError("called_on_null_or_undefined", 247 throw MakeTypeError("called_on_null_or_undefined",
243 ["Object.prototype.isPrototypeOf"]); 248 ["Object.prototype.isPrototypeOf"]);
244 } 249 }
245 if (!IS_SPEC_OBJECT(V)) return false; 250 if (!IS_SPEC_OBJECT(V)) return false;
246 return %IsInPrototypeChain(this, V); 251 return %IsInPrototypeChain(this, V);
247 } 252 }
248 253
249 254
250 // ECMA-262 - 15.2.4.6 255 // ECMA-262 - 15.2.4.6
251 function ObjectPropertyIsEnumerable(V) { 256 function ObjectPropertyIsEnumerable(V) {
252 return %IsPropertyEnumerable(ToObject(this), ToString(V)); 257 var P = ToString(V);
258 if (%IsJSProxy(this)) {
259 var desc = GetOwnProperty(this, P);
260 return IS_UNDEFINED(desc) ? false : desc.isEnumerable();
261 }
262 return %IsPropertyEnumerable(ToObject(this), P);
253 } 263 }
254 264
255 265
256 // Extensions for providing property getters and setters. 266 // Extensions for providing property getters and setters.
257 function ObjectDefineGetter(name, fun) { 267 function ObjectDefineGetter(name, fun) {
258 var receiver = this; 268 var receiver = this;
259 if (receiver == null && !IS_UNDETECTABLE(receiver)) { 269 if (receiver == null && !IS_UNDETECTABLE(receiver)) {
260 receiver = %GlobalReceiver(global); 270 receiver = %GlobalReceiver(global);
261 } 271 }
262 if (!IS_FUNCTION(fun)) { 272 if (!IS_FUNCTION(fun)) {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 if (receiver == null && !IS_UNDETECTABLE(receiver)) { 311 if (receiver == null && !IS_UNDETECTABLE(receiver)) {
302 receiver = %GlobalReceiver(global); 312 receiver = %GlobalReceiver(global);
303 } 313 }
304 return %LookupAccessor(ToObject(receiver), ToString(name), SETTER); 314 return %LookupAccessor(ToObject(receiver), ToString(name), SETTER);
305 } 315 }
306 316
307 317
308 function ObjectKeys(obj) { 318 function ObjectKeys(obj) {
309 if (!IS_SPEC_OBJECT(obj)) 319 if (!IS_SPEC_OBJECT(obj))
310 throw MakeTypeError("obj_ctor_property_non_object", ["keys"]); 320 throw MakeTypeError("obj_ctor_property_non_object", ["keys"]);
321 if (%IsJSProxy(obj)) {
322 var handler = %GetHandler(obj);
323 var names = CallTrap0(handler, "keys", DerivedKeysTrap);
324 return ToStringArray(names);
325 }
311 return %LocalKeys(obj); 326 return %LocalKeys(obj);
312 } 327 }
313 328
314 329
315 // ES5 8.10.1. 330 // ES5 8.10.1.
316 function IsAccessorDescriptor(desc) { 331 function IsAccessorDescriptor(desc) {
317 if (IS_UNDEFINED(desc)) return false; 332 if (IS_UNDEFINED(desc)) return false;
318 return desc.hasGetter() || desc.hasSetter(); 333 return desc.hasGetter() || desc.hasSetter();
319 } 334 }
320 335
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 desc.setValue(desc_array[VALUE_INDEX]); 584 desc.setValue(desc_array[VALUE_INDEX]);
570 desc.setWritable(desc_array[WRITABLE_INDEX]); 585 desc.setWritable(desc_array[WRITABLE_INDEX]);
571 } 586 }
572 desc.setEnumerable(desc_array[ENUMERABLE_INDEX]); 587 desc.setEnumerable(desc_array[ENUMERABLE_INDEX]);
573 desc.setConfigurable(desc_array[CONFIGURABLE_INDEX]); 588 desc.setConfigurable(desc_array[CONFIGURABLE_INDEX]);
574 589
575 return desc; 590 return desc;
576 } 591 }
577 592
578 593
594 // For Harmony proxies.
595 function GetTrap(handler, name, defaultTrap) {
596 var trap = handler[name];
597 if (IS_UNDEFINED(trap)) {
598 if (IS_UNDEFINED(defaultTrap)) {
599 throw MakeTypeError("handler_trap_missing", [handler, name]);
600 }
601 trap = defaultTrap;
602 } else if (!IS_FUNCTION(trap)) {
603 throw MakeTypeError("handler_trap_must_be_callable", [handler, name]);
604 }
605 return trap;
606 }
607
608
609 function CallTrap0(handler, name, defaultTrap) {
610 return %_CallFunction(handler, GetTrap(handler, name, defaultTrap));
611 }
612
613
614 function CallTrap1(handler, name, defaultTrap, x) {
615 return %_CallFunction(handler, x, GetTrap(handler, name, defaultTrap));
616 }
617
618
619 function CallTrap2(handler, name, defaultTrap, x, y) {
620 return %_CallFunction(handler, x, y, GetTrap(handler, name, defaultTrap));
621 }
622
623
579 // ES5 section 8.12.2. 624 // ES5 section 8.12.2.
580 function GetProperty(obj, p) { 625 function GetProperty(obj, p) {
581 if (%IsJSProxy(obj)) { 626 if (%IsJSProxy(obj)) {
582 var handler = %GetHandler(obj); 627 var handler = %GetHandler(obj);
583 var getProperty = handler.getPropertyDescriptor; 628 var descriptor = CallTrap1(obj, "getPropertyDescriptor", void 0, p);
584 if (IS_UNDEFINED(getProperty)) {
585 throw MakeTypeError("handler_trap_missing",
586 [handler, "getPropertyDescriptor"]);
587 }
588 var descriptor = getProperty.call(handler, p);
589 if (IS_UNDEFINED(descriptor)) return descriptor; 629 if (IS_UNDEFINED(descriptor)) return descriptor;
590 var desc = ToCompletePropertyDescriptor(descriptor); 630 var desc = ToCompletePropertyDescriptor(descriptor);
591 if (!desc.configurable) { 631 if (!desc.isConfigurable()) {
592 throw MakeTypeError("proxy_prop_not_configurable", 632 throw MakeTypeError("proxy_prop_not_configurable",
593 [handler, "getPropertyDescriptor", p, descriptor]); 633 [handler, "getPropertyDescriptor", p, descriptor]);
594 } 634 }
595 return desc; 635 return desc;
596 } 636 }
597 var prop = GetOwnProperty(obj); 637 var prop = GetOwnProperty(obj);
598 if (!IS_UNDEFINED(prop)) return prop; 638 if (!IS_UNDEFINED(prop)) return prop;
599 var proto = %GetPrototype(obj); 639 var proto = %GetPrototype(obj);
600 if (IS_NULL(proto)) return void 0; 640 if (IS_NULL(proto)) return void 0;
601 return GetProperty(proto, p); 641 return GetProperty(proto, p);
602 } 642 }
603 643
604 644
605 // ES5 section 8.12.6 645 // ES5 section 8.12.6
606 function HasProperty(obj, p) { 646 function HasProperty(obj, p) {
607 if (%IsJSProxy(obj)) { 647 if (%IsJSProxy(obj)) {
608 var handler = %GetHandler(obj); 648 var handler = %GetHandler(obj);
609 var has = handler.has; 649 return ToBoolean(CallTrap1(handler, "has", DerivedHasTrap, p));
610 if (IS_UNDEFINED(has)) has = DerivedHasTrap;
611 return ToBoolean(has.call(handler, obj, p));
612 } 650 }
613 var desc = GetProperty(obj, p); 651 var desc = GetProperty(obj, p);
614 return IS_UNDEFINED(desc) ? false : true; 652 return IS_UNDEFINED(desc) ? false : true;
615 } 653 }
616 654
617 655
618 // ES5 section 8.12.1. 656 // ES5 section 8.12.1.
619 function GetOwnProperty(obj, p) { 657 function GetOwnProperty(obj, v) {
658 var p = ToString(v);
659 if (%IsJSProxy(obj)) {
660 var handler = %GetHandler(obj);
661 var descriptor = CallTrap1(handler, "getOwnPropertyDescriptor", void 0, p);
662 if (IS_UNDEFINED(descriptor)) return descriptor;
663 var desc = ToCompletePropertyDescriptor(descriptor);
664 if (!desc.isConfigurable()) {
665 throw MakeTypeError("proxy_prop_not_configurable",
666 [handler, "getOwnPropertyDescriptor", p, descriptor]);
667 }
668 return desc;
669 }
670
620 // GetOwnProperty returns an array indexed by the constants 671 // GetOwnProperty returns an array indexed by the constants
621 // defined in macros.py. 672 // defined in macros.py.
622 // If p is not a property on obj undefined is returned. 673 // If p is not a property on obj undefined is returned.
623 var props = %GetOwnProperty(ToObject(obj), ToString(p)); 674 var props = %GetOwnProperty(ToObject(obj), ToString(v));
624 675
625 // A false value here means that access checks failed. 676 // A false value here means that access checks failed.
626 if (props === false) return void 0; 677 if (props === false) return void 0;
627 678
628 return ConvertDescriptorArrayToDescriptor(props); 679 return ConvertDescriptorArrayToDescriptor(props);
629 } 680 }
630 681
631 682
632 // Harmony proxies. 683 // Harmony proxies.
633 function DefineProxyProperty(obj, p, attributes, should_throw) { 684 function DefineProxyProperty(obj, p, attributes, should_throw) {
634 var handler = %GetHandler(obj); 685 var handler = %GetHandler(obj);
635 var defineProperty = handler.defineProperty; 686 var result = CallTrap2(handler, "defineProperty", void 0, p, attributes);
636 if (IS_UNDEFINED(defineProperty)) {
637 throw MakeTypeError("handler_trap_missing", [handler, "defineProperty"]);
638 }
639 var result = defineProperty.call(handler, p, attributes);
640 if (!ToBoolean(result)) { 687 if (!ToBoolean(result)) {
641 if (should_throw) { 688 if (should_throw) {
642 throw MakeTypeError("handler_failed", [handler, "defineProperty"]); 689 throw MakeTypeError("handler_returned_false",
690 [handler, "defineProperty"]);
643 } else { 691 } else {
644 return false; 692 return false;
645 } 693 }
646 } 694 }
647 return true; 695 return true;
648 } 696 }
649 697
650 698
651 // ES5 8.12.9. 699 // ES5 8.12.9.
652 function DefineOwnProperty(obj, p, desc, should_throw) { 700 function DefineOwnProperty(obj, p, desc, should_throw) {
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
822 function ObjectGetPrototypeOf(obj) { 870 function ObjectGetPrototypeOf(obj) {
823 if (!IS_SPEC_OBJECT(obj)) 871 if (!IS_SPEC_OBJECT(obj))
824 throw MakeTypeError("obj_ctor_property_non_object", ["getPrototypeOf"]); 872 throw MakeTypeError("obj_ctor_property_non_object", ["getPrototypeOf"]);
825 return %GetPrototype(obj); 873 return %GetPrototype(obj);
826 } 874 }
827 875
828 876
829 // ES5 section 15.2.3.3 877 // ES5 section 15.2.3.3
830 function ObjectGetOwnPropertyDescriptor(obj, p) { 878 function ObjectGetOwnPropertyDescriptor(obj, p) {
831 if (!IS_SPEC_OBJECT(obj)) 879 if (!IS_SPEC_OBJECT(obj))
832 throw MakeTypeError("obj_ctor_property_non_object", ["getOwnPropertyDescript or"]); 880 throw MakeTypeError("obj_ctor_property_non_object",
881 ["getOwnPropertyDescriptor"]);
833 var desc = GetOwnProperty(obj, p); 882 var desc = GetOwnProperty(obj, p);
834 return FromPropertyDescriptor(desc); 883 return FromPropertyDescriptor(desc);
835 } 884 }
836 885
837 886
838 // For Harmony proxies 887 // For Harmony proxies
839 function ToStringArray(obj, trap) { 888 function ToStringArray(obj, trap) {
840 if (!IS_SPEC_OBJECT(obj)) { 889 if (!IS_SPEC_OBJECT(obj)) {
841 throw MakeTypeError("proxy_non_object_prop_names", [obj, trap]); 890 throw MakeTypeError("proxy_non_object_prop_names", [obj, trap]);
842 } 891 }
(...skipping 13 matching lines...) Expand all
856 905
857 906
858 // ES5 section 15.2.3.4. 907 // ES5 section 15.2.3.4.
859 function ObjectGetOwnPropertyNames(obj) { 908 function ObjectGetOwnPropertyNames(obj) {
860 if (!IS_SPEC_OBJECT(obj)) 909 if (!IS_SPEC_OBJECT(obj))
861 throw MakeTypeError("obj_ctor_property_non_object", ["getOwnPropertyNames"]) ; 910 throw MakeTypeError("obj_ctor_property_non_object", ["getOwnPropertyNames"]) ;
862 911
863 // Special handling for proxies. 912 // Special handling for proxies.
864 if (%IsJSProxy(obj)) { 913 if (%IsJSProxy(obj)) {
865 var handler = %GetHandler(obj); 914 var handler = %GetHandler(obj);
866 var getOwnPropertyNames = handler.getOwnPropertyNames; 915 var names = CallTrap0(handler, "getOwnPropertyNames", void 0);
867 if (IS_UNDEFINED(getOwnPropertyNames)) {
868 throw MakeTypeError("handler_trap_missing",
869 [handler, "getOwnPropertyNames"]);
870 }
871 var names = getOwnPropertyNames.call(handler);
872 return ToStringArray(names, "getOwnPropertyNames"); 916 return ToStringArray(names, "getOwnPropertyNames");
873 } 917 }
874 918
875 // Find all the indexed properties. 919 // Find all the indexed properties.
876 920
877 // Get the local element names. 921 // Get the local element names.
878 var propertyNames = %GetLocalElementNames(obj); 922 var propertyNames = %GetLocalElementNames(obj);
879 923
880 // Get names for indexed interceptor properties. 924 // Get names for indexed interceptor properties.
881 if (%GetInterceptorInfo(obj) & 1) { 925 if (%GetInterceptorInfo(obj) & 1) {
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
988 } 1032 }
989 for (var i = 0; i < key_values.length; i += 2) { 1033 for (var i = 0; i < key_values.length; i += 2) {
990 var key = key_values[i]; 1034 var key = key_values[i];
991 var desc = key_values[i + 1]; 1035 var desc = key_values[i + 1];
992 DefineOwnProperty(obj, key, desc, true); 1036 DefineOwnProperty(obj, key, desc, true);
993 } 1037 }
994 return obj; 1038 return obj;
995 } 1039 }
996 1040
997 1041
1042 // Harmony proxies.
1043 function ProxyFix(obj) {
1044 var handler = %GetHandler(obj);
1045 var props = CallTrap0(handler, "fix", void 0);
1046 if (IS_UNDEFINED(props)) {
1047 throw MakeTypeError("handler_returned_undefined", [handler, "fix"]);
1048 }
1049 %Fix(obj);
1050 ObjectDefineProperties(obj, props);
1051 }
1052
1053
998 // ES5 section 15.2.3.8. 1054 // ES5 section 15.2.3.8.
999 function ObjectSeal(obj) { 1055 function ObjectSeal(obj) {
1000 if (!IS_SPEC_OBJECT(obj)) { 1056 if (!IS_SPEC_OBJECT(obj)) {
1001 throw MakeTypeError("obj_ctor_property_non_object", ["seal"]); 1057 throw MakeTypeError("obj_ctor_property_non_object", ["seal"]);
1002 } 1058 }
1059 if (%IsJSProxy(obj)) {
1060 ProxyFix(obj);
1061 }
1003 var names = ObjectGetOwnPropertyNames(obj); 1062 var names = ObjectGetOwnPropertyNames(obj);
1004 for (var i = 0; i < names.length; i++) { 1063 for (var i = 0; i < names.length; i++) {
1005 var name = names[i]; 1064 var name = names[i];
1006 var desc = GetOwnProperty(obj, name); 1065 var desc = GetOwnProperty(obj, name);
1007 if (desc.isConfigurable()) { 1066 if (desc.isConfigurable()) {
1008 desc.setConfigurable(false); 1067 desc.setConfigurable(false);
1009 DefineOwnProperty(obj, name, desc, true); 1068 DefineOwnProperty(obj, name, desc, true);
1010 } 1069 }
1011 } 1070 }
1012 return ObjectPreventExtension(obj); 1071 %PreventExtensions(obj);
1072 return obj;
1013 } 1073 }
1014 1074
1015 1075
1016 // ES5 section 15.2.3.9. 1076 // ES5 section 15.2.3.9.
1017 function ObjectFreeze(obj) { 1077 function ObjectFreeze(obj) {
1018 if (!IS_SPEC_OBJECT(obj)) { 1078 if (!IS_SPEC_OBJECT(obj)) {
1019 throw MakeTypeError("obj_ctor_property_non_object", ["freeze"]); 1079 throw MakeTypeError("obj_ctor_property_non_object", ["freeze"]);
1020 } 1080 }
1081 if (%IsJSProxy(obj)) {
1082 ProxyFix(obj);
1083 }
1021 var names = ObjectGetOwnPropertyNames(obj); 1084 var names = ObjectGetOwnPropertyNames(obj);
1022 for (var i = 0; i < names.length; i++) { 1085 for (var i = 0; i < names.length; i++) {
1023 var name = names[i]; 1086 var name = names[i];
1024 var desc = GetOwnProperty(obj, name); 1087 var desc = GetOwnProperty(obj, name);
1025 if (desc.isWritable() || desc.isConfigurable()) { 1088 if (desc.isWritable() || desc.isConfigurable()) {
1026 if (IsDataDescriptor(desc)) desc.setWritable(false); 1089 if (IsDataDescriptor(desc)) desc.setWritable(false);
1027 desc.setConfigurable(false); 1090 desc.setConfigurable(false);
1028 DefineOwnProperty(obj, name, desc, true); 1091 DefineOwnProperty(obj, name, desc, true);
1029 } 1092 }
1030 } 1093 }
1031 return ObjectPreventExtension(obj); 1094 %PreventExtensions(obj);
1095 return obj;
1032 } 1096 }
1033 1097
1034 1098
1035 // ES5 section 15.2.3.10 1099 // ES5 section 15.2.3.10
1036 function ObjectPreventExtension(obj) { 1100 function ObjectPreventExtension(obj) {
1037 if (!IS_SPEC_OBJECT(obj)) { 1101 if (!IS_SPEC_OBJECT(obj)) {
1038 throw MakeTypeError("obj_ctor_property_non_object", ["preventExtension"]); 1102 throw MakeTypeError("obj_ctor_property_non_object", ["preventExtension"]);
1039 } 1103 }
1104 if (%IsJSProxy(obj)) {
1105 ProxyFix(obj);
1106 }
1040 %PreventExtensions(obj); 1107 %PreventExtensions(obj);
1041 return obj; 1108 return obj;
1042 } 1109 }
1043 1110
1044 1111
1045 // ES5 section 15.2.3.11 1112 // ES5 section 15.2.3.11
1046 function ObjectIsSealed(obj) { 1113 function ObjectIsSealed(obj) {
1047 if (!IS_SPEC_OBJECT(obj)) { 1114 if (!IS_SPEC_OBJECT(obj)) {
1048 throw MakeTypeError("obj_ctor_property_non_object", ["isSealed"]); 1115 throw MakeTypeError("obj_ctor_property_non_object", ["isSealed"]);
1049 } 1116 }
1117 if (%IsJSProxy(obj)) {
1118 return false;
1119 }
1050 var names = ObjectGetOwnPropertyNames(obj); 1120 var names = ObjectGetOwnPropertyNames(obj);
1051 for (var i = 0; i < names.length; i++) { 1121 for (var i = 0; i < names.length; i++) {
1052 var name = names[i]; 1122 var name = names[i];
1053 var desc = GetOwnProperty(obj, name); 1123 var desc = GetOwnProperty(obj, name);
1054 if (desc.isConfigurable()) return false; 1124 if (desc.isConfigurable()) return false;
1055 } 1125 }
1056 if (!ObjectIsExtensible(obj)) { 1126 if (!ObjectIsExtensible(obj)) {
1057 return true; 1127 return true;
1058 } 1128 }
1059 return false; 1129 return false;
1060 } 1130 }
1061 1131
1062 1132
1063 // ES5 section 15.2.3.12 1133 // ES5 section 15.2.3.12
1064 function ObjectIsFrozen(obj) { 1134 function ObjectIsFrozen(obj) {
1065 if (!IS_SPEC_OBJECT(obj)) { 1135 if (!IS_SPEC_OBJECT(obj)) {
1066 throw MakeTypeError("obj_ctor_property_non_object", ["isFrozen"]); 1136 throw MakeTypeError("obj_ctor_property_non_object", ["isFrozen"]);
1067 } 1137 }
1138 if (%IsJSProxy(obj)) {
1139 return false;
1140 }
1068 var names = ObjectGetOwnPropertyNames(obj); 1141 var names = ObjectGetOwnPropertyNames(obj);
1069 for (var i = 0; i < names.length; i++) { 1142 for (var i = 0; i < names.length; i++) {
1070 var name = names[i]; 1143 var name = names[i];
1071 var desc = GetOwnProperty(obj, name); 1144 var desc = GetOwnProperty(obj, name);
1072 if (IsDataDescriptor(desc) && desc.isWritable()) return false; 1145 if (IsDataDescriptor(desc) && desc.isWritable()) return false;
1073 if (desc.isConfigurable()) return false; 1146 if (desc.isConfigurable()) return false;
1074 } 1147 }
1075 if (!ObjectIsExtensible(obj)) { 1148 if (!ObjectIsExtensible(obj)) {
1076 return true; 1149 return true;
1077 } 1150 }
1078 return false; 1151 return false;
1079 } 1152 }
1080 1153
1081 1154
1082 // ES5 section 15.2.3.13 1155 // ES5 section 15.2.3.13
1083 function ObjectIsExtensible(obj) { 1156 function ObjectIsExtensible(obj) {
1084 if (!IS_SPEC_OBJECT(obj)) { 1157 if (!IS_SPEC_OBJECT(obj)) {
1085 throw MakeTypeError("obj_ctor_property_non_object", ["isExtensible"]); 1158 throw MakeTypeError("obj_ctor_property_non_object", ["isExtensible"]);
1086 } 1159 }
1160 if (%IsJSProxy(obj)) {
1161 return true;
1162 }
1087 return %IsExtensible(obj); 1163 return %IsExtensible(obj);
1088 } 1164 }
1089 1165
1090 1166
1091 %SetCode($Object, function(x) { 1167 %SetCode($Object, function(x) {
1092 if (%_IsConstructCall()) { 1168 if (%_IsConstructCall()) {
1093 if (x == null) return this; 1169 if (x == null) return this;
1094 return ToObject(x); 1170 return ToObject(x);
1095 } else { 1171 } else {
1096 if (x == null) return { }; 1172 if (x == null) return { };
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
1457 // ---------------------------------------------------------------------------- 1533 // ----------------------------------------------------------------------------
1458 1534
1459 function SetupFunction() { 1535 function SetupFunction() {
1460 InstallFunctions($Function.prototype, DONT_ENUM, $Array( 1536 InstallFunctions($Function.prototype, DONT_ENUM, $Array(
1461 "bind", FunctionBind, 1537 "bind", FunctionBind,
1462 "toString", FunctionToString 1538 "toString", FunctionToString
1463 )); 1539 ));
1464 } 1540 }
1465 1541
1466 SetupFunction(); 1542 SetupFunction();
OLDNEW
« no previous file with comments | « src/v8globals.h ('k') | src/v8utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698