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

Side by Side Diff: src/v8natives.js

Issue 6062002: Merge 6006:6095 from bleeding_edge to experimental/gc branch. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/gc/
Patch Set: Created 10 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 | Annotate | Revision Log
« no previous file with comments | « src/v8-counters.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 545 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 (!desc.hasValue() || 556 (!desc.hasValue() ||
557 SameValue(desc.getValue(), current.getValue())) && 557 SameValue(desc.getValue(), current.getValue())) &&
558 (!desc.hasGetter() || 558 (!desc.hasGetter() ||
559 SameValue(desc.getGet(), current.getGet())) && 559 SameValue(desc.getGet(), current.getGet())) &&
560 (!desc.hasSetter() || 560 (!desc.hasSetter() ||
561 SameValue(desc.getSet(), current.getSet()))) { 561 SameValue(desc.getSet(), current.getSet()))) {
562 return true; 562 return true;
563 } 563 }
564 564
565 // Step 7 565 // Step 7
566 if (desc.isConfigurable() || desc.isEnumerable() != current.isEnumerable()) 566 if (desc.isConfigurable() || desc.isEnumerable() != current.isEnumerable())
567 throw MakeTypeError("redefine_disallowed", ["defineProperty"]); 567 throw MakeTypeError("redefine_disallowed", ["defineProperty"]);
568 // Step 9 568 // Step 9
569 if (IsDataDescriptor(current) != IsDataDescriptor(desc)) 569 if (IsDataDescriptor(current) != IsDataDescriptor(desc))
570 throw MakeTypeError("redefine_disallowed", ["defineProperty"]); 570 throw MakeTypeError("redefine_disallowed", ["defineProperty"]);
571 // Step 10 571 // Step 10
572 if (IsDataDescriptor(current) && IsDataDescriptor(desc)) { 572 if (IsDataDescriptor(current) && IsDataDescriptor(desc)) {
573 if (!current.isWritable() && desc.isWritable()) 573 if (!current.isWritable() && desc.isWritable())
574 throw MakeTypeError("redefine_disallowed", ["defineProperty"]); 574 throw MakeTypeError("redefine_disallowed", ["defineProperty"]);
575 if (!current.isWritable() && desc.hasValue() && 575 if (!current.isWritable() && desc.hasValue() &&
576 !SameValue(desc.getValue(), current.getValue())) { 576 !SameValue(desc.getValue(), current.getValue())) {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 flag |= READ_ONLY; 616 flag |= READ_ONLY;
617 } 617 }
618 var value = void 0; // Default value is undefined. 618 var value = void 0; // Default value is undefined.
619 if (desc.hasValue()) { 619 if (desc.hasValue()) {
620 value = desc.getValue(); 620 value = desc.getValue();
621 } else if (!IS_UNDEFINED(current)) { 621 } else if (!IS_UNDEFINED(current)) {
622 value = current.getValue(); 622 value = current.getValue();
623 } 623 }
624 %DefineOrRedefineDataProperty(obj, p, value, flag); 624 %DefineOrRedefineDataProperty(obj, p, value, flag);
625 } else { 625 } else {
626 if (desc.hasGetter() && IS_FUNCTION(desc.getGet())) { 626 if (desc.hasGetter() &&
627 (IS_FUNCTION(desc.getGet()) || IS_UNDEFINED(desc.getGet()))) {
627 %DefineOrRedefineAccessorProperty(obj, p, GETTER, desc.getGet(), flag); 628 %DefineOrRedefineAccessorProperty(obj, p, GETTER, desc.getGet(), flag);
628 } 629 }
629 if (desc.hasSetter() && IS_FUNCTION(desc.getSet())) { 630 if (desc.hasSetter() &&
631 (IS_FUNCTION(desc.getSet()) || IS_UNDEFINED(desc.getSet()))) {
630 %DefineOrRedefineAccessorProperty(obj, p, SETTER, desc.getSet(), flag); 632 %DefineOrRedefineAccessorProperty(obj, p, SETTER, desc.getSet(), flag);
631 } 633 }
632 } 634 }
633 return true; 635 return true;
634 } 636 }
635 637
636 638
637 // ES5 section 15.2.3.2. 639 // ES5 section 15.2.3.2.
638 function ObjectGetPrototypeOf(obj) { 640 function ObjectGetPrototypeOf(obj) {
639 if (!IS_SPEC_OBJECT(obj)) 641 if (!IS_SPEC_OBJECT(obj))
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
902 904
903 function BooleanValueOf() { 905 function BooleanValueOf() {
904 // NOTE: Both Boolean objects and values can enter here as 906 // NOTE: Both Boolean objects and values can enter here as
905 // 'this'. This is not as dictated by ECMA-262. 907 // 'this'. This is not as dictated by ECMA-262.
906 if (!IS_BOOLEAN(this) && !IS_BOOLEAN_WRAPPER(this)) 908 if (!IS_BOOLEAN(this) && !IS_BOOLEAN_WRAPPER(this))
907 throw new $TypeError('Boolean.prototype.valueOf is not generic'); 909 throw new $TypeError('Boolean.prototype.valueOf is not generic');
908 return %_ValueOf(this); 910 return %_ValueOf(this);
909 } 911 }
910 912
911 913
912 function BooleanToJSON(key) {
913 return CheckJSONPrimitive(this.valueOf());
914 }
915
916
917 // ---------------------------------------------------------------------------- 914 // ----------------------------------------------------------------------------
918 915
919 916
920 function SetupBoolean() { 917 function SetupBoolean() {
921 InstallFunctions($Boolean.prototype, DONT_ENUM, $Array( 918 InstallFunctions($Boolean.prototype, DONT_ENUM, $Array(
922 "toString", BooleanToString, 919 "toString", BooleanToString,
923 "valueOf", BooleanValueOf, 920 "valueOf", BooleanValueOf
924 "toJSON", BooleanToJSON
925 )); 921 ));
926 } 922 }
927 923
928 SetupBoolean(); 924 SetupBoolean();
929 925
930 // ---------------------------------------------------------------------------- 926 // ----------------------------------------------------------------------------
931 // Number 927 // Number
932 928
933 // Set the Number function and constructor. 929 // Set the Number function and constructor.
934 %SetCode($Number, function(x) { 930 %SetCode($Number, function(x) {
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
1014 if (IS_UNDEFINED(precision)) return ToString(%_ValueOf(this)); 1010 if (IS_UNDEFINED(precision)) return ToString(%_ValueOf(this));
1015 var p = TO_INTEGER(precision); 1011 var p = TO_INTEGER(precision);
1016 if (p < 1 || p > 21) { 1012 if (p < 1 || p > 21) {
1017 throw new $RangeError("toPrecision() argument must be between 1 and 21"); 1013 throw new $RangeError("toPrecision() argument must be between 1 and 21");
1018 } 1014 }
1019 var x = ToNumber(this); 1015 var x = ToNumber(this);
1020 return %NumberToPrecision(x, p); 1016 return %NumberToPrecision(x, p);
1021 } 1017 }
1022 1018
1023 1019
1024 function CheckJSONPrimitive(val) {
1025 if (!IsPrimitive(val))
1026 throw MakeTypeError('result_not_primitive', ['toJSON', val]);
1027 return val;
1028 }
1029
1030
1031 function NumberToJSON(key) {
1032 return CheckJSONPrimitive(this.valueOf());
1033 }
1034
1035
1036 // ---------------------------------------------------------------------------- 1020 // ----------------------------------------------------------------------------
1037 1021
1038 function SetupNumber() { 1022 function SetupNumber() {
1039 %OptimizeObjectForAddingMultipleProperties($Number.prototype, 8); 1023 %OptimizeObjectForAddingMultipleProperties($Number.prototype, 8);
1040 // Setup the constructor property on the Number prototype object. 1024 // Setup the constructor property on the Number prototype object.
1041 %SetProperty($Number.prototype, "constructor", $Number, DONT_ENUM); 1025 %SetProperty($Number.prototype, "constructor", $Number, DONT_ENUM);
1042 1026
1043 %OptimizeObjectForAddingMultipleProperties($Number, 5); 1027 %OptimizeObjectForAddingMultipleProperties($Number, 5);
1044 // ECMA-262 section 15.7.3.1. 1028 // ECMA-262 section 15.7.3.1.
1045 %SetProperty($Number, 1029 %SetProperty($Number,
(...skipping 20 matching lines...) Expand all
1066 DONT_ENUM | DONT_DELETE | READ_ONLY); 1050 DONT_ENUM | DONT_DELETE | READ_ONLY);
1067 %ToFastProperties($Number); 1051 %ToFastProperties($Number);
1068 1052
1069 // Setup non-enumerable functions on the Number prototype object. 1053 // Setup non-enumerable functions on the Number prototype object.
1070 InstallFunctions($Number.prototype, DONT_ENUM, $Array( 1054 InstallFunctions($Number.prototype, DONT_ENUM, $Array(
1071 "toString", NumberToString, 1055 "toString", NumberToString,
1072 "toLocaleString", NumberToLocaleString, 1056 "toLocaleString", NumberToLocaleString,
1073 "valueOf", NumberValueOf, 1057 "valueOf", NumberValueOf,
1074 "toFixed", NumberToFixed, 1058 "toFixed", NumberToFixed,
1075 "toExponential", NumberToExponential, 1059 "toExponential", NumberToExponential,
1076 "toPrecision", NumberToPrecision, 1060 "toPrecision", NumberToPrecision
1077 "toJSON", NumberToJSON
1078 )); 1061 ));
1079 } 1062 }
1080 1063
1081 SetupNumber(); 1064 SetupNumber();
1082 1065
1083 1066
1084
1085 // ---------------------------------------------------------------------------- 1067 // ----------------------------------------------------------------------------
1086 // Function 1068 // Function
1087 1069
1088 $Function.prototype.constructor = $Function; 1070 $Function.prototype.constructor = $Function;
1089 1071
1090 function FunctionSourceString(func) { 1072 function FunctionSourceString(func) {
1091 if (!IS_FUNCTION(func)) { 1073 if (!IS_FUNCTION(func)) {
1092 throw new $TypeError('Function.prototype.toString is not generic'); 1074 throw new $TypeError('Function.prototype.toString is not generic');
1093 } 1075 }
1094 1076
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
1193 // ---------------------------------------------------------------------------- 1175 // ----------------------------------------------------------------------------
1194 1176
1195 function SetupFunction() { 1177 function SetupFunction() {
1196 InstallFunctions($Function.prototype, DONT_ENUM, $Array( 1178 InstallFunctions($Function.prototype, DONT_ENUM, $Array(
1197 "bind", FunctionBind, 1179 "bind", FunctionBind,
1198 "toString", FunctionToString 1180 "toString", FunctionToString
1199 )); 1181 ));
1200 } 1182 }
1201 1183
1202 SetupFunction(); 1184 SetupFunction();
OLDNEW
« no previous file with comments | « src/v8-counters.h ('k') | src/v8utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698