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

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

Issue 1410473002: Reland: Use simple/fast inline function version of MinMax in JS (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: after yangs fix possible to use utils.ImportNow in test Created 5 years, 2 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/js/runtime.js ('k') | test/mjsunit/minmax-simple.js » ('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 var ArrayValues; 14 var ArrayValues;
15 var GlobalArray = global.Array; 15 var GlobalArray = global.Array;
16 var GlobalArrayBuffer = global.ArrayBuffer; 16 var GlobalArrayBuffer = global.ArrayBuffer;
17 var GlobalDataView = global.DataView; 17 var GlobalDataView = global.DataView;
18 var GlobalObject = global.Object; 18 var GlobalObject = global.Object;
19 var InternalArray = utils.InternalArray; 19 var InternalArray = utils.InternalArray;
20 var iteratorSymbol = utils.ImportNow("iterator_symbol"); 20 var iteratorSymbol = utils.ImportNow("iterator_symbol");
21 var MaxSimple;
22 var MinSimple;
21 var ToPositiveInteger; 23 var ToPositiveInteger;
22 var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol"); 24 var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol");
23 25
24 macro TYPED_ARRAYS(FUNCTION) 26 macro TYPED_ARRAYS(FUNCTION)
25 // arrayIds below should be synchronized with Runtime_TypedArrayInitialize. 27 // arrayIds below should be synchronized with Runtime_TypedArrayInitialize.
26 FUNCTION(1, Uint8Array, 1) 28 FUNCTION(1, Uint8Array, 1)
27 FUNCTION(2, Int8Array, 1) 29 FUNCTION(2, Int8Array, 1)
28 FUNCTION(3, Uint16Array, 2) 30 FUNCTION(3, Uint16Array, 2)
29 FUNCTION(4, Int16Array, 2) 31 FUNCTION(4, Int16Array, 2)
30 FUNCTION(5, Uint32Array, 4) 32 FUNCTION(5, Uint32Array, 4)
31 FUNCTION(6, Int32Array, 4) 33 FUNCTION(6, Int32Array, 4)
32 FUNCTION(7, Float32Array, 4) 34 FUNCTION(7, Float32Array, 4)
33 FUNCTION(8, Float64Array, 8) 35 FUNCTION(8, Float64Array, 8)
34 FUNCTION(9, Uint8ClampedArray, 1) 36 FUNCTION(9, Uint8ClampedArray, 1)
35 endmacro 37 endmacro
36 38
37 macro DECLARE_GLOBALS(INDEX, NAME, SIZE) 39 macro DECLARE_GLOBALS(INDEX, NAME, SIZE)
38 var GlobalNAME = global.NAME; 40 var GlobalNAME = global.NAME;
39 endmacro 41 endmacro
40 42
41 TYPED_ARRAYS(DECLARE_GLOBALS) 43 TYPED_ARRAYS(DECLARE_GLOBALS)
42 44
43 utils.Import(function(from) { 45 utils.Import(function(from) {
44 ArrayValues = from.ArrayValues; 46 ArrayValues = from.ArrayValues;
47 MaxSimple = from.MaxSimple;
48 MinSimple = from.MinSimple;
45 ToPositiveInteger = from.ToPositiveInteger; 49 ToPositiveInteger = from.ToPositiveInteger;
46 }); 50 });
47 51
48 // --------------- Typed Arrays --------------------- 52 // --------------- Typed Arrays ---------------------
49 53
50 macro TYPED_ARRAY_CONSTRUCTOR(ARRAY_ID, NAME, ELEMENT_SIZE) 54 macro TYPED_ARRAY_CONSTRUCTOR(ARRAY_ID, NAME, ELEMENT_SIZE)
51 function NAMEConstructByArrayBuffer(obj, buffer, byteOffset, length) { 55 function NAMEConstructByArrayBuffer(obj, buffer, byteOffset, length) {
52 if (!IS_UNDEFINED(byteOffset)) { 56 if (!IS_UNDEFINED(byteOffset)) {
53 byteOffset = ToPositiveInteger(byteOffset, kInvalidTypedArrayLength); 57 byteOffset = ToPositiveInteger(byteOffset, kInvalidTypedArrayLength);
54 } 58 }
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 var beginInt = TO_INTEGER(begin); 210 var beginInt = TO_INTEGER(begin);
207 if (!IS_UNDEFINED(end)) { 211 if (!IS_UNDEFINED(end)) {
208 var endInt = TO_INTEGER(end); 212 var endInt = TO_INTEGER(end);
209 var srcLength = %_TypedArrayGetLength(this); 213 var srcLength = %_TypedArrayGetLength(this);
210 } else { 214 } else {
211 var srcLength = %_TypedArrayGetLength(this); 215 var srcLength = %_TypedArrayGetLength(this);
212 var endInt = srcLength; 216 var endInt = srcLength;
213 } 217 }
214 218
215 if (beginInt < 0) { 219 if (beginInt < 0) {
216 beginInt = MAX_SIMPLE(0, srcLength + beginInt); 220 beginInt = MaxSimple(0, srcLength + beginInt);
217 } else { 221 } else {
218 beginInt = MIN_SIMPLE(beginInt, srcLength); 222 beginInt = MinSimple(beginInt, srcLength);
219 } 223 }
220 224
221 if (endInt < 0) { 225 if (endInt < 0) {
222 endInt = MAX_SIMPLE(0, srcLength + endInt); 226 endInt = MaxSimple(0, srcLength + endInt);
223 } else { 227 } else {
224 endInt = MIN_SIMPLE(endInt, srcLength); 228 endInt = MinSimple(endInt, srcLength);
225 } 229 }
226 230
227 if (endInt < beginInt) { 231 if (endInt < beginInt) {
228 endInt = beginInt; 232 endInt = beginInt;
229 } 233 }
230 234
231 var newLength = endInt - beginInt; 235 var newLength = endInt - beginInt;
232 var beginByteOffset = 236 var beginByteOffset =
233 %_ArrayBufferViewGetByteOffset(this) + beginInt * ELEMENT_SIZE; 237 %_ArrayBufferViewGetByteOffset(this) + beginInt * ELEMENT_SIZE;
234 return new GlobalNAME(%TypedArrayGetBuffer(this), 238 return new GlobalNAME(%TypedArrayGetBuffer(this),
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 "setUint32", DataViewSetUint32JS, 508 "setUint32", DataViewSetUint32JS,
505 509
506 "getFloat32", DataViewGetFloat32JS, 510 "getFloat32", DataViewGetFloat32JS,
507 "setFloat32", DataViewSetFloat32JS, 511 "setFloat32", DataViewSetFloat32JS,
508 512
509 "getFloat64", DataViewGetFloat64JS, 513 "getFloat64", DataViewGetFloat64JS,
510 "setFloat64", DataViewSetFloat64JS 514 "setFloat64", DataViewSetFloat64JS
511 ]); 515 ]);
512 516
513 }) 517 })
OLDNEW
« no previous file with comments | « src/js/runtime.js ('k') | test/mjsunit/minmax-simple.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698