blob: b4ea2d79e7cb88ca123dedd46995f2fa081ff654 [file] [log] [blame]
Shih-wei Liao9407c602011-09-16 10:36:43 -07001// Copyright 2011 Google Inc. All Rights Reserved.
2
Shih-wei Liao9407c602011-09-16 10:36:43 -07003public class StackWalk2 {
4 // use v1 for this
5
6 String str = new String(); // use v0 for str in <init>
7
8 int f() {
9 g(1); // use v0 for 1, v1 for this
10 g(2); // use v0 for 2, v1 for this
11 strTest(); // use v1 for this
12 return 0;
13 }
14
15 void g(int num_calls) throws RuntimeException {
16 if (num_calls == 1) { // use v0 for 1, v3 for num_calls
17 System.logI("1st call"); // use v0 for PrintStream, v1 for "1st call"
18 refmap2(24); // use v0 for 24, v2 for this
19 } else if (num_calls == 2) { // use v0 for 2, v3 for num_calls
20 System.logI("2nd call"); // use v0 for PrintStream, v1 for "2nd call"
21 refmap2(25); // use v0 for 24, v2 for this
22 }
23 throw new RuntimeException(); // use v0 for new RuntimeException
24 }
25
26 void strTest() {
27 System.logI(str); // use v1 for PrintStream, v2, v3 for str
28 str = null; // use v1 for null, v3 for str
29 str = new String("ya"); // use v2 for "ya", v1 for new String
30 String s = str; // use v0, v1, v3
31 System.logI(str); // use v1 for PrintStream, v2, v3 for str
32 System.logI(s); // use v1 for PrintStream, v0 for s
33 s = null; // use v0
34 System.logI(s); // use v1 for PrintStream, v0 for s
35 }
36
37 native int refmap2(int x);
38
39 static {
40 System.loadLibrary("arttest");
41 }
42
43 public static void main(String[] args) {
44 StackWalk2 st = new StackWalk2();
45 st.f();
46 }
47}