@@ -72,7 +72,7 @@ checkROMMethodInfoCache(J9ClassLoader *classLoader, void *key, J9ROMMethodInfo *
7272 exemplar.key = key;
7373 J9ROMMethodInfo *entry = (J9ROMMethodInfo *)hashTableFind (cache, &exemplar);
7474 if (NULL != entry) {
75- *outInfo = *entry; /* Copy struct */
75+ *outInfo = *entry;
7676 found = true ;
7777 }
7878 }
@@ -95,18 +95,19 @@ updateROMMethodInfoCache(J9JavaVM *vm, J9ClassLoader *classLoader, J9ROMMethodIn
9595
9696 J9HashTable *cache = classLoader->romMethodInfoCache ;
9797 if (NULL == cache) {
98+ /* Create the cache if it doesn't exist */
9899 cache = hashTableNew (
99- OMRPORT_FROM_J9PORT (vm->portLibrary ),
100- J9_GET_CALLSITE (),
101- 0 ,
102- sizeof (J9ROMMethodInfo),
103- sizeof (J9ROMMethodInfo *),
104- 0 ,
105- J9MEM_CATEGORY_VM,
106- romMethodInfoHashFn,
107- romMethodInfoEqualFn,
108- NULL ,
109- NULL );
100+ OMRPORT_FROM_J9PORT (vm->portLibrary ),
101+ J9_GET_CALLSITE (),
102+ 0 ,
103+ sizeof (J9ROMMethodInfo),
104+ sizeof (J9ROMMethodInfo *),
105+ 0 ,
106+ J9MEM_CATEGORY_VM,
107+ romMethodInfoHashFn,
108+ romMethodInfoEqualFn,
109+ NULL ,
110+ NULL );
110111 classLoader->romMethodInfoCache = cache;
111112 }
112113
@@ -117,69 +118,100 @@ updateROMMethodInfoCache(J9JavaVM *vm, J9ClassLoader *classLoader, J9ROMMethodIn
117118 omrthread_monitor_exit (mapCacheMutex);
118119}
119120
120- void
121- populateROMMethodInfo (J9StackWalkState *walkState, J9ROMMethod *romMethod, void *key)
121+ static void
122+ populateROMMethodInfo (J9StackWalkState *walkState, J9ROMMethod *romMethod, void *key, UDATA pc, bool computeStackAndLocals )
122123{
123- initializeBasicROMMethodInfo (walkState, romMethod);
124-
125124 J9Method *method = walkState->method ;
126125 J9ClassLoader *classLoader = J9_CLASS_FROM_METHOD (method)->classLoader ;
127126 J9JavaVM *vm = walkState->javaVM ;
128127
129- UDATA codeSize = (UDATA)J9_BYTECODE_SIZE_FROM_ROM_METHOD (romMethod);
130- void *bytecodeStart = (void *)J9_BYTECODE_START_FROM_ROM_METHOD (romMethod);
131-
132- bool isMethodCase = (key == (void *)romMethod);
133- UDATA pc = 0 ;
134-
135- if (!isMethodCase) {
136- // Compute PC only if key points into bytecode range
137- if ((uintptr_t )key >= (uintptr_t )bytecodeStart &&
138- (uintptr_t )key < (uintptr_t )bytecodeStart + codeSize) {
139- pc = (UDATA)((uintptr_t )key - (uintptr_t )bytecodeStart);
140- }
141- }
142-
143- J9ROMClass *romClass = J9_CLASS_FROM_METHOD (method)->romClass ;
144128 J9ROMMethodInfo newInfo = {0 };
145129 newInfo.key = key;
130+ J9ROMClass *romClass = J9_CLASS_FROM_METHOD (method)->romClass ;
146131
147- // Always compute argbits
132+ /* Always compute argument bits */
148133 j9localmap_ArgBitsForPC0 (romClass, romMethod, newInfo.argbits );
149134
150- if (!isMethodCase && pc < codeSize ) {
151- // Stack map
135+ if (computeStackAndLocals && pc < (UDATA) J9_BYTECODE_SIZE_FROM_ROM_METHOD (romMethod) ) {
136+ /* Compute stack map for this PC */
152137 j9stackmap_StackBitsForPC (
153- vm->portLibrary ,
154- pc,
155- romClass,
156- romMethod,
157- newInfo.stackmap ,
158- J9_STACKMAP_CACHE_SLOTS << 5 ,
159- NULL , NULL , NULL );
160-
161- // Local map
138+ vm->portLibrary ,
139+ pc,
140+ romClass,
141+ romMethod,
142+ newInfo.stackmap ,
143+ J9_STACKMAP_CACHE_SLOTS << 5 ,
144+ NULL ,
145+ NULL ,
146+ NULL );
147+
148+ /* Compute local variable map for this PC */
162149 vm->localMapFunction (
163- vm->portLibrary ,
164- romClass,
165- romMethod,
166- pc,
167- newInfo.localmap ,
168- NULL , NULL , NULL );
150+ vm->portLibrary ,
151+ romClass,
152+ romMethod,
153+ pc,
154+ newInfo.localmap ,
155+ NULL ,
156+ NULL ,
157+ NULL );
169158 }
170159
171- // Copy metadata
160+ /* Copy metadata */
172161 newInfo.modifiers = romMethod->modifiers ;
173162 newInfo.argCount = J9_ARG_COUNT_FROM_ROM_METHOD (romMethod);
174163 newInfo.tempCount = J9_TEMP_COUNT_FROM_ROM_METHOD (romMethod);
175164
176- // Insert into cache
165+ /* Insert into cache */
177166 updateROMMethodInfoCache (vm, classLoader, &newInfo);
178167
179- // Reflect it into the current walkState
168+ /* Reflect into current walkState */
180169 walkState->romMethodInfo = newInfo;
181170}
182171
172+ void
173+ getROMMethodInfoForROMMethod (J9StackWalkState *walkState, J9ROMMethod *romMethod)
174+ {
175+ initializeBasicROMMethodInfo (walkState, romMethod);
176+ J9Method *method = walkState->method ;
177+ J9ClassLoader *classLoader = J9_CLASS_FROM_METHOD (method)->classLoader ;
178+
179+ void *key = (void *)romMethod;
180+ J9ROMMethodInfo tmp = {0 };
181+
182+ /* Check cache first */
183+ if (!checkROMMethodInfoCache (classLoader, key, &tmp)) {
184+ /* Cache miss or not populated: populate argbits only */
185+ populateROMMethodInfo (walkState, romMethod, key, 0 , false );
186+ } else {
187+ walkState->romMethodInfo = tmp;
188+ }
189+ }
190+
191+ /* Bytecode PC: compute argbits + stackmap + localmap */
192+ void
193+ getROMMethodInfoForBytecodePC (J9StackWalkState *walkState, J9ROMMethod *romMethod, UDATA pc)
194+ {
195+ initializeBasicROMMethodInfo (walkState, romMethod);
196+ if (pc <= J9SF_MAX_SPECIAL_FRAME_TYPE || pc >= (UDATA)J9_BYTECODE_SIZE_FROM_ROM_METHOD (romMethod)) {
197+ return ;
198+ }
199+
200+ J9Method *method = walkState->method ;
201+ J9ClassLoader *classLoader = J9_CLASS_FROM_METHOD (method)->classLoader ;
202+
203+ void *key = (void *)( (uintptr_t )J9_BYTECODE_START_FROM_ROM_METHOD (romMethod) + (uintptr_t )pc );
204+ J9ROMMethodInfo tmp = {0 };
205+
206+ /* Check cache first */
207+ if (!checkROMMethodInfoCache (classLoader, key, &tmp)) {
208+ /* Cache miss or not populated: compute stack/local maps */
209+ populateROMMethodInfo (walkState, romMethod, key, pc, true );
210+ } else {
211+ walkState->romMethodInfo = tmp;
212+ }
213+ }
214+
183215#if 0
184216
185217void
0 commit comments