Revert 7763, missing implementation on x64 and arm for call and apply with null or...
authorricow@chromium.org <ricow@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Tue, 3 May 2011 13:45:19 +0000 (13:45 +0000)
committerricow@chromium.org <ricow@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Tue, 3 May 2011 13:45:19 +0000 (13:45 +0000)
Review URL: http://codereview.chromium.org/6913024

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7764 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/array.js
src/date.js
src/ia32/builtins-ia32.cc
src/messages.js
src/string.js
src/v8natives.js
test/es5conform/es5conform.status
test/mjsunit/function-call.js
test/mjsunit/regress/regress-485.js
test/mozilla/mozilla.status
test/sputnik/sputnik.status

index df080a7..b062083 100644 (file)
@@ -397,11 +397,6 @@ function ArrayToLocaleString() {
 
 
 function ArrayJoin(separator) {
-  if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
-    throw MakeTypeError("called_on_null_or_undefined",
-                        ["Array.prototype.join"]);
-  }
-
   if (IS_UNDEFINED(separator)) {
     separator = ',';
   } else if (!IS_STRING(separator)) {
@@ -418,11 +413,6 @@ function ArrayJoin(separator) {
 // Removes the last element from the array and returns it. See
 // ECMA-262, section 15.4.4.6.
 function ArrayPop() {
-  if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
-    throw MakeTypeError("called_on_null_or_undefined",
-                        ["Array.prototype.pop"]);
-  }
-
   var n = TO_UINT32(this.length);
   if (n == 0) {
     this.length = n;
@@ -439,11 +429,6 @@ function ArrayPop() {
 // Appends the arguments to the end of the array and returns the new
 // length of the array. See ECMA-262, section 15.4.4.7.
 function ArrayPush() {
-  if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
-    throw MakeTypeError("called_on_null_or_undefined",
-                        ["Array.prototype.push"]);
-  }
-
   var n = TO_UINT32(this.length);
   var m = %_ArgumentsLength();
   for (var i = 0; i < m; i++) {
@@ -455,11 +440,6 @@ function ArrayPush() {
 
 
 function ArrayConcat(arg1) {  // length == 1
-  if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
-    throw MakeTypeError("called_on_null_or_undefined",
-                        ["Array.prototype.concat"]);
-  }
-
   var arg_count = %_ArgumentsLength();
   var arrays = new InternalArray(1 + arg_count);
   arrays[0] = this;
@@ -516,11 +496,6 @@ function SparseReverse(array, len) {
 
 
 function ArrayReverse() {
-  if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
-    throw MakeTypeError("called_on_null_or_undefined",
-                        ["Array.prototype.reverse"]);
-  }
-
   var j = TO_UINT32(this.length) - 1;
 
   if (UseSparseVariant(this, j, IS_ARRAY(this))) {
@@ -552,11 +527,6 @@ function ArrayReverse() {
 
 
 function ArrayShift() {
-  if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
-    throw MakeTypeError("called_on_null_or_undefined",
-                        ["Array.prototype.shift"]);
-  }
-
   var len = TO_UINT32(this.length);
 
   if (len === 0) {
@@ -578,11 +548,6 @@ function ArrayShift() {
 
 
 function ArrayUnshift(arg1) {  // length == 1
-  if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
-    throw MakeTypeError("called_on_null_or_undefined",
-                        ["Array.prototype.unshift"]);
-  }
-
   var len = TO_UINT32(this.length);
   var num_arguments = %_ArgumentsLength();
 
@@ -602,11 +567,6 @@ function ArrayUnshift(arg1) {  // length == 1
 
 
 function ArraySlice(start, end) {
-  if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
-    throw MakeTypeError("called_on_null_or_undefined",
-                        ["Array.prototype.slice"]);
-  }
-
   var len = TO_UINT32(this.length);
   var start_i = TO_INTEGER(start);
   var end_i = len;
@@ -644,11 +604,6 @@ function ArraySlice(start, end) {
 
 
 function ArraySplice(start, delete_count) {
-  if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
-    throw MakeTypeError("called_on_null_or_undefined",
-                        ["Array.prototype.splice"]);
-  }
-
   var num_arguments = %_ArgumentsLength();
 
   var len = TO_UINT32(this.length);
@@ -720,11 +675,6 @@ function ArraySplice(start, delete_count) {
 
 
 function ArraySort(comparefn) {
-  if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
-    throw MakeTypeError("called_on_null_or_undefined",
-                        ["Array.prototype.sort"]);
-  }
-
   // In-place QuickSort algorithm.
   // For short (length <= 22) arrays, insertion sort is used for efficiency.
 
@@ -986,11 +936,6 @@ function ArraySort(comparefn) {
 // preserving the semantics, since the calls to the receiver function can add
 // or delete elements from the array.
 function ArrayFilter(f, receiver) {
-  if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
-    throw MakeTypeError("called_on_null_or_undefined",
-                        ["Array.prototype.filter"]);
-  }
-
   if (!IS_FUNCTION(f)) {
     throw MakeTypeError('called_non_callable', [ f ]);
   }
@@ -1012,11 +957,6 @@ function ArrayFilter(f, receiver) {
 
 
 function ArrayForEach(f, receiver) {
-  if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
-    throw MakeTypeError("called_on_null_or_undefined",
-                        ["Array.prototype.forEach"]);
-  }
-
   if (!IS_FUNCTION(f)) {
     throw MakeTypeError('called_non_callable', [ f ]);
   }
@@ -1035,11 +975,6 @@ function ArrayForEach(f, receiver) {
 // Executes the function once for each element present in the
 // array until it finds one where callback returns true.
 function ArraySome(f, receiver) {
-  if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
-    throw MakeTypeError("called_on_null_or_undefined",
-                        ["Array.prototype.some"]);
-  }
-
   if (!IS_FUNCTION(f)) {
     throw MakeTypeError('called_non_callable', [ f ]);
   }
@@ -1057,11 +992,6 @@ function ArraySome(f, receiver) {
 
 
 function ArrayEvery(f, receiver) {
-  if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
-    throw MakeTypeError("called_on_null_or_undefined",
-                        ["Array.prototype.every"]);
-  }
-
   if (!IS_FUNCTION(f)) {
     throw MakeTypeError('called_non_callable', [ f ]);
   }
@@ -1078,11 +1008,6 @@ function ArrayEvery(f, receiver) {
 }
 
 function ArrayMap(f, receiver) {
-  if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
-    throw MakeTypeError("called_on_null_or_undefined",
-                        ["Array.prototype.map"]);
-  }
-
   if (!IS_FUNCTION(f)) {
     throw MakeTypeError('called_non_callable', [ f ]);
   }
@@ -1103,11 +1028,6 @@ function ArrayMap(f, receiver) {
 
 
 function ArrayIndexOf(element, index) {
-  if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
-    throw MakeTypeError("called_on_null_or_undefined",
-                        ["Array.prototype.indexOf"]);
-  }
-
   var length = TO_UINT32(this.length);
   if (length == 0) return -1;
   if (IS_UNDEFINED(index)) {
@@ -1165,11 +1085,6 @@ function ArrayIndexOf(element, index) {
 
 
 function ArrayLastIndexOf(element, index) {
-  if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
-    throw MakeTypeError("called_on_null_or_undefined",
-                        ["Array.prototype.lastIndexOf"]);
-  }
-
   var length = TO_UINT32(this.length);
   if (length == 0) return -1;
   if (%_ArgumentsLength() < 2) {
@@ -1223,11 +1138,6 @@ function ArrayLastIndexOf(element, index) {
 
 
 function ArrayReduce(callback, current) {
-  if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
-    throw MakeTypeError("called_on_null_or_undefined",
-                        ["Array.prototype.reduce"]);
-  }
-
   if (!IS_FUNCTION(callback)) {
     throw MakeTypeError('called_non_callable', [callback]);
   }
@@ -1257,11 +1167,6 @@ function ArrayReduce(callback, current) {
 }
 
 function ArrayReduceRight(callback, current) {
-  if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
-    throw MakeTypeError("called_on_null_or_undefined",
-                        ["Array.prototype.reduceRight"]);
-  }
-
   if (!IS_FUNCTION(callback)) {
     throw MakeTypeError('called_non_callable', [callback]);
   }
index 5a2e9a2..242ab7b 100644 (file)
@@ -684,7 +684,7 @@ function DateGetUTCDate() {
 
 // ECMA 262 - 15.9.5.16
 function DateGetDay() {
-  var t = DATE_VALUE(this);
+  var t = %_ValueOf(this);
   if (NUMBER_IS_NAN(t)) return t;
   return WeekDay(LocalTimeNoCheck(t));
 }
@@ -692,7 +692,7 @@ function DateGetDay() {
 
 // ECMA 262 - 15.9.5.17
 function DateGetUTCDay() {
-  var t = DATE_VALUE(this);
+  var t = %_ValueOf(this);
   if (NUMBER_IS_NAN(t)) return t;
   return WeekDay(t);
 }
index 0906897..29c67b5 100644 (file)
@@ -599,15 +599,6 @@ void Builtins::Generate_FunctionCall(MacroAssembler* masm) {
               1 << SharedFunctionInfo::kStrictModeBitWithinByte);
     __ j(not_equal, &shift_arguments);
 
-    // Do not transform the receiver for natives (shared already in ebx).
-    __ mov(ebx, FieldOperand(ebx, SharedFunctionInfo::kScriptOffset));
-    __ cmp(ebx, factory->undefined_value());
-    __ j(equal, &shift_arguments);
-    __ mov(ebx, FieldOperand(ebx, Script::kTypeOffset));
-    __ SmiUntag(ebx);
-    __ cmp(ebx, Script::TYPE_NATIVE);
-    __ j(equal, &shift_arguments);
-
     // Compute the receiver in non-strict mode.
     __ mov(ebx, Operand(esp, eax, times_4, 0));  // First argument.
     __ test(ebx, Immediate(kSmiTagMask));
@@ -764,20 +755,10 @@ void Builtins::Generate_FunctionApply(MacroAssembler* masm) {
             1 << SharedFunctionInfo::kStrictModeBitWithinByte);
   __ j(not_equal, &push_receiver);
 
-  Factory* factory = masm->isolate()->factory();
-
-  // Do not transform the receiver for natives (shared already in ecx).
-  __ mov(ecx, FieldOperand(ecx, SharedFunctionInfo::kScriptOffset));
-  __ cmp(ecx, factory->undefined_value());
-  __ j(equal, &push_receiver);
-  __ mov(ecx, FieldOperand(ecx, Script::kTypeOffset));
-  __ SmiUntag(ecx);
-  __ cmp(ecx, Script::TYPE_NATIVE);
-  __ j(equal, &push_receiver);
-
   // Compute the receiver in non-strict mode.
   __ test(ebx, Immediate(kSmiTagMask));
   __ j(zero, &call_to_object);
+  Factory* factory = masm->isolate()->factory();
   __ cmp(ebx, factory->null_value());
   __ j(equal, &use_global_receiver);
   __ cmp(ebx, factory->undefined_value());
index 14cedec..fdeae7d 100644 (file)
@@ -207,7 +207,6 @@ function FormatMessage(message) {
       invalid_json:                 ["String '", "%0", "' is not valid JSON"],
       circular_structure:           ["Converting circular structure to JSON"],
       obj_ctor_property_non_object: ["Object.", "%0", " called on non-object"],
-      called_on_null_or_undefined:  ["%0", " called on null or undefined"],
       array_indexof_not_defined:    ["Array.getIndexOf: Argument undefined"],
       object_not_extensible:        ["Can't add property ", "%0", ", object is not extensible"],
       illegal_access:               ["Illegal access"],
@@ -1071,10 +1070,6 @@ function errorToStringDetectCycle() {
 }
 
 function errorToString() {
-  if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
-    throw MakeTypeError("called_on_null_or_undefined",
-                        ["Error.prototype.toString"]);
-  }
   // This helper function is needed because access to properties on
   // the builtins object do not work inside of a catch clause.
   function isCyclicErrorMarker(o) { return o === cyclic_error_marker; }
index bed211a..d8d402c 100644 (file)
@@ -62,10 +62,6 @@ function StringValueOf() {
 
 // ECMA-262, section 15.5.4.4
 function StringCharAt(pos) {
-  if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
-    throw MakeTypeError("called_on_null_or_undefined",
-                        ["String.prototype.charAt"]);
-  }
   var result = %_StringCharAt(this, pos);
   if (%_IsSmi(result)) {
     result = %_StringCharAt(TO_STRING_INLINE(this), TO_INTEGER(pos));
@@ -76,10 +72,6 @@ function StringCharAt(pos) {
 
 // ECMA-262 section 15.5.4.5
 function StringCharCodeAt(pos) {
-  if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
-    throw MakeTypeError("called_on_null_or_undefined",
-                        ["String.prototype.charCodeAt"]);
-  }
   var result = %_StringCharCodeAt(this, pos);
   if (!%_IsSmi(result)) {
     result = %_StringCharCodeAt(TO_STRING_INLINE(this), TO_INTEGER(pos));
@@ -90,9 +82,6 @@ function StringCharCodeAt(pos) {
 
 // ECMA-262, section 15.5.4.6
 function StringConcat() {
-  if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
-    throw MakeTypeError("called_on_null_or_undefined", ["String.prototype.concat"]);
-  }
   var len = %_ArgumentsLength();
   var this_as_string = TO_STRING_INLINE(this);
   if (len === 1) {
@@ -113,10 +102,6 @@ function StringConcat() {
 
 // ECMA-262 section 15.5.4.7
 function StringIndexOf(pattern /* position */) {  // length == 1
-  if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
-    throw MakeTypeError("called_on_null_or_undefined",
-                        ["String.prototype.indexOf"]);
-  }
   var subject = TO_STRING_INLINE(this);
   pattern = TO_STRING_INLINE(pattern);
   var index = 0;
@@ -132,10 +117,6 @@ function StringIndexOf(pattern /* position */) {  // length == 1
 
 // ECMA-262 section 15.5.4.8
 function StringLastIndexOf(pat /* position */) {  // length == 1
-  if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
-    throw MakeTypeError("called_on_null_or_undefined",
-                        ["String.prototype.lastIndexOf"]);
-  }
   var sub = TO_STRING_INLINE(this);
   var subLength = sub.length;
   var pat = TO_STRING_INLINE(pat);
@@ -165,10 +146,6 @@ function StringLastIndexOf(pat /* position */) {  // length == 1
 // This function is implementation specific.  For now, we do not
 // do anything locale specific.
 function StringLocaleCompare(other) {
-  if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
-    throw MakeTypeError("called_on_null_or_undefined",
-                        ["String.prototype.localeCompare"]);
-  }
   if (%_ArgumentsLength() === 0) return 0;
   return %StringLocaleCompare(TO_STRING_INLINE(this), 
                               TO_STRING_INLINE(other));
@@ -177,10 +154,6 @@ function StringLocaleCompare(other) {
 
 // ECMA-262 section 15.5.4.10
 function StringMatch(regexp) {
-  if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
-    throw MakeTypeError("called_on_null_or_undefined",
-                        ["String.prototype.match"]);
-  }
   var subject = TO_STRING_INLINE(this);
   if (IS_REGEXP(regexp)) {
     if (!regexp.global) return RegExpExecNoTests(regexp, subject, 0);
@@ -214,10 +187,6 @@ var reusableMatchInfo = [2, "", "", -1, -1];
 
 // ECMA-262, section 15.5.4.11
 function StringReplace(search, replace) {
-  if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
-    throw MakeTypeError("called_on_null_or_undefined",
-                        ["String.prototype.replace"]);
-  }
   var subject = TO_STRING_INLINE(this);
 
   // Delegate to one of the regular expression variants if necessary.
@@ -498,10 +467,6 @@ function StringReplaceNonGlobalRegExpWithFunction(subject, regexp, replace) {
 
 // ECMA-262 section 15.5.4.12
 function StringSearch(re) {
-  if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
-    throw MakeTypeError("called_on_null_or_undefined",
-                        ["String.prototype.search"]);
-  }
   var regexp;
   if (IS_STRING(re)) {
     regexp = %_GetFromCache(STRING_TO_REGEXP_CACHE_ID, re);
@@ -520,10 +485,6 @@ function StringSearch(re) {
 
 // ECMA-262 section 15.5.4.13
 function StringSlice(start, end) {
-  if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
-    throw MakeTypeError("called_on_null_or_undefined",
-                        ["String.prototype.slice"]);
-  }
   var s = TO_STRING_INLINE(this);
   var s_len = s.length;
   var start_i = TO_INTEGER(start);
@@ -559,10 +520,6 @@ function StringSlice(start, end) {
 
 // ECMA-262 section 15.5.4.14
 function StringSplit(separator, limit) {
-  if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
-    throw MakeTypeError("called_on_null_or_undefined",
-                        ["String.prototype.split"]);
-  }
   var subject = TO_STRING_INLINE(this);
   limit = (IS_UNDEFINED(limit)) ? 0xffffffff : TO_UINT32(limit);
   if (limit === 0) return [];
@@ -656,10 +613,6 @@ function StringSplit(separator, limit) {
 
 // ECMA-262 section 15.5.4.15
 function StringSubstring(start, end) {
-  if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
-    throw MakeTypeError("called_on_null_or_undefined",
-                        ["String.prototype.subString"]);
-  }
   var s = TO_STRING_INLINE(this);
   var s_len = s.length;
 
@@ -693,10 +646,6 @@ function StringSubstring(start, end) {
 
 // This is not a part of ECMA-262.
 function StringSubstr(start, n) {
-  if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
-    throw MakeTypeError("called_on_null_or_undefined",
-                        ["String.prototype.substr"]);
-  }
   var s = TO_STRING_INLINE(this);
   var len;
 
@@ -737,65 +686,37 @@ function StringSubstr(start, n) {
 
 // ECMA-262, 15.5.4.16
 function StringToLowerCase() {
-  if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
-    throw MakeTypeError("called_on_null_or_undefined",
-                        ["String.prototype.toLowerCase"]);
-  }
   return %StringToLowerCase(TO_STRING_INLINE(this));
 }
 
 
 // ECMA-262, 15.5.4.17
 function StringToLocaleLowerCase() {
-  if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
-    throw MakeTypeError("called_on_null_or_undefined",
-                        ["String.prototype.toLocaleLowerCase"]);
-  }
   return %StringToLowerCase(TO_STRING_INLINE(this));
 }
 
 
 // ECMA-262, 15.5.4.18
 function StringToUpperCase() {
-  if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
-    throw MakeTypeError("called_on_null_or_undefined",
-                        ["String.prototype.toUpperCase"]);
-  }
   return %StringToUpperCase(TO_STRING_INLINE(this));
 }
 
 
 // ECMA-262, 15.5.4.19
 function StringToLocaleUpperCase() {
-  if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
-    throw MakeTypeError("called_on_null_or_undefined",
-                        ["String.prototype.toLocaleUpperCase"]);
-  }
   return %StringToUpperCase(TO_STRING_INLINE(this));
 }
 
 // ES5, 15.5.4.20
 function StringTrim() {
-  if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
-    throw MakeTypeError("called_on_null_or_undefined",
-                        ["String.prototype.trim"]);
-  }
   return %StringTrim(TO_STRING_INLINE(this), true, true);
 }
 
 function StringTrimLeft() {
-  if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
-    throw MakeTypeError("called_on_null_or_undefined",
-                        ["String.prototype.trimLeft"]);
-  }
   return %StringTrim(TO_STRING_INLINE(this), true, false);
 }
 
 function StringTrimRight() {
-  if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
-    throw MakeTypeError("called_on_null_or_undefined",
-                        ["String.prototype.trimRight"]);
-  }
   return %StringTrim(TO_STRING_INLINE(this), false, true);
 }
 
index 7a4be27..4fcf0ac 100644 (file)
@@ -208,20 +208,12 @@ $Object.prototype.constructor = $Object;
 
 // ECMA-262 - 15.2.4.2
 function ObjectToString() {
-  if (IS_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
-    return '[object Undefined]';
-  }
-  if (IS_NULL(this)) return  '[object Null]';
   return "[object " + %_ClassOf(ToObject(this)) + "]";
 }
 
 
 // ECMA-262 - 15.2.4.3
 function ObjectToLocaleString() {
-  if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
-    throw MakeTypeError("called_on_null_or_undefined",
-                        ["Object.prototype.toLocaleString"]);
-  }
   return this.toString();
 }
 
@@ -240,10 +232,6 @@ function ObjectHasOwnProperty(V) {
 
 // ECMA-262 - 15.2.4.6
 function ObjectIsPrototypeOf(V) {
-  if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
-    throw MakeTypeError("called_on_null_or_undefined",
-                        ["Object.prototype.isPrototypeOf"]);
-  }
   if (!IS_SPEC_OBJECT(V)) return false;
   return %IsInPrototypeChain(this, V);
 }
@@ -1074,10 +1062,6 @@ function NumberToString(radix) {
 
 // ECMA-262 section 15.7.4.3
 function NumberToLocaleString() {
-  if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
-    throw MakeTypeError("called_on_null_or_undefined",
-                        ["Number.prototype.toLocaleString"]);
-  }
   return this.toString();
 }
 
@@ -1098,10 +1082,6 @@ function NumberToFixed(fractionDigits) {
   if (f < 0 || f > 20) {
     throw new $RangeError("toFixed() digits argument must be between 0 and 20");
   }
-  if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
-    throw MakeTypeError("called_on_null_or_undefined",
-                        ["Number.prototype.toFixed"]);
-  }
   var x = ToNumber(this);
   return %NumberToFixed(x, f);
 }
@@ -1116,10 +1096,6 @@ function NumberToExponential(fractionDigits) {
       throw new $RangeError("toExponential() argument must be between 0 and 20");
     }
   }
-  if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
-    throw MakeTypeError("called_on_null_or_undefined",
-                        ["Number.prototype.toExponential"]);
-  }
   var x = ToNumber(this);
   return %NumberToExponential(x, f);
 }
@@ -1127,10 +1103,6 @@ function NumberToExponential(fractionDigits) {
 
 // ECMA-262 section 15.7.4.7
 function NumberToPrecision(precision) {
-  if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
-    throw MakeTypeError("called_on_null_or_undefined",
-                        ["Number.prototype.toPrecision"]);
-  }
   if (IS_UNDEFINED(precision)) return ToString(%_ValueOf(this));
   var p = TO_INTEGER(precision);
   if (p < 1 || p > 21) {
index 55712ba..1dc90d3 100644 (file)
@@ -172,6 +172,14 @@ chapter15/15.2/15.2.3/15.2.3.4/15.2.3.4-4-34: FAIL_OK
 # SUBSETFAIL
 chapter15/15.2/15.2.3/15.2.3.4/15.2.3.4-4-35: FAIL_OK
 
+# Bad test - the spec does not say anything about throwing errors
+# on calling Array.prototype.indexOf with undefined as argument.
+chapter15/15.4/15.4.4/15.4.4.14/15.4.4.14-1-1: FAIL_OK
+
+# Bad test - the spec does not say anything about throwing errors
+# on calling Array.prototype.indexOf with null as argument.
+chapter15/15.4/15.4.4/15.4.4.14/15.4.4.14-1-2: FAIL_OK
+
 # Bad test - the test at the end should be "i === true".
 chapter15/15.4/15.4.4/15.4.4.17/15.4.4.17-8-10: FAIL_OK
 
@@ -196,6 +204,10 @@ chapter15/15.4/15.4.4/15.4.4.22/15.4.4.22-9-c-ii-4-s: SKIP
 # have no effect on the actual array on which reduceRight is called.
 chapter15/15.4/15.4.4/15.4.4.22/15.4.4.22-9-7: FAIL_OK
 
+# We do not implement trim correctly on null and undefined.
+chapter15/15.5/15.5.4/15.5.4.20/15.5.4.20-1-1: FAIL
+chapter15/15.5/15.5.4/15.5.4.20/15.5.4.20-1-2: FAIL
+
 # We do not correctly recognize \uFEFF as whitespace
 chapter15/15.5/15.5.4/15.5.4.20/15.5.4.20-4-10: FAIL
 chapter15/15.5/15.5.4/15.5.4.20/15.5.4.20-4-18: FAIL
index 1a118a2..e69de29 100644 (file)
@@ -1,326 +0,0 @@
-// Copyright 2011 the V8 project authors. All rights reserved.
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//     * Redistributions of source code must retain the above copyright
-//       notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-//       copyright notice, this list of conditions and the following
-//       disclaimer in the documentation and/or other materials provided
-//       with the distribution.
-//     * Neither the name of Google Inc. nor the names of its
-//       contributors may be used to endorse or promote products derived
-//       from this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
-var should_throw_on_null_and_undefined =
-    [Object.prototype.toLocaleString,
-     Object.prototype.valueOf,
-     Object.prototype.hasOwnProperty,
-     Object.prototype.isPrototypeOf,
-     Object.prototype.propertyIsEnumerable,
-     Array.prototype.toString,
-     Array.prototype.toLocaleString,
-     Array.prototype.concat,
-     Array.prototype.join,
-     Array.prototype.pop,
-     Array.prototype.push,
-     Array.prototype.reverse,
-     Array.prototype.shift,
-     Array.prototype.slice,
-     Array.prototype.sort,
-     Array.prototype.splice,
-     Array.prototype.unshift,
-     Array.prototype.indexOf,
-     Array.prototype.lastIndexOf,
-     Array.prototype.every,
-     Array.prototype.some,
-     Array.prototype.forEach,
-     Array.prototype.map,
-     Array.prototype.filter,
-     Array.prototype.reduce,
-     Array.prototype.reduceRight,
-     String.prototype.charAt,
-     String.prototype.charCodeAt,
-     String.prototype.concat,
-     String.prototype.indexOf,
-     String.prototype.lastIndexOf,
-     String.prototype.localeCompare,
-     String.prototype.match,
-     String.prototype.replace,
-     String.prototype.search,
-     String.prototype.slice,
-     String.prototype.split,
-     String.prototype.substring,
-     String.prototype.toLowerCase,
-     String.prototype.toLocaleLowerCase,
-     String.prototype.toUpperCase,
-     String.prototype.toLocaleUpperCase,
-     String.prototype.trim,
-     Number.prototype.toLocaleString,
-     Error.prototype.toString];
-
-// Non generic natives does not work on any input other than the specific
-// type, but since this change will allow call to be invoked with undefined
-// or null as this we still explicitly test that we throw on these here.
-var non_generic =
-    [Function.prototype.toString,
-     Function.prototype.call,
-     Function.prototype.apply,
-     String.prototype.toString,
-     String.prototype.valueOf,
-     Boolean.prototype.toString,
-     Boolean.prototype.valueOf,
-     Number.prototype.toString,
-     Number.prototype.valueOf,
-     Number.prototype.toFixed,
-     Number.prototype.toExponential,
-     Number.prototype.toPrecision,
-     Date.prototype.toString,
-     Date.prototype.toDateString,
-     Date.prototype.toTimeString,
-     Date.prototype.toLocaleString,
-     Date.prototype.toLocaleDateString,
-     Date.prototype.toLocaleTimeString,
-     Date.prototype.valueOf,
-     Date.prototype.getTime,
-     Date.prototype.getFullYear,
-     Date.prototype.getUTCFullYear,
-     Date.prototype.getMonth,
-     Date.prototype.getUTCMonth,
-     Date.prototype.getDate,
-     Date.prototype.getUTCDate,
-     Date.prototype.getDay,
-     Date.prototype.getUTCDay,
-     Date.prototype.getHours,
-     Date.prototype.getUTCHours,
-     Date.prototype.getMinutes,
-     Date.prototype.getUTCMinutes,
-     Date.prototype.getSeconds,
-     Date.prototype.getUTCSeconds,
-     Date.prototype.getMilliseconds,
-     Date.prototype.getUTCMilliseconds,
-     Date.prototype.getTimezoneOffset,
-     Date.prototype.setTime,
-     Date.prototype.setMilliseconds,
-     Date.prototype.setUTCMilliseconds,
-     Date.prototype.setSeconds,
-     Date.prototype.setUTCSeconds,
-     Date.prototype.setMinutes,
-     Date.prototype.setUTCMinutes,
-     Date.prototype.setHours,
-     Date.prototype.setUTCHours,
-     Date.prototype.setDate,
-     Date.prototype.setUTCDate,
-     Date.prototype.setMonth,
-     Date.prototype.setUTCMonth,
-     Date.prototype.setFullYear,
-     Date.prototype.setUTCFullYear,
-     Date.prototype.toUTCString,
-     Date.prototype.toISOString,
-     Date.prototype.toJSON,
-     RegExp.prototype.exec,
-     RegExp.prototype.test,
-     RegExp.prototype.toString];
-
-
-// Mapping functions.
-var mapping_functions =
-    [Array.prototype.every,
-     Array.prototype.some,
-     Array.prototype.forEach,
-     Array.prototype.map,
-     Array.prototype.filter];
-
-// Reduce functions.
-var reducing_functions =
-    [Array.prototype.reduce,
-     Array.prototype.reduceRight];
-
-// Test that all natives using the ToObject call throws the right exception.
-for (var i = 0; i < should_throw_on_null_and_undefined.length; i++) {
-  // Sanity check that all functions are correct
-  assertEquals(typeof(should_throw_on_null_and_undefined[i]), "function");
-
-  try {
-    // We call all functions with no parameters, which means that essential
-    // parameters will have the undefined value.
-    // The test for whether the "this" value is null or undefined is always
-    // performed before access to the other parameters, so even if the
-    // undefined value is an invalid argument value, it mustn't change
-    // the result of the test.
-    should_throw_on_null_and_undefined[i].call(null);
-    assertUnreachable();
-  } catch (e) {
-    assertTrue("called_on_null_or_undefined" == e.type ||
-               "null_to_object" == e.type);
-  }
-
-  try {
-    should_throw_on_null_and_undefined[i].call(undefined);
-    assertUnreachable();
-  } catch (e) {
-    assertTrue("called_on_null_or_undefined" == e.type ||
-               "null_to_object" == e.type);
-  }
-
-  try {
-    should_throw_on_null_and_undefined[i].apply(null);
-    assertUnreachable();
-  } catch (e) {
-    assertTrue("called_on_null_or_undefined" == e.type ||
-               "null_to_object" == e.type);
-  }
-
-  try {
-    should_throw_on_null_and_undefined[i].apply(undefined);
-    assertUnreachable();
-  } catch (e) {
-    assertTrue("called_on_null_or_undefined" == e.type ||
-               "null_to_object" == e.type);
-  }
-}
-
-// Test that all natives that are non generic throws on null and undefined.
-for (var i = 0; i < non_generic.length; i++) {
-  // Sanity check that all functions are correct
-  assertEquals(typeof(non_generic[i]), "function");
-  try {
-    non_generic[i].call(null);
-    assertUnreachable();
-  } catch (e) {
-    assertTrue(e instanceof TypeError);
-  }
-
-  try {
-    non_generic[i].call(null);
-    assertUnreachable();
-  } catch (e) {
-    assertTrue(e instanceof TypeError);
-  }
-
-  try {
-    non_generic[i].apply(null);
-    assertUnreachable();
-  } catch (e) {
-    assertTrue(e instanceof TypeError);
-  }
-
-  try {
-    non_generic[i].apply(null);
-    assertUnreachable();
-  } catch (e) {
-    assertTrue(e instanceof TypeError);
-  }
-}
-
-
-// Test that we still throw when calling with thisArg null or undefined
-// through an array mapping function.
-var array = [1,2,3,4,5];
-for (var j = 0; j < mapping_functions.length; j++) {
-  for (var i = 0; i < should_throw_on_null_and_undefined.length; i++) {
-    try {
-      mapping_functions[j].call(array,
-                                should_throw_on_null_and_undefined[i],
-                                null);
-      assertUnreachable();
-    } catch (e) {
-      assertTrue("called_on_null_or_undefined" == e.type ||
-                 "null_to_object" == e.type);
-    }
-
-    try {
-      mapping_functions[j].call(array,
-                                should_throw_on_null_and_undefined[i],
-                                undefined);
-      assertUnreachable();
-    } catch (e) {
-      assertTrue("called_on_null_or_undefined" == e.type ||
-                 "null_to_object" == e.type);
-    }
-  }
-}
-
-for (var j = 0; j < mapping_functions.length; j++) {
-  for (var i = 0; i < non_generic.length; i++) {
-    try {
-      mapping_functions[j].call(array,
-                                non_generic[i],
-                                null);
-      assertUnreachable();
-    } catch (e) {
-      assertTrue(e instanceof TypeError);
-    }
-
-    try {
-      mapping_functions[j].call(array,
-                                non_generic[i],
-                                undefined);
-      assertUnreachable();
-    } catch (e) {
-      assertTrue(e instanceof TypeError);
-    }
-  }
-}
-
-
-// Reduce functions do a call with null as this argument.
-for (var j = 0; j < reducing_functions.length; j++) {
-  for (var i = 0; i < should_throw_on_null_and_undefined.length; i++) {
-    try {
-      reducing_functions[j].call(array, should_throw_on_null_and_undefined[i]);
-      assertUnreachable();
-    } catch (e) {
-      assertTrue("called_on_null_or_undefined" == e.type ||
-                 "null_to_object" == e.type);
-    }
-
-    try {
-      reducing_functions[j].call(array, should_throw_on_null_and_undefined[i]);
-      assertUnreachable();
-    } catch (e) {
-      assertTrue("called_on_null_or_undefined" == e.type ||
-                 "null_to_object" == e.type);
-    }
-  }
-}
-
-for (var j = 0; j < reducing_functions.length; j++) {
-  for (var i = 0; i < non_generic.length; i++) {
-    try {
-      reducing_functions[j].call(array, non_generic[i]);
-      assertUnreachable();
-    } catch (e) {
-      assertTrue(e instanceof TypeError);
-    }
-
-    try {
-      reducing_functions[j].call(array, non_generic[i]);
-      assertUnreachable();
-    } catch (e) {
-      assertTrue(e instanceof TypeError);
-    }
-  }
-}
-
-
-// Object.prototype.toString()
-assertEquals(Object.prototype.toString.call(null),
-             '[object Null]')
-
-assertEquals(Object.prototype.toString.call(undefined),
-             '[object Undefined]')
index e5182b3..62c6fb9 100755 (executable)
@@ -38,6 +38,19 @@ var builtin = Object.prototype.valueOf;  // Builtin function that returns this.
 
 assertEquals(global, builtin(), "Direct call to builtin");
 
+assertEquals(global, builtin.call(), "call() to builtin");
+assertEquals(global, builtin.call(null), "call(null) to builtin");
+assertEquals(global, builtin.call(undefined), "call(undefined) to builtin");
+
+assertEquals(global, builtin.apply(), "apply() to builtin");
+assertEquals(global, builtin.apply(null), "apply(null) to builtin");
+assertEquals(global, builtin.apply(undefined), "apply(undefined) to builtin");
+
+assertEquals(global, builtin.call.call(builtin), "call.call() to builtin");
+assertEquals(global, builtin.call.apply(builtin), "call.apply() to builtin");
+assertEquals(global, builtin.apply.call(builtin), "apply.call() to builtin");
+assertEquals(global, builtin.apply.apply(builtin), "apply.apply() to builtin");
+
 
 // Builtin that depends on value of this to compute result.
 var builtin2 = Object.prototype.toString;
index e281e67..b9528bd 100644 (file)
@@ -610,9 +610,6 @@ js1_5/Regress/regress-306633: FAIL
 # We fail on out of memory.  The important thing is not to crash.
 js1_5/Regress/regress-303213: FAIL || TIMEOUT if $mode == debug
 
-# This test fails since we now throw in String.prototype.match when apply
-# is given null or undefined as this argument (and so does firefox nightly).
-js1_5/Regress/regress-295052: FAIL
 
 # Bug 1202592: New ecma_3/String/15.5.4.11 is failing.
 ecma_3/String/15.5.4.11: FAIL
index f322840..6da87ea 100644 (file)
@@ -179,6 +179,7 @@ S11.1.5_A4.2: FAIL_OK
 S9.9_A1: FAIL_OK
 S9.9_A2: FAIL_OK
 
+
 ##################### SKIPPED TESTS #####################
 
 # These tests take a looong time to run in debug mode.
@@ -188,6 +189,26 @@ S15.1.3.1_A2.5_T1: PASS, SKIP if $mode == debug
 # V8 Bug: http://code.google.com/p/v8/issues/detail?id=1196
 S8.7_A5_T2: FAIL
 
+# V8 bugs: http://code.google.com/p/v8/issues/detail?id=1198
+# V8 should not wrap this when calling builtin functions
+S15.2.4.3_A12: FAIL
+S15.2.4.7_A13: FAIL
+# Object.prototype.toString
+S15.2.4.2_A12: FAIL
+S15.2.4.2_A13: FAIL
+# Object.prototype.toLocaleString
+S15.2.4.3_A13: FAIL
+S15.2.4.4_A13: FAIL
+S15.2.4.4_A12: FAIL
+# Object.prototype.propertyIsEnumerable
+S15.2.4.7_A12: FAIL
+# Object.prototype.hasOwnProperty
+S15.2.4.5_A12: FAIL
+S15.2.4.5_A13: FAIL
+# Object.prototype.isPrototypeOf
+S15.2.4.6_A13: FAIL
+S15.2.4.6_A12: FAIL
+
 # Invalid test case (recent change adding var changes semantics)
 S8.3_A1_T1: FAIL
 # Test bug: http://code.google.com/p/sputniktests/issues/detail?id=35
@@ -249,7 +270,6 @@ S11.4.3_A3.6: FAIL_OK
 S15.10.7_A3_T2: FAIL_OK
 S15.10.7_A3_T1: FAIL_OK
 
-
 [ $arch == arm ]
 
 # BUG(3251225): Tests that timeout with --nocrankshaft.