0N/A/*
2273N/A * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1472N/A * or visit www.oracle.com if you need additional information or have any
1472N/A * questions.
0N/A *
0N/A */
0N/A
1879N/A#include "precompiled.hpp"
1879N/A#include "code/debugInfoRec.hpp"
1879N/A#include "code/pcDesc.hpp"
1879N/A#include "gc_interface/collectedHeap.inline.hpp"
1879N/A#include "memory/space.hpp"
1879N/A#include "memory/universe.inline.hpp"
1879N/A#include "oops/oop.inline.hpp"
1879N/A#include "oops/oop.inline2.hpp"
1879N/A#include "prims/forte.hpp"
1879N/A#include "runtime/thread.hpp"
1879N/A#include "runtime/vframe.hpp"
1879N/A#include "runtime/vframeArray.hpp"
0N/A
107N/A// These name match the names reported by the forte quality kit
107N/Aenum {
107N/A ticks_no_Java_frame = 0,
107N/A ticks_no_class_load = -1,
107N/A ticks_GC_active = -2,
107N/A ticks_unknown_not_Java = -3,
107N/A ticks_not_walkable_not_Java = -4,
107N/A ticks_unknown_Java = -5,
107N/A ticks_not_walkable_Java = -6,
107N/A ticks_unknown_state = -7,
107N/A ticks_thread_exit = -8,
107N/A ticks_deopt = -9,
107N/A ticks_safepoint = -10
107N/A};
0N/A
0N/A//-------------------------------------------------------
0N/A
0N/A// Native interfaces for use by Forte tools.
0N/A
0N/A
0N/A#ifndef IA64
0N/A
0N/Aclass vframeStreamForte : public vframeStreamCommon {
0N/A public:
0N/A // constructor that starts with sender of frame fr (top_frame)
0N/A vframeStreamForte(JavaThread *jt, frame fr, bool stop_at_java_call_stub);
0N/A void forte_next();
0N/A};
0N/A
0N/A
1349N/Astatic bool is_decipherable_compiled_frame(JavaThread* thread, frame* fr, nmethod* nm);
107N/Astatic bool is_decipherable_interpreted_frame(JavaThread* thread,
1349N/A frame* fr,
1349N/A methodOop* method_p,
1349N/A int* bci_p);
0N/A
0N/A
0N/A
0N/A
107N/AvframeStreamForte::vframeStreamForte(JavaThread *jt,
107N/A frame fr,
107N/A bool stop_at_java_call_stub) : vframeStreamCommon(jt) {
0N/A
0N/A _stop_at_java_call_stub = stop_at_java_call_stub;
107N/A _frame = fr;
0N/A
107N/A // We must always have a valid frame to start filling
0N/A
107N/A bool filled_in = fill_from_frame();
0N/A
107N/A assert(filled_in, "invariant");
0N/A
0N/A}
0N/A
0N/A
0N/A// Solaris SPARC Compiler1 needs an additional check on the grandparent
0N/A// of the top_frame when the parent of the top_frame is interpreted and
0N/A// the grandparent is compiled. However, in this method we do not know
0N/A// the relationship of the current _frame relative to the top_frame so
0N/A// we implement a more broad sanity check. When the previous callee is
0N/A// interpreted and the current sender is compiled, we verify that the
0N/A// current sender is also walkable. If it is not walkable, then we mark
0N/A// the current vframeStream as at the end.
0N/Avoid vframeStreamForte::forte_next() {
0N/A // handle frames with inlining
0N/A if (_mode == compiled_mode &&
0N/A vframeStreamCommon::fill_in_compiled_inlined_sender()) {
0N/A return;
0N/A }
0N/A
0N/A // handle general case
0N/A
0N/A int loop_count = 0;
0N/A int loop_max = MaxJavaStackTraceDepth * 2;
0N/A
0N/A
0N/A do {
0N/A
107N/A loop_count++;
0N/A
107N/A // By the time we get here we should never see unsafe but better
107N/A // safe then segv'd
0N/A
107N/A if (loop_count > loop_max || !_frame.safe_for_sender(_thread)) {
0N/A _mode = at_end_mode;
0N/A return;
0N/A }
0N/A
107N/A _frame = _frame.sender(&_reg_map);
0N/A
0N/A } while (!fill_from_frame());
0N/A}
0N/A
107N/A// Determine if 'fr' is a decipherable compiled frame. We are already
107N/A// assured that fr is for a java nmethod.
107N/A
1349N/Astatic bool is_decipherable_compiled_frame(JavaThread* thread, frame* fr, nmethod* nm) {
107N/A assert(nm->is_java_method(), "invariant");
107N/A
1349N/A if (thread->has_last_Java_frame() && thread->last_Java_pc() == fr->pc()) {
1349N/A // We're stopped at a call into the JVM so look for a PcDesc with
1349N/A // the actual pc reported by the frame.
1349N/A PcDesc* pc_desc = nm->pc_desc_at(fr->pc());
107N/A
1349N/A // Did we find a useful PcDesc?
107N/A if (pc_desc != NULL &&
1349N/A pc_desc->scope_decode_offset() != DebugInformationRecorder::serialized_null) {
1349N/A return true;
0N/A }
0N/A }
107N/A
1349N/A // We're at some random pc in the nmethod so search for the PcDesc
1349N/A // whose pc is greater than the current PC. It's done this way
1349N/A // because the extra PcDescs that are recorded for improved debug
1349N/A // info record the end of the region covered by the ScopeDesc
1349N/A // instead of the beginning.
1349N/A PcDesc* pc_desc = nm->pc_desc_near(fr->pc() + 1);
1349N/A
1349N/A // Now do we have a useful PcDesc?
1349N/A if (pc_desc == NULL ||
1349N/A pc_desc->scope_decode_offset() == DebugInformationRecorder::serialized_null) {
1349N/A // No debug information available for this pc
1349N/A // vframeStream would explode if we try and walk the frames.
1349N/A return false;
1349N/A }
1349N/A
1349N/A // This PcDesc is useful however we must adjust the frame's pc
1349N/A // so that the vframeStream lookups will use this same pc
1349N/A fr->set_pc(pc_desc->real_pc(nm));
107N/A return true;
0N/A}
0N/A
1349N/A
0N/A// Determine if 'fr' is a walkable interpreted frame. Returns false
0N/A// if it is not. *method_p, and *bci_p are not set when false is
0N/A// returned. *method_p is non-NULL if frame was executing a Java
0N/A// method. *bci_p is != -1 if a valid BCI in the Java method could
0N/A// be found.
0N/A// Note: this method returns true when a valid Java method is found
0N/A// even if a valid BCI cannot be found.
0N/A
107N/Astatic bool is_decipherable_interpreted_frame(JavaThread* thread,
1349N/A frame* fr,
1349N/A methodOop* method_p,
1349N/A int* bci_p) {
0N/A assert(fr->is_interpreted_frame(), "just checking");
0N/A
0N/A // top frame is an interpreted frame
0N/A // check if it is walkable (i.e. valid methodOop and valid bci)
107N/A
107N/A // Because we may be racing a gc thread the method and/or bci
107N/A // of a valid interpreter frame may look bad causing us to
107N/A // fail the is_interpreted_frame_valid test. If the thread
107N/A // is in any of the following states we are assured that the
107N/A // frame is in fact valid and we must have hit the race.
107N/A
107N/A JavaThreadState state = thread->thread_state();
107N/A bool known_valid = (state == _thread_in_native ||
107N/A state == _thread_in_vm ||
107N/A state == _thread_blocked );
107N/A
107N/A if (known_valid || fr->is_interpreted_frame_valid(thread)) {
107N/A
107N/A // The frame code should completely validate the frame so that
107N/A // references to methodOop and bci are completely safe to access
107N/A // If they aren't the frame code should be fixed not this
107N/A // code. However since gc isn't locked out the values could be
107N/A // stale. This is a race we can never completely win since we can't
107N/A // lock out gc so do one last check after retrieving their values
107N/A // from the frame for additional safety
107N/A
107N/A methodOop method = fr->interpreter_frame_method();
107N/A
107N/A // We've at least found a method.
107N/A // NOTE: there is something to be said for the approach that
107N/A // if we don't find a valid bci then the method is not likely
107N/A // a valid method. Then again we may have caught an interpreter
107N/A // frame in the middle of construction and the bci field is
107N/A // not yet valid.
107N/A
107N/A *method_p = method;
107N/A
107N/A // See if gc may have invalidated method since we validated frame
107N/A
107N/A if (!Universe::heap()->is_valid_method(method)) return false;
107N/A
107N/A intptr_t bcx = fr->interpreter_frame_bcx();
107N/A
107N/A int bci = method->validate_bci_from_bcx(bcx);
107N/A
107N/A // note: bci is set to -1 if not a valid bci
107N/A *bci_p = bci;
107N/A return true;
0N/A }
107N/A
0N/A return false;
0N/A}
0N/A
0N/A
107N/A// Determine if 'fr' can be used to find an initial Java frame.
107N/A// Return false if it can not find a fully decipherable Java frame
107N/A// (in other words a frame that isn't safe to use in a vframe stream).
107N/A// Obviously if it can't even find a Java frame false will also be returned.
107N/A//
107N/A// If we find a Java frame decipherable or not then by definition we have
107N/A// identified a method and that will be returned to the caller via method_p.
107N/A// If we can determine a bci that is returned also. (Hmm is it possible
107N/A// to return a method and bci and still return false? )
107N/A//
107N/A// The initial Java frame we find (if any) is return via initial_frame_p.
0N/A//
107N/A
107N/Astatic bool find_initial_Java_frame(JavaThread* thread,
107N/A frame* fr,
107N/A frame* initial_frame_p,
107N/A methodOop* method_p,
107N/A int* bci_p) {
107N/A
107N/A // It is possible that for a frame containing an nmethod
107N/A // we can capture the method but no bci. If we get no
107N/A // bci the frame isn't walkable but the method is usable.
107N/A // Therefore we init the returned methodOop to NULL so the
107N/A // caller can make the distinction.
107N/A
107N/A *method_p = NULL;
107N/A
107N/A // On the initial call to this method the frame we get may not be
107N/A // recognizable to us. This should only happen if we are in a JRT_LEAF
107N/A // or something called by a JRT_LEAF method.
107N/A
0N/A
107N/A
107N/A frame candidate = *fr;
107N/A
107N/A // If the starting frame we were given has no codeBlob associated with
107N/A // it see if we can find such a frame because only frames with codeBlobs
107N/A // are possible Java frames.
107N/A
107N/A if (fr->cb() == NULL) {
107N/A
107N/A // See if we can find a useful frame
107N/A int loop_count;
107N/A int loop_max = MaxJavaStackTraceDepth * 2;
107N/A RegisterMap map(thread, false);
107N/A
107N/A for (loop_count = 0; loop_count < loop_max; loop_count++) {
107N/A if (!candidate.safe_for_sender(thread)) return false;
107N/A candidate = candidate.sender(&map);
107N/A if (candidate.cb() != NULL) break;
107N/A }
107N/A if (candidate.cb() == NULL) return false;
0N/A }
0N/A
107N/A // We have a frame known to be in the codeCache
107N/A // We will hopefully be able to figure out something to do with it.
0N/A int loop_count;
0N/A int loop_max = MaxJavaStackTraceDepth * 2;
107N/A RegisterMap map(thread, false);
0N/A
0N/A for (loop_count = 0; loop_count < loop_max; loop_count++) {
0N/A
107N/A if (candidate.is_first_frame()) {
107N/A // If initial frame is frame from StubGenerator and there is no
107N/A // previous anchor, there are no java frames associated with a method
107N/A return false;
107N/A }
0N/A
107N/A if (candidate.is_interpreted_frame()) {
107N/A if (is_decipherable_interpreted_frame(thread, &candidate, method_p, bci_p)) {
107N/A *initial_frame_p = candidate;
107N/A return true;
107N/A }
0N/A
107N/A // Hopefully we got some data
107N/A return false;
0N/A }
0N/A
107N/A if (candidate.cb()->is_nmethod()) {
107N/A
107N/A nmethod* nm = (nmethod*) candidate.cb();
107N/A *method_p = nm->method();
0N/A
107N/A // If the frame isn't fully decipherable then the default
107N/A // value for the bci is a signal that we don't have a bci.
107N/A // If we have a decipherable frame this bci value will
107N/A // not be used.
107N/A
107N/A *bci_p = -1;
0N/A
107N/A *initial_frame_p = candidate;
107N/A
107N/A // Native wrapper code is trivial to decode by vframeStream
107N/A
107N/A if (nm->is_native_method()) return true;
0N/A
107N/A // If it isn't decipherable then we have found a pc that doesn't
107N/A // have a PCDesc that can get us a bci however we did find
107N/A // a method
0N/A
1349N/A if (!is_decipherable_compiled_frame(thread, &candidate, nm)) {
0N/A return false;
107N/A }
0N/A
107N/A // is_decipherable_compiled_frame may modify candidate's pc
107N/A *initial_frame_p = candidate;
0N/A
1349N/A assert(nm->pc_desc_at(candidate.pc()) != NULL, "if it's decipherable then pc must be valid");
1349N/A
107N/A return true;
107N/A }
107N/A
107N/A // Must be some stub frame that we don't care about
0N/A
107N/A if (!candidate.safe_for_sender(thread)) return false;
107N/A candidate = candidate.sender(&map);
0N/A
107N/A // If it isn't in the code cache something is wrong
107N/A // since once we find a frame in the code cache they
107N/A // all should be there.
107N/A
107N/A if (candidate.cb() == NULL) return false;
107N/A
0N/A }
0N/A
107N/A return false;
107N/A
0N/A}
0N/A
0N/A
0N/A// call frame copied from old .h file and renamed
0N/Atypedef struct {
0N/A jint lineno; // line number in the source file
0N/A jmethodID method_id; // method executed in this frame
0N/A} ASGCT_CallFrame;
0N/A
0N/A// call trace copied from old .h file and renamed
0N/Atypedef struct {
0N/A JNIEnv *env_id; // Env where trace was recorded
0N/A jint num_frames; // number of frames in this trace
0N/A ASGCT_CallFrame *frames; // frames
0N/A} ASGCT_CallTrace;
0N/A
0N/Astatic void forte_fill_call_trace_given_top(JavaThread* thd,
107N/A ASGCT_CallTrace* trace,
107N/A int depth,
107N/A frame top_frame) {
0N/A NoHandleMark nhm;
0N/A
107N/A frame initial_Java_frame;
0N/A methodOop method;
0N/A int bci;
0N/A int count;
0N/A
0N/A count = 0;
0N/A assert(trace->frames != NULL, "trace->frames must be non-NULL");
0N/A
107N/A bool fully_decipherable = find_initial_Java_frame(thd, &top_frame, &initial_Java_frame, &method, &bci);
107N/A
107N/A // The frame might not be walkable but still recovered a method
107N/A // (e.g. an nmethod with no scope info for the pc
107N/A
107N/A if (method == NULL) return;
0N/A
0N/A CollectedHeap* ch = Universe::heap();
0N/A
107N/A // The method is not stored GC safe so see if GC became active
107N/A // after we entered AsyncGetCallTrace() and before we try to
107N/A // use the methodOop.
107N/A // Yes, there is still a window after this check and before
107N/A // we use methodOop below, but we can't lock out GC so that
107N/A // has to be an acceptable risk.
107N/A if (!ch->is_valid_method(method)) {
107N/A trace->num_frames = ticks_GC_active; // -2
0N/A return;
0N/A }
0N/A
107N/A // We got a Java frame however it isn't fully decipherable
107N/A // so it won't necessarily be safe to use it for the
107N/A // initial frame in the vframe stream.
107N/A
107N/A if (!fully_decipherable) {
107N/A // Take whatever method the top-frame decoder managed to scrape up.
107N/A // We look further at the top frame only if non-safepoint
107N/A // debugging information is available.
107N/A count++;
107N/A trace->num_frames = count;
107N/A trace->frames[0].method_id = method->find_jmethod_id_or_null();
107N/A if (!method->is_native()) {
107N/A trace->frames[0].lineno = bci;
107N/A } else {
107N/A trace->frames[0].lineno = -3;
107N/A }
107N/A
107N/A if (!initial_Java_frame.safe_for_sender(thd)) return;
107N/A
107N/A RegisterMap map(thd, false);
107N/A initial_Java_frame = initial_Java_frame.sender(&map);
107N/A }
107N/A
107N/A vframeStreamForte st(thd, initial_Java_frame, false);
107N/A
0N/A for (; !st.at_end() && count < depth; st.forte_next(), count++) {
0N/A bci = st.bci();
0N/A method = st.method();
0N/A
0N/A // The method is not stored GC safe so see if GC became active
0N/A // after we entered AsyncGetCallTrace() and before we try to
0N/A // use the methodOop.
0N/A // Yes, there is still a window after this check and before
0N/A // we use methodOop below, but we can't lock out GC so that
0N/A // has to be an acceptable risk.
0N/A if (!ch->is_valid_method(method)) {
0N/A // we throw away everything we've gathered in this sample since
0N/A // none of it is safe
107N/A trace->num_frames = ticks_GC_active; // -2
0N/A return;
0N/A }
0N/A
0N/A trace->frames[count].method_id = method->find_jmethod_id_or_null();
0N/A if (!method->is_native()) {
0N/A trace->frames[count].lineno = bci;
0N/A } else {
0N/A trace->frames[count].lineno = -3;
0N/A }
0N/A }
0N/A trace->num_frames = count;
0N/A return;
0N/A}
0N/A
0N/A
0N/A// Forte Analyzer AsyncGetCallTrace() entry point. Currently supported
0N/A// on Linux X86, Solaris SPARC and Solaris X86.
0N/A//
0N/A// Async-safe version of GetCallTrace being called from a signal handler
0N/A// when a LWP gets interrupted by SIGPROF but the stack traces are filled
0N/A// with different content (see below).
0N/A//
0N/A// This function must only be called when JVM/TI
0N/A// CLASS_LOAD events have been enabled since agent startup. The enabled
0N/A// event will cause the jmethodIDs to be allocated at class load time.
0N/A// The jmethodIDs cannot be allocated in a signal handler because locks
0N/A// cannot be grabbed in a signal handler safely.
0N/A//
0N/A// void (*AsyncGetCallTrace)(ASGCT_CallTrace *trace, jint depth, void* ucontext)
0N/A//
0N/A// Called by the profiler to obtain the current method call stack trace for
0N/A// a given thread. The thread is identified by the env_id field in the
0N/A// ASGCT_CallTrace structure. The profiler agent should allocate a ASGCT_CallTrace
0N/A// structure with enough memory for the requested stack depth. The VM fills in
0N/A// the frames buffer and the num_frames field.
0N/A//
0N/A// Arguments:
0N/A//
0N/A// trace - trace data structure to be filled by the VM.
0N/A// depth - depth of the call stack trace.
0N/A// ucontext - ucontext_t of the LWP
0N/A//
0N/A// ASGCT_CallTrace:
0N/A// typedef struct {
0N/A// JNIEnv *env_id;
0N/A// jint num_frames;
0N/A// ASGCT_CallFrame *frames;
0N/A// } ASGCT_CallTrace;
0N/A//
0N/A// Fields:
0N/A// env_id - ID of thread which executed this trace.
0N/A// num_frames - number of frames in the trace.
0N/A// (< 0 indicates the frame is not walkable).
0N/A// frames - the ASGCT_CallFrames that make up this trace. Callee followed by callers.
0N/A//
0N/A// ASGCT_CallFrame:
0N/A// typedef struct {
0N/A// jint lineno;
0N/A// jmethodID method_id;
0N/A// } ASGCT_CallFrame;
0N/A//
0N/A// Fields:
0N/A// 1) For Java frame (interpreted and compiled),
0N/A// lineno - bci of the method being executed or -1 if bci is not available
0N/A// method_id - jmethodID of the method being executed
0N/A// 2) For native method
0N/A// lineno - (-3)
0N/A// method_id - jmethodID of the method being executed
0N/A
0N/Aextern "C" {
2072N/AJNIEXPORT
0N/Avoid AsyncGetCallTrace(ASGCT_CallTrace *trace, jint depth, void* ucontext) {
0N/A JavaThread* thread;
0N/A
0N/A if (trace->env_id == NULL ||
0N/A (thread = JavaThread::thread_from_jni_environment(trace->env_id)) == NULL ||
0N/A thread->is_exiting()) {
0N/A
0N/A // bad env_id, thread has exited or thread is exiting
107N/A trace->num_frames = ticks_thread_exit; // -8
0N/A return;
0N/A }
0N/A
0N/A if (thread->in_deopt_handler()) {
0N/A // thread is in the deoptimization handler so return no frames
107N/A trace->num_frames = ticks_deopt; // -9
0N/A return;
0N/A }
0N/A
0N/A assert(JavaThread::current() == thread,
0N/A "AsyncGetCallTrace must be called by the current interrupted thread");
0N/A
0N/A if (!JvmtiExport::should_post_class_load()) {
107N/A trace->num_frames = ticks_no_class_load; // -1
0N/A return;
0N/A }
0N/A
0N/A if (Universe::heap()->is_gc_active()) {
107N/A trace->num_frames = ticks_GC_active; // -2
0N/A return;
0N/A }
0N/A
0N/A switch (thread->thread_state()) {
0N/A case _thread_new:
0N/A case _thread_uninitialized:
0N/A case _thread_new_trans:
0N/A // We found the thread on the threads list above, but it is too
0N/A // young to be useful so return that there are no Java frames.
0N/A trace->num_frames = 0;
0N/A break;
0N/A case _thread_in_native:
0N/A case _thread_in_native_trans:
0N/A case _thread_blocked:
0N/A case _thread_blocked_trans:
0N/A case _thread_in_vm:
0N/A case _thread_in_vm_trans:
0N/A {
0N/A frame fr;
0N/A
0N/A // param isInJava == false - indicate we aren't in Java code
0N/A if (!thread->pd_get_top_frame_for_signal_handler(&fr, ucontext, false)) {
107N/A trace->num_frames = ticks_unknown_not_Java; // -3 unknown frame
107N/A } else {
0N/A if (!thread->has_last_Java_frame()) {
107N/A trace->num_frames = 0; // No Java frames
0N/A } else {
107N/A trace->num_frames = ticks_not_walkable_not_Java; // -4 non walkable frame by default
107N/A forte_fill_call_trace_given_top(thread, trace, depth, fr);
107N/A
107N/A // This assert would seem to be valid but it is not.
107N/A // It would be valid if we weren't possibly racing a gc
107N/A // thread. A gc thread can make a valid interpreted frame
107N/A // look invalid. It's a small window but it does happen.
107N/A // The assert is left here commented out as a reminder.
107N/A // assert(trace->num_frames != ticks_not_walkable_not_Java, "should always be walkable");
107N/A
0N/A }
0N/A }
0N/A }
0N/A break;
0N/A case _thread_in_Java:
0N/A case _thread_in_Java_trans:
0N/A {
0N/A frame fr;
0N/A
0N/A // param isInJava == true - indicate we are in Java code
0N/A if (!thread->pd_get_top_frame_for_signal_handler(&fr, ucontext, true)) {
107N/A trace->num_frames = ticks_unknown_Java; // -5 unknown frame
0N/A } else {
107N/A trace->num_frames = ticks_not_walkable_Java; // -6, non walkable frame by default
0N/A forte_fill_call_trace_given_top(thread, trace, depth, fr);
0N/A }
0N/A }
0N/A break;
0N/A default:
0N/A // Unknown thread state
107N/A trace->num_frames = ticks_unknown_state; // -7
0N/A break;
0N/A }
0N/A}
0N/A
0N/A
0N/A#ifndef _WINDOWS
0N/A// Support for the Forte(TM) Peformance Tools collector.
0N/A//
0N/A// The method prototype is derived from libcollector.h. For more
0N/A// information, please see the libcollect man page.
0N/A
0N/A// Method to let libcollector know about a dynamically loaded function.
0N/A// Because it is weakly bound, the calls become NOP's when the library
0N/A// isn't present.
2796N/A#ifdef __APPLE__
2796N/A// XXXDARWIN: Link errors occur even when __attribute__((weak_import))
2796N/A// is added
2796N/A#define collector_func_load(x0,x1,x2,x3,x4,x5,x6) (0)
2796N/A#else
0N/Avoid collector_func_load(char* name,
0N/A void* null_argument_1,
0N/A void* null_argument_2,
0N/A void *vaddr,
0N/A int size,
0N/A int zero_argument,
0N/A void* null_argument_3);
0N/A#pragma weak collector_func_load
0N/A#define collector_func_load(x0,x1,x2,x3,x4,x5,x6) \
0N/A ( collector_func_load ? collector_func_load(x0,x1,x2,x3,x4,x5,x6),0 : 0 )
2796N/A#endif // __APPLE__
0N/A#endif // !_WINDOWS
0N/A
0N/A} // end extern "C"
0N/A#endif // !IA64
0N/A
0N/Avoid Forte::register_stub(const char* name, address start, address end) {
0N/A#if !defined(_WINDOWS) && !defined(IA64)
0N/A assert(pointer_delta(end, start, sizeof(jbyte)) < INT_MAX,
1409N/A "Code size exceeds maximum range");
0N/A
0N/A collector_func_load((char*)name, NULL, NULL, start,
0N/A pointer_delta(end, start, sizeof(jbyte)), 0, NULL);
0N/A#endif // !_WINDOWS && !IA64
0N/A}