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

Side by Side Diff: test/mjsunit/es6/array-iterator-detached.js

Issue 2609913002: [builtins] throw if TypedArray buffer is detached during iteration (Closed)
Patch Set: fix the other compiler error Created 3 years, 11 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 unified diff | Download patch
« no previous file with comments | « src/compiler/js-builtin-reducer.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2017 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // Flags: --allow-natives-syntax
6
7 function Baseline() {
8 let array = new Uint8Array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]);
9
10 let it = array[Symbol.iterator]();
11 assertEquals(0, it.next().value);
12 assertEquals(1, it.next().value);
13 assertEquals(2, it.next().value);
14 %ArrayBufferNeuter(array.buffer);
15 it.next();
16 };
17 %NeverOptimizeFunction(Baseline);
18
19 assertThrows(Baseline, TypeError,
20 "Cannot perform Array Iterator.prototype.next on a detached ArrayBuffer");
21
22 function Turbo(count = 10000) {
23 let array = Array(10000);
24 for (let i = 0; i < 10000; ++i) {
25 array[i] = 254;
26 }
27 array[5000] = 255;
28 array = new Uint8Array(array);
29
30 let sum = 0;
31 let it = array[Symbol.iterator]();
32 for (let i = 0; i < count; ++i) {
33 let result = it.next();
34 if (result.value === 255) {
35 %ArrayBufferNeuter(array.buffer);
36 }
37 sum += result.value;
38 }
39 return sum;
40 }
41
42 Turbo(10);
43 Turbo(10);
44 %OptimizeFunctionOnNextCall(Turbo);
45
46 assertThrows(Turbo, TypeError,
47 "Cannot perform Array Iterator.prototype.next on a detached ArrayBuffer");
OLDNEW
« no previous file with comments | « src/compiler/js-builtin-reducer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698