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