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

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: 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 // See Runtime_GetOptimizationStatus in runtime-test.cc
8 const kInterpreted = 8;
9 const kNo = 2;
10
11 function Baseline() {
12 let array = new Uint8Array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]);
13
14 let it = array[Symbol.iterator]();
15 assertEquals(0, it.next().value);
16 assertEquals(1, it.next().value);
17 assertEquals(2, it.next().value);
18 %ArrayBufferNeuter(array.buffer);
19 it.next();
20 };
21 %NeverOptimizeFunction(Baseline);
22
23 assertThrows(Baseline, TypeError,
24 "Cannot perform Array Iterator.prototype.next on a detached ArrayBuffer");
25
26 function Turbo() {
27 let array = Array(5000);
28 for (let i = 0; i < 5000; ++i) {
29 array[i] = 254;
30 }
31 array[3000] = 255;
32 array = new Uint8Array(array);
33
34 let sum = 0;
35 let it = array[Symbol.iterator]();
36 for (let i = 0; i < 5000; ++i) {
37 let result = it.next();
38 if (result.value === 255) {
39 let state = %GetOptimizationStatus(Turbo);
40 assertTrue(state === kInterpreted || state === kNo,
41 "Turbo should be optimized using TurboFan backend.");
caitp 2017/01/03 16:26:36 these sorts of assertions are hard to get right :(
42 %ArrayBufferNeuter(array.buffer);
43 }
44 sum += result.value;
45 }
46 return sum;
47 }
48
49 assertThrows(Turbo, TypeError,
50 "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