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

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

Issue 1186733002: Add %TypedArray% to proto chain (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: changes from arv's review Created 5 years, 6 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 | « no previous file | src/runtime/runtime-function.cc » ('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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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 macro TYPED_ARRAYS(FUNCTION)
15 // arrayIds below should be synchronized with Runtime_TypedArrayInitialize.
16 FUNCTION(Uint8Array)
17 FUNCTION(Int8Array)
18 FUNCTION(Uint16Array)
19 FUNCTION(Int16Array)
20 FUNCTION(Uint32Array)
21 FUNCTION(Int32Array)
22 FUNCTION(Float32Array)
23 FUNCTION(Float64Array)
24 FUNCTION(Uint8ClampedArray)
25 endmacro
26 14
27 macro DECLARE_GLOBALS(NAME) 15 macro DECLARE_GLOBALS(NAME)
28 var GlobalNAME = global.NAME; 16 var GlobalNAME = global.NAME;
29 endmacro 17 endmacro
30 18
31 TYPED_ARRAYS(DECLARE_GLOBALS)
32 DECLARE_GLOBALS(Array) 19 DECLARE_GLOBALS(Array)
20 DECLARE_GLOBALS(Uint8Array)
21 DECLARE_GLOBALS(Int8Array)
22 DECLARE_GLOBALS(Uint16Array)
23 DECLARE_GLOBALS(Int16Array)
24 DECLARE_GLOBALS(Uint32Array)
25 DECLARE_GLOBALS(Int32Array)
26 DECLARE_GLOBALS(Float32Array)
27 DECLARE_GLOBALS(Float64Array)
28 DECLARE_GLOBALS(Uint8ClampedArray)
33 29
34 var ArrayFrom; 30 var ArrayFrom;
35 var ArrayToString; 31 var ArrayToString;
36 var InnerArrayCopyWithin; 32 var InnerArrayCopyWithin;
37 var InnerArrayEvery; 33 var InnerArrayEvery;
38 var InnerArrayFill; 34 var InnerArrayFill;
39 var InnerArrayFilter; 35 var InnerArrayFilter;
40 var InnerArrayFind; 36 var InnerArrayFind;
41 var InnerArrayFindIndex; 37 var InnerArrayFindIndex;
42 var InnerArrayForEach; 38 var InnerArrayForEach;
43 var InnerArrayIndexOf; 39 var InnerArrayIndexOf;
44 var InnerArrayJoin; 40 var InnerArrayJoin;
45 var InnerArrayLastIndexOf; 41 var InnerArrayLastIndexOf;
46 var InnerArrayMap; 42 var InnerArrayMap;
47 var InnerArrayReverse; 43 var InnerArrayReverse;
48 var InnerArraySome; 44 var InnerArraySome;
49 var InnerArraySort; 45 var InnerArraySort;
50 var InnerArrayToLocaleString; 46 var InnerArrayToLocaleString;
51 var IsNaN; 47 var IsNaN;
52 var MathMax; 48 var MathMax;
53 var MathMin; 49 var MathMin;
50 var TypedArray = GlobalUint8Array.__proto__;
51 var TypedArrayPrototype = GlobalUint8Array.prototype.__proto__;
54 52
55 utils.Import(function(from) { 53 utils.Import(function(from) {
56 ArrayFrom = from.ArrayFrom; 54 ArrayFrom = from.ArrayFrom;
57 ArrayToString = from.ArrayToString; 55 ArrayToString = from.ArrayToString;
58 InnerArrayCopyWithin = from.InnerArrayCopyWithin; 56 InnerArrayCopyWithin = from.InnerArrayCopyWithin;
59 InnerArrayEvery = from.InnerArrayEvery; 57 InnerArrayEvery = from.InnerArrayEvery;
60 InnerArrayFill = from.InnerArrayFill; 58 InnerArrayFill = from.InnerArrayFill;
61 InnerArrayFilter = from.InnerArrayFilter; 59 InnerArrayFilter = from.InnerArrayFilter;
62 InnerArrayFind = from.InnerArrayFind; 60 InnerArrayFind = from.InnerArrayFind;
63 InnerArrayFindIndex = from.InnerArrayFindIndex; 61 InnerArrayFindIndex = from.InnerArrayFindIndex;
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 367
370 368
371 function TypedArrayFrom(source, mapfn, thisArg) { 369 function TypedArrayFrom(source, mapfn, thisArg) {
372 // TODO(littledan): Investigate if there is a receiver which could be 370 // TODO(littledan): Investigate if there is a receiver which could be
373 // faster to accumulate on than Array, e.g., a TypedVector. 371 // faster to accumulate on than Array, e.g., a TypedVector.
374 var array = %_CallFunction(GlobalArray, source, mapfn, thisArg, ArrayFrom); 372 var array = %_CallFunction(GlobalArray, source, mapfn, thisArg, ArrayFrom);
375 return ConstructTypedArray(this, array); 373 return ConstructTypedArray(this, array);
376 } 374 }
377 %FunctionSetLength(TypedArrayFrom, 1); 375 %FunctionSetLength(TypedArrayFrom, 1);
378 376
379 // TODO(littledan): Fix the TypedArray proto chain (bug v8:4085).
380 macro EXTEND_TYPED_ARRAY(NAME)
381 // Set up non-enumerable functions on the object. 377 // Set up non-enumerable functions on the object.
382 utils.InstallFunctions(GlobalNAME, DONT_ENUM | DONT_DELETE | READ_ONLY, [ 378 utils.InstallFunctions(TypedArray, DONT_ENUM | DONT_DELETE | READ_ONLY, [
383 "from", TypedArrayFrom, 379 "from", TypedArrayFrom,
384 "of", TypedArrayOf 380 "of", TypedArrayOf
385 ]); 381 ]);
386 382
387 // Set up non-enumerable functions on the prototype object. 383 // Set up non-enumerable functions on the prototype object.
388 utils.InstallFunctions(GlobalNAME.prototype, DONT_ENUM, [ 384 utils.InstallFunctions(TypedArrayPrototype, DONT_ENUM, [
389 "copyWithin", TypedArrayCopyWithin, 385 "copyWithin", TypedArrayCopyWithin,
390 "every", TypedArrayEvery, 386 "every", TypedArrayEvery,
391 "fill", TypedArrayFill, 387 "fill", TypedArrayFill,
392 "filter", TypedArrayFilter, 388 "filter", TypedArrayFilter,
393 "find", TypedArrayFind, 389 "find", TypedArrayFind,
394 "findIndex", TypedArrayFindIndex, 390 "findIndex", TypedArrayFindIndex,
395 "indexOf", TypedArrayIndexOf, 391 "indexOf", TypedArrayIndexOf,
396 "join", TypedArrayJoin, 392 "join", TypedArrayJoin,
397 "lastIndexOf", TypedArrayLastIndexOf, 393 "lastIndexOf", TypedArrayLastIndexOf,
398 "forEach", TypedArrayForEach, 394 "forEach", TypedArrayForEach,
399 "map", TypedArrayMap, 395 "map", TypedArrayMap,
400 "reduce", TypedArrayReduce, 396 "reduce", TypedArrayReduce,
401 "reduceRight", TypedArrayReduceRight, 397 "reduceRight", TypedArrayReduceRight,
402 "reverse", TypedArrayReverse, 398 "reverse", TypedArrayReverse,
403 "slice", TypedArraySlice, 399 "slice", TypedArraySlice,
404 "some", TypedArraySome, 400 "some", TypedArraySome,
405 "sort", TypedArraySort, 401 "sort", TypedArraySort,
406 "toString", TypedArrayToString, 402 "toString", TypedArrayToString,
407 "toLocaleString", TypedArrayToLocaleString 403 "toLocaleString", TypedArrayToLocaleString
408 ]); 404 ]);
409 endmacro
410
411 TYPED_ARRAYS(EXTEND_TYPED_ARRAY)
412 405
413 }) 406 })
OLDNEW
« no previous file with comments | « no previous file | src/runtime/runtime-function.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698