Revert of Revert of Wrap typed array implementations in functions. (patchset #1 id:1 of https://codereview.chromium.org/1086683002/)

Reason for revert:
I don't think this is the cause.

Original issue's description:
> Revert of Wrap typed array implementations in functions. (patchset #1 id:1 of https://codereview.chromium.org/1082703003/)
>
> Reason for revert:
> [Sheriff] Flaky nosnap failures:
> http://build.chromium.org/p/client.v8/builders/V8%20Linux%20-%20arm64%20-%20sim%20-%20nosnap%20-%20debug%20-%201/builds/1720
> http://build.chromium.org/p/client.v8/builders/V8%20Linux%20-%20nosnap%20-%20debug/builds/3312
> http://build.chromium.org/p/client.v8/builders/V8%20Linux%20-%20nosnap%20-%20debug/builds/3313
>
> Original issue's description:
> > Wrap typed array implementations in functions.
> >
> > R=mvstanton@chromium.org
> >
> > Committed: https://crrev.com/6fc394a15614b74776f9bbeeb0486f430bdc8597
> > Cr-Commit-Position: refs/heads/master@{#27784}
>
> TBR=mvstanton@chromium.org,yangguo@chromium.org
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
>
> Committed: https://crrev.com/8e3fa7adf20f4f9c9125076a878d601eee7c9f35
> Cr-Commit-Position: refs/heads/master@{#27789}

TBR=mvstanton@chromium.org,machenbach@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true

Review URL: https://codereview.chromium.org/1083013002

Cr-Commit-Position: refs/heads/master@{#27803}
This commit is contained in:
yangguo 2015-04-13 22:58:25 -07:00 committed by Commit bot
parent 2b16f54d94
commit d7fe3b83f5
5 changed files with 116 additions and 121 deletions

View File

@ -2,13 +2,35 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
var $iteratorCreateResultObject;
var $arrayValues;
(function() {
"use strict"; "use strict";
%CheckIsBootstrapping();
// This file relies on the fact that the following declaration has been made var GlobalArray = global.Array;
// in runtime.js: var GlobalObject = global.Object;
// var $Array = global.Array;
macro TYPED_ARRAYS(FUNCTION)
FUNCTION(Uint8Array)
FUNCTION(Int8Array)
FUNCTION(Uint16Array)
FUNCTION(Int16Array)
FUNCTION(Uint32Array)
FUNCTION(Int32Array)
FUNCTION(Float32Array)
FUNCTION(Float64Array)
FUNCTION(Uint8ClampedArray)
endmacro
macro COPY_FROM_GLOBAL(NAME)
var GlobalNAME = global.NAME;
endmacro
TYPED_ARRAYS(COPY_FROM_GLOBAL)
var arrayIteratorObjectSymbol = GLOBAL_PRIVATE("ArrayIterator#object"); var arrayIteratorObjectSymbol = GLOBAL_PRIVATE("ArrayIterator#object");
var arrayIteratorNextIndexSymbol = GLOBAL_PRIVATE("ArrayIterator#next"); var arrayIteratorNextIndexSymbol = GLOBAL_PRIVATE("ArrayIterator#next");
@ -100,60 +122,38 @@ function ArrayKeys() {
} }
function SetUpArrayIterator() { %FunctionSetPrototype(ArrayIterator, new GlobalObject());
%CheckIsBootstrapping(); %FunctionSetInstanceClassName(ArrayIterator, 'Array Iterator');
%FunctionSetPrototype(ArrayIterator, new $Object()); InstallFunctions(ArrayIterator.prototype, DONT_ENUM, [
%FunctionSetInstanceClassName(ArrayIterator, 'Array Iterator'); 'next', ArrayIteratorNext
]);
%FunctionSetName(ArrayIteratorIterator, '[Symbol.iterator]');
%AddNamedProperty(ArrayIterator.prototype, symbolIterator,
ArrayIteratorIterator, DONT_ENUM);
%AddNamedProperty(ArrayIterator.prototype, symbolToStringTag,
"Array Iterator", READ_ONLY | DONT_ENUM);
InstallFunctions(ArrayIterator.prototype, DONT_ENUM, [ InstallFunctions(GlobalArray.prototype, DONT_ENUM, [
'next', ArrayIteratorNext // No 'values' since it breaks webcompat: http://crbug.com/409858
]); 'entries', ArrayEntries,
%FunctionSetName(ArrayIteratorIterator, '[Symbol.iterator]'); 'keys', ArrayKeys
%AddNamedProperty(ArrayIterator.prototype, symbolIterator, ]);
ArrayIteratorIterator, DONT_ENUM);
%AddNamedProperty(ArrayIterator.prototype, symbolToStringTag,
"Array Iterator", READ_ONLY | DONT_ENUM);
}
SetUpArrayIterator();
%AddNamedProperty(GlobalArray.prototype, symbolIterator, ArrayValues,
function ExtendArrayPrototype() { DONT_ENUM);
%CheckIsBootstrapping();
InstallFunctions($Array.prototype, DONT_ENUM, [
// No 'values' since it breaks webcompat: http://crbug.com/409858
'entries', ArrayEntries,
'keys', ArrayKeys
]);
%AddNamedProperty($Array.prototype, symbolIterator, ArrayValues, DONT_ENUM);
}
ExtendArrayPrototype();
function ExtendTypedArrayPrototypes() {
%CheckIsBootstrapping();
macro TYPED_ARRAYS(FUNCTION)
FUNCTION(Uint8Array)
FUNCTION(Int8Array)
FUNCTION(Uint16Array)
FUNCTION(Int16Array)
FUNCTION(Uint32Array)
FUNCTION(Int32Array)
FUNCTION(Float32Array)
FUNCTION(Float64Array)
FUNCTION(Uint8ClampedArray)
endmacro
macro EXTEND_TYPED_ARRAY(NAME) macro EXTEND_TYPED_ARRAY(NAME)
%AddNamedProperty($NAME.prototype, 'entries', ArrayEntries, DONT_ENUM); %AddNamedProperty(GlobalNAME.prototype, 'entries', ArrayEntries, DONT_ENUM);
%AddNamedProperty($NAME.prototype, 'values', ArrayValues, DONT_ENUM); %AddNamedProperty(GlobalNAME.prototype, 'values', ArrayValues, DONT_ENUM);
%AddNamedProperty($NAME.prototype, 'keys', ArrayKeys, DONT_ENUM); %AddNamedProperty(GlobalNAME.prototype, 'keys', ArrayKeys, DONT_ENUM);
%AddNamedProperty($NAME.prototype, symbolIterator, ArrayValues, DONT_ENUM); %AddNamedProperty(GlobalNAME.prototype, symbolIterator, ArrayValues,
DONT_ENUM);
endmacro endmacro
TYPED_ARRAYS(EXTEND_TYPED_ARRAY) TYPED_ARRAYS(EXTEND_TYPED_ARRAY)
}
ExtendTypedArrayPrototypes(); $iteratorCreateResultObject = CreateIteratorResultObject;
$arrayValues = ArrayValues;
})();

View File

@ -2,9 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
(function() {
"use strict"; "use strict";
var $ArrayBuffer = global.ArrayBuffer; %CheckIsBootstrapping();
var GlobalArrayBuffer = global.ArrayBuffer;
var GlobalObject = global.Object;
// ------------------------------------------------------------------- // -------------------------------------------------------------------
@ -56,7 +61,7 @@ function ArrayBufferSlice(start, end) {
} }
var newLen = fin - first; var newLen = fin - first;
// TODO(dslomov): implement inheritance // TODO(dslomov): implement inheritance
var result = new $ArrayBuffer(newLen); var result = new GlobalArrayBuffer(newLen);
%ArrayBufferSliceImpl(this, result, first); %ArrayBufferSliceImpl(this, result, first);
return result; return result;
@ -66,29 +71,26 @@ function ArrayBufferIsViewJS(obj) {
return %ArrayBufferIsView(obj); return %ArrayBufferIsView(obj);
} }
function SetUpArrayBuffer() {
%CheckIsBootstrapping();
// Set up the ArrayBuffer constructor function. // Set up the ArrayBuffer constructor function.
%SetCode($ArrayBuffer, ArrayBufferConstructor); %SetCode(GlobalArrayBuffer, ArrayBufferConstructor);
%FunctionSetPrototype($ArrayBuffer, new $Object()); %FunctionSetPrototype(GlobalArrayBuffer, new GlobalObject());
// Set up the constructor property on the ArrayBuffer prototype object. // Set up the constructor property on the ArrayBuffer prototype object.
%AddNamedProperty( %AddNamedProperty(
$ArrayBuffer.prototype, "constructor", $ArrayBuffer, DONT_ENUM); GlobalArrayBuffer.prototype, "constructor", GlobalArrayBuffer, DONT_ENUM);
%AddNamedProperty($ArrayBuffer.prototype, %AddNamedProperty(GlobalArrayBuffer.prototype,
symbolToStringTag, "ArrayBuffer", DONT_ENUM | READ_ONLY); symbolToStringTag, "ArrayBuffer", DONT_ENUM | READ_ONLY);
InstallGetter($ArrayBuffer.prototype, "byteLength", ArrayBufferGetByteLen); InstallGetter(GlobalArrayBuffer.prototype, "byteLength", ArrayBufferGetByteLen);
InstallFunctions($ArrayBuffer, DONT_ENUM, [ InstallFunctions(GlobalArrayBuffer, DONT_ENUM, [
"isView", ArrayBufferIsViewJS "isView", ArrayBufferIsViewJS
]); ]);
InstallFunctions($ArrayBuffer.prototype, DONT_ENUM, [ InstallFunctions(GlobalArrayBuffer.prototype, DONT_ENUM, [
"slice", ArrayBufferSlice "slice", ArrayBufferSlice
]); ]);
}
SetUpArrayBuffer(); })();

View File

@ -1566,7 +1566,7 @@ void Genesis::InstallNativeFunctions() {
native_object_get_notifier); native_object_get_notifier);
INSTALL_NATIVE(JSFunction, "NativeObjectNotifierPerformChange", INSTALL_NATIVE(JSFunction, "NativeObjectNotifierPerformChange",
native_object_notifier_perform_change); native_object_notifier_perform_change);
INSTALL_NATIVE(JSFunction, "ArrayValues", array_values_iterator); INSTALL_NATIVE(JSFunction, "$arrayValues", array_values_iterator);
} }

