Commit 166b0c83 authored by yangguo@chromium.org's avatar yangguo@chromium.org

Use %_IsSmi instead of %MaxSmi.

ToPositiveInteger already makes sure that if l can be represented as a
smi, it will be represented as a smi.  This way we can avoid doing a
runtime call to retrieve a constant.

R=dslomov@chromium.org

Review URL: https://codereview.chromium.org/81063002

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@17983 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 8e266c22
...@@ -86,8 +86,8 @@ macro TYPED_ARRAY_CONSTRUCTOR(ARRAY_ID, NAME, ELEMENT_SIZE) ...@@ -86,8 +86,8 @@ macro TYPED_ARRAY_CONSTRUCTOR(ARRAY_ID, NAME, ELEMENT_SIZE)
function NAMEConstructByLength(obj, length) { function NAMEConstructByLength(obj, length) {
var l = IS_UNDEFINED(length) ? var l = IS_UNDEFINED(length) ?
0 : ToPositiveInteger(length, "invalid_typed_array_length"); 0 : ToPositiveInteger(length, "invalid_typed_array_length");
if (l > %MaxSmi()) { if (!%_IsSmi(l)) {
throw MakeRangeError("invalid_typed_array_length"); throw MakeRangeError("invalid_typed_array_length");
} }
var byteLength = l * ELEMENT_SIZE; var byteLength = l * ELEMENT_SIZE;
...@@ -98,7 +98,7 @@ macro TYPED_ARRAY_CONSTRUCTOR(ARRAY_ID, NAME, ELEMENT_SIZE) ...@@ -98,7 +98,7 @@ macro TYPED_ARRAY_CONSTRUCTOR(ARRAY_ID, NAME, ELEMENT_SIZE)
function NAMEConstructByArrayLike(obj, arrayLike) { function NAMEConstructByArrayLike(obj, arrayLike) {
var length = arrayLike.length; var length = arrayLike.length;
var l = ToPositiveInteger(length, "invalid_typed_array_length"); var l = ToPositiveInteger(length, "invalid_typed_array_length");
if(!%TypedArrayInitializeFromArrayLike(obj, ARRAY_ID, arrayLike, l)) { if (!%TypedArrayInitializeFromArrayLike(obj, ARRAY_ID, arrayLike, l)) {
for (var i = 0; i < l; i++) { for (var i = 0; i < l; i++) {
// It is crucial that we let any execptions from arrayLike[i] // It is crucial that we let any execptions from arrayLike[i]
// propagate outside the function. // propagate outside the function.
...@@ -108,7 +108,6 @@ macro TYPED_ARRAY_CONSTRUCTOR(ARRAY_ID, NAME, ELEMENT_SIZE) ...@@ -108,7 +108,6 @@ macro TYPED_ARRAY_CONSTRUCTOR(ARRAY_ID, NAME, ELEMENT_SIZE)
} }
function NAMEConstructor(arg1, arg2, arg3) { function NAMEConstructor(arg1, arg2, arg3) {
if (%_IsConstructCall()) { if (%_IsConstructCall()) {
if (IS_ARRAYBUFFER(arg1)) { if (IS_ARRAYBUFFER(arg1)) {
NAMEConstructByArrayBuffer(this, arg1, arg2, arg3); NAMEConstructByArrayBuffer(this, arg1, arg2, arg3);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment