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

Side by Side Diff: src/typedarray.js

Issue 1154483002: Hook up more import/exports in natives. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: do not leak utils object Created 5 years, 7 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/third_party/fdlibm/fdlibm.js ('k') | src/uri.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 GlobalArray = global.Array; 14 var GlobalArray = global.Array;
15 var GlobalArrayBuffer = global.ArrayBuffer; 15 var GlobalArrayBuffer = global.ArrayBuffer;
16 var GlobalDataView = global.DataView; 16 var GlobalDataView = global.DataView;
17 var GlobalObject = global.Object; 17 var GlobalObject = global.Object;
18 18
19 var MathMax;
20 var MathMin;
21
22 utils.Import(function(from) {
23 MathMax = from.MathMax;
24 MathMin = from.MathMin;
25 });
26
27 // -------------------------------------------------------------------
28
29
30 macro TYPED_ARRAYS(FUNCTION) 19 macro TYPED_ARRAYS(FUNCTION)
31 // arrayIds below should be synchronized with Runtime_TypedArrayInitialize. 20 // arrayIds below should be synchronized with Runtime_TypedArrayInitialize.
32 FUNCTION(1, Uint8Array, 1) 21 FUNCTION(1, Uint8Array, 1)
33 FUNCTION(2, Int8Array, 1) 22 FUNCTION(2, Int8Array, 1)
34 FUNCTION(3, Uint16Array, 2) 23 FUNCTION(3, Uint16Array, 2)
35 FUNCTION(4, Int16Array, 2) 24 FUNCTION(4, Int16Array, 2)
36 FUNCTION(5, Uint32Array, 4) 25 FUNCTION(5, Uint32Array, 4)
37 FUNCTION(6, Int32Array, 4) 26 FUNCTION(6, Int32Array, 4)
38 FUNCTION(7, Float32Array, 4) 27 FUNCTION(7, Float32Array, 4)
39 FUNCTION(8, Float64Array, 8) 28 FUNCTION(8, Float64Array, 8)
40 FUNCTION(9, Uint8ClampedArray, 1) 29 FUNCTION(9, Uint8ClampedArray, 1)
41 endmacro 30 endmacro
42 31
43 macro DECLARE_GLOBALS(INDEX, NAME, SIZE) 32 macro DECLARE_GLOBALS(INDEX, NAME, SIZE)
44 var GlobalNAME = global.NAME; 33 var GlobalNAME = global.NAME;
45 endmacro 34 endmacro
46 35
47 TYPED_ARRAYS(DECLARE_GLOBALS) 36 TYPED_ARRAYS(DECLARE_GLOBALS)
48 37
38 var MathMax;
39 var MathMin;
40
41 utils.Import(function(from) {
42 MathMax = from.MathMax;
43 MathMin = from.MathMin;
44 });
45
49 // --------------- Typed Arrays --------------------- 46 // --------------- Typed Arrays ---------------------
50 47
51 macro TYPED_ARRAY_CONSTRUCTOR(ARRAY_ID, NAME, ELEMENT_SIZE) 48 macro TYPED_ARRAY_CONSTRUCTOR(ARRAY_ID, NAME, ELEMENT_SIZE)
52 function NAMEConstructByArrayBuffer(obj, buffer, byteOffset, length) { 49 function NAMEConstructByArrayBuffer(obj, buffer, byteOffset, length) {
53 if (!IS_UNDEFINED(byteOffset)) { 50 if (!IS_UNDEFINED(byteOffset)) {
54 byteOffset = 51 byteOffset =
55 $toPositiveInteger(byteOffset, kInvalidTypedArrayLength); 52 $toPositiveInteger(byteOffset, kInvalidTypedArrayLength);
56 } 53 }
57 if (!IS_UNDEFINED(length)) { 54 if (!IS_UNDEFINED(length)) {
58 length = $toPositiveInteger(length, kInvalidTypedArrayLength); 55 length = $toPositiveInteger(length, kInvalidTypedArrayLength);
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 %SetCode(GlobalNAME, NAMEConstructor); 316 %SetCode(GlobalNAME, NAMEConstructor);
320 %FunctionSetPrototype(GlobalNAME, new GlobalObject()); 317 %FunctionSetPrototype(GlobalNAME, new GlobalObject());
321 318
322 %AddNamedProperty(GlobalNAME, "BYTES_PER_ELEMENT", ELEMENT_SIZE, 319 %AddNamedProperty(GlobalNAME, "BYTES_PER_ELEMENT", ELEMENT_SIZE,
323 READ_ONLY | DONT_ENUM | DONT_DELETE); 320 READ_ONLY | DONT_ENUM | DONT_DELETE);
324 %AddNamedProperty(GlobalNAME.prototype, 321 %AddNamedProperty(GlobalNAME.prototype,
325 "constructor", global.NAME, DONT_ENUM); 322 "constructor", global.NAME, DONT_ENUM);
326 %AddNamedProperty(GlobalNAME.prototype, 323 %AddNamedProperty(GlobalNAME.prototype,
327 "BYTES_PER_ELEMENT", ELEMENT_SIZE, 324 "BYTES_PER_ELEMENT", ELEMENT_SIZE,
328 READ_ONLY | DONT_ENUM | DONT_DELETE); 325 READ_ONLY | DONT_ENUM | DONT_DELETE);
329 $installGetter(GlobalNAME.prototype, "buffer", NAME_GetBuffer); 326 utils.InstallGetter(GlobalNAME.prototype, "buffer", NAME_GetBuffer);
330 $installGetter(GlobalNAME.prototype, "byteOffset", NAME_GetByteOffset, 327 utils.InstallGetter(GlobalNAME.prototype, "byteOffset", NAME_GetByteOffset,
331 DONT_ENUM | DONT_DELETE); 328 DONT_ENUM | DONT_DELETE);
332 $installGetter(GlobalNAME.prototype, "byteLength", NAME_GetByteLength, 329 utils.InstallGetter(GlobalNAME.prototype, "byteLength", NAME_GetByteLength,
333 DONT_ENUM | DONT_DELETE); 330 DONT_ENUM | DONT_DELETE);
334 $installGetter(GlobalNAME.prototype, "length", NAME_GetLength, 331 utils.InstallGetter(GlobalNAME.prototype, "length", NAME_GetLength,
335 DONT_ENUM | DONT_DELETE); 332 DONT_ENUM | DONT_DELETE);
336 $installGetter(GlobalNAME.prototype, symbolToStringTag, 333 utils.InstallGetter(GlobalNAME.prototype, symbolToStringTag,
337 TypedArrayGetToStringTag); 334 TypedArrayGetToStringTag);
338 $installFunctions(GlobalNAME.prototype, DONT_ENUM, [ 335 utils.InstallFunctions(GlobalNAME.prototype, DONT_ENUM, [
339 "subarray", NAMESubArray, 336 "subarray", NAMESubArray,
340 "set", TypedArraySet 337 "set", TypedArraySet
341 ]); 338 ]);
342 endmacro 339 endmacro
343 340
344 TYPED_ARRAYS(SETUP_TYPED_ARRAY) 341 TYPED_ARRAYS(SETUP_TYPED_ARRAY)
345 342
346 // --------------------------- DataView ----------------------------- 343 // --------------------------- DataView -----------------------------
347 344
348 function DataViewConstructor(buffer, byteOffset, byteLength) { // length = 3 345 function DataViewConstructor(buffer, byteOffset, byteLength) { // length = 3
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 // Setup the DataView constructor. 431 // Setup the DataView constructor.
435 %SetCode(GlobalDataView, DataViewConstructor); 432 %SetCode(GlobalDataView, DataViewConstructor);
436 %FunctionSetPrototype(GlobalDataView, new GlobalObject); 433 %FunctionSetPrototype(GlobalDataView, new GlobalObject);
437 434
438 // Set up constructor property on the DataView prototype. 435 // Set up constructor property on the DataView prototype.
439 %AddNamedProperty(GlobalDataView.prototype, "constructor", GlobalDataView, 436 %AddNamedProperty(GlobalDataView.prototype, "constructor", GlobalDataView,
440 DONT_ENUM); 437 DONT_ENUM);
441 %AddNamedProperty(GlobalDataView.prototype, symbolToStringTag, "DataView", 438 %AddNamedProperty(GlobalDataView.prototype, symbolToStringTag, "DataView",
442 READ_ONLY|DONT_ENUM); 439 READ_ONLY|DONT_ENUM);
443 440
444 $installGetter(GlobalDataView.prototype, "buffer", DataViewGetBufferJS); 441 utils.InstallGetter(GlobalDataView.prototype, "buffer", DataViewGetBufferJS);
445 $installGetter(GlobalDataView.prototype, "byteOffset", DataViewGetByteOffset); 442 utils.InstallGetter(GlobalDataView.prototype, "byteOffset",
446 $installGetter(GlobalDataView.prototype, "byteLength", DataViewGetByteLength); 443 DataViewGetByteOffset);
444 utils.InstallGetter(GlobalDataView.prototype, "byteLength",
445 DataViewGetByteLength);
447 446
448 $installFunctions(GlobalDataView.prototype, DONT_ENUM, [ 447 utils.InstallFunctions(GlobalDataView.prototype, DONT_ENUM, [
449 "getInt8", DataViewGetInt8JS, 448 "getInt8", DataViewGetInt8JS,
450 "setInt8", DataViewSetInt8JS, 449 "setInt8", DataViewSetInt8JS,
451 450
452 "getUint8", DataViewGetUint8JS, 451 "getUint8", DataViewGetUint8JS,
453 "setUint8", DataViewSetUint8JS, 452 "setUint8", DataViewSetUint8JS,
454 453
455 "getInt16", DataViewGetInt16JS, 454 "getInt16", DataViewGetInt16JS,
456 "setInt16", DataViewSetInt16JS, 455 "setInt16", DataViewSetInt16JS,
457 456
458 "getUint16", DataViewGetUint16JS, 457 "getUint16", DataViewGetUint16JS,
459 "setUint16", DataViewSetUint16JS, 458 "setUint16", DataViewSetUint16JS,
460 459
461 "getInt32", DataViewGetInt32JS, 460 "getInt32", DataViewGetInt32JS,
462 "setInt32", DataViewSetInt32JS, 461 "setInt32", DataViewSetInt32JS,
463 462
464 "getUint32", DataViewGetUint32JS, 463 "getUint32", DataViewGetUint32JS,
465 "setUint32", DataViewSetUint32JS, 464 "setUint32", DataViewSetUint32JS,
466 465
467 "getFloat32", DataViewGetFloat32JS, 466 "getFloat32", DataViewGetFloat32JS,
468 "setFloat32", DataViewSetFloat32JS, 467 "setFloat32", DataViewSetFloat32JS,
469 468
470 "getFloat64", DataViewGetFloat64JS, 469 "getFloat64", DataViewGetFloat64JS,
471 "setFloat64", DataViewSetFloat64JS 470 "setFloat64", DataViewSetFloat64JS
472 ]); 471 ]);
473 472
474 }) 473 })
OLDNEW
« no previous file with comments | « src/third_party/fdlibm/fdlibm.js ('k') | src/uri.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698