Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
57 lines (54 loc) · 1.35 KB

File metadata and controls

57 lines (54 loc) · 1.35 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
function doAlloc() {
var x0 = null;
var x1 = null;
var x2 = null;
var x3 = null;
var x4 = null;
var x5 = null;
var x6 = null;
var x7 = null;
var x8 = null;
var x9 = null;
for (var i = 0; i < 100000; i++) {
x0 = [];
x1 = [];
x2 = [];
x3 = [];
x4 = [];
x5 = [];
x6 = [];
x7 = [];
x8 = [];
x9 = [];
}
// We must prevent the Hermes (or other) compiler from optimizing away the allocations
// in the loop above. So we use the most recent objects allocated, in a way where we
// return the result. (A compiler *could* be smart enough to realize that only the last
// loop iteration is needed, but Hermes, at least, is not that smart today.)
x0.push(0);
x1.push(1);
x2.push(2);
x3.push(3);
x4.push(4);
x5.push(5);
x6.push(6);
x7.push(7);
x8.push(8);
x9.push(9);
return x0[0] + x1[0] + x2[0] + x3[0] + x4[0] +
x5[0] + x6[0] + x7[0] + x8[0] + x9[0];
}
function allocNTimes(n) {
var sum = 0;
for (var i = 0; i < n; i++) {
sum += doAlloc()
}
return sum;
}
print(allocNTimes(500));
Morty Proxy This is a proxified and sanitized view of the page, visit original site.