View File

@ -48,7 +48,7 @@ function StringIteratorNext() {
var s = GET_PRIVATE(iterator, stringIteratorIteratedStringSymbol); var s = GET_PRIVATE(iterator, stringIteratorIteratedStringSymbol);
if (IS_UNDEFINED(s)) { if (IS_UNDEFINED(s)) {
return CreateIteratorResultObject(UNDEFINED, true); return $iteratorCreateResultObject(UNDEFINED, true);
} }
var position = GET_PRIVATE(iterator, stringIteratorNextIndexSymbol); var position = GET_PRIVATE(iterator, stringIteratorNextIndexSymbol);
@ -57,7 +57,7 @@ function StringIteratorNext() {
if (position >= length) { if (position >= length) {
SET_PRIVATE(iterator, stringIteratorIteratedStringSymbol, SET_PRIVATE(iterator, stringIteratorIteratedStringSymbol,
UNDEFINED); UNDEFINED);
return CreateIteratorResultObject(UNDEFINED, true); return $iteratorCreateResultObject(UNDEFINED, true);
} }
var first = %_StringCharCodeAt(s, position); var first = %_StringCharCodeAt(s, position);
@ -74,7 +74,7 @@ function StringIteratorNext() {
SET_PRIVATE(iterator, stringIteratorNextIndexSymbol, position); SET_PRIVATE(iterator, stringIteratorNextIndexSymbol, position);
return CreateIteratorResultObject(resultString, false); return $iteratorCreateResultObject(resultString, false);
} }

View File

@ -2,13 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
(function() {
"use strict"; "use strict";
// This file relies on the fact that the following declaration has been made %CheckIsBootstrapping();
// in runtime.js:
// var $Array = global.Array;
var $ArrayBuffer = global.ArrayBuffer;
var GlobalArray = global.Array;
var GlobalArrayBuffer = global.ArrayBuffer;
// --------------- Typed Arrays --------------------- // --------------- Typed Arrays ---------------------
macro TYPED_ARRAYS(FUNCTION) macro TYPED_ARRAYS(FUNCTION)
@ -78,7 +79,7 @@ function NAMEConstructByLength(obj, length) {
} }
var byteLength = l * ELEMENT_SIZE; var byteLength = l * ELEMENT_SIZE;
if (byteLength > %_TypedArrayMaxSizeInHeap()) { if (byteLength > %_TypedArrayMaxSizeInHeap()) {
var buffer = new $ArrayBuffer(byteLength); var buffer = new GlobalArrayBuffer(byteLength);
%_TypedArrayInitialize(obj, ARRAY_ID, buffer, 0, byteLength); %_TypedArrayInitialize(obj, ARRAY_ID, buffer, 0, byteLength);
} else { } else {
%_TypedArrayInitialize(obj, ARRAY_ID, null, 0, byteLength); %_TypedArrayInitialize(obj, ARRAY_ID, null, 0, byteLength);
@ -243,7 +244,7 @@ function TypedArraySetFromOverlappingTypedArray(target, source, offset) {
} }
var rightIndex = CopyRightPart(); var rightIndex = CopyRightPart();
var temp = new $Array(rightIndex + 1 - leftIndex); var temp = new GlobalArray(rightIndex + 1 - leftIndex);
for (var i = leftIndex; i <= rightIndex; i++) { for (var i = leftIndex; i <= rightIndex; i++) {
temp[i - leftIndex] = source[i]; temp[i - leftIndex] = source[i];
} }
@ -300,7 +301,6 @@ function TypedArrayGetToStringTag() {
// ------------------------------------------------------------------- // -------------------------------------------------------------------
function SetupTypedArrays() {
macro SETUP_TYPED_ARRAY(ARRAY_ID, NAME, ELEMENT_SIZE) macro SETUP_TYPED_ARRAY(ARRAY_ID, NAME, ELEMENT_SIZE)
%CheckIsBootstrapping(); %CheckIsBootstrapping();
%SetCode(global.NAME, NAMEConstructor); %SetCode(global.NAME, NAMEConstructor);
@ -329,9 +329,6 @@ macro SETUP_TYPED_ARRAY(ARRAY_ID, NAME, ELEMENT_SIZE)
endmacro endmacro
TYPED_ARRAYS(SETUP_TYPED_ARRAY) TYPED_ARRAYS(SETUP_TYPED_ARRAY)
}
SetupTypedArrays();
// --------------------------- DataView ----------------------------- // --------------------------- DataView -----------------------------
@ -439,47 +436,43 @@ endmacro
DATA_VIEW_TYPES(DATA_VIEW_GETTER_SETTER) DATA_VIEW_TYPES(DATA_VIEW_GETTER_SETTER)
function SetupDataView() { // Setup the DataView constructor.
%CheckIsBootstrapping(); %SetCode($DataView, DataViewConstructor);
%FunctionSetPrototype($DataView, new $Object);
// Setup the DataView constructor. // Set up constructor property on the DataView prototype.
%SetCode($DataView, DataViewConstructor); %AddNamedProperty($DataView.prototype, "constructor", $DataView, DONT_ENUM);
%FunctionSetPrototype($DataView, new $Object); %AddNamedProperty(
$DataView.prototype, symbolToStringTag, "DataView", READ_ONLY|DONT_ENUM);
// Set up constructor property on the DataView prototype. InstallGetter($DataView.prototype, "buffer", DataViewGetBufferJS);
%AddNamedProperty($DataView.prototype, "constructor", $DataView, DONT_ENUM); InstallGetter($DataView.prototype, "byteOffset", DataViewGetByteOffset);
%AddNamedProperty( InstallGetter($DataView.prototype, "byteLength", DataViewGetByteLength);
$DataView.prototype, symbolToStringTag, "DataView", READ_ONLY|DONT_ENUM);
InstallGetter($DataView.prototype, "buffer", DataViewGetBufferJS); InstallFunctions($DataView.prototype, DONT_ENUM, [
InstallGetter($DataView.prototype, "byteOffset", DataViewGetByteOffset); "getInt8", DataViewGetInt8JS,
InstallGetter($DataView.prototype, "byteLength", DataViewGetByteLength); "setInt8", DataViewSetInt8JS,
InstallFunctions($DataView.prototype, DONT_ENUM, [ "getUint8", DataViewGetUint8JS,
"getInt8", DataViewGetInt8JS, "setUint8", DataViewSetUint8JS,
"setInt8", DataViewSetInt8JS,
"getUint8", DataViewGetUint8JS, "getInt16", DataViewGetInt16JS,
"setUint8", DataViewSetUint8JS, "setInt16", DataViewSetInt16JS,
"getInt16", DataViewGetInt16JS, "getUint16", DataViewGetUint16JS,
"setInt16", DataViewSetInt16JS, "setUint16", DataViewSetUint16JS,
"getUint16", DataViewGetUint16JS, "getInt32", DataViewGetInt32JS,
"setUint16", DataViewSetUint16JS, "setInt32", DataViewSetInt32JS,
"getInt32", DataViewGetInt32JS, "getUint32", DataViewGetUint32JS,
"setInt32", DataViewSetInt32JS, "setUint32", DataViewSetUint32JS,
"getUint32", DataViewGetUint32JS, "getFloat32", DataViewGetFloat32JS,
"setUint32", DataViewSetUint32JS, "setFloat32", DataViewSetFloat32JS,
"getFloat32", DataViewGetFloat32JS, "getFloat64", DataViewGetFloat64JS,
"setFloat32", DataViewSetFloat32JS, "setFloat64", DataViewSetFloat64JS
]);
"getFloat64", DataViewGetFloat64JS, })();
"setFloat64", DataViewSetFloat64JS
]);
}
SetupDataView();