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

Unified Diff: src/typedarray.js

Issue 1083013002: Revert of Revert of Wrap typed array implementations in functions. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/string-iterator.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/typedarray.js
diff --git a/src/typedarray.js b/src/typedarray.js
index 1faa051cce7bda0b1dc5b4eeaaa43f7ccacabbea..0a73be941f238d3096ca0a84bd9e9e17ac187f3a 100644
--- a/src/typedarray.js
+++ b/src/typedarray.js
@@ -2,13 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+(function() {
+
"use strict";
-// This file relies on the fact that the following declaration has been made
-// in runtime.js:
-// var $Array = global.Array;
-var $ArrayBuffer = global.ArrayBuffer;
-
+%CheckIsBootstrapping();
+
+var GlobalArray = global.Array;
+var GlobalArrayBuffer = global.ArrayBuffer;
// --------------- Typed Arrays ---------------------
macro TYPED_ARRAYS(FUNCTION)
@@ -78,7 +79,7 @@
}
var byteLength = l * ELEMENT_SIZE;
if (byteLength > %_TypedArrayMaxSizeInHeap()) {
- var buffer = new $ArrayBuffer(byteLength);
+ var buffer = new GlobalArrayBuffer(byteLength);
%_TypedArrayInitialize(obj, ARRAY_ID, buffer, 0, byteLength);
} else {
%_TypedArrayInitialize(obj, ARRAY_ID, null, 0, byteLength);
@@ -243,7 +244,7 @@
}
var rightIndex = CopyRightPart();
- var temp = new $Array(rightIndex + 1 - leftIndex);
+ var temp = new GlobalArray(rightIndex + 1 - leftIndex);
for (var i = leftIndex; i <= rightIndex; i++) {
temp[i - leftIndex] = source[i];
}
@@ -300,7 +301,6 @@
// -------------------------------------------------------------------
-function SetupTypedArrays() {
macro SETUP_TYPED_ARRAY(ARRAY_ID, NAME, ELEMENT_SIZE)
%CheckIsBootstrapping();
%SetCode(global.NAME, NAMEConstructor);
@@ -329,9 +329,6 @@
endmacro
TYPED_ARRAYS(SETUP_TYPED_ARRAY)
-}
-
-SetupTypedArrays();
// --------------------------- DataView -----------------------------
@@ -439,47 +436,43 @@
DATA_VIEW_TYPES(DATA_VIEW_GETTER_SETTER)
-function SetupDataView() {
- %CheckIsBootstrapping();
-
- // Setup the DataView constructor.
- %SetCode($DataView, DataViewConstructor);
- %FunctionSetPrototype($DataView, new $Object);
-
- // Set up constructor property on the DataView prototype.
- %AddNamedProperty($DataView.prototype, "constructor", $DataView, DONT_ENUM);
- %AddNamedProperty(
- $DataView.prototype, symbolToStringTag, "DataView", READ_ONLY|DONT_ENUM);
-
- InstallGetter($DataView.prototype, "buffer", DataViewGetBufferJS);
- InstallGetter($DataView.prototype, "byteOffset", DataViewGetByteOffset);
- InstallGetter($DataView.prototype, "byteLength", DataViewGetByteLength);
-
- InstallFunctions($DataView.prototype, DONT_ENUM, [
- "getInt8", DataViewGetInt8JS,
- "setInt8", DataViewSetInt8JS,
-
- "getUint8", DataViewGetUint8JS,
- "setUint8", DataViewSetUint8JS,
-
- "getInt16", DataViewGetInt16JS,
- "setInt16", DataViewSetInt16JS,
-
- "getUint16", DataViewGetUint16JS,
- "setUint16", DataViewSetUint16JS,
-
- "getInt32", DataViewGetInt32JS,
- "setInt32", DataViewSetInt32JS,
-
- "getUint32", DataViewGetUint32JS,
- "setUint32", DataViewSetUint32JS,
-
- "getFloat32", DataViewGetFloat32JS,
- "setFloat32", DataViewSetFloat32JS,
-
- "getFloat64", DataViewGetFloat64JS,
- "setFloat64", DataViewSetFloat64JS
- ]);
-}
-
-SetupDataView();
+// Setup the DataView constructor.
+%SetCode($DataView, DataViewConstructor);
+%FunctionSetPrototype($DataView, new $Object);
+
+// Set up constructor property on the DataView prototype.
+%AddNamedProperty($DataView.prototype, "constructor", $DataView, DONT_ENUM);
+%AddNamedProperty(
+ $DataView.prototype, symbolToStringTag, "DataView", READ_ONLY|DONT_ENUM);
+
+InstallGetter($DataView.prototype, "buffer", DataViewGetBufferJS);
+InstallGetter($DataView.prototype, "byteOffset", DataViewGetByteOffset);
+InstallGetter($DataView.prototype, "byteLength", DataViewGetByteLength);
+
+InstallFunctions($DataView.prototype, DONT_ENUM, [
+ "getInt8", DataViewGetInt8JS,
+ "setInt8", DataViewSetInt8JS,
+
+ "getUint8", DataViewGetUint8JS,
+ "setUint8", DataViewSetUint8JS,
+
+ "getInt16", DataViewGetInt16JS,
+ "setInt16", DataViewSetInt16JS,
+
+ "getUint16", DataViewGetUint16JS,
+ "setUint16", DataViewSetUint16JS,
+
+ "getInt32", DataViewGetInt32JS,
+ "setInt32", DataViewSetInt32JS,
+
+ "getUint32", DataViewGetUint32JS,
+ "setUint32", DataViewSetUint32JS,
+
+ "getFloat32", DataViewGetFloat32JS,
+ "setFloat32", DataViewSetFloat32JS,
+
+ "getFloat64", DataViewGetFloat64JS,
+ "setFloat64", DataViewSetFloat64JS
+]);
+
+})();
« no previous file with comments | « src/string-iterator.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698