1 /*
  2  * Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved.
  3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  4  *
  5  * This code is free software; you can redistribute it and/or modify it
  6  * under the terms of the GNU General Public License version 2 only, as
  7  * published by the Free Software Foundation.
  8  *
  9  * This code is distributed in the hope that it will be useful, but WITHOUT
 10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 12  * version 2 for more details (a copy is included in the LICENSE file that
 13  * accompanied this code).
 14  *
 15  * You should have received a copy of the GNU General Public License version
 16  * 2 along with this work; if not, write to the Free Software Foundation,
 17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 18  *
 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  *
 23  */
 24 
 25 #include "precompiled.hpp"
 26 #include "code/debugInfoRec.hpp"
 27 #include "code/pcDesc.hpp"
 28 #include "gc/shared/collectedHeap.inline.hpp"
 29 #include "memory/universe.hpp"
 30 #include "oops/oop.inline.hpp"
 31 #include "prims/forte.hpp"
 32 #include "prims/jvmtiExport.hpp"
 33 #include "runtime/frame.inline.hpp"
 34 #include "runtime/javaCalls.hpp"
 35 #include "runtime/thread.inline.hpp"
 36 #include "runtime/vframe.inline.hpp"
 37 #include "runtime/vframeArray.hpp"
 38 
 39 // call frame copied from old .h file and renamed
 40 typedef struct {
 41     jint lineno;                      // line number in the source file
 42     jmethodID method_id;              // method executed in this frame
 43 } ASGCT_CallFrame;
 44 
 45 // call trace copied from old .h file and renamed
 46 typedef struct {
 47     JNIEnv *env_id;                   // Env where trace was recorded
 48     jint num_frames;                  // number of frames in this trace
 49     ASGCT_CallFrame *frames;          // frames
 50 } ASGCT_CallTrace;
 51 
 52 // These name match the names reported by the forte quality kit
 53 enum {
 54   ticks_no_Java_frame         =  0,
 55   ticks_no_class_load         = -1,
 56   ticks_GC_active             = -2,
 57   ticks_unknown_not_Java      = -3,
 58   ticks_not_walkable_not_Java = -4,
 59   ticks_unknown_Java          = -5,
 60   ticks_not_walkable_Java     = -6,
 61   ticks_unknown_state         = -7,
 62   ticks_thread_exit           = -8,
 63   ticks_deopt                 = -9,
 64   ticks_safepoint             = -10
 65 };
 66 
 67 #if INCLUDE_JVMTI
 68 
 69 //-------------------------------------------------------
 70 
 71 // Native interfaces for use by Forte tools.
 72 
 73 
 74 #if !defined(IA64)
 75 
 76 class vframeStreamForte : public vframeStreamCommon {
 77  public:
 78   // constructor that starts with sender of frame fr (top_frame)
 79   vframeStreamForte(JavaThread *jt, frame fr, bool stop_at_java_call_stub);
 80   void forte_next();
 81 };
 82 
 83 
 84 static bool is_decipherable_compiled_frame(JavaThread* thread, frame* fr, CompiledMethod* nm);
 85 static bool is_decipherable_interpreted_frame(JavaThread* thread,
 86                                               frame* fr,
 87                                               Method** method_p,
 88                                               int* bci_p);
 89 
 90 
 91 
 92 
 93 vframeStreamForte::vframeStreamForte(JavaThread *jt,
 94                                      frame fr,
 95                                      bool stop_at_java_call_stub) : vframeStreamCommon(jt, false /* process_frames */) {
 96 
 97   _stop_at_java_call_stub = stop_at_java_call_stub;
 98   _frame = fr;
 99 
100   // We must always have a valid frame to start filling
101 
102   bool filled_in = fill_from_frame();
103 
104   assert(filled_in, "invariant");
105 
106 }
107 
108 
109 // Solaris SPARC Compiler1 needs an additional check on the grandparent
110 // of the top_frame when the parent of the top_frame is interpreted and
111 // the grandparent is compiled. However, in this method we do not know
112 // the relationship of the current _frame relative to the top_frame so
113 // we implement a more broad sanity check. When the previous callee is
114 // interpreted and the current sender is compiled, we verify that the
115 // current sender is also walkable. If it is not walkable, then we mark
116 // the current vframeStream as at the end.
117 void vframeStreamForte::forte_next() {
118   // handle frames with inlining
119   if (_mode == compiled_mode &&
120       vframeStreamCommon::fill_in_compiled_inlined_sender()) {
121     return;
122   }
123 
124   // handle general case
125 
126   int loop_count = 0;
127   int loop_max = MaxJavaStackTraceDepth * 2;
128 
129 
130   do {
131 
132     loop_count++;
133 
134     // By the time we get here we should never see unsafe but better
135     // safe then segv'd
136 
137     if ((loop_max != 0 && loop_count > loop_max) || !_frame.safe_for_sender(_thread)) {
138       _mode = at_end_mode;
139       return;
140     }
141 
142     _frame = _frame.sender(&_reg_map);
143 
144   } while (!fill_from_frame());
145 }
146 
147 // Determine if 'fr' is a decipherable compiled frame. We are already
148 // assured that fr is for a java compiled method.
149 
150 static bool is_decipherable_compiled_frame(JavaThread* thread, frame* fr, CompiledMethod* nm) {
151   assert(nm->is_java_method(), "invariant");
152 
153   if (thread->has_last_Java_frame() && thread->last_Java_pc() == fr->pc()) {
154     // We're stopped at a call into the JVM so look for a PcDesc with
155     // the actual pc reported by the frame.
156     PcDesc* pc_desc = nm->pc_desc_at(fr->pc());
157 
158     // Did we find a useful PcDesc?
159     if (pc_desc != NULL &&
160         pc_desc->scope_decode_offset() != DebugInformationRecorder::serialized_null) {
161       return true;
162     }
163   }
164 
165   // We're at some random pc in the compiled method so search for the PcDesc
166   // whose pc is greater than the current PC.  It's done this way
167   // because the extra PcDescs that are recorded for improved debug
168   // info record the end of the region covered by the ScopeDesc
169   // instead of the beginning.
170   PcDesc* pc_desc = nm->pc_desc_near(fr->pc() + 1);
171 
172   // Now do we have a useful PcDesc?
173   if (pc_desc == NULL ||
174       pc_desc->scope_decode_offset() == DebugInformationRecorder::serialized_null) {
175     // No debug information is available for this PC.
176     //
177     // vframeStreamCommon::fill_from_frame() will decode the frame depending
178     // on the state of the thread.
179     //
180     // Case #1: If the thread is in Java (state == _thread_in_Java), then
181     // the vframeStreamCommon object will be filled as if the frame were a native
182     // compiled frame. Therefore, no debug information is needed.
183     //
184     // Case #2: If the thread is in any other state, then two steps will be performed:
185     // - if asserts are enabled, found_bad_method_frame() will be called and
186     //   the assert in found_bad_method_frame() will be triggered;
187     // - if asserts are disabled, the vframeStreamCommon object will be filled
188     //   as if it were a native compiled frame.
189     //
190     // Case (2) is similar to the way interpreter frames are processed in
191     // vframeStreamCommon::fill_from_interpreter_frame in case no valid BCI
192     // was found for an interpreted frame. If asserts are enabled, the assert
193     // in found_bad_method_frame() will be triggered. If asserts are disabled,
194     // the vframeStreamCommon object will be filled afterwards as if the
195     // interpreter were at the point of entering into the method.
196     return false;
197   }
198 
199   // This PcDesc is useful however we must adjust the frame's pc
200   // so that the vframeStream lookups will use this same pc
201   fr->set_pc(pc_desc->real_pc(nm));
202   return true;
203 }
204 
205 
206 // Determine if 'fr' is a walkable interpreted frame. Returns false
207 // if it is not. *method_p, and *bci_p are not set when false is
208 // returned. *method_p is non-NULL if frame was executing a Java
209 // method. *bci_p is != -1 if a valid BCI in the Java method could
210 // be found.
211 // Note: this method returns true when a valid Java method is found
212 // even if a valid BCI cannot be found.
213 
214 static bool is_decipherable_interpreted_frame(JavaThread* thread,
215                                               frame* fr,
216                                               Method** method_p,
217                                               int* bci_p) {
218   assert(fr->is_interpreted_frame(), "just checking");
219 
220   // top frame is an interpreted frame
221   // check if it is walkable (i.e. valid Method* and valid bci)
222 
223   // Because we may be racing a gc thread the method and/or bci
224   // of a valid interpreter frame may look bad causing us to
225   // fail the is_interpreted_frame_valid test. If the thread
226   // is in any of the following states we are assured that the
227   // frame is in fact valid and we must have hit the race.
228 
229   JavaThreadState state = thread->thread_state();
230   bool known_valid = (state == _thread_in_native ||
231                       state == _thread_in_vm ||
232                       state == _thread_blocked );
233 
234   if (known_valid || fr->is_interpreted_frame_valid(thread)) {
235 
236     // The frame code should completely validate the frame so that
237     // references to Method* and bci are completely safe to access
238     // If they aren't the frame code should be fixed not this
239     // code. However since gc isn't locked out the values could be
240     // stale. This is a race we can never completely win since we can't
241     // lock out gc so do one last check after retrieving their values
242     // from the frame for additional safety
243 
244     Method* method = fr->interpreter_frame_method();
245 
246     // We've at least found a method.
247     // NOTE: there is something to be said for the approach that
248     // if we don't find a valid bci then the method is not likely
249     // a valid method. Then again we may have caught an interpreter
250     // frame in the middle of construction and the bci field is
251     // not yet valid.
252     if (!Method::is_valid_method(method)) return false;
253     *method_p = method; // If the Method* found is invalid, it is
254                         // ignored by forte_fill_call_trace_given_top().
255                         // So set method_p only if the Method is valid.
256 
257     address bcp = fr->interpreter_frame_bcp();
258     int bci = method->validate_bci_from_bcp(bcp);
259 
260     // note: bci is set to -1 if not a valid bci
261     *bci_p = bci;
262     return true;
263   }
264 
265   return false;
266 }
267 
268 
269 // Determine if a Java frame can be found starting with the frame 'fr'.
270 //
271 // Check the return value of find_initial_Java_frame and the value of
272 // 'method_p' to decide on how use the results returned by this method.
273 //
274 // If 'method_p' is not NULL, an initial Java frame has been found and
275 // the stack can be walked starting from that initial frame. In this case,
276 // 'method_p' points to the Method that the initial frame belongs to and
277 // the initial Java frame is returned in initial_frame_p.
278 //
279 // find_initial_Java_frame() returns true if a Method has been found (i.e.,
280 // 'method_p' is not NULL) and the initial frame that belongs to that Method
281 // is decipherable.
282 //
283 // A frame is considered to be decipherable:
284 //
285 // - if the frame is a compiled frame and a PCDesc is available;
286 //
287 // - if the frame is an interpreter frame that is valid or the thread is
288 //   state (_thread_in_native || state == _thread_in_vm || state == _thread_blocked).
289 //
290 // Note that find_initial_Java_frame() can return false even if an initial
291 // Java method was found (e.g., there is no PCDesc available for the method).
292 //
293 // If 'method_p' is NULL, it was not possible to find a Java frame when
294 // walking the stack starting from 'fr'. In this case find_initial_Java_frame
295 // returns false.
296 
297 static bool find_initial_Java_frame(JavaThread* thread,
298                                     frame* fr,
299                                     frame* initial_frame_p,
300                                     Method** method_p,
301                                     int* bci_p) {
302 
303   // It is possible that for a frame containing a compiled method
304   // we can capture the method but no bci. If we get no
305   // bci the frame isn't walkable but the method is usable.
306   // Therefore we init the returned Method* to NULL so the
307   // caller can make the distinction.
308 
309   *method_p = NULL;
310 
311   // On the initial call to this method the frame we get may not be
312   // recognizable to us. This should only happen if we are in a JRT_LEAF
313   // or something called by a JRT_LEAF method.
314 
315   frame candidate = *fr;
316 
317 #ifdef ZERO
318   // Zero has no frames with code blobs, so the generic code fails.
319   // Instead, try to do Zero-specific search for Java frame.
320 
321   {
322     RegisterMap map(thread, false, false);
323 
324     while (true) {
325       // Cannot walk this frame? Cannot do anything anymore.
326       if (!candidate.safe_for_sender(thread)) {
327         return false;
328       }
329 
330       if (candidate.is_entry_frame()) {
331         // jcw is NULL if the java call wrapper could not be found
332         JavaCallWrapper* jcw = candidate.entry_frame_call_wrapper_if_safe(thread);
333         // If initial frame is frame from StubGenerator and there is no
334         // previous anchor, there are no java frames associated with a method
335         if (jcw == NULL || jcw->is_first_frame()) {
336           return false;
337         }
338       }
339 
340       // If we find a decipherable interpreted frame, this is our initial frame.
341       if (candidate.is_interpreted_frame()) {
342         if (is_decipherable_interpreted_frame(thread, &candidate, method_p, bci_p)) {
343           *initial_frame_p = candidate;
344           return true;
345         }
346       }
347 
348       // Walk some more.
349       candidate = candidate.sender(&map);
350     }
351 
352     // No dice, report no initial frames.
353     return false;
354   }
355 #endif
356 
357   // If the starting frame we were given has no codeBlob associated with
358   // it see if we can find such a frame because only frames with codeBlobs
359   // are possible Java frames.
360 
361   if (fr->cb() == NULL) {
362 
363     // See if we can find a useful frame
364     int loop_count;
365     int loop_max = MaxJavaStackTraceDepth * 2;
366     RegisterMap map(thread, false, false);
367 
368     for (loop_count = 0; loop_max == 0 || loop_count < loop_max; loop_count++) {
369       if (!candidate.safe_for_sender(thread)) return false;
370       candidate = candidate.sender(&map);
371       if (candidate.cb() != NULL) break;
372     }
373     if (candidate.cb() == NULL) return false;
374   }
375 
376   // We have a frame known to be in the codeCache
377   // We will hopefully be able to figure out something to do with it.
378   int loop_count;
379   int loop_max = MaxJavaStackTraceDepth * 2;
380   RegisterMap map(thread, false, false);
381 
382   for (loop_count = 0; loop_max == 0 || loop_count < loop_max; loop_count++) {
383 
384     if (candidate.is_entry_frame()) {
385       // jcw is NULL if the java call wrapper couldn't be found
386       JavaCallWrapper *jcw = candidate.entry_frame_call_wrapper_if_safe(thread);
387       // If initial frame is frame from StubGenerator and there is no
388       // previous anchor, there are no java frames associated with a method
389       if (jcw == NULL || jcw->is_first_frame()) {
390         return false;
391       }
392     }
393 
394     if (candidate.is_interpreted_frame()) {
395       if (is_decipherable_interpreted_frame(thread, &candidate, method_p, bci_p)) {
396         *initial_frame_p = candidate;
397         return true;
398       }
399 
400       // Hopefully we got some data
401       return false;
402     }
403 
404     if (candidate.cb()->is_compiled()) {
405 
406       CompiledMethod* nm = candidate.cb()->as_compiled_method();
407       *method_p = nm->method();
408 
409       // If the frame is not decipherable, then the value of -1
410       // for the BCI is used to signal that no BCI is available.
411       // Furthermore, the method returns false in this case.
412       //
413       // If a decipherable frame is available, the BCI value will
414       // not be used.
415 
416       *bci_p = -1;
417 
418       *initial_frame_p = candidate;
419 
420       // Native wrapper code is trivial to decode by vframeStream
421 
422       if (nm->is_native_method()) return true;
423 
424       // If the frame is not decipherable, then a PC was found
425       // that does not have a PCDesc from which a BCI can be obtained.
426       // Nevertheless, a Method was found.
427 
428       if (!is_decipherable_compiled_frame(thread, &candidate, nm)) {
429         return false;
430       }
431 
432       // is_decipherable_compiled_frame may modify candidate's pc
433       *initial_frame_p = candidate;
434 
435       assert(nm->pc_desc_at(candidate.pc()) != NULL, "debug information must be available if the frame is decipherable");
436 
437       return true;
438     }
439 
440     // Must be some stub frame that we don't care about
441 
442     if (!candidate.safe_for_sender(thread)) return false;
443     candidate = candidate.sender(&map);
444 
445     // If it isn't in the code cache something is wrong
446     // since once we find a frame in the code cache they
447     // all should be there.
448 
449     if (candidate.cb() == NULL) return false;
450 
451   }
452 
453   return false;
454 
455 }
456 
457 static void forte_fill_call_trace_given_top(JavaThread* thd,
458                                             ASGCT_CallTrace* trace,
459                                             int depth,
460                                             frame top_frame) {
461   NoHandleMark nhm;
462 
463   frame initial_Java_frame;
464   Method* method;
465   int bci = -1; // assume BCI is not available for method
466                 // update with correct information if available
467   int count;
468 
469   count = 0;
470   assert(trace->frames != NULL, "trace->frames must be non-NULL");
471 
472   // Walk the stack starting from 'top_frame' and search for an initial Java frame.
473   find_initial_Java_frame(thd, &top_frame, &initial_Java_frame, &method, &bci);
474 
475   // Check if a Java Method has been found.
476   if (method == NULL) return;
477 
478   if (!Method::is_valid_method(method)) {
479     trace->num_frames = ticks_GC_active; // -2
480     return;
481   }
482 
483   vframeStreamForte st(thd, initial_Java_frame, false);
484 
485   for (; !st.at_end() && count < depth; st.forte_next(), count++) {
486     bci = st.bci();
487     method = st.method();
488 
489     if (!Method::is_valid_method(method)) {
490       // we throw away everything we've gathered in this sample since
491       // none of it is safe
492       trace->num_frames = ticks_GC_active; // -2
493       return;
494     }
495 
496     trace->frames[count].method_id = method->find_jmethod_id_or_null();
497     if (!method->is_native()) {
498       trace->frames[count].lineno = bci;
499     } else {
500       trace->frames[count].lineno = -3;
501     }
502   }
503   trace->num_frames = count;
504   return;
505 }
506 
507 
508 // Forte Analyzer AsyncGetCallTrace() entry point. Currently supported
509 // on Linux X86, Solaris SPARC and Solaris X86.
510 //
511 // Async-safe version of GetCallTrace being called from a signal handler
512 // when a LWP gets interrupted by SIGPROF but the stack traces are filled
513 // with different content (see below).
514 //
515 // This function must only be called when JVM/TI
516 // CLASS_LOAD events have been enabled since agent startup. The enabled
517 // event will cause the jmethodIDs to be allocated at class load time.
518 // The jmethodIDs cannot be allocated in a signal handler because locks
519 // cannot be grabbed in a signal handler safely.
520 //
521 // void (*AsyncGetCallTrace)(ASGCT_CallTrace *trace, jint depth, void* ucontext)
522 //
523 // Called by the profiler to obtain the current method call stack trace for
524 // a given thread. The thread is identified by the env_id field in the
525 // ASGCT_CallTrace structure. The profiler agent should allocate a ASGCT_CallTrace
526 // structure with enough memory for the requested stack depth. The VM fills in
527 // the frames buffer and the num_frames field.
528 //
529 // Arguments:
530 //
531 //   trace    - trace data structure to be filled by the VM.
532 //   depth    - depth of the call stack trace.
533 //   ucontext - ucontext_t of the LWP
534 //
535 // ASGCT_CallTrace:
536 //   typedef struct {
537 //       JNIEnv *env_id;
538 //       jint num_frames;
539 //       ASGCT_CallFrame *frames;
540 //   } ASGCT_CallTrace;
541 //
542 // Fields:
543 //   env_id     - ID of thread which executed this trace.
544 //   num_frames - number of frames in the trace.
545 //                (< 0 indicates the frame is not walkable).
546 //   frames     - the ASGCT_CallFrames that make up this trace. Callee followed by callers.
547 //
548 //  ASGCT_CallFrame:
549 //    typedef struct {
550 //        jint lineno;
551 //        jmethodID method_id;
552 //    } ASGCT_CallFrame;
553 //
554 //  Fields:
555 //    1) For Java frame (interpreted and compiled),
556 //       lineno    - bci of the method being executed or -1 if bci is not available
557 //       method_id - jmethodID of the method being executed
558 //    2) For native method
559 //       lineno    - (-3)
560 //       method_id - jmethodID of the method being executed
561 
562 extern "C" {
563 JNIEXPORT
564 void AsyncGetCallTrace(ASGCT_CallTrace *trace, jint depth, void* ucontext) {
565   JavaThread* thread;
566 
567   if (trace->env_id == NULL ||
568     (thread = JavaThread::thread_from_jni_environment(trace->env_id)) == NULL ||
569     thread->is_exiting()) {
570 
571     // bad env_id, thread has exited or thread is exiting
572     trace->num_frames = ticks_thread_exit; // -8
573     return;
574   }
575 
576   if (thread->in_deopt_handler()) {
577     // thread is in the deoptimization handler so return no frames
578     trace->num_frames = ticks_deopt; // -9
579     return;
580   }
581 
582   assert(JavaThread::current() == thread,
583          "AsyncGetCallTrace must be called by the current interrupted thread");
584 
585   if (!JvmtiExport::should_post_class_load()) {
586     trace->num_frames = ticks_no_class_load; // -1
587     return;
588   }
589 
590   if (Universe::heap()->is_gc_active()) {
591     trace->num_frames = ticks_GC_active; // -2
592     return;
593   }
594 
595   switch (thread->thread_state()) {
596   case _thread_new:
597   case _thread_uninitialized:
598   case _thread_new_trans:
599     // We found the thread on the threads list above, but it is too
600     // young to be useful so return that there are no Java frames.
601     trace->num_frames = 0;
602     break;
603   case _thread_in_native:
604   case _thread_in_native_trans:
605   case _thread_blocked:
606   case _thread_blocked_trans:
607   case _thread_in_vm:
608   case _thread_in_vm_trans:
609     {
610       frame fr;
611 
612       // param isInJava == false - indicate we aren't in Java code
613       if (!thread->pd_get_top_frame_for_signal_handler(&fr, ucontext, false)) {
614         trace->num_frames = ticks_unknown_not_Java;  // -3 unknown frame
615       } else {
616         if (!thread->has_last_Java_frame()) {
617           trace->num_frames = 0; // No Java frames
618         } else {
619           trace->num_frames = ticks_not_walkable_not_Java;    // -4 non walkable frame by default
620           forte_fill_call_trace_given_top(thread, trace, depth, fr);
621 
622           // This assert would seem to be valid but it is not.
623           // It would be valid if we weren't possibly racing a gc
624           // thread. A gc thread can make a valid interpreted frame
625           // look invalid. It's a small window but it does happen.
626           // The assert is left here commented out as a reminder.
627           // assert(trace->num_frames != ticks_not_walkable_not_Java, "should always be walkable");
628 
629         }
630       }
631     }
632     break;
633   case _thread_in_Java:
634   case _thread_in_Java_trans:
635     {
636       frame fr;
637 
638       // param isInJava == true - indicate we are in Java code
639       if (!thread->pd_get_top_frame_for_signal_handler(&fr, ucontext, true)) {
640         trace->num_frames = ticks_unknown_Java;  // -5 unknown frame
641       } else {
642         trace->num_frames = ticks_not_walkable_Java;  // -6, non walkable frame by default
643         forte_fill_call_trace_given_top(thread, trace, depth, fr);
644       }
645     }
646     break;
647   default:
648     // Unknown thread state
649     trace->num_frames = ticks_unknown_state; // -7
650     break;
651   }
652 }
653 
654 
655 #ifndef _WINDOWS
656 // Support for the Forte(TM) Peformance Tools collector.
657 //
658 // The method prototype is derived from libcollector.h. For more
659 // information, please see the libcollect man page.
660 
661 // Method to let libcollector know about a dynamically loaded function.
662 // Because it is weakly bound, the calls become NOP's when the library
663 // isn't present.
664 #ifdef __APPLE__
665 // XXXDARWIN: Link errors occur even when __attribute__((weak_import))
666 // is added
667 #define collector_func_load(x0,x1,x2,x3,x4,x5,x6) ((void) 0)
668 #else
669 void    collector_func_load(char* name,
670                             void* null_argument_1,
671                             void* null_argument_2,
672                             void *vaddr,
673                             int size,
674                             int zero_argument,
675                             void* null_argument_3);
676 #pragma weak collector_func_load
677 #define collector_func_load(x0,x1,x2,x3,x4,x5,x6) \
678         ( collector_func_load ? collector_func_load(x0,x1,x2,x3,x4,x5,x6),(void)0 : (void)0 )
679 #endif // __APPLE__
680 #endif // !_WINDOWS
681 
682 } // end extern "C"
683 #endif // !IA64
684 
685 void Forte::register_stub(const char* name, address start, address end) {
686 #if !defined(_WINDOWS) && !defined(IA64)
687   assert(pointer_delta(end, start, sizeof(jbyte)) < INT_MAX,
688          "Code size exceeds maximum range");
689 
690   collector_func_load((char*)name, NULL, NULL, start,
691     pointer_delta(end, start, sizeof(jbyte)), 0, NULL);
692 #endif // !_WINDOWS && !IA64
693 }
694 
695 #else // INCLUDE_JVMTI
696 extern "C" {
697   JNIEXPORT
698   void AsyncGetCallTrace(ASGCT_CallTrace *trace, jint depth, void* ucontext) {
699     trace->num_frames = ticks_no_class_load; // -1
700   }
701 }
702 #endif // INCLUDE_JVMTI