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

Side by Side Diff: src/v8natives.js

Issue 1131843002: Revert of Revert of Wrap runtime.js in a function. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 7 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/uri.js ('k') | test/cctest/compiler/test-run-jscalls.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 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 var $delete; 5 var $delete;
6 var $functionSourceString; 6 var $functionSourceString;
7 var $getIterator; 7 var $getIterator;
8 var $getMethod; 8 var $getMethod;
9 var $globalEval; 9 var $globalEval;
10 var $installConstants; 10 var $installConstants;
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 %InternalSetPrototype(prototype, null); 148 %InternalSetPrototype(prototype, null);
149 %ToFastProperties(prototype); 149 %ToFastProperties(prototype);
150 } 150 }
151 151
152 152
153 // ---------------------------------------------------------------------------- 153 // ----------------------------------------------------------------------------
154 154
155 155
156 // ECMA 262 - 15.1.4 156 // ECMA 262 - 15.1.4
157 function GlobalIsNaN(number) { 157 function GlobalIsNaN(number) {
158 if (!IS_NUMBER(number)) number = NonNumberToNumber(number); 158 number = TO_NUMBER_INLINE(number);
159 return NUMBER_IS_NAN(number); 159 return NUMBER_IS_NAN(number);
160 } 160 }
161 161
162 162
163 // ECMA 262 - 15.1.5 163 // ECMA 262 - 15.1.5
164 function GlobalIsFinite(number) { 164 function GlobalIsFinite(number) {
165 if (!IS_NUMBER(number)) number = NonNumberToNumber(number); 165 number = TO_NUMBER_INLINE(number);
166 return NUMBER_IS_FINITE(number); 166 return NUMBER_IS_FINITE(number);
167 } 167 }
168 168
169 169
170 // ECMA-262 - 15.1.2.2 170 // ECMA-262 - 15.1.2.2
171 function GlobalParseInt(string, radix) { 171 function GlobalParseInt(string, radix) {
172 if (IS_UNDEFINED(radix) || radix === 10 || radix === 0) { 172 if (IS_UNDEFINED(radix) || radix === 10 || radix === 0) {
173 // Some people use parseInt instead of Math.floor. This 173 // Some people use parseInt instead of Math.floor. This
174 // optimization makes parseInt on a Smi 12 times faster (60ns 174 // optimization makes parseInt on a Smi 12 times faster (60ns
175 // vs 800ns). The following optimization makes parseInt on a 175 // vs 800ns). The following optimization makes parseInt on a
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 } 283 }
284 284
285 285
286 // ECMA-262 - 15.2.4.5 286 // ECMA-262 - 15.2.4.5
287 function ObjectHasOwnProperty(V) { 287 function ObjectHasOwnProperty(V) {
288 if (%_IsJSProxy(this)) { 288 if (%_IsJSProxy(this)) {
289 // TODO(rossberg): adjust once there is a story for symbols vs proxies. 289 // TODO(rossberg): adjust once there is a story for symbols vs proxies.
290 if (IS_SYMBOL(V)) return false; 290 if (IS_SYMBOL(V)) return false;
291 291
292 var handler = %GetHandler(this); 292 var handler = %GetHandler(this);
293 return CallTrap1(handler, "hasOwn", $proxyDerivedHasOwnTrap, ToName(V)); 293 return CallTrap1(handler, "hasOwn", $proxyDerivedHasOwnTrap, $toName(V));
294 } 294 }
295 return %HasOwnProperty(TO_OBJECT_INLINE(this), ToName(V)); 295 return %HasOwnProperty(TO_OBJECT_INLINE(this), $toName(V));
296 } 296 }
297 297
298 298
299 // ECMA-262 - 15.2.4.6 299 // ECMA-262 - 15.2.4.6
300 function ObjectIsPrototypeOf(V) { 300 function ObjectIsPrototypeOf(V) {
301 if (!IS_SPEC_OBJECT(V)) return false; 301 if (!IS_SPEC_OBJECT(V)) return false;
302 CHECK_OBJECT_COERCIBLE(this, "Object.prototype.isPrototypeOf"); 302 CHECK_OBJECT_COERCIBLE(this, "Object.prototype.isPrototypeOf");
303 return %IsInPrototypeChain(this, V); 303 return %IsInPrototypeChain(this, V);
304 } 304 }
305 305
306 306
307 // ECMA-262 - 15.2.4.6 307 // ECMA-262 - 15.2.4.6
308 function ObjectPropertyIsEnumerable(V) { 308 function ObjectPropertyIsEnumerable(V) {
309 var P = ToName(V); 309 var P = $toName(V);
310 if (%_IsJSProxy(this)) { 310 if (%_IsJSProxy(this)) {
311 // TODO(rossberg): adjust once there is a story for symbols vs proxies. 311 // TODO(rossberg): adjust once there is a story for symbols vs proxies.
312 if (IS_SYMBOL(V)) return false; 312 if (IS_SYMBOL(V)) return false;
313 313
314 var desc = GetOwnPropertyJS(this, P); 314 var desc = GetOwnPropertyJS(this, P);
315 return IS_UNDEFINED(desc) ? false : desc.isEnumerable(); 315 return IS_UNDEFINED(desc) ? false : desc.isEnumerable();
316 } 316 }
317 return %IsPropertyEnumerable(TO_OBJECT_INLINE(this), P); 317 return %IsPropertyEnumerable(TO_OBJECT_INLINE(this), P);
318 } 318 }
319 319
320 320
321 // Extensions for providing property getters and setters. 321 // Extensions for providing property getters and setters.
322 function ObjectDefineGetter(name, fun) { 322 function ObjectDefineGetter(name, fun) {
323 var receiver = this; 323 var receiver = this;
324 if (receiver == null && !IS_UNDETECTABLE(receiver)) { 324 if (receiver == null && !IS_UNDETECTABLE(receiver)) {
325 receiver = %GlobalProxy(global); 325 receiver = %GlobalProxy(global);
326 } 326 }
327 if (!IS_SPEC_FUNCTION(fun)) { 327 if (!IS_SPEC_FUNCTION(fun)) {
328 throw MakeTypeError(kObjectGetterExpectingFunction); 328 throw MakeTypeError(kObjectGetterExpectingFunction);
329 } 329 }
330 var desc = new PropertyDescriptor(); 330 var desc = new PropertyDescriptor();
331 desc.setGet(fun); 331 desc.setGet(fun);
332 desc.setEnumerable(true); 332 desc.setEnumerable(true);
333 desc.setConfigurable(true); 333 desc.setConfigurable(true);
334 DefineOwnProperty(TO_OBJECT_INLINE(receiver), ToName(name), desc, false); 334 DefineOwnProperty(TO_OBJECT_INLINE(receiver), $toName(name), desc, false);
335 } 335 }
336 336
337 337
338 function ObjectLookupGetter(name) { 338 function ObjectLookupGetter(name) {
339 var receiver = this; 339 var receiver = this;
340 if (receiver == null && !IS_UNDETECTABLE(receiver)) { 340 if (receiver == null && !IS_UNDETECTABLE(receiver)) {
341 receiver = %GlobalProxy(global); 341 receiver = %GlobalProxy(global);
342 } 342 }
343 return %LookupAccessor(TO_OBJECT_INLINE(receiver), ToName(name), GETTER); 343 return %LookupAccessor(TO_OBJECT_INLINE(receiver), $toName(name), GETTER);
344 } 344 }
345 345
346 346
347 function ObjectDefineSetter(name, fun) { 347 function ObjectDefineSetter(name, fun) {
348 var receiver = this; 348 var receiver = this;
349 if (receiver == null && !IS_UNDETECTABLE(receiver)) { 349 if (receiver == null && !IS_UNDETECTABLE(receiver)) {
350 receiver = %GlobalProxy(global); 350 receiver = %GlobalProxy(global);
351 } 351 }
352 if (!IS_SPEC_FUNCTION(fun)) { 352 if (!IS_SPEC_FUNCTION(fun)) {
353 throw MakeTypeError(kObjectSetterExpectingFunction); 353 throw MakeTypeError(kObjectSetterExpectingFunction);
354 } 354 }
355 var desc = new PropertyDescriptor(); 355 var desc = new PropertyDescriptor();
356 desc.setSet(fun); 356 desc.setSet(fun);
357 desc.setEnumerable(true); 357 desc.setEnumerable(true);
358 desc.setConfigurable(true); 358 desc.setConfigurable(true);
359 DefineOwnProperty(TO_OBJECT_INLINE(receiver), ToName(name), desc, false); 359 DefineOwnProperty(TO_OBJECT_INLINE(receiver), $toName(name), desc, false);
360 } 360 }
361 361
362 362
363 function ObjectLookupSetter(name) { 363 function ObjectLookupSetter(name) {
364 var receiver = this; 364 var receiver = this;
365 if (receiver == null && !IS_UNDETECTABLE(receiver)) { 365 if (receiver == null && !IS_UNDETECTABLE(receiver)) {
366 receiver = %GlobalProxy(global); 366 receiver = %GlobalProxy(global);
367 } 367 }
368 return %LookupAccessor(TO_OBJECT_INLINE(receiver), ToName(name), SETTER); 368 return %LookupAccessor(TO_OBJECT_INLINE(receiver), $toName(name), SETTER);
369 } 369 }
370 370
371 371
372 function ObjectKeys(obj) { 372 function ObjectKeys(obj) {
373 obj = TO_OBJECT_INLINE(obj); 373 obj = TO_OBJECT_INLINE(obj);
374 if (%_IsJSProxy(obj)) { 374 if (%_IsJSProxy(obj)) {
375 var handler = %GetHandler(obj); 375 var handler = %GetHandler(obj);
376 var names = CallTrap0(handler, "keys", $proxyDerivedKeysTrap); 376 var names = CallTrap0(handler, "keys", $proxyDerivedKeysTrap);
377 return ToNameArray(names, "keys", false); 377 return ToNameArray(names, "keys", false);
378 } 378 }
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 } 451 }
452 452
453 453
454 // ES5 8.10.5. 454 // ES5 8.10.5.
455 function ToPropertyDescriptor(obj) { 455 function ToPropertyDescriptor(obj) {
456 if (!IS_SPEC_OBJECT(obj)) throw MakeTypeError(kPropertyDescObject, obj); 456 if (!IS_SPEC_OBJECT(obj)) throw MakeTypeError(kPropertyDescObject, obj);
457 457
458 var desc = new PropertyDescriptor(); 458 var desc = new PropertyDescriptor();
459 459
460 if ("enumerable" in obj) { 460 if ("enumerable" in obj) {
461 desc.setEnumerable(ToBoolean(obj.enumerable)); 461 desc.setEnumerable($toBoolean(obj.enumerable));
462 } 462 }
463 463
464 if ("configurable" in obj) { 464 if ("configurable" in obj) {
465 desc.setConfigurable(ToBoolean(obj.configurable)); 465 desc.setConfigurable($toBoolean(obj.configurable));
466 } 466 }
467 467
468 if ("value" in obj) { 468 if ("value" in obj) {
469 desc.setValue(obj.value); 469 desc.setValue(obj.value);
470 } 470 }
471 471
472 if ("writable" in obj) { 472 if ("writable" in obj) {
473 desc.setWritable(ToBoolean(obj.writable)); 473 desc.setWritable($toBoolean(obj.writable));
474 } 474 }
475 475
476 if ("get" in obj) { 476 if ("get" in obj) {
477 var get = obj.get; 477 var get = obj.get;
478 if (!IS_UNDEFINED(get) && !IS_SPEC_FUNCTION(get)) { 478 if (!IS_UNDEFINED(get) && !IS_SPEC_FUNCTION(get)) {
479 throw MakeTypeError(kObjectGetterCallable, get); 479 throw MakeTypeError(kObjectGetterCallable, get);
480 } 480 }
481 desc.setGet(get); 481 desc.setGet(get);
482 } 482 }
483 483
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
660 } 660 }
661 661
662 662
663 function CallTrap2(handler, name, defaultTrap, x, y) { 663 function CallTrap2(handler, name, defaultTrap, x, y) {
664 return %_CallFunction(handler, x, y, GetTrap(handler, name, defaultTrap)); 664 return %_CallFunction(handler, x, y, GetTrap(handler, name, defaultTrap));
665 } 665 }
666 666
667 667
668 // ES5 section 8.12.1. 668 // ES5 section 8.12.1.
669 function GetOwnPropertyJS(obj, v) { 669 function GetOwnPropertyJS(obj, v) {
670 var p = ToName(v); 670 var p = $toName(v);
671 if (%_IsJSProxy(obj)) { 671 if (%_IsJSProxy(obj)) {
672 // TODO(rossberg): adjust once there is a story for symbols vs proxies. 672 // TODO(rossberg): adjust once there is a story for symbols vs proxies.
673 if (IS_SYMBOL(v)) return UNDEFINED; 673 if (IS_SYMBOL(v)) return UNDEFINED;
674 674
675 var handler = %GetHandler(obj); 675 var handler = %GetHandler(obj);
676 var descriptor = CallTrap1( 676 var descriptor = CallTrap1(
677 handler, "getOwnPropertyDescriptor", UNDEFINED, p); 677 handler, "getOwnPropertyDescriptor", UNDEFINED, p);
678 if (IS_UNDEFINED(descriptor)) return descriptor; 678 if (IS_UNDEFINED(descriptor)) return descriptor;
679 var desc = ToCompletePropertyDescriptor(descriptor); 679 var desc = ToCompletePropertyDescriptor(descriptor);
680 if (!desc.isConfigurable()) { 680 if (!desc.isConfigurable()) {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
717 } 717 }
718 718
719 719
720 // Harmony proxies. 720 // Harmony proxies.
721 function DefineProxyProperty(obj, p, attributes, should_throw) { 721 function DefineProxyProperty(obj, p, attributes, should_throw) {
722 // TODO(rossberg): adjust once there is a story for symbols vs proxies. 722 // TODO(rossberg): adjust once there is a story for symbols vs proxies.
723 if (IS_SYMBOL(p)) return false; 723 if (IS_SYMBOL(p)) return false;
724 724
725 var handler = %GetHandler(obj); 725 var handler = %GetHandler(obj);
726 var result = CallTrap2(handler, "defineProperty", UNDEFINED, p, attributes); 726 var result = CallTrap2(handler, "defineProperty", UNDEFINED, p, attributes);
727 if (!ToBoolean(result)) { 727 if (!$toBoolean(result)) {
728 if (should_throw) { 728 if (should_throw) {
729 throw MakeTypeError(kProxyHandlerReturned, 729 throw MakeTypeError(kProxyHandlerReturned,
730 handler, "false", "defineProperty"); 730 handler, "false", "defineProperty");
731 } else { 731 } else {
732 return false; 732 return false;
733 } 733 }
734 } 734 }
735 return true; 735 return true;
736 } 736 }
737 737
738 738
739 // ES5 8.12.9. 739 // ES5 8.12.9.
740 function DefineObjectProperty(obj, p, desc, should_throw) { 740 function DefineObjectProperty(obj, p, desc, should_throw) {
741 var current_array = %GetOwnProperty(obj, ToName(p)); 741 var current_array = %GetOwnProperty(obj, $toName(p));
742 var current = ConvertDescriptorArrayToDescriptor(current_array); 742 var current = ConvertDescriptorArrayToDescriptor(current_array);
743 var extensible = %IsExtensible(obj); 743 var extensible = %IsExtensible(obj);
744 744
745 // Error handling according to spec. 745 // Error handling according to spec.
746 // Step 3 746 // Step 3
747 if (IS_UNDEFINED(current) && !extensible) { 747 if (IS_UNDEFINED(current) && !extensible) {
748 if (should_throw) { 748 if (should_throw) {
749 throw MakeTypeError(kDefineDisallowed, p); 749 throw MakeTypeError(kDefineDisallowed, p);
750 } else { 750 } else {
751 return false; 751 return false;
752 } 752 }
753 } 753 }
754 754
755 if (!IS_UNDEFINED(current)) { 755 if (!IS_UNDEFINED(current)) {
756 // Step 5 and 6 756 // Step 5 and 6
757 if ((IsGenericDescriptor(desc) || 757 if ((IsGenericDescriptor(desc) ||
758 IsDataDescriptor(desc) == IsDataDescriptor(current)) && 758 IsDataDescriptor(desc) == IsDataDescriptor(current)) &&
759 (!desc.hasEnumerable() || 759 (!desc.hasEnumerable() ||
760 SameValue(desc.isEnumerable(), current.isEnumerable())) && 760 $sameValue(desc.isEnumerable(), current.isEnumerable())) &&
761 (!desc.hasConfigurable() || 761 (!desc.hasConfigurable() ||
762 SameValue(desc.isConfigurable(), current.isConfigurable())) && 762 $sameValue(desc.isConfigurable(), current.isConfigurable())) &&
763 (!desc.hasWritable() || 763 (!desc.hasWritable() ||
764 SameValue(desc.isWritable(), current.isWritable())) && 764 $sameValue(desc.isWritable(), current.isWritable())) &&
765 (!desc.hasValue() || 765 (!desc.hasValue() ||
766 SameValue(desc.getValue(), current.getValue())) && 766 $sameValue(desc.getValue(), current.getValue())) &&
767 (!desc.hasGetter() || 767 (!desc.hasGetter() ||
768 SameValue(desc.getGet(), current.getGet())) && 768 $sameValue(desc.getGet(), current.getGet())) &&
769 (!desc.hasSetter() || 769 (!desc.hasSetter() ||
770 SameValue(desc.getSet(), current.getSet()))) { 770 $sameValue(desc.getSet(), current.getSet()))) {
771 return true; 771 return true;
772 } 772 }
773 if (!current.isConfigurable()) { 773 if (!current.isConfigurable()) {
774 // Step 7 774 // Step 7
775 if (desc.isConfigurable() || 775 if (desc.isConfigurable() ||
776 (desc.hasEnumerable() && 776 (desc.hasEnumerable() &&
777 desc.isEnumerable() != current.isEnumerable())) { 777 desc.isEnumerable() != current.isEnumerable())) {
778 if (should_throw) { 778 if (should_throw) {
779 throw MakeTypeError(kRedefineDisallowed, p); 779 throw MakeTypeError(kRedefineDisallowed, p);
780 } else { 780 } else {
(...skipping 13 matching lines...) Expand all
794 // Step 10a 794 // Step 10a
795 if (IsDataDescriptor(current) && IsDataDescriptor(desc)) { 795 if (IsDataDescriptor(current) && IsDataDescriptor(desc)) {
796 if (!current.isWritable() && desc.isWritable()) { 796 if (!current.isWritable() && desc.isWritable()) {
797 if (should_throw) { 797 if (should_throw) {
798 throw MakeTypeError(kRedefineDisallowed, p); 798 throw MakeTypeError(kRedefineDisallowed, p);
799 } else { 799 } else {
800 return false; 800 return false;
801 } 801 }
802 } 802 }
803 if (!current.isWritable() && desc.hasValue() && 803 if (!current.isWritable() && desc.hasValue() &&
804 !SameValue(desc.getValue(), current.getValue())) { 804 !$sameValue(desc.getValue(), current.getValue())) {
805 if (should_throw) { 805 if (should_throw) {
806 throw MakeTypeError(kRedefineDisallowed, p); 806 throw MakeTypeError(kRedefineDisallowed, p);
807 } else { 807 } else {
808 return false; 808 return false;
809 } 809 }
810 } 810 }
811 } 811 }
812 // Step 11 812 // Step 11
813 if (IsAccessorDescriptor(desc) && IsAccessorDescriptor(current)) { 813 if (IsAccessorDescriptor(desc) && IsAccessorDescriptor(current)) {
814 if (desc.hasSetter() && !SameValue(desc.getSet(), current.getSet())) { 814 if (desc.hasSetter() &&
815 !$sameValue(desc.getSet(), current.getSet())) {
815 if (should_throw) { 816 if (should_throw) {
816 throw MakeTypeError(kRedefineDisallowed, p); 817 throw MakeTypeError(kRedefineDisallowed, p);
817 } else { 818 } else {
818 return false; 819 return false;
819 } 820 }
820 } 821 }
821 if (desc.hasGetter() && !SameValue(desc.getGet(),current.getGet())) { 822 if (desc.hasGetter() && !$sameValue(desc.getGet(),current.getGet())) {
822 if (should_throw) { 823 if (should_throw) {
823 throw MakeTypeError(kRedefineDisallowed, p); 824 throw MakeTypeError(kRedefineDisallowed, p);
824 } else { 825 } else {
825 return false; 826 return false;
826 } 827 }
827 } 828 }
828 } 829 }
829 } 830 }
830 } 831 }
831 } 832 }
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
907 // property, hence we use generated code throughout this function instead of 908 // property, hence we use generated code throughout this function instead of
908 // DefineObjectProperty() to modify its value. 909 // DefineObjectProperty() to modify its value.
909 910
910 // Step 3 - Special handling for length property. 911 // Step 3 - Special handling for length property.
911 if (p === "length") { 912 if (p === "length") {
912 var length = obj.length; 913 var length = obj.length;
913 var old_length = length; 914 var old_length = length;
914 if (!desc.hasValue()) { 915 if (!desc.hasValue()) {
915 return DefineObjectProperty(obj, "length", desc, should_throw); 916 return DefineObjectProperty(obj, "length", desc, should_throw);
916 } 917 }
917 var new_length = ToUint32(desc.getValue()); 918 var new_length = $toUint32(desc.getValue());
918 if (new_length != ToNumber(desc.getValue())) { 919 if (new_length != $toNumber(desc.getValue())) {
919 throw MakeRangeError(kArrayLengthOutOfRange); 920 throw MakeRangeError(kArrayLengthOutOfRange);
920 } 921 }
921 var length_desc = GetOwnPropertyJS(obj, "length"); 922 var length_desc = GetOwnPropertyJS(obj, "length");
922 if (new_length != length && !length_desc.isWritable()) { 923 if (new_length != length && !length_desc.isWritable()) {
923 if (should_throw) { 924 if (should_throw) {
924 throw MakeTypeError(kRedefineDisallowed, p); 925 throw MakeTypeError(kRedefineDisallowed, p);
925 } else { 926 } else {
926 return false; 927 return false;
927 } 928 }
928 } 929 }
929 var threw = false; 930 var threw = false;
930 931
931 var emit_splice = %IsObserved(obj) && new_length !== old_length; 932 var emit_splice = %IsObserved(obj) && new_length !== old_length;
932 var removed; 933 var removed;
933 if (emit_splice) { 934 if (emit_splice) {
934 $observeBeginPerformSplice(obj); 935 $observeBeginPerformSplice(obj);
935 removed = []; 936 removed = [];
936 if (new_length < old_length) 937 if (new_length < old_length)
937 removed.length = old_length - new_length; 938 removed.length = old_length - new_length;
938 } 939 }
939 940
940 while (new_length < length--) { 941 while (new_length < length--) {
941 var index = ToString(length); 942 var index = $toString(length);
942 if (emit_splice) { 943 if (emit_splice) {
943 var deletedDesc = GetOwnPropertyJS(obj, index); 944 var deletedDesc = GetOwnPropertyJS(obj, index);
944 if (deletedDesc && deletedDesc.hasValue()) 945 if (deletedDesc && deletedDesc.hasValue())
945 removed[length - new_length] = deletedDesc.getValue(); 946 removed[length - new_length] = deletedDesc.getValue();
946 } 947 }
947 if (!Delete(obj, index, false)) { 948 if (!Delete(obj, index, false)) {
948 new_length = length + 1; 949 new_length = length + 1;
949 threw = true; 950 threw = true;
950 break; 951 break;
951 } 952 }
(...skipping 11 matching lines...) Expand all
963 throw MakeTypeError(kRedefineDisallowed, p); 964 throw MakeTypeError(kRedefineDisallowed, p);
964 } else { 965 } else {
965 return false; 966 return false;
966 } 967 }
967 } 968 }
968 return true; 969 return true;
969 } 970 }
970 971
971 // Step 4 - Special handling for array index. 972 // Step 4 - Special handling for array index.
972 if (!IS_SYMBOL(p)) { 973 if (!IS_SYMBOL(p)) {
973 var index = ToUint32(p); 974 var index = $toUint32(p);
974 var emit_splice = false; 975 var emit_splice = false;
975 if (ToString(index) == p && index != 4294967295) { 976 if ($toString(index) == p && index != 4294967295) {
976 var length = obj.length; 977 var length = obj.length;
977 if (index >= length && %IsObserved(obj)) { 978 if (index >= length && %IsObserved(obj)) {
978 emit_splice = true; 979 emit_splice = true;
979 $observeBeginPerformSplice(obj); 980 $observeBeginPerformSplice(obj);
980 } 981 }
981 982
982 var length_desc = GetOwnPropertyJS(obj, "length"); 983 var length_desc = GetOwnPropertyJS(obj, "length");
983 if ((index >= length && !length_desc.isWritable()) || 984 if ((index >= length && !length_desc.isWritable()) ||
984 !DefineObjectProperty(obj, p, desc, true)) { 985 !DefineObjectProperty(obj, p, desc, true)) {
985 if (emit_splice) 986 if (emit_splice)
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
1048 var desc = GetOwnPropertyJS(TO_OBJECT_INLINE(obj), p); 1049 var desc = GetOwnPropertyJS(TO_OBJECT_INLINE(obj), p);
1049 return FromPropertyDescriptor(desc); 1050 return FromPropertyDescriptor(desc);
1050 } 1051 }
1051 1052
1052 1053
1053 // For Harmony proxies 1054 // For Harmony proxies
1054 function ToNameArray(obj, trap, includeSymbols) { 1055 function ToNameArray(obj, trap, includeSymbols) {
1055 if (!IS_SPEC_OBJECT(obj)) { 1056 if (!IS_SPEC_OBJECT(obj)) {
1056 throw MakeTypeError(kProxyNonObjectPropNames, trap, obj); 1057 throw MakeTypeError(kProxyNonObjectPropNames, trap, obj);
1057 } 1058 }
1058 var n = ToUint32(obj.length); 1059 var n = $toUint32(obj.length);
1059 var array = new GlobalArray(n); 1060 var array = new GlobalArray(n);
1060 var realLength = 0; 1061 var realLength = 0;
1061 var names = { __proto__: null }; // TODO(rossberg): use sets once ready. 1062 var names = { __proto__: null }; // TODO(rossberg): use sets once ready.
1062 for (var index = 0; index < n; index++) { 1063 for (var index = 0; index < n; index++) {
1063 var s = ToName(obj[index]); 1064 var s = $toName(obj[index]);
1064 // TODO(rossberg): adjust once there is a story for symbols vs proxies. 1065 // TODO(rossberg): adjust once there is a story for symbols vs proxies.
1065 if (IS_SYMBOL(s) && !includeSymbols) continue; 1066 if (IS_SYMBOL(s) && !includeSymbols) continue;
1066 if (%HasOwnProperty(names, s)) { 1067 if (%HasOwnProperty(names, s)) {
1067 throw MakeTypeError(kProxyRepeatedPropName, trap, s); 1068 throw MakeTypeError(kProxyRepeatedPropName, trap, s);
1068 } 1069 }
1069 array[index] = s; 1070 array[index] = s;
1070 ++realLength; 1071 ++realLength;
1071 names[s] = 0; 1072 names[s] = 0;
1072 } 1073 }
1073 array.length = realLength; 1074 array.length = realLength;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1122 var seenKeys = { __proto__: null }; 1123 var seenKeys = { __proto__: null };
1123 var j = 0; 1124 var j = 0;
1124 for (var i = 0; i < propertyNames.length; ++i) { 1125 for (var i = 0; i < propertyNames.length; ++i) {
1125 var name = propertyNames[i]; 1126 var name = propertyNames[i];
1126 if (IS_SYMBOL(name)) { 1127 if (IS_SYMBOL(name)) {
1127 if ((filter & PROPERTY_ATTRIBUTES_SYMBOLIC) || IS_PRIVATE(name)) { 1128 if ((filter & PROPERTY_ATTRIBUTES_SYMBOLIC) || IS_PRIVATE(name)) {
1128 continue; 1129 continue;
1129 } 1130 }
1130 } else { 1131 } else {
1131 if (filter & PROPERTY_ATTRIBUTES_STRING) continue; 1132 if (filter & PROPERTY_ATTRIBUTES_STRING) continue;
1132 name = ToString(name); 1133 name = $toString(name);
1133 } 1134 }
1134 if (seenKeys[name]) continue; 1135 if (seenKeys[name]) continue;
1135 seenKeys[name] = true; 1136 seenKeys[name] = true;
1136 propertyNames[j++] = name; 1137 propertyNames[j++] = name;
1137 } 1138 }
1138 propertyNames.length = j; 1139 propertyNames.length = j;
1139 } 1140 }
1140 1141
1141 return propertyNames; 1142 return propertyNames;
1142 } 1143 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1179 if (!IS_UNDEFINED(properties)) ObjectDefineProperties(obj, properties); 1180 if (!IS_UNDEFINED(properties)) ObjectDefineProperties(obj, properties);
1180 return obj; 1181 return obj;
1181 } 1182 }
1182 1183
1183 1184
1184 // ES5 section 15.2.3.6. 1185 // ES5 section 15.2.3.6.
1185 function ObjectDefineProperty(obj, p, attributes) { 1186 function ObjectDefineProperty(obj, p, attributes) {
1186 if (!IS_SPEC_OBJECT(obj)) { 1187 if (!IS_SPEC_OBJECT(obj)) {
1187 throw MakeTypeError(kCalledOnNonObject, "Object.defineProperty"); 1188 throw MakeTypeError(kCalledOnNonObject, "Object.defineProperty");
1188 } 1189 }
1189 var name = ToName(p); 1190 var name = $toName(p);
1190 if (%_IsJSProxy(obj)) { 1191 if (%_IsJSProxy(obj)) {
1191 // Clone the attributes object for protection. 1192 // Clone the attributes object for protection.
1192 // TODO(rossberg): not spec'ed yet, so not sure if this should involve 1193 // TODO(rossberg): not spec'ed yet, so not sure if this should involve
1193 // non-own properties as it does (or non-enumerable ones, as it doesn't?). 1194 // non-own properties as it does (or non-enumerable ones, as it doesn't?).
1194 var attributesClone = { __proto__: null }; 1195 var attributesClone = { __proto__: null };
1195 for (var a in attributes) { 1196 for (var a in attributes) {
1196 attributesClone[a] = attributes[a]; 1197 attributesClone[a] = attributes[a];
1197 } 1198 }
1198 DefineProxyProperty(obj, name, attributesClone, true); 1199 DefineProxyProperty(obj, name, attributesClone, true);
1199 // The following would implement the spec as in the current proposal, 1200 // The following would implement the spec as in the current proposal,
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
1403 if (!IS_SPEC_OBJECT(obj)) return false; 1404 if (!IS_SPEC_OBJECT(obj)) return false;
1404 if (%_IsJSProxy(obj)) { 1405 if (%_IsJSProxy(obj)) {
1405 return true; 1406 return true;
1406 } 1407 }
1407 return %IsExtensible(obj); 1408 return %IsExtensible(obj);
1408 } 1409 }
1409 1410
1410 1411
1411 // ECMA-262, Edition 6, section 19.1.2.10 1412 // ECMA-262, Edition 6, section 19.1.2.10
1412 function ObjectIs(obj1, obj2) { 1413 function ObjectIs(obj1, obj2) {
1413 return SameValue(obj1, obj2); 1414 return $sameValue(obj1, obj2);
1414 } 1415 }
1415 1416
1416 1417
1417 // ECMA-262, Edition 6, section B.2.2.1.1 1418 // ECMA-262, Edition 6, section B.2.2.1.1
1418 function ObjectGetProto() { 1419 function ObjectGetProto() {
1419 return %_GetPrototype(TO_OBJECT_INLINE(this)); 1420 return %_GetPrototype(TO_OBJECT_INLINE(this));
1420 } 1421 }
1421 1422
1422 1423
1423 // ECMA-262, Edition 6, section B.2.2.1.2 1424 // ECMA-262, Edition 6, section B.2.2.1.2
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
1487 // deliverChangeRecords, getNotifier, observe and unobserve are added 1488 // deliverChangeRecords, getNotifier, observe and unobserve are added
1488 // in object-observe.js. 1489 // in object-observe.js.
1489 ]); 1490 ]);
1490 1491
1491 1492
1492 // ---------------------------------------------------------------------------- 1493 // ----------------------------------------------------------------------------
1493 // Boolean 1494 // Boolean
1494 1495
1495 function BooleanConstructor(x) { 1496 function BooleanConstructor(x) {
1496 if (%_IsConstructCall()) { 1497 if (%_IsConstructCall()) {
1497 %_SetValueOf(this, ToBoolean(x)); 1498 %_SetValueOf(this, $toBoolean(x));
1498 } else { 1499 } else {
1499 return ToBoolean(x); 1500 return $toBoolean(x);
1500 } 1501 }
1501 } 1502 }
1502 1503
1503 1504
1504 function BooleanToString() { 1505 function BooleanToString() {
1505 // NOTE: Both Boolean objects and values can enter here as 1506 // NOTE: Both Boolean objects and values can enter here as
1506 // 'this'. This is not as dictated by ECMA-262. 1507 // 'this'. This is not as dictated by ECMA-262.
1507 var b = this; 1508 var b = this;
1508 if (!IS_BOOLEAN(b)) { 1509 if (!IS_BOOLEAN(b)) {
1509 if (!IS_BOOLEAN_WRAPPER(b)) { 1510 if (!IS_BOOLEAN_WRAPPER(b)) {
(...skipping 25 matching lines...) Expand all
1535 InstallFunctions(GlobalBoolean.prototype, DONT_ENUM, [ 1536 InstallFunctions(GlobalBoolean.prototype, DONT_ENUM, [
1536 "toString", BooleanToString, 1537 "toString", BooleanToString,
1537 "valueOf", BooleanValueOf 1538 "valueOf", BooleanValueOf
1538 ]); 1539 ]);
1539 1540
1540 1541
1541 // ---------------------------------------------------------------------------- 1542 // ----------------------------------------------------------------------------
1542 // Number 1543 // Number
1543 1544
1544 function NumberConstructor(x) { 1545 function NumberConstructor(x) {
1545 var value = %_ArgumentsLength() == 0 ? 0 : ToNumber(x); 1546 var value = %_ArgumentsLength() == 0 ? 0 : $toNumber(x);
1546 if (%_IsConstructCall()) { 1547 if (%_IsConstructCall()) {
1547 %_SetValueOf(this, value); 1548 %_SetValueOf(this, value);
1548 } else { 1549 } else {
1549 return value; 1550 return value;
1550 } 1551 }
1551 } 1552 }
1552 1553
1553 1554
1554 // ECMA-262 section 15.7.4.2. 1555 // ECMA-262 section 15.7.4.2.
1555 function NumberToStringJS(radix) { 1556 function NumberToStringJS(radix) {
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
1648 function NumberToPrecisionJS(precision) { 1649 function NumberToPrecisionJS(precision) {
1649 var x = this; 1650 var x = this;
1650 if (!IS_NUMBER(this)) { 1651 if (!IS_NUMBER(this)) {
1651 if (!IS_NUMBER_WRAPPER(this)) { 1652 if (!IS_NUMBER_WRAPPER(this)) {
1652 throw MakeTypeError(kIncompatibleMethodReceiver, 1653 throw MakeTypeError(kIncompatibleMethodReceiver,
1653 "Number.prototype.toPrecision", this); 1654 "Number.prototype.toPrecision", this);
1654 } 1655 }
1655 // Get the value of this number in case it's an object. 1656 // Get the value of this number in case it's an object.
1656 x = %_ValueOf(this); 1657 x = %_ValueOf(this);
1657 } 1658 }
1658 if (IS_UNDEFINED(precision)) return ToString(%_ValueOf(this)); 1659 if (IS_UNDEFINED(precision)) return $toString(%_ValueOf(this));
1659 var p = TO_INTEGER(precision); 1660 var p = TO_INTEGER(precision);
1660 1661
1661 if (NUMBER_IS_NAN(x)) return "NaN"; 1662 if (NUMBER_IS_NAN(x)) return "NaN";
1662 if (x == INFINITY) return "Infinity"; 1663 if (x == INFINITY) return "Infinity";
1663 if (x == -INFINITY) return "-Infinity"; 1664 if (x == -INFINITY) return "-Infinity";
1664 1665
1665 if (p < 1 || p > 21) { 1666 if (p < 1 || p > 21) {
1666 throw MakeRangeError(kToPrecisionFormatRange); 1667 throw MakeRangeError(kToPrecisionFormatRange);
1667 } 1668 }
1668 return %NumberToPrecision(x, p); 1669 return %NumberToPrecision(x, p);
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
1863 // To be consistent with our normal functions we leave this as it is. 1864 // To be consistent with our normal functions we leave this as it is.
1864 // TODO(lrn): Do set these to be thrower. 1865 // TODO(lrn): Do set these to be thrower.
1865 return result; 1866 return result;
1866 } 1867 }
1867 1868
1868 1869
1869 function NewFunctionString(args, function_token) { 1870 function NewFunctionString(args, function_token) {
1870 var n = args.length; 1871 var n = args.length;
1871 var p = ''; 1872 var p = '';
1872 if (n > 1) { 1873 if (n > 1) {
1873 p = ToString(args[0]); 1874 p = $toString(args[0]);
1874 for (var i = 1; i < n - 1; i++) { 1875 for (var i = 1; i < n - 1; i++) {
1875 p += ',' + ToString(args[i]); 1876 p += ',' + $toString(args[i]);
1876 } 1877 }
1877 // If the formal parameters string include ) - an illegal 1878 // If the formal parameters string include ) - an illegal
1878 // character - it may make the combined function expression 1879 // character - it may make the combined function expression
1879 // compile. We avoid this problem by checking for this early on. 1880 // compile. We avoid this problem by checking for this early on.
1880 if (%_CallFunction(p, ')', $stringIndexOf) != -1) { 1881 if (%_CallFunction(p, ')', $stringIndexOf) != -1) {
1881 throw MakeSyntaxError(kParenthesisInArgString); 1882 throw MakeSyntaxError(kParenthesisInArgString);
1882 } 1883 }
1883 // If the formal parameters include an unbalanced block comment, the 1884 // If the formal parameters include an unbalanced block comment, the
1884 // function must be rejected. Since JavaScript does not allow nested 1885 // function must be rejected. Since JavaScript does not allow nested
1885 // comments we can include a trailing block comment to catch this. 1886 // comments we can include a trailing block comment to catch this.
1886 p += '\n/' + '**/'; 1887 p += '\n/' + '**/';
1887 } 1888 }
1888 var body = (n > 0) ? ToString(args[n - 1]) : ''; 1889 var body = (n > 0) ? $toString(args[n - 1]) : '';
1889 return '(' + function_token + '(' + p + ') {\n' + body + '\n})'; 1890 return '(' + function_token + '(' + p + ') {\n' + body + '\n})';
1890 } 1891 }
1891 1892
1892 1893
1893 function FunctionConstructor(arg1) { // length == 1 1894 function FunctionConstructor(arg1) { // length == 1
1894 var source = NewFunctionString(arguments, 'function'); 1895 var source = NewFunctionString(arguments, 'function');
1895 var global_proxy = %GlobalProxy(global); 1896 var global_proxy = %GlobalProxy(global);
1896 // Compile the string in the constructor and not a helper so that errors 1897 // Compile the string in the constructor and not a helper so that errors
1897 // appear to come from here. 1898 // appear to come from here.
1898 var f = %_CallFunction(global_proxy, %CompileString(source, true)); 1899 var f = %_CallFunction(global_proxy, %CompileString(source, true));
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
1957 $objectLookupSetter = ObjectLookupSetter; 1958 $objectLookupSetter = ObjectLookupSetter;
1958 $objectToString = ObjectToString; 1959 $objectToString = ObjectToString;
1959 $overrideFunction = OverrideFunction; 1960 $overrideFunction = OverrideFunction;
1960 $ownPropertyKeys = OwnPropertyKeys; 1961 $ownPropertyKeys = OwnPropertyKeys;
1961 $setFunctionName = SetFunctionName; 1962 $setFunctionName = SetFunctionName;
1962 $setUpLockedPrototype = SetUpLockedPrototype; 1963 $setUpLockedPrototype = SetUpLockedPrototype;
1963 $toCompletePropertyDescriptor = ToCompletePropertyDescriptor; 1964 $toCompletePropertyDescriptor = ToCompletePropertyDescriptor;
1964 $toNameArray = ToNameArray; 1965 $toNameArray = ToNameArray;
1965 1966
1966 })(); 1967 })();
OLDNEW
« no previous file with comments | « src/uri.js ('k') | test/cctest/compiler/test-run-jscalls.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698