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

Side by Side Diff: src/js/typedarray.js

Issue 2778623003: [typedarrays] Check detached buffer at start of typed array methods (Closed)
Patch Set: pass test262 for subarray Created 3 years, 8 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/crankshaft/hydrogen.cc ('k') | src/objects-inl.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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 (function(global, utils) { 5 (function(global, utils) {
6 6
7 "use strict"; 7 "use strict";
8 8
9 %CheckIsBootstrapping(); 9 %CheckIsBootstrapping();
10 10
11 // ------------------------------------------------------------------- 11 // -------------------------------------------------------------------
12 // Imports 12 // Imports
13 13
14 // array.js has to come before typedarray.js for this to work 14 // array.js has to come before typedarray.js for this to work
15 var ArrayToString = utils.ImportNow("ArrayToString"); 15 var ArrayToString = utils.ImportNow("ArrayToString");
16 var ArrayValues;
17 var GetIterator; 16 var GetIterator;
18 var GetMethod; 17 var GetMethod;
19 var GlobalArray = global.Array; 18 var GlobalArray = global.Array;
20 var GlobalArrayBuffer = global.ArrayBuffer; 19 var GlobalArrayBuffer = global.ArrayBuffer;
21 var GlobalArrayBufferPrototype = GlobalArrayBuffer.prototype; 20 var GlobalArrayBufferPrototype = GlobalArrayBuffer.prototype;
22 var GlobalObject = global.Object; 21 var GlobalObject = global.Object;
23 var InnerArrayFilter; 22 var InnerArrayFilter;
24 var InnerArrayFind; 23 var InnerArrayFind;
25 var InnerArrayFindIndex; 24 var InnerArrayFindIndex;
26 var InnerArrayJoin; 25 var InnerArrayJoin;
(...skipping 22 matching lines...) Expand all
49 48
50 macro DECLARE_GLOBALS(NAME, SIZE) 49 macro DECLARE_GLOBALS(NAME, SIZE)
51 var GlobalNAME = global.NAME; 50 var GlobalNAME = global.NAME;
52 endmacro 51 endmacro
53 52
54 TYPED_ARRAYS(DECLARE_GLOBALS) 53 TYPED_ARRAYS(DECLARE_GLOBALS)
55 54
56 var GlobalTypedArray = %object_get_prototype_of(GlobalUint8Array); 55 var GlobalTypedArray = %object_get_prototype_of(GlobalUint8Array);
57 56
58 utils.Import(function(from) { 57 utils.Import(function(from) {
59 ArrayValues = from.ArrayValues;
60 GetIterator = from.GetIterator; 58 GetIterator = from.GetIterator;
61 GetMethod = from.GetMethod; 59 GetMethod = from.GetMethod;
62 InnerArrayFilter = from.InnerArrayFilter; 60 InnerArrayFilter = from.InnerArrayFilter;
63 InnerArrayFind = from.InnerArrayFind; 61 InnerArrayFind = from.InnerArrayFind;
64 InnerArrayFindIndex = from.InnerArrayFindIndex; 62 InnerArrayFindIndex = from.InnerArrayFindIndex;
65 InnerArrayJoin = from.InnerArrayJoin; 63 InnerArrayJoin = from.InnerArrayJoin;
66 InnerArraySort = from.InnerArraySort; 64 InnerArraySort = from.InnerArraySort;
67 InnerArrayToLocaleString = from.InnerArrayToLocaleString; 65 InnerArrayToLocaleString = from.InnerArrayToLocaleString;
68 MaxSimple = from.MaxSimple; 66 MaxSimple = from.MaxSimple;
69 MinSimple = from.MinSimple; 67 MinSimple = from.MinSimple;
70 SpeciesConstructor = from.SpeciesConstructor; 68 SpeciesConstructor = from.SpeciesConstructor;
71 ToPositiveInteger = from.ToPositiveInteger; 69 ToPositiveInteger = from.ToPositiveInteger;
72 ToIndex = from.ToIndex; 70 ToIndex = from.ToIndex;
73 }); 71 });
74 72
75 // --------------- Typed Arrays --------------------- 73 // --------------- Typed Arrays ---------------------
76 74
75 // ES6 section 22.2.3.5.1 ValidateTypedArray ( O )
76 function ValidateTypedArray(array, methodName) {
77 if (!IS_TYPEDARRAY(array)) throw %make_type_error(kNotTypedArray);
78
79 if (%_ArrayBufferViewWasNeutered(array))
80 throw %make_type_error(kDetachedOperation, methodName);
81 }
82
77 function TypedArrayDefaultConstructor(typedArray) { 83 function TypedArrayDefaultConstructor(typedArray) {
78 switch (%_ClassOf(typedArray)) { 84 switch (%_ClassOf(typedArray)) {
79 macro TYPED_ARRAY_CONSTRUCTOR_CASE(NAME, ELEMENT_SIZE) 85 macro TYPED_ARRAY_CONSTRUCTOR_CASE(NAME, ELEMENT_SIZE)
80 case "NAME": 86 case "NAME":
81 return GlobalNAME; 87 return GlobalNAME;
82 endmacro 88 endmacro
83 TYPED_ARRAYS(TYPED_ARRAY_CONSTRUCTOR_CASE) 89 TYPED_ARRAYS(TYPED_ARRAY_CONSTRUCTOR_CASE)
84 } 90 }
85 // The TypeError should not be generated since all callers should 91 // The TypeError should not be generated since all callers should
86 // have already called ValidateTypedArray. 92 // have already called ValidateTypedArray.
87 throw %make_type_error(kIncompatibleMethodReceiver, 93 throw %make_type_error(kIncompatibleMethodReceiver,
88 "TypedArrayDefaultConstructor", this); 94 "TypedArrayDefaultConstructor", this);
89 } 95 }
90 96
91 function TypedArrayCreate(constructor, arg0, arg1, arg2) { 97 function TypedArrayCreate(constructor, arg0, arg1, arg2) {
92 if (IS_UNDEFINED(arg1)) { 98 if (IS_UNDEFINED(arg1)) {
93 var newTypedArray = new constructor(arg0); 99 var newTypedArray = new constructor(arg0);
94 } else { 100 } else {
95 var newTypedArray = new constructor(arg0, arg1, arg2); 101 var newTypedArray = new constructor(arg0, arg1, arg2);
96 } 102 }
97 if (!IS_TYPEDARRAY(newTypedArray)) throw %make_type_error(kNotTypedArray); 103 ValidateTypedArray(newTypedArray, "TypedArrayCreate");
98 // TODO(littledan): Check for being detached, here and elsewhere
99 // All callers where the first argument is a Number have no additional
100 // arguments.
101 if (IS_NUMBER(arg0) && %_TypedArrayGetLength(newTypedArray) < arg0) { 104 if (IS_NUMBER(arg0) && %_TypedArrayGetLength(newTypedArray) < arg0) {
102 throw %make_type_error(kTypedArrayTooShort); 105 throw %make_type_error(kTypedArrayTooShort);
103 } 106 }
104 return newTypedArray; 107 return newTypedArray;
105 } 108 }
106 109
107 function TypedArraySpeciesCreate(exemplar, arg0, arg1, arg2, conservative) { 110 function TypedArraySpeciesCreate(exemplar, arg0, arg1, arg2) {
108 var defaultConstructor = TypedArrayDefaultConstructor(exemplar); 111 var defaultConstructor = TypedArrayDefaultConstructor(exemplar);
109 var constructor = SpeciesConstructor(exemplar, defaultConstructor, 112 var constructor = SpeciesConstructor(exemplar, defaultConstructor);
110 conservative);
111 return TypedArrayCreate(constructor, arg0, arg1, arg2); 113 return TypedArrayCreate(constructor, arg0, arg1, arg2);
112 } 114 }
113 115
114 macro TYPED_ARRAY_CONSTRUCTOR(NAME, ELEMENT_SIZE) 116 macro TYPED_ARRAY_CONSTRUCTOR(NAME, ELEMENT_SIZE)
115 function NAMEConstructByIterable(obj, iterable, iteratorFn) { 117 function NAMEConstructByIterable(obj, iterable, iteratorFn) {
116 if (%has_iteration_side_effects(iterable)) { 118 if (%has_iteration_side_effects(iterable)) {
117 var list = new InternalArray(); 119 var list = new InternalArray();
118 // Reading the Symbol.iterator property of iterable twice would be 120 // Reading the Symbol.iterator property of iterable twice would be
119 // observable with getters, so instead, we call the function which 121 // observable with getters, so instead, we call the function which
120 // was already looked up, and wrap it in another iterable. The 122 // was already looked up, and wrap it in another iterable. The
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 endInt = MinSimple(endInt, srcLength); 202 endInt = MinSimple(endInt, srcLength);
201 } 203 }
202 204
203 if (endInt < beginInt) { 205 if (endInt < beginInt) {
204 endInt = beginInt; 206 endInt = beginInt;
205 } 207 }
206 208
207 var newLength = endInt - beginInt; 209 var newLength = endInt - beginInt;
208 var beginByteOffset = 210 var beginByteOffset =
209 %_ArrayBufferViewGetByteOffset(this) + beginInt * ELEMENT_SIZE; 211 %_ArrayBufferViewGetByteOffset(this) + beginInt * ELEMENT_SIZE;
210 // BUG(v8:4665): For web compatibility, subarray needs to always build an 212 return TypedArraySpeciesCreate(this, %TypedArrayGetBuffer(this),
211 // instance of the default constructor. 213 beginByteOffset, newLength);
212 // TODO(littledan): Switch to the standard or standardize the fix
213 return new GlobalNAME(%TypedArrayGetBuffer(this), beginByteOffset, newLength);
214 } 214 }
215 endmacro 215 endmacro
216 216
217 TYPED_ARRAYS(TYPED_ARRAY_CONSTRUCTOR) 217 TYPED_ARRAYS(TYPED_ARRAY_CONSTRUCTOR)
218 218
219 function TypedArraySubArray(begin, end) { 219 function TypedArraySubArray(begin, end) {
220 switch (%_ClassOf(this)) { 220 switch (%_ClassOf(this)) {
221 macro TYPED_ARRAY_SUBARRAY_CASE(NAME, ELEMENT_SIZE) 221 macro TYPED_ARRAY_SUBARRAY_CASE(NAME, ELEMENT_SIZE)
222 case "NAME": 222 case "NAME":
223 return %_Call(NAMESubArray, this, begin, end); 223 return %_Call(NAMESubArray, this, begin, end);
224 endmacro 224 endmacro
225 TYPED_ARRAYS(TYPED_ARRAY_SUBARRAY_CASE) 225 TYPED_ARRAYS(TYPED_ARRAY_SUBARRAY_CASE)
226 } 226 }
227 throw %make_type_error(kIncompatibleMethodReceiver, 227 throw %make_type_error(kIncompatibleMethodReceiver,
228 "get TypedArray.prototype.subarray", this); 228 "get %TypedArray%.prototype.subarray", this);
229 } 229 }
230 %SetForceInlineFlag(TypedArraySubArray); 230 %SetForceInlineFlag(TypedArraySubArray);
231 231
232 232
233 233
234 function TypedArraySetFromArrayLike(target, source, sourceLength, offset) { 234 function TypedArraySetFromArrayLike(target, source, sourceLength, offset) {
235 if (offset > 0) { 235 if (offset > 0) {
236 for (var i = 0; i < sourceLength; i++) { 236 for (var i = 0; i < sourceLength; i++) {
237 target[offset + i] = source[i]; 237 target[offset + i] = source[i];
238 } 238 }
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 if (i in array) { 353 if (i in array) {
354 var element = array[i]; 354 var element = array[i];
355 if (!%_Call(f, receiver, element, i, array)) return false; 355 if (!%_Call(f, receiver, element, i, array)) return false;
356 } 356 }
357 } 357 }
358 return true; 358 return true;
359 } 359 }
360 360
361 // ES6 draft 05-05-15, section 22.2.3.7 361 // ES6 draft 05-05-15, section 22.2.3.7
362 function TypedArrayEvery(f, receiver) { 362 function TypedArrayEvery(f, receiver) {
363 if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray); 363 ValidateTypedArray(this, "%TypedArray%.prototype.every");
364 364
365 var length = %_TypedArrayGetLength(this); 365 var length = %_TypedArrayGetLength(this);
366 366
367 return InnerTypedArrayEvery(f, receiver, this, length); 367 return InnerTypedArrayEvery(f, receiver, this, length);
368 } 368 }
369 %FunctionSetLength(TypedArrayEvery, 1); 369 %FunctionSetLength(TypedArrayEvery, 1);
370 370
371 function InnerTypedArrayForEach(f, receiver, array, length) { 371 function InnerTypedArrayForEach(f, receiver, array, length) {
372 if (!IS_CALLABLE(f)) throw %make_type_error(kCalledNonCallable, f); 372 if (!IS_CALLABLE(f)) throw %make_type_error(kCalledNonCallable, f);
373 373
374 if (IS_UNDEFINED(receiver)) { 374 if (IS_UNDEFINED(receiver)) {
375 for (var i = 0; i < length; i++) { 375 for (var i = 0; i < length; i++) {
376 if (i in array) { 376 if (i in array) {
377 var element = array[i]; 377 var element = array[i];
378 f(element, i, array); 378 f(element, i, array);
379 } 379 }
380 } 380 }
381 } else { 381 } else {
382 for (var i = 0; i < length; i++) { 382 for (var i = 0; i < length; i++) {
383 if (i in array) { 383 if (i in array) {
384 var element = array[i]; 384 var element = array[i];
385 %_Call(f, receiver, element, i, array); 385 %_Call(f, receiver, element, i, array);
386 } 386 }
387 } 387 }
388 } 388 }
389 } 389 }
390 390
391 // ES6 draft 08-24-14, section 22.2.3.12 391 // ES6 draft 08-24-14, section 22.2.3.12
392 function TypedArrayForEach(f, receiver) { 392 function TypedArrayForEach(f, receiver) {
393 if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray); 393 ValidateTypedArray(this, "%TypedArray%.prototype.forEach");
394 394
395 var length = %_TypedArrayGetLength(this); 395 var length = %_TypedArrayGetLength(this);
396 396
397 InnerTypedArrayForEach(f, receiver, this, length); 397 InnerTypedArrayForEach(f, receiver, this, length);
398 } 398 }
399 %FunctionSetLength(TypedArrayForEach, 1); 399 %FunctionSetLength(TypedArrayForEach, 1);
400 400
401 401
402 // ES6 draft 07-15-13, section 22.2.3.9 402 // ES6 draft 07-15-13, section 22.2.3.9
403 function TypedArrayFilter(f, thisArg) { 403 function TypedArrayFilter(f, thisArg) {
404 if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray); 404 ValidateTypedArray(this, "%TypeArray%.prototype.filter");
405 405
406 var length = %_TypedArrayGetLength(this); 406 var length = %_TypedArrayGetLength(this);
407 if (!IS_CALLABLE(f)) throw %make_type_error(kCalledNonCallable, f); 407 if (!IS_CALLABLE(f)) throw %make_type_error(kCalledNonCallable, f);
408 var result = new InternalArray(); 408 var result = new InternalArray();
409 InnerArrayFilter(f, thisArg, this, length, result); 409 InnerArrayFilter(f, thisArg, this, length, result);
410 var captured = result.length; 410 var captured = result.length;
411 var output = TypedArraySpeciesCreate(this, captured); 411 var output = TypedArraySpeciesCreate(this, captured);
412 for (var i = 0; i < captured; i++) { 412 for (var i = 0; i < captured; i++) {
413 output[i] = result[i]; 413 output[i] = result[i];
414 } 414 }
415 return output; 415 return output;
416 } 416 }
417 %FunctionSetLength(TypedArrayFilter, 1); 417 %FunctionSetLength(TypedArrayFilter, 1);
418 418
419 419
420 // ES6 draft 07-15-13, section 22.2.3.10 420 // ES6 draft 07-15-13, section 22.2.3.10
421 function TypedArrayFind(predicate, thisArg) { 421 function TypedArrayFind(predicate, thisArg) {
422 if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray); 422 ValidateTypedArray(this, "%TypedArray%.prototype.find");
423 423
424 var length = %_TypedArrayGetLength(this); 424 var length = %_TypedArrayGetLength(this);
425 425
426 return InnerArrayFind(predicate, thisArg, this, length); 426 return InnerArrayFind(predicate, thisArg, this, length);
427 } 427 }
428 %FunctionSetLength(TypedArrayFind, 1); 428 %FunctionSetLength(TypedArrayFind, 1);
429 429
430 430
431 // ES6 draft 07-15-13, section 22.2.3.11 431 // ES6 draft 07-15-13, section 22.2.3.11
432 function TypedArrayFindIndex(predicate, thisArg) { 432 function TypedArrayFindIndex(predicate, thisArg) {
433 if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray); 433 ValidateTypedArray(this, "%TypedArray%.prototype.findIndex");
434 434
435 var length = %_TypedArrayGetLength(this); 435 var length = %_TypedArrayGetLength(this);
436 436
437 return InnerArrayFindIndex(predicate, thisArg, this, length); 437 return InnerArrayFindIndex(predicate, thisArg, this, length);
438 } 438 }
439 %FunctionSetLength(TypedArrayFindIndex, 1); 439 %FunctionSetLength(TypedArrayFindIndex, 1);
440 440
441 441
442 // ES6 draft 05-18-15, section 22.2.3.25 442 // ES6 draft 05-18-15, section 22.2.3.25
443 function TypedArraySort(comparefn) { 443 function TypedArraySort(comparefn) {
444 if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray); 444 ValidateTypedArray(this, "%TypedArray%.prototype.sort");
445 445
446 var length = %_TypedArrayGetLength(this); 446 var length = %_TypedArrayGetLength(this);
447 447
448 if (IS_UNDEFINED(comparefn)) { 448 if (IS_UNDEFINED(comparefn)) {
449 return %TypedArraySortFast(this); 449 return %TypedArraySortFast(this);
450 } 450 }
451 451
452 return InnerArraySort(this, length, comparefn); 452 return InnerArraySort(this, length, comparefn);
453 } 453 }
454 454
455 455
456 // ES6 draft 07-15-13, section 22.2.3.18 456 // ES6 draft 07-15-13, section 22.2.3.18
457 function TypedArrayMap(f, thisArg) { 457 function TypedArrayMap(f, thisArg) {
458 if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray); 458 ValidateTypedArray(this, "%TypedArray%.prototype.map");
459 459
460 var length = %_TypedArrayGetLength(this); 460 var length = %_TypedArrayGetLength(this);
461 var result = TypedArraySpeciesCreate(this, length); 461 var result = TypedArraySpeciesCreate(this, length);
462 if (!IS_CALLABLE(f)) throw %make_type_error(kCalledNonCallable, f); 462 if (!IS_CALLABLE(f)) throw %make_type_error(kCalledNonCallable, f);
463 for (var i = 0; i < length; i++) { 463 for (var i = 0; i < length; i++) {
464 var element = this[i]; 464 var element = this[i];
465 result[i] = %_Call(f, thisArg, element, i, this); 465 result[i] = %_Call(f, thisArg, element, i, this);
466 } 466 }
467 return result; 467 return result;
468 } 468 }
469 %FunctionSetLength(TypedArrayMap, 1); 469 %FunctionSetLength(TypedArrayMap, 1);
470 470
471 function InnerTypedArraySome(f, receiver, array, length) { 471 function InnerTypedArraySome(f, receiver, array, length) {
472 if (!IS_CALLABLE(f)) throw %make_type_error(kCalledNonCallable, f); 472 if (!IS_CALLABLE(f)) throw %make_type_error(kCalledNonCallable, f);
473 473
474 for (var i = 0; i < length; i++) { 474 for (var i = 0; i < length; i++) {
475 if (i in array) { 475 if (i in array) {
476 var element = array[i]; 476 var element = array[i];
477 if (%_Call(f, receiver, element, i, array)) return true; 477 if (%_Call(f, receiver, element, i, array)) return true;
478 } 478 }
479 } 479 }
480 return false; 480 return false;
481 } 481 }
482 482
483 // ES6 draft 05-05-15, section 22.2.3.24 483 // ES6 draft 05-05-15, section 22.2.3.24
484 function TypedArraySome(f, receiver) { 484 function TypedArraySome(f, receiver) {
485 if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray); 485 ValidateTypedArray(this, "%TypedArray%.prototype.some");
486 486
487 var length = %_TypedArrayGetLength(this); 487 var length = %_TypedArrayGetLength(this);
488 488
489 return InnerTypedArraySome(f, receiver, this, length); 489 return InnerTypedArraySome(f, receiver, this, length);
490 } 490 }
491 %FunctionSetLength(TypedArraySome, 1); 491 %FunctionSetLength(TypedArraySome, 1);
492 492
493 493
494 // ES6 section 22.2.3.27 494 // ES6 section 22.2.3.27
495 function TypedArrayToLocaleString() { 495 function TypedArrayToLocaleString() {
496 if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray); 496 ValidateTypedArray(this, "%TypedArray%.prototype.toLocaleString");
497 497
498 var length = %_TypedArrayGetLength(this); 498 var length = %_TypedArrayGetLength(this);
499 499
500 return InnerArrayToLocaleString(this, length); 500 return InnerArrayToLocaleString(this, length);
501 } 501 }
502 502
503 503
504 // ES6 section 22.2.3.14 504 // ES6 section 22.2.3.14
505 function TypedArrayJoin(separator) { 505 function TypedArrayJoin(separator) {
506 if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray); 506 ValidateTypedArray(this, "%TypedArray%.prototype.join");
507 507
508 var length = %_TypedArrayGetLength(this); 508 var length = %_TypedArrayGetLength(this);
509 509
510 return InnerArrayJoin(separator, this, length); 510 return InnerArrayJoin(separator, this, length);
511 } 511 }
512 512
513 function InnerTypedArrayReduce( 513 function InnerTypedArrayReduce(
514 callback, current, array, length, argumentsLength) { 514 callback, current, array, length, argumentsLength) {
515 if (!IS_CALLABLE(callback)) { 515 if (!IS_CALLABLE(callback)) {
516 throw %make_type_error(kCalledNonCallable, callback); 516 throw %make_type_error(kCalledNonCallable, callback);
(...skipping 14 matching lines...) Expand all
531 if (i in array) { 531 if (i in array) {
532 var element = array[i]; 532 var element = array[i];
533 current = callback(current, element, i, array); 533 current = callback(current, element, i, array);
534 } 534 }
535 } 535 }
536 return current; 536 return current;
537 } 537 }
538 538
539 // ES6 draft 07-15-13, section 22.2.3.19 539 // ES6 draft 07-15-13, section 22.2.3.19
540 function TypedArrayReduce(callback, current) { 540 function TypedArrayReduce(callback, current) {
541 if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray); 541 ValidateTypedArray(this, "%TypedArray%.prototype.reduce");
542 542
543 var length = %_TypedArrayGetLength(this); 543 var length = %_TypedArrayGetLength(this);
544 return InnerTypedArrayReduce( 544 return InnerTypedArrayReduce(
545 callback, current, this, length, arguments.length); 545 callback, current, this, length, arguments.length);
546 } 546 }
547 %FunctionSetLength(TypedArrayReduce, 1); 547 %FunctionSetLength(TypedArrayReduce, 1);
548 548
549 function InnerArrayReduceRight(callback, current, array, length, 549 function InnerArrayReduceRight(callback, current, array, length,
550 argumentsLength) { 550 argumentsLength) {
551 if (!IS_CALLABLE(callback)) { 551 if (!IS_CALLABLE(callback)) {
(...skipping 15 matching lines...) Expand all
567 if (i in array) { 567 if (i in array) {
568 var element = array[i]; 568 var element = array[i];
569 current = callback(current, element, i, array); 569 current = callback(current, element, i, array);
570 } 570 }
571 } 571 }
572 return current; 572 return current;
573 } 573 }
574 574
575 // ES6 draft 07-15-13, section 22.2.3.19 575 // ES6 draft 07-15-13, section 22.2.3.19
576 function TypedArrayReduceRight(callback, current) { 576 function TypedArrayReduceRight(callback, current) {
577 if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray); 577 ValidateTypedArray(this, "%TypedArray%.prototype.reduceRight");
578 578
579 var length = %_TypedArrayGetLength(this); 579 var length = %_TypedArrayGetLength(this);
580 return InnerArrayReduceRight(callback, current, this, length, 580 return InnerArrayReduceRight(callback, current, this, length,
581 arguments.length); 581 arguments.length);
582 } 582 }
583 %FunctionSetLength(TypedArrayReduceRight, 1); 583 %FunctionSetLength(TypedArrayReduceRight, 1);
584 584
585 585
586 // ES6 draft 08-24-14, section 22.2.2.2 586 // ES6 draft 08-24-14, section 22.2.2.2
587 function TypedArrayOf() { 587 function TypedArrayOf() {
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
688 %AddNamedProperty(GlobalNAME.prototype, 688 %AddNamedProperty(GlobalNAME.prototype,
689 "constructor", global.NAME, DONT_ENUM); 689 "constructor", global.NAME, DONT_ENUM);
690 %AddNamedProperty(GlobalNAME.prototype, 690 %AddNamedProperty(GlobalNAME.prototype,
691 "BYTES_PER_ELEMENT", ELEMENT_SIZE, 691 "BYTES_PER_ELEMENT", ELEMENT_SIZE,
692 READ_ONLY | DONT_ENUM | DONT_DELETE); 692 READ_ONLY | DONT_ENUM | DONT_DELETE);
693 endmacro 693 endmacro
694 694
695 TYPED_ARRAYS(SETUP_TYPED_ARRAY) 695 TYPED_ARRAYS(SETUP_TYPED_ARRAY)
696 696
697 }) 697 })
OLDNEW
« no previous file with comments | « src/crankshaft/hydrogen.cc ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698