4697e5bbab
This wraps float arrays with a proxy to make raw buffer use slow paths avoiding different NAN patterns. This also mocks out large typed arrays when passing the lenth as third constructor parameter. BUG=chromium:691287,chromium:690898 NOTRY=true Change-Id: Ic4295b0d8690e5209aceeda9ed93efdd580194c0 Reviewed-on: https://chromium-review.googlesource.com/441624 Commit-Queue: Michael Achenbach <machenbach@chromium.org> Reviewed-by: Yang Guo <yangguo@chromium.org> Cr-Commit-Position: refs/heads/master@{#43229}
46 lines
1.5 KiB
JavaScript
46 lines
1.5 KiB
JavaScript
// Copyright 2017 the V8 project authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
// This is intended for permanent JS behavior changes for mocking out
|
|
// non-deterministic behavior. For temporary suppressions, please refer to
|
|
// v8_suppressions.js.
|
|
// This mocks only architecture specific differences. Refer to v8_mocks.js
|
|
// for the general case.
|
|
// This file is loaded before each correctness test cases and won't get
|
|
// minimized.
|
|
|
|
// Mock maximum typed-array length and limit to 1MiB.
|
|
(function () {
|
|
var mock = function(arrayType) {
|
|
var handler = {
|
|
construct: function(target, args) {
|
|
var arrayLength = args[0]
|
|
if (args.length > 0 &&
|
|
Number.isInteger(args[0]) &&
|
|
args[0] > 1048576) {
|
|
args[0] = 1048576
|
|
} else if (args.length > 2 &&
|
|
Number.isInteger(args[2]) &&
|
|
args[2] > 1048576) {
|
|
args[2] = 1048576
|
|
}
|
|
return new (
|
|
Function.prototype.bind.apply(arrayType, [null].concat(args)));
|
|
},
|
|
};
|
|
return new Proxy(arrayType, handler);
|
|
}
|
|
|
|
ArrayBuffer = mock(ArrayBuffer);
|
|
Int8Array = mock(Int8Array);
|
|
Uint8Array = mock(Uint8Array);
|
|
Uint8ClampedArray = mock(Uint8ClampedArray);
|
|
Int16Array = mock(Int16Array);
|
|
Uint16Array = mock(Uint16Array);
|
|
Int32Array = mock(Int32Array);
|
|
Uint32Array = mock(Uint32Array);
|
|
Float32Array = mock(Float32Array);
|
|
Float64Array = mock(Float64Array);
|
|
})();
|