summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/ion/inlining/TypedObject-TypeDescrIsSimpleType.js
blob: 7536c4218ca169d0d5321087e86098002faa3b20 (plain)
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
/* -*- tab-width: 8; indent-tabs-mode: nil; js-indent-level: 2 -*-
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

/* Testing TypeDescrIsSimpleType() is tricky because it's not exposed.
 * However, the implementation of <typed-object>.build() must use it.
 *
 * This basically asserts that build() works, and thus that the code is
 * at least not broken.
 *
 * To verify that inlining happens:
 *
 * Run this with IONFLAGS=logs, generate pdfs with iongraph, and then
 * try running "pdfgrep TypeDescrIsSimpleType func*pass00*.pdf", this
 * might net a couple of functions that are likely candidates for
 * manual inspection.
 */

if (!this.TypedObject) {
    print("No TypedObject, skipping");
    quit();
}

var T = TypedObject;
var AT = new T.ArrayType(T.uint32, 100);

function check() {
    return AT.build(x => x+1);
}

function test() {
    var w;
    for ( var i=0 ; i < 100 ; i++ )
	w = check();
    return w;
}

var w = test();
assertEq(w.length, 100);
assertEq(w[99], 100);
print("Done");