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

Unified Diff: src/typedarray.js

Issue 148153010: Synchronize with r15701. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/type-info.cc ('k') | src/types.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/typedarray.js
diff --git a/src/typedarray.js b/src/typedarray.js
index 57d0c60f9ba00dfd4a00e1649d872057d76269f8..a7421ae1c97823dc3f1a8fb9a705e273c69f02ed 100644
--- a/src/typedarray.js
+++ b/src/typedarray.js
@@ -154,7 +154,14 @@ function TypedArraySet(obj, offset) {
var l = obj.length;
if (IS_UNDEFINED(l)) {
- throw MakeTypeError("invalid_argument");
+ if (IS_NUMBER(obj)) {
+ // For number as a first argument, throw TypeError
+ // instead of silently ignoring the call, so that
+ // the user knows (s)he did something wrong.
+ // (Consistent with Firefox and Blink/WebKit)
+ throw MakeTypeError("invalid_argument");
+ }
+ return;
}
if (intOffset + l > this.length) {
throw MakeRangeError("typed_array_set_source_too_large");
@@ -259,6 +266,9 @@ function DataViewGetInt8(offset, little_endian) {
throw MakeTypeError('incompatible_method_reciever',
['DataView.getInt8', this]);
}
+ if (%_ArgumentsLength() < 1) {
+ throw MakeTypeError('invalid_argument');
+ }
return %DataViewGetInt8(this,
ToPositiveDataViewOffset(offset),
!!little_endian);
@@ -269,6 +279,9 @@ function DataViewSetInt8(offset, value, little_endian) {
throw MakeTypeError('incompatible_method_reciever',
['DataView.setInt8', this]);
}
+ if (%_ArgumentsLength() < 1) {
+ throw MakeTypeError('invalid_argument');
+ }
%DataViewSetInt8(this,
ToPositiveDataViewOffset(offset),
TO_NUMBER_INLINE(value),
@@ -280,6 +293,9 @@ function DataViewGetUint8(offset, little_endian) {
throw MakeTypeError('incompatible_method_reciever',
['DataView.getUint8', this]);
}
+ if (%_ArgumentsLength() < 1) {
+ throw MakeTypeError('invalid_argument');
+ }
return %DataViewGetUint8(this,
ToPositiveDataViewOffset(offset),
!!little_endian);
@@ -290,6 +306,9 @@ function DataViewSetUint8(offset, value, little_endian) {
throw MakeTypeError('incompatible_method_reciever',
['DataView.setUint8', this]);
}
+ if (%_ArgumentsLength() < 1) {
+ throw MakeTypeError('invalid_argument');
+ }
%DataViewSetUint8(this,
ToPositiveDataViewOffset(offset),
TO_NUMBER_INLINE(value),
@@ -301,6 +320,9 @@ function DataViewGetInt16(offset, little_endian) {
throw MakeTypeError('incompatible_method_reciever',
['DataView.getInt16', this]);
}
+ if (%_ArgumentsLength() < 1) {
+ throw MakeTypeError('invalid_argument');
+ }
return %DataViewGetInt16(this,
ToPositiveDataViewOffset(offset),
!!little_endian);
@@ -311,6 +333,9 @@ function DataViewSetInt16(offset, value, little_endian) {
throw MakeTypeError('incompatible_method_reciever',
['DataView.setInt16', this]);
}
+ if (%_ArgumentsLength() < 1) {
+ throw MakeTypeError('invalid_argument');
+ }
%DataViewSetInt16(this,
ToPositiveDataViewOffset(offset),
TO_NUMBER_INLINE(value),
@@ -322,6 +347,9 @@ function DataViewGetUint16(offset, little_endian) {
throw MakeTypeError('incompatible_method_reciever',
['DataView.getUint16', this]);
}
+ if (%_ArgumentsLength() < 1) {
+ throw MakeTypeError('invalid_argument');
+ }
return %DataViewGetUint16(this,
ToPositiveDataViewOffset(offset),
!!little_endian);
@@ -332,6 +360,9 @@ function DataViewSetUint16(offset, value, little_endian) {
throw MakeTypeError('incompatible_method_reciever',
['DataView.setUint16', this]);
}
+ if (%_ArgumentsLength() < 1) {
+ throw MakeTypeError('invalid_argument');
+ }
%DataViewSetUint16(this,
ToPositiveDataViewOffset(offset),
TO_NUMBER_INLINE(value),
@@ -343,6 +374,9 @@ function DataViewGetInt32(offset, little_endian) {
throw MakeTypeError('incompatible_method_reciever',
['DataView.getInt32', this]);
}
+ if (%_ArgumentsLength() < 1) {
+ throw MakeTypeError('invalid_argument');
+ }
return %DataViewGetInt32(this,
ToPositiveDataViewOffset(offset),
!!little_endian);
@@ -353,6 +387,9 @@ function DataViewSetInt32(offset, value, little_endian) {
throw MakeTypeError('incompatible_method_reciever',
['DataView.setInt32', this]);
}
+ if (%_ArgumentsLength() < 2) {
+ throw MakeTypeError('invalid_argument');
+ }
%DataViewSetInt32(this,
ToPositiveDataViewOffset(offset),
TO_NUMBER_INLINE(value),
@@ -364,6 +401,9 @@ function DataViewGetUint32(offset, little_endian) {
throw MakeTypeError('incompatible_method_reciever',
['DataView.getUint32', this]);
}
+ if (%_ArgumentsLength() < 1) {
+ throw MakeTypeError('invalid_argument');
+ }
return %DataViewGetUint32(this,
ToPositiveDataViewOffset(offset),
!!little_endian);
@@ -374,6 +414,9 @@ function DataViewSetUint32(offset, value, little_endian) {
throw MakeTypeError('incompatible_method_reciever',
['DataView.setUint32', this]);
}
+ if (%_ArgumentsLength() < 1) {
+ throw MakeTypeError('invalid_argument');
+ }
%DataViewSetUint32(this,
ToPositiveDataViewOffset(offset),
TO_NUMBER_INLINE(value),
@@ -385,6 +428,9 @@ function DataViewGetFloat32(offset, little_endian) {
throw MakeTypeError('incompatible_method_reciever',
['DataView.getFloat32', this]);
}
+ if (%_ArgumentsLength() < 1) {
+ throw MakeTypeError('invalid_argument');
+ }
return %DataViewGetFloat32(this,
ToPositiveDataViewOffset(offset),
!!little_endian);
@@ -395,6 +441,9 @@ function DataViewSetFloat32(offset, value, little_endian) {
throw MakeTypeError('incompatible_method_reciever',
['DataView.setFloat32', this]);
}
+ if (%_ArgumentsLength() < 1) {
+ throw MakeTypeError('invalid_argument');
+ }
%DataViewSetFloat32(this,
ToPositiveDataViewOffset(offset),
TO_NUMBER_INLINE(value),
@@ -406,9 +455,8 @@ function DataViewGetFloat64(offset, little_endian) {
throw MakeTypeError('incompatible_method_reciever',
['DataView.getFloat64', this]);
}
- offset = TO_INTEGER(offset);
- if (offset < 0) {
- throw MakeRangeError("invalid_data_view_accessor_offset");
+ if (%_ArgumentsLength() < 1) {
+ throw MakeTypeError('invalid_argument');
}
return %DataViewGetFloat64(this,
ToPositiveDataViewOffset(offset),
@@ -420,9 +468,8 @@ function DataViewSetFloat64(offset, value, little_endian) {
throw MakeTypeError('incompatible_method_reciever',
['DataView.setFloat64', this]);
}
- offset = TO_INTEGER(offset);
- if (offset < 0) {
- throw MakeRangeError("invalid_data_view_accessor_offset");
+ if (%_ArgumentsLength() < 1) {
+ throw MakeTypeError('invalid_argument');
}
%DataViewSetFloat64(this,
ToPositiveDataViewOffset(offset),
« no previous file with comments | « src/type-info.cc ('k') | src/types.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698