v8/test/mjsunit/harmony/sharedarraybuffer-stress.js
Jakob Kummerow 9f7ae50aa8 [ubsan] Make ARM and ARM64 UBSan-clean
Bug: v8:3770,v8:9666
Change-Id: I7b7652887d6b60fbb80e1100834bc7c9df0544d8
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1792909
Commit-Queue: Jakob Kummerow <jkummerow@chromium.org>
Reviewed-by: Martyn Capewell <martyn.capewell@arm.com>
Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
Reviewed-by: Jakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#63801}
2019-09-16 15:03:45 +00:00

35 lines
890 B
JavaScript

// Copyright 2019 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.
function Alloc(size) {
let b = new SharedArrayBuffer(size);
let v = new Int32Array(b);
return {buffer : b, view : v};
}
function RunSomeAllocs(total, retained, size) {
print(`-------iterations = ${total}, retained = ${retained} -------`);
var array = new Array(retained);
for (var i = 0; i < total; i++) {
let pair = Alloc(size);
// For some iterations, retain the memory, view, or both.
switch (i % 3) {
case 0:
pair.memory = null;
break;
case 1:
pair.view = null;
break;
case 2:
break;
}
array[i % retained] = pair;
}
}
RunSomeAllocs(10, 1, 1024);
RunSomeAllocs(100, 3, 2048);
RunSomeAllocs(1000, 10, 16384);
RunSomeAllocs(10000, 20, 32768);