Elliott Hughes | 2faa5f1 | 2012-01-30 14:42:07 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2011 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
Shih-wei Liao | 63433ba | 2011-10-15 18:40:39 -0700 | [diff] [blame] | 16 | |
| 17 | #include <stdio.h> |
| 18 | |
| 19 | #include "UniquePtr.h" |
| 20 | #include "class_linker.h" |
Ian Rogers | 0c7abda | 2012-09-19 13:33:42 -0700 | [diff] [blame] | 21 | #include "gc_map.h" |
Shih-wei Liao | 63433ba | 2011-10-15 18:40:39 -0700 | [diff] [blame] | 22 | #include "object.h" |
Ian Rogers | 6d4d9fc | 2011-11-30 16:24:48 -0800 | [diff] [blame] | 23 | #include "object_utils.h" |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 24 | #include "scoped_thread_state_change.h" |
Shih-wei Liao | 371814f | 2011-10-27 16:52:10 -0700 | [diff] [blame] | 25 | #include "thread.h" |
Shih-wei Liao | 63433ba | 2011-10-15 18:40:39 -0700 | [diff] [blame] | 26 | #include "jni.h" |
Ian Rogers | 776ac1f | 2012-04-13 23:36:36 -0700 | [diff] [blame] | 27 | #include "verifier/method_verifier.h" |
Shih-wei Liao | 63433ba | 2011-10-15 18:40:39 -0700 | [diff] [blame] | 28 | |
| 29 | namespace art { |
| 30 | |
Ian Rogers | 6d4d9fc | 2011-11-30 16:24:48 -0800 | [diff] [blame] | 31 | #define IS_IN_REF_BITMAP(mh, ref_bitmap, reg) \ |
| 32 | ( ((reg) < mh.GetCodeItem()->registers_size_) && \ |
Shih-wei Liao | 39723d3 | 2011-10-24 02:20:31 -0700 | [diff] [blame] | 33 | (( *((ref_bitmap) + (reg)/8) >> ((reg) % 8) ) & 0x01) ) |
Shih-wei Liao | 63433ba | 2011-10-15 18:40:39 -0700 | [diff] [blame] | 34 | |
Shih-wei Liao | 39723d3 | 2011-10-24 02:20:31 -0700 | [diff] [blame] | 35 | #define CHECK_REGS_CONTAIN_REFS(...) \ |
| 36 | do { \ |
Shih-wei Liao | 63433ba | 2011-10-15 18:40:39 -0700 | [diff] [blame] | 37 | int t[] = {__VA_ARGS__}; \ |
| 38 | int t_size = sizeof(t) / sizeof(*t); \ |
| 39 | for (int i = 0; i < t_size; ++i) \ |
Ian Rogers | 6d4d9fc | 2011-11-30 16:24:48 -0800 | [diff] [blame] | 40 | CHECK(IS_IN_REF_BITMAP(mh, ref_bitmap, t[i])) \ |
Shih-wei Liao | 39723d3 | 2011-10-24 02:20:31 -0700 | [diff] [blame] | 41 | << "Error: Reg @ " << i << "-th argument is not in GC map"; \ |
Elliott Hughes | b25c3f6 | 2012-03-26 16:35:06 -0700 | [diff] [blame] | 42 | } while (false) |
Shih-wei Liao | 63433ba | 2011-10-15 18:40:39 -0700 | [diff] [blame] | 43 | |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 44 | struct ReferenceMap2Visitor : public StackVisitor { |
| 45 | explicit ReferenceMap2Visitor(const ManagedStack* stack, |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 46 | const std::vector<TraceStackFrame>* trace_stack) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 47 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 48 | : StackVisitor(stack, trace_stack, NULL) { |
Shih-wei Liao | 63433ba | 2011-10-15 18:40:39 -0700 | [diff] [blame] | 49 | } |
| 50 | |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 51 | bool VisitFrame() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 52 | Method* m = GetMethod(); |
| 53 | if (!m || m->IsNative() || m->IsRuntimeMethod() || IsShadowFrame()) { |
Elliott Hughes | 530fa00 | 2012-03-12 11:44:49 -0700 | [diff] [blame] | 54 | return true; |
Shih-wei Liao | 63433ba | 2011-10-15 18:40:39 -0700 | [diff] [blame] | 55 | } |
| 56 | LOG(INFO) << "At " << PrettyMethod(m, false); |
| 57 | |
Ian Rogers | 0c7abda | 2012-09-19 13:33:42 -0700 | [diff] [blame] | 58 | NativePcOffsetToReferenceMap map(m->GetNativeGcMap()); |
Shih-wei Liao | 63433ba | 2011-10-15 18:40:39 -0700 | [diff] [blame] | 59 | |
Shih-wei Liao | 63433ba | 2011-10-15 18:40:39 -0700 | [diff] [blame] | 60 | if (m->IsCalleeSaveMethod()) { |
| 61 | LOG(WARNING) << "no PC for " << PrettyMethod(m); |
Elliott Hughes | 530fa00 | 2012-03-12 11:44:49 -0700 | [diff] [blame] | 62 | return true; |
Shih-wei Liao | 63433ba | 2011-10-15 18:40:39 -0700 | [diff] [blame] | 63 | } |
| 64 | |
Shih-wei Liao | 371814f | 2011-10-27 16:52:10 -0700 | [diff] [blame] | 65 | // Enable this to dump reference map to LOG(INFO) |
| 66 | if (false) { |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 67 | ScopedObjectAccess ts(Thread::Current()); |
Ian Rogers | 776ac1f | 2012-04-13 23:36:36 -0700 | [diff] [blame] | 68 | art::verifier::MethodVerifier::VerifyMethodAndDump(m); |
Shih-wei Liao | 371814f | 2011-10-27 16:52:10 -0700 | [diff] [blame] | 69 | } |
Shih-wei Liao | 39723d3 | 2011-10-24 02:20:31 -0700 | [diff] [blame] | 70 | const uint8_t* ref_bitmap = NULL; |
Ian Rogers | 6d4d9fc | 2011-11-30 16:24:48 -0800 | [diff] [blame] | 71 | MethodHelper mh(m); |
| 72 | std::string m_name(mh.GetName()); |
Shih-wei Liao | 63433ba | 2011-10-15 18:40:39 -0700 | [diff] [blame] | 73 | |
| 74 | // Given the method name and the number of times the method has been called, |
| 75 | // we know the Dex registers with live reference values. Assert that what we |
| 76 | // find is what is expected. |
| 77 | if (m_name.compare("f") == 0) { |
Ian Rogers | 0c7abda | 2012-09-19 13:33:42 -0700 | [diff] [blame] | 78 | ref_bitmap = map.FindBitMap(m->NativePcOffset(m->ToNativePc(0x03U))); |
Shih-wei Liao | 39723d3 | 2011-10-24 02:20:31 -0700 | [diff] [blame] | 79 | CHECK(ref_bitmap); |
| 80 | CHECK_REGS_CONTAIN_REFS(8); // v8: this |
Shih-wei Liao | 63433ba | 2011-10-15 18:40:39 -0700 | [diff] [blame] | 81 | |
Ian Rogers | 0c7abda | 2012-09-19 13:33:42 -0700 | [diff] [blame] | 82 | ref_bitmap = map.FindBitMap(m->NativePcOffset(m->ToNativePc(0x06U))); |
Shih-wei Liao | 39723d3 | 2011-10-24 02:20:31 -0700 | [diff] [blame] | 83 | CHECK(ref_bitmap); |
Shih-wei Liao | 371814f | 2011-10-27 16:52:10 -0700 | [diff] [blame] | 84 | CHECK_REGS_CONTAIN_REFS(8, 1); // v8: this, v1: x |
Shih-wei Liao | 63433ba | 2011-10-15 18:40:39 -0700 | [diff] [blame] | 85 | |
Ian Rogers | 0c7abda | 2012-09-19 13:33:42 -0700 | [diff] [blame] | 86 | ref_bitmap = map.FindBitMap(m->NativePcOffset(m->ToNativePc(0x08U))); |
Shih-wei Liao | 39723d3 | 2011-10-24 02:20:31 -0700 | [diff] [blame] | 87 | CHECK(ref_bitmap); |
Shih-wei Liao | 371814f | 2011-10-27 16:52:10 -0700 | [diff] [blame] | 88 | CHECK_REGS_CONTAIN_REFS(8, 3, 1); // v8: this, v3: y, v1: x |
Shih-wei Liao | 63433ba | 2011-10-15 18:40:39 -0700 | [diff] [blame] | 89 | |
Ian Rogers | 0c7abda | 2012-09-19 13:33:42 -0700 | [diff] [blame] | 90 | ref_bitmap = map.FindBitMap(m->NativePcOffset(m->ToNativePc(0x0cU))); |
Shih-wei Liao | 39723d3 | 2011-10-24 02:20:31 -0700 | [diff] [blame] | 91 | CHECK(ref_bitmap); |
Shih-wei Liao | 371814f | 2011-10-27 16:52:10 -0700 | [diff] [blame] | 92 | CHECK_REGS_CONTAIN_REFS(8, 3, 1); // v8: this, v3: y, v1: x |
Shih-wei Liao | 63433ba | 2011-10-15 18:40:39 -0700 | [diff] [blame] | 93 | |
Ian Rogers | 0c7abda | 2012-09-19 13:33:42 -0700 | [diff] [blame] | 94 | ref_bitmap = map.FindBitMap(m->NativePcOffset(m->ToNativePc(0x0eU))); |
Shih-wei Liao | 39723d3 | 2011-10-24 02:20:31 -0700 | [diff] [blame] | 95 | CHECK(ref_bitmap); |
Shih-wei Liao | 371814f | 2011-10-27 16:52:10 -0700 | [diff] [blame] | 96 | CHECK_REGS_CONTAIN_REFS(8, 3, 1); // v8: this, v3: y, v1: x |
Shih-wei Liao | 63433ba | 2011-10-15 18:40:39 -0700 | [diff] [blame] | 97 | |
Ian Rogers | 0c7abda | 2012-09-19 13:33:42 -0700 | [diff] [blame] | 98 | ref_bitmap = map.FindBitMap(m->NativePcOffset(m->ToNativePc(0x10U))); |
Shih-wei Liao | 39723d3 | 2011-10-24 02:20:31 -0700 | [diff] [blame] | 99 | CHECK(ref_bitmap); |
Shih-wei Liao | 371814f | 2011-10-27 16:52:10 -0700 | [diff] [blame] | 100 | CHECK_REGS_CONTAIN_REFS(8, 3, 1); // v8: this, v3: y, v1: x |
Shih-wei Liao | 63433ba | 2011-10-15 18:40:39 -0700 | [diff] [blame] | 101 | |
Ian Rogers | 0c7abda | 2012-09-19 13:33:42 -0700 | [diff] [blame] | 102 | ref_bitmap = map.FindBitMap(m->NativePcOffset(m->ToNativePc(0x13U))); |
Shih-wei Liao | 39723d3 | 2011-10-24 02:20:31 -0700 | [diff] [blame] | 103 | CHECK(ref_bitmap); |
Shih-wei Liao | 371814f | 2011-10-27 16:52:10 -0700 | [diff] [blame] | 104 | // v2 is added because of the instruction at DexPC 0024. Object merges with 0 is Object. See: |
| 105 | // 0024: move-object v3, v2 |
| 106 | // 0025: goto 0013 |
| 107 | // Detaled dex instructions for ReferenceMap.java are at the end of this function. |
| 108 | CHECK_REGS_CONTAIN_REFS(8, 3, 2, 1); // v8: this, v3: y, v2: y, v1: x |
Shih-wei Liao | 63433ba | 2011-10-15 18:40:39 -0700 | [diff] [blame] | 109 | |
Ian Rogers | 0c7abda | 2012-09-19 13:33:42 -0700 | [diff] [blame] | 110 | ref_bitmap = map.FindBitMap(m->NativePcOffset(m->ToNativePc(0x18U))); |
Shih-wei Liao | 39723d3 | 2011-10-24 02:20:31 -0700 | [diff] [blame] | 111 | CHECK(ref_bitmap); |
Shih-wei Liao | 371814f | 2011-10-27 16:52:10 -0700 | [diff] [blame] | 112 | CHECK_REGS_CONTAIN_REFS(8, 2, 1, 0); // v8: this, v2: y, v1: x, v0: ex |
Shih-wei Liao | 63433ba | 2011-10-15 18:40:39 -0700 | [diff] [blame] | 113 | |
Ian Rogers | 0c7abda | 2012-09-19 13:33:42 -0700 | [diff] [blame] | 114 | ref_bitmap = map.FindBitMap(m->NativePcOffset(m->ToNativePc(0x1aU))); |
Shih-wei Liao | 39723d3 | 2011-10-24 02:20:31 -0700 | [diff] [blame] | 115 | CHECK(ref_bitmap); |
Shih-wei Liao | 371814f | 2011-10-27 16:52:10 -0700 | [diff] [blame] | 116 | CHECK_REGS_CONTAIN_REFS(8, 5, 2, 1, 0); // v8: this, v5: x[1], v2: y, v1: x, v0: ex |
Shih-wei Liao | 63433ba | 2011-10-15 18:40:39 -0700 | [diff] [blame] | 117 | |
Ian Rogers | 0c7abda | 2012-09-19 13:33:42 -0700 | [diff] [blame] | 118 | ref_bitmap = map.FindBitMap(m->NativePcOffset(m->ToNativePc(0x1dU))); |
Shih-wei Liao | 39723d3 | 2011-10-24 02:20:31 -0700 | [diff] [blame] | 119 | CHECK(ref_bitmap); |
Shih-wei Liao | 371814f | 2011-10-27 16:52:10 -0700 | [diff] [blame] | 120 | CHECK_REGS_CONTAIN_REFS(8, 5, 2, 1, 0); // v8: this, v5: x[1], v2: y, v1: x, v0: ex |
Shih-wei Liao | 63433ba | 2011-10-15 18:40:39 -0700 | [diff] [blame] | 121 | |
Ian Rogers | 0c7abda | 2012-09-19 13:33:42 -0700 | [diff] [blame] | 122 | ref_bitmap = map.FindBitMap(m->NativePcOffset(m->ToNativePc(0x1fU))); |
Shih-wei Liao | 39723d3 | 2011-10-24 02:20:31 -0700 | [diff] [blame] | 123 | CHECK(ref_bitmap); |
Shih-wei Liao | 371814f | 2011-10-27 16:52:10 -0700 | [diff] [blame] | 124 | // v5 is removed from the root set because there is a "merge" operation. |
| 125 | // See 0015: if-nez v2, 001f. |
| 126 | CHECK_REGS_CONTAIN_REFS(8, 2, 1, 0); // v8: this, v2: y, v1: x, v0: ex |
Shih-wei Liao | 63433ba | 2011-10-15 18:40:39 -0700 | [diff] [blame] | 127 | |
Ian Rogers | 0c7abda | 2012-09-19 13:33:42 -0700 | [diff] [blame] | 128 | ref_bitmap = map.FindBitMap(m->NativePcOffset(m->ToNativePc(0x21U))); |
Shih-wei Liao | 39723d3 | 2011-10-24 02:20:31 -0700 | [diff] [blame] | 129 | CHECK(ref_bitmap); |
Shih-wei Liao | 371814f | 2011-10-27 16:52:10 -0700 | [diff] [blame] | 130 | CHECK_REGS_CONTAIN_REFS(8, 2, 1, 0); // v8: this, v2: y, v1: x, v0: ex |
Shih-wei Liao | 63433ba | 2011-10-15 18:40:39 -0700 | [diff] [blame] | 131 | |
Ian Rogers | 0c7abda | 2012-09-19 13:33:42 -0700 | [diff] [blame] | 132 | ref_bitmap = map.FindBitMap(m->NativePcOffset(m->ToNativePc(0x25U))); |
Shih-wei Liao | 39723d3 | 2011-10-24 02:20:31 -0700 | [diff] [blame] | 133 | CHECK(ref_bitmap); |
Shih-wei Liao | 371814f | 2011-10-27 16:52:10 -0700 | [diff] [blame] | 134 | CHECK_REGS_CONTAIN_REFS(8, 3, 2, 1, 0); // v8: this, v3: y, v2: y, v1: x, v0: ex |
Shih-wei Liao | 63433ba | 2011-10-15 18:40:39 -0700 | [diff] [blame] | 135 | |
Ian Rogers | 0c7abda | 2012-09-19 13:33:42 -0700 | [diff] [blame] | 136 | ref_bitmap = map.FindBitMap(m->NativePcOffset(m->ToNativePc(0x27U))); |
Shih-wei Liao | 39723d3 | 2011-10-24 02:20:31 -0700 | [diff] [blame] | 137 | CHECK(ref_bitmap); |
Shih-wei Liao | 371814f | 2011-10-27 16:52:10 -0700 | [diff] [blame] | 138 | CHECK_REGS_CONTAIN_REFS(8, 4, 2, 1); // v8: this, v4: ex, v2: y, v1: x |
Shih-wei Liao | 63433ba | 2011-10-15 18:40:39 -0700 | [diff] [blame] | 139 | |
Ian Rogers | 0c7abda | 2012-09-19 13:33:42 -0700 | [diff] [blame] | 140 | ref_bitmap = map.FindBitMap(m->NativePcOffset(m->ToNativePc(0x29U))); |
Shih-wei Liao | 39723d3 | 2011-10-24 02:20:31 -0700 | [diff] [blame] | 141 | CHECK(ref_bitmap); |
Shih-wei Liao | 371814f | 2011-10-27 16:52:10 -0700 | [diff] [blame] | 142 | CHECK_REGS_CONTAIN_REFS(8, 4, 2, 1); // v8: this, v4: ex, v2: y, v1: x |
Shih-wei Liao | 63433ba | 2011-10-15 18:40:39 -0700 | [diff] [blame] | 143 | |
Ian Rogers | 0c7abda | 2012-09-19 13:33:42 -0700 | [diff] [blame] | 144 | ref_bitmap = map.FindBitMap(m->NativePcOffset(m->ToNativePc(0x2cU))); |
Shih-wei Liao | 39723d3 | 2011-10-24 02:20:31 -0700 | [diff] [blame] | 145 | CHECK(ref_bitmap); |
Shih-wei Liao | 371814f | 2011-10-27 16:52:10 -0700 | [diff] [blame] | 146 | CHECK_REGS_CONTAIN_REFS(8, 4, 2, 1); // v8: this, v4: ex, v2: y, v1: x |
Shih-wei Liao | 39723d3 | 2011-10-24 02:20:31 -0700 | [diff] [blame] | 147 | |
Ian Rogers | 0c7abda | 2012-09-19 13:33:42 -0700 | [diff] [blame] | 148 | ref_bitmap = map.FindBitMap(m->NativePcOffset(m->ToNativePc(0x2fU))); |
Shih-wei Liao | 39723d3 | 2011-10-24 02:20:31 -0700 | [diff] [blame] | 149 | CHECK(ref_bitmap); |
Shih-wei Liao | 371814f | 2011-10-27 16:52:10 -0700 | [diff] [blame] | 150 | CHECK_REGS_CONTAIN_REFS(8, 4, 3, 2, 1); // v8: this, v4: ex, v3: y, v2: y, v1: x |
Shih-wei Liao | 39723d3 | 2011-10-24 02:20:31 -0700 | [diff] [blame] | 151 | |
Ian Rogers | 0c7abda | 2012-09-19 13:33:42 -0700 | [diff] [blame] | 152 | ref_bitmap = map.FindBitMap(m->NativePcOffset(m->ToNativePc(0x32U))); |
Shih-wei Liao | 39723d3 | 2011-10-24 02:20:31 -0700 | [diff] [blame] | 153 | CHECK(ref_bitmap); |
Shih-wei Liao | 371814f | 2011-10-27 16:52:10 -0700 | [diff] [blame] | 154 | CHECK_REGS_CONTAIN_REFS(8, 3, 2, 1, 0); // v8: this, v3: y, v2: y, v1: x, v0: ex |
Shih-wei Liao | 63433ba | 2011-10-15 18:40:39 -0700 | [diff] [blame] | 155 | } |
Elliott Hughes | 530fa00 | 2012-03-12 11:44:49 -0700 | [diff] [blame] | 156 | |
| 157 | return true; |
Shih-wei Liao | 63433ba | 2011-10-15 18:40:39 -0700 | [diff] [blame] | 158 | } |
| 159 | }; |
| 160 | |
Shih-wei Liao | 371814f | 2011-10-27 16:52:10 -0700 | [diff] [blame] | 161 | // Dex instructions for the function 'f' in ReferenceMap.java |
| 162 | // Virtual methods - |
| 163 | // #0 : (in LReferenceMap;) |
| 164 | // name : 'f' |
| 165 | // type : '()Ljava/lang/Object;' |
| 166 | // access : 0x0000 () |
| 167 | // code - |
| 168 | // registers : 9 |
| 169 | // ins : 1 |
| 170 | // outs : 2 |
| 171 | // insns size : 51 16-bit code units |
| 172 | // |[0001e8] ReferenceMap.f:()Ljava/lang/Object; |
| 173 | // |0000: const/4 v4, #int 2 // #2 |
| 174 | // |0001: const/4 v7, #int 0 // #0 |
| 175 | // |0002: const/4 v6, #int 1 // #1 |
| 176 | // |
| 177 | //0:[Unknown],1:[Unknown],2:[Unknown],3:[Unknown],4:[32-bit Constant: 2],5:[Unknown],6:[32-bit Constant: 1],7:[Zero],8:[Reference: ReferenceMap], |
| 178 | // |0003: new-array v1, v4, [Ljava/lang/Object; // type@0007 |
| 179 | // |0005: const/4 v2, #int 0 // #0 |
| 180 | |
| 181 | //0:[Unknown],1:[Reference: java.lang.Object[]],2:[Zero],3:[Unknown],4:[32-bit Constant: 2],5:[Unknown],6:[32-bit Constant: 1],7:[Zero],8:[Reference: ReferenceMap], |
| 182 | // |0006: new-instance v3, Ljava/lang/Object; // type@0003 |
| 183 | |
| 184 | //[Unknown],1:[Reference: java.lang.Object[]],2:[Zero],3:[Uninitialized Reference: java.lang.Object],4:[32-bit Constant: 2],5:[Unknown],6:[32-bit Constant: 1],7:[Zero],8:[Reference: ReferenceMap], |
| 185 | // |0008: +invoke-object-init/range {}, Ljava/lang/Object;.<init>:()V // method@0005 |
| 186 | // |000b: const/4 v4, #int 2 // #2 |
| 187 | |
| 188 | //0:[Unknown],1:[Reference: java.lang.Object[]],2:[Zero],3:[Reference: java.lang.Object],4:[32-bit Constant: 2],5:[Unknown],6:[32-bit Constant: 1],7:[Zero],8:[Reference: ReferenceMap], |
| 189 | // |000c: aput-object v3, v1, v4 |
| 190 | |
| 191 | //0:[Unknown],1:[Reference: java.lang.Object[]],2:[Zero],3:[Reference: java.lang.Object],4:[32-bit Constant: 2],5:[Unknown],6:[32-bit Constant: 1],7:[Zero],8:[Reference: ReferenceMap], |
| 192 | // |000e: aput-object v3, v1, v6 |
| 193 | |
| 194 | //0:[Unknown],1:[Reference: java.lang.Object[]],2:[Zero],3:[Reference: java.lang.Object],4:[32-bit Constant: 2],5:[Unknown],6:[32-bit Constant: 1],7:[Zero],8:[Reference: ReferenceMap], |
| 195 | // |0010: +invoke-virtual-quick {v8, v7}, [000c] // vtable #000c |
| 196 | |
| 197 | //0:[Conflict],1:[Reference: java.lang.Object[]],2:[Reference: java.lang.Object],3:[Reference: java.lang.Object],4:[32-bit Constant: 2],5:[Conflict],6:[32-bit Constant: 1],7:[Zero],8:[Reference: ReferenceMap], |
| 198 | // |0013: return-object v3 |
| 199 | // |0014: move-exception v0 |
| 200 | |
| 201 | //0:[Reference: java.lang.Exception],1:[Reference: java.lang.Object[]],2:[Reference: java.lang.Object],3:[Conflict],4:[32-bit Constant: 2],5:[Unknown],6:[32-bit Constant: 1],7:[Zero],8:[Reference: ReferenceMap], |
| 202 | // |0015: if-nez v2, 001f // +000a |
| 203 | // |0017: const/4 v4, #int 1 // #1 |
| 204 | |
| 205 | //0:[Reference: java.lang.Exception],1:[Reference: java.lang.Object[]],2:[Reference: java.lang.Object],3:[Conflict],4:[32-bit Constant: 1],5:[Unknown],6:[32-bit Constant: 1],7:[Zero],8:[Reference: ReferenceMap], |
| 206 | // |0018: new-instance v5, Ljava/lang/Object; // type@0003 |
| 207 | |
| 208 | //0:[Reference: java.lang.Exception],1:[Reference: java.lang.Object[]],2:[Reference: java.lang.Object],3:[Conflict],4:[32-bit Constant: 1],5:[Uninitialized Reference: java.lang.Object],6:[32-bit Constant: 1],7:[Zero],8:[Reference: ReferenceMap], |
| 209 | // |001a: +invoke-object-init/range {}, Ljava/lang/Object;.<init>:()V // method@0005 |
| 210 | |
| 211 | //0:[Reference: java.lang.Exception],1:[Reference: java.lang.Object[]],2:[Reference: java.lang.Object],3:[Conflict],4:[32-bit Constant: 1],5:[Reference: java.lang.Object],6:[32-bit Constant: 1],7:[Zero],8:[Reference: ReferenceMap], |
| 212 | // |001d: aput-object v5, v1, v4 |
| 213 | |
| 214 | //0:[Reference: java.lang.Exception],1:[Reference: java.lang.Object[]],2:[Reference: java.lang.Object],3:[Conflict],4:[32-bit Constant: 2],5:[Conflict],6:[32-bit Constant: 1],7:[Zero],8:[Reference: ReferenceMap], |
| 215 | // |001f: aput-object v2, v1, v6 |
| 216 | |
| 217 | //0:[Reference: java.lang.Exception],1:[Reference: java.lang.Object[]],2:[Reference: java.lang.Object],3:[Conflict],4:[32-bit Constant: 2],5:[Conflict],6:[32-bit Constant: 1],7:[Zero],8:[Reference: ReferenceMap], |
| 218 | // |0021: +invoke-virtual-quick {v8, v7}, [000c] // vtable #000c |
| 219 | // |0024: move-object v3, v2 |
| 220 | |
| 221 | //0:[Reference: java.lang.Exception],1:[Reference: java.lang.Object[]],2:[Reference: java.lang.Object],3:[Reference: java.lang.Object],4:[32-bit Constant: 2],5:[Conflict],6:[32-bit Constant: 1],7:[Zero],8:[Reference: ReferenceMap], |
| 222 | // |0025: goto 0013 // -0012 |
| 223 | // |0026: move-exception v4 |
| 224 | |
| 225 | //0:[Conflict],1:[Reference: java.lang.Object[]],2:[Reference: java.lang.Object],3:[Conflict],4:[Reference: java.lang.Throwable],5:[Conflict],6:[32-bit Constant: 1],7:[Zero],8:[Reference: ReferenceMap], |
| 226 | // |0027: aput-object v2, v1, v6 |
| 227 | |
| 228 | //0:[Conflict],1:[Reference: java.lang.Object[]],2:[Reference: java.lang.Object],3:[Conflict],4:[Reference: java.lang.Throwable],5:[Conflict],6:[32-bit Constant: 1],7:[Zero],8:[Reference: ReferenceMap], |
| 229 | // |0029: +invoke-virtual-quick {v8, v7}, [000c] // vtable #000c |
| 230 | |
| 231 | //0:[Conflict],1:[Reference: java.lang.Object[]],2:[Reference: java.lang.Object],3:[Conflict],4:[Reference: java.lang.Throwable],5:[Conflict],6:[32-bit Constant: 1],7:[Zero],8:[Reference: ReferenceMap], |
| 232 | // |002c: throw v4 |
| 233 | // |002d: move-exception v4 |
| 234 | // |002e: move-object v2, v3 |
| 235 | |
| 236 | //0:[Unknown],1:[Reference: java.lang.Object[]],2:[Reference: java.lang.Object],3:[Reference: java.lang.Object],4:[Reference: java.lang.Throwable],5:[Unknown],6:[32-bit Constant: 1],7:[Zero],8:[Reference: ReferenceMap], |
| 237 | // |002f: goto 0027 // -0008 |
| 238 | // |0030: move-exception v0 |
| 239 | // |0031: move-object v2, v3 |
| 240 | |
| 241 | //0:[Reference: java.lang.Exception],1:[Reference: java.lang.Object[]],2:[Reference: java.lang.Object],3:[Reference: java.lang.Object],4:[32-bit Constant: 2],5:[Unknown],6:[32-bit Constant: 1],7:[Zero],8:[Reference: ReferenceMap], |
| 242 | // |0032: goto 0015 // -001d |
| 243 | // catches : 3 |
| 244 | // 0x0006 - 0x000b |
| 245 | // Ljava/lang/Exception; -> 0x0014 |
| 246 | // <any> -> 0x0026 |
| 247 | // 0x000c - 0x000e |
| 248 | // Ljava/lang/Exception; -> 0x0030 |
| 249 | // <any> -> 0x002d |
| 250 | // 0x0018 - 0x001f |
| 251 | // <any> -> 0x0026 |
| 252 | // positions : |
| 253 | // 0x0003 line=8 |
| 254 | // 0x0005 line=9 |
| 255 | // 0x0006 line=11 |
| 256 | // 0x000b line=12 |
| 257 | // 0x000e line=18 |
| 258 | // 0x0010 line=19 |
| 259 | // 0x0013 line=21 |
| 260 | // 0x0014 line=13 |
| 261 | // 0x0015 line=14 |
| 262 | // 0x0017 line=15 |
| 263 | // 0x001f line=18 |
| 264 | // 0x0021 line=19 |
| 265 | // 0x0025 line=20 |
| 266 | // 0x0026 line=18 |
| 267 | // 0x0029 line=19 |
| 268 | // 0x002d line=18 |
| 269 | // 0x0030 line=13 |
| 270 | // locals : |
| 271 | // 0x0006 - 0x000b reg=2 y Ljava/lang/Object; |
| 272 | // 0x000b - 0x0013 reg=3 y Ljava/lang/Object; |
| 273 | // 0x0014 - 0x0015 reg=2 y Ljava/lang/Object; |
| 274 | // 0x0015 - 0x0026 reg=0 ex Ljava/lang/Exception; |
| 275 | // 0x002d - 0x0032 reg=3 y Ljava/lang/Object; |
| 276 | // 0x0005 - 0x0033 reg=1 x [Ljava/lang/Object; |
| 277 | // 0x0032 - 0x0033 reg=2 y Ljava/lang/Object; |
| 278 | // 0x0000 - 0x0033 reg=8 this LReferenceMap; |
| 279 | |
Elliott Hughes | 1bac54f | 2012-03-16 12:48:31 -0700 | [diff] [blame] | 280 | extern "C" JNIEXPORT jint JNICALL Java_ReferenceMap_refmap(JNIEnv*, jobject, jint count) { |
Shih-wei Liao | 63433ba | 2011-10-15 18:40:39 -0700 | [diff] [blame] | 281 | // Visitor |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 282 | ScopedObjectAccess ts(Thread::Current()); |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 283 | ReferenceMap2Visitor mapper(Thread::Current()->GetManagedStack(), |
| 284 | Thread::Current()->GetTraceStack()); |
| 285 | mapper.WalkStack(); |
Shih-wei Liao | 63433ba | 2011-10-15 18:40:39 -0700 | [diff] [blame] | 286 | |
| 287 | return count + 1; |
| 288 | } |
| 289 | |
| 290 | } |