forte.cpp 22.0 KB
Newer Older
D
duke 已提交
1
/*
X
xdono 已提交
2
 * Copyright 2003-2008 Sun Microsystems, Inc.  All Rights Reserved.
D
duke 已提交
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * This code is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 only, as
 * published by the Free Software Foundation.
 *
 * This code is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * version 2 for more details (a copy is included in the LICENSE file that
 * accompanied this code).
 *
 * You should have received a copy of the GNU General Public License version
 * 2 along with this work; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
 * CA 95054 USA or visit www.sun.com if you need additional information or
 * have any questions.
 *
 */

# include "incls/_precompiled.incl"
# include "incls/_forte.cpp.incl"

28 29 30 31 32 33 34 35 36 37 38 39 40 41
// These name match the names reported by the forte quality kit
enum {
  ticks_no_Java_frame         =  0,
  ticks_no_class_load         = -1,
  ticks_GC_active             = -2,
  ticks_unknown_not_Java      = -3,
  ticks_not_walkable_not_Java = -4,
  ticks_unknown_Java          = -5,
  ticks_not_walkable_Java     = -6,
  ticks_unknown_state         = -7,
  ticks_thread_exit           = -8,
  ticks_deopt                 = -9,
  ticks_safepoint             = -10
};
D
duke 已提交
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57

//-------------------------------------------------------

// Native interfaces for use by Forte tools.


#ifndef IA64

class vframeStreamForte : public vframeStreamCommon {
 public:
  // constructor that starts with sender of frame fr (top_frame)
  vframeStreamForte(JavaThread *jt, frame fr, bool stop_at_java_call_stub);
  void forte_next();
};


58
static bool is_decipherable_compiled_frame(JavaThread* thread, frame* fr, nmethod* nm);
59
static bool is_decipherable_interpreted_frame(JavaThread* thread,
60 61 62
                                              frame* fr,
                                              methodOop* method_p,
                                              int* bci_p);
D
duke 已提交
63 64 65 66




67 68 69
vframeStreamForte::vframeStreamForte(JavaThread *jt,
                                     frame fr,
                                     bool stop_at_java_call_stub) : vframeStreamCommon(jt) {
D
duke 已提交
70 71

  _stop_at_java_call_stub = stop_at_java_call_stub;
72
  _frame = fr;
D
duke 已提交
73

74
  // We must always have a valid frame to start filling
D
duke 已提交
75

76
  bool filled_in = fill_from_frame();
D
duke 已提交
77

78
  assert(filled_in, "invariant");
D
duke 已提交
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105

}


// Solaris SPARC Compiler1 needs an additional check on the grandparent
// of the top_frame when the parent of the top_frame is interpreted and
// the grandparent is compiled. However, in this method we do not know
// the relationship of the current _frame relative to the top_frame so
// we implement a more broad sanity check. When the previous callee is
// interpreted and the current sender is compiled, we verify that the
// current sender is also walkable. If it is not walkable, then we mark
// the current vframeStream as at the end.
void vframeStreamForte::forte_next() {
  // handle frames with inlining
  if (_mode == compiled_mode &&
      vframeStreamCommon::fill_in_compiled_inlined_sender()) {
    return;
  }

  // handle general case

  int loop_count = 0;
  int loop_max = MaxJavaStackTraceDepth * 2;


  do {

106
    loop_count++;
D
duke 已提交
107

108 109
    // By the time we get here we should never see unsafe but better
    // safe then segv'd
D
duke 已提交
110

111
    if (loop_count > loop_max || !_frame.safe_for_sender(_thread)) {
D
duke 已提交
112 113 114 115
      _mode = at_end_mode;
      return;
    }

116
    _frame = _frame.sender(&_reg_map);
D
duke 已提交
117 118 119 120

  } while (!fill_from_frame());
}

121 122 123
// Determine if 'fr' is a decipherable compiled frame. We are already
// assured that fr is for a java nmethod.

124
static bool is_decipherable_compiled_frame(JavaThread* thread, frame* fr, nmethod* nm) {
125 126
  assert(nm->is_java_method(), "invariant");

127 128 129 130
  if (thread->has_last_Java_frame() && thread->last_Java_pc() == fr->pc()) {
    // We're stopped at a call into the JVM so look for a PcDesc with
    // the actual pc reported by the frame.
    PcDesc* pc_desc = nm->pc_desc_at(fr->pc());
131

132
    // Did we find a useful PcDesc?
133
    if (pc_desc != NULL &&
134 135
        pc_desc->scope_decode_offset() != DebugInformationRecorder::serialized_null) {
      return true;
D
duke 已提交
136
    }
137
  }
138

139 140 141 142 143 144
  // We're at some random pc in the nmethod so search for the PcDesc
  // whose pc is greater than the current PC.  It's done this way
  // because the extra PcDescs that are recorded for improved debug
  // info record the end of the region covered by the ScopeDesc
  // instead of the beginning.
  PcDesc* pc_desc = nm->pc_desc_near(fr->pc() + 1);
145

146 147 148 149 150 151
  // Now do we have a useful PcDesc?
  if (pc_desc == NULL ||
      pc_desc->scope_decode_offset() == DebugInformationRecorder::serialized_null) {
    // No debug information available for this pc
    // vframeStream would explode if we try and walk the frames.
    return false;
D
duke 已提交
152
  }
153

154 155 156
  // This PcDesc is useful however we must adjust the frame's pc
  // so that the vframeStream lookups will use this same pc
  fr->set_pc(pc_desc->real_pc(nm));
157
  return true;
D
duke 已提交
158 159
}

160

D
duke 已提交
161 162 163 164 165 166 167 168
// Determine if 'fr' is a walkable interpreted frame. Returns false
// if it is not. *method_p, and *bci_p are not set when false is
// returned. *method_p is non-NULL if frame was executing a Java
// method. *bci_p is != -1 if a valid BCI in the Java method could
// be found.
// Note: this method returns true when a valid Java method is found
// even if a valid BCI cannot be found.

169
static bool is_decipherable_interpreted_frame(JavaThread* thread,
170 171 172
                                              frame* fr,
                                              methodOop* method_p,
                                              int* bci_p) {
D
duke 已提交
173 174 175 176
  assert(fr->is_interpreted_frame(), "just checking");

  // top frame is an interpreted frame
  // check if it is walkable (i.e. valid methodOop and valid bci)
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220

  // Because we may be racing a gc thread the method and/or bci
  // of a valid interpreter frame may look bad causing us to
  // fail the is_interpreted_frame_valid test. If the thread
  // is in any of the following states we are assured that the
  // frame is in fact valid and we must have hit the race.

  JavaThreadState state = thread->thread_state();
  bool known_valid = (state == _thread_in_native ||
                      state == _thread_in_vm ||
                      state == _thread_blocked );

  if (known_valid || fr->is_interpreted_frame_valid(thread)) {

    // The frame code should completely validate the frame so that
    // references to methodOop and bci are completely safe to access
    // If they aren't the frame code should be fixed not this
    // code. However since gc isn't locked out the values could be
    // stale. This is a race we can never completely win since we can't
    // lock out gc so do one last check after retrieving their values
    // from the frame for additional safety

    methodOop method = fr->interpreter_frame_method();

    // We've at least found a method.
    // NOTE: there is something to be said for the approach that
    // if we don't find a valid bci then the method is not likely
    // a valid method. Then again we may have caught an interpreter
    // frame in the middle of construction and the bci field is
    // not yet valid.

    *method_p = method;

    // See if gc may have invalidated method since we validated frame

    if (!Universe::heap()->is_valid_method(method)) return false;

    intptr_t bcx = fr->interpreter_frame_bcx();

    int      bci = method->validate_bci_from_bcx(bcx);

    // note: bci is set to -1 if not a valid bci
    *bci_p = bci;
    return true;
D
duke 已提交
221
  }
222

D
duke 已提交
223 224 225 226
  return false;
}


227 228 229 230 231 232 233 234 235 236 237
// Determine if 'fr' can be used to find an initial Java frame.
// Return false if it can not find a fully decipherable Java frame
// (in other words a frame that isn't safe to use in a vframe stream).
// Obviously if it can't even find a Java frame false will also be returned.
//
// If we find a Java frame decipherable or not then by definition we have
// identified a method and that will be returned to the caller via method_p.
// If we can determine a bci that is returned also. (Hmm is it possible
// to return a method and bci and still return false? )
//
// The initial Java frame we find (if any) is return via initial_frame_p.
D
duke 已提交
238 239
//

240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256
static bool find_initial_Java_frame(JavaThread* thread,
                                    frame* fr,
                                    frame* initial_frame_p,
                                    methodOop* method_p,
                                    int* bci_p) {

  // It is possible that for a frame containing an nmethod
  // we can capture the method but no bci. If we get no
  // bci the frame isn't walkable but the method is usable.
  // Therefore we init the returned methodOop to NULL so the
  // caller can make the distinction.

  *method_p = NULL;

  // On the initial call to this method the frame we get may not be
  // recognizable to us. This should only happen if we are in a JRT_LEAF
  // or something called by a JRT_LEAF method.
D
duke 已提交
257 258 259 260 261



  frame candidate = *fr;

262 263 264 265 266
  // If the starting frame we were given has no codeBlob associated with
  // it see if we can find such a frame because only frames with codeBlobs
  // are possible Java frames.

  if (fr->cb() == NULL) {
D
duke 已提交
267

268 269 270 271 272 273 274 275 276 277 278 279 280 281 282
    // See if we can find a useful frame
    int loop_count;
    int loop_max = MaxJavaStackTraceDepth * 2;
    RegisterMap map(thread, false);

    for (loop_count = 0; loop_count < loop_max; loop_count++) {
      if (!candidate.safe_for_sender(thread)) return false;
      candidate = candidate.sender(&map);
      if (candidate.cb() != NULL) break;
    }
    if (candidate.cb() == NULL) return false;
  }

  // We have a frame known to be in the codeCache
  // We will hopefully be able to figure out something to do with it.
D
duke 已提交
283 284
  int loop_count;
  int loop_max = MaxJavaStackTraceDepth * 2;
285
  RegisterMap map(thread, false);
D
duke 已提交
286 287 288

  for (loop_count = 0; loop_count < loop_max; loop_count++) {

289 290 291 292 293
    if (candidate.is_first_frame()) {
      // If initial frame is frame from StubGenerator and there is no
      // previous anchor, there are no java frames associated with a method
      return false;
    }
D
duke 已提交
294

295 296 297 298
    if (candidate.is_interpreted_frame()) {
      if (is_decipherable_interpreted_frame(thread, &candidate, method_p, bci_p)) {
        *initial_frame_p = candidate;
        return true;
D
duke 已提交
299
      }
300 301 302

      // Hopefully we got some data
      return false;
D
duke 已提交
303 304
    }

305
    if (candidate.cb()->is_nmethod()) {
D
duke 已提交
306

307 308
      nmethod* nm = (nmethod*) candidate.cb();
      *method_p = nm->method();
D
duke 已提交
309

310 311 312 313
      // If the frame isn't fully decipherable then the default
      // value for the bci is a signal that we don't have a bci.
      // If we have a decipherable frame this bci value will
      // not be used.
D
duke 已提交
314

315
      *bci_p = -1;
D
duke 已提交
316

317
      *initial_frame_p = candidate;
D
duke 已提交
318

319
      // Native wrapper code is trivial to decode by vframeStream
D
duke 已提交
320

321
      if (nm->is_native_method()) return true;
D
duke 已提交
322

323 324 325 326
      // If it isn't decipherable then we have found a pc that doesn't
      // have a PCDesc that can get us a bci however we did find
      // a method

327
      if (!is_decipherable_compiled_frame(thread, &candidate, nm)) {
328 329 330 331 332 333
        return false;
      }

      // is_decipherable_compiled_frame may modify candidate's pc
      *initial_frame_p = candidate;

334 335
      assert(nm->pc_desc_at(candidate.pc()) != NULL, "if it's decipherable then pc must be valid");

336
      return true;
D
duke 已提交
337 338
    }

339 340 341 342 343 344 345 346 347 348 349
    // Must be some stub frame that we don't care about

    if (!candidate.safe_for_sender(thread)) return false;
    candidate = candidate.sender(&map);

    // If it isn't in the code cache something is wrong
    // since once we find a frame in the code cache they
    // all should be there.

    if (candidate.cb() == NULL) return false;

D
duke 已提交
350 351
  }

352 353
  return false;

D
duke 已提交
354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370
}


// call frame copied from old .h file and renamed
typedef struct {
    jint lineno;                      // line number in the source file
    jmethodID method_id;              // method executed in this frame
} ASGCT_CallFrame;

// call trace copied from old .h file and renamed
typedef struct {
    JNIEnv *env_id;                   // Env where trace was recorded
    jint num_frames;                  // number of frames in this trace
    ASGCT_CallFrame *frames;          // frames
} ASGCT_CallTrace;

static void forte_fill_call_trace_given_top(JavaThread* thd,
371 372 373
                                            ASGCT_CallTrace* trace,
                                            int depth,
                                            frame top_frame) {
D
duke 已提交
374 375
  NoHandleMark nhm;

376
  frame initial_Java_frame;
D
duke 已提交
377 378 379 380 381 382 383
  methodOop method;
  int bci;
  int count;

  count = 0;
  assert(trace->frames != NULL, "trace->frames must be non-NULL");

384 385 386 387 388 389
  bool fully_decipherable = find_initial_Java_frame(thd, &top_frame, &initial_Java_frame, &method, &bci);

  // The frame might not be walkable but still recovered a method
  // (e.g. an nmethod with no scope info for the pc

  if (method == NULL) return;
D
duke 已提交
390 391 392

  CollectedHeap* ch = Universe::heap();

393 394 395 396 397 398 399 400 401 402
  // The method is not stored GC safe so see if GC became active
  // after we entered AsyncGetCallTrace() and before we try to
  // use the methodOop.
  // Yes, there is still a window after this check and before
  // we use methodOop below, but we can't lock out GC so that
  // has to be an acceptable risk.
  if (!ch->is_valid_method(method)) {
    trace->num_frames = ticks_GC_active; // -2
    return;
  }
D
duke 已提交
403

404 405 406 407 408 409 410 411 412 413 414 415 416 417 418
  // We got a Java frame however it isn't fully decipherable
  // so it won't necessarily be safe to use it for the
  // initial frame in the vframe stream.

  if (!fully_decipherable) {
    // Take whatever method the top-frame decoder managed to scrape up.
    // We look further at the top frame only if non-safepoint
    // debugging information is available.
    count++;
    trace->num_frames = count;
    trace->frames[0].method_id = method->find_jmethod_id_or_null();
    if (!method->is_native()) {
      trace->frames[0].lineno = bci;
    } else {
      trace->frames[0].lineno = -3;
D
duke 已提交
419 420
    }

421 422 423 424
    if (!initial_Java_frame.safe_for_sender(thd)) return;

    RegisterMap map(thd, false);
    initial_Java_frame = initial_Java_frame.sender(&map);
D
duke 已提交
425 426
  }

427 428
  vframeStreamForte st(thd, initial_Java_frame, false);

D
duke 已提交
429 430 431 432 433 434 435 436 437 438 439 440 441
  for (; !st.at_end() && count < depth; st.forte_next(), count++) {
    bci = st.bci();
    method = st.method();

    // The method is not stored GC safe so see if GC became active
    // after we entered AsyncGetCallTrace() and before we try to
    // use the methodOop.
    // Yes, there is still a window after this check and before
    // we use methodOop below, but we can't lock out GC so that
    // has to be an acceptable risk.
    if (!ch->is_valid_method(method)) {
      // we throw away everything we've gathered in this sample since
      // none of it is safe
442
      trace->num_frames = ticks_GC_active; // -2
D
duke 已提交
443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513
      return;
    }

    trace->frames[count].method_id = method->find_jmethod_id_or_null();
    if (!method->is_native()) {
      trace->frames[count].lineno = bci;
    } else {
      trace->frames[count].lineno = -3;
    }
  }
  trace->num_frames = count;
  return;
}


// Forte Analyzer AsyncGetCallTrace() entry point. Currently supported
// on Linux X86, Solaris SPARC and Solaris X86.
//
// Async-safe version of GetCallTrace being called from a signal handler
// when a LWP gets interrupted by SIGPROF but the stack traces are filled
// with different content (see below).
//
// This function must only be called when JVM/TI
// CLASS_LOAD events have been enabled since agent startup. The enabled
// event will cause the jmethodIDs to be allocated at class load time.
// The jmethodIDs cannot be allocated in a signal handler because locks
// cannot be grabbed in a signal handler safely.
//
// void (*AsyncGetCallTrace)(ASGCT_CallTrace *trace, jint depth, void* ucontext)
//
// Called by the profiler to obtain the current method call stack trace for
// a given thread. The thread is identified by the env_id field in the
// ASGCT_CallTrace structure. The profiler agent should allocate a ASGCT_CallTrace
// structure with enough memory for the requested stack depth. The VM fills in
// the frames buffer and the num_frames field.
//
// Arguments:
//
//   trace    - trace data structure to be filled by the VM.
//   depth    - depth of the call stack trace.
//   ucontext - ucontext_t of the LWP
//
// ASGCT_CallTrace:
//   typedef struct {
//       JNIEnv *env_id;
//       jint num_frames;
//       ASGCT_CallFrame *frames;
//   } ASGCT_CallTrace;
//
// Fields:
//   env_id     - ID of thread which executed this trace.
//   num_frames - number of frames in the trace.
//                (< 0 indicates the frame is not walkable).
//   frames     - the ASGCT_CallFrames that make up this trace. Callee followed by callers.
//
//  ASGCT_CallFrame:
//    typedef struct {
//        jint lineno;
//        jmethodID method_id;
//    } ASGCT_CallFrame;
//
//  Fields:
//    1) For Java frame (interpreted and compiled),
//       lineno    - bci of the method being executed or -1 if bci is not available
//       method_id - jmethodID of the method being executed
//    2) For native method
//       lineno    - (-3)
//       method_id - jmethodID of the method being executed

extern "C" {
void AsyncGetCallTrace(ASGCT_CallTrace *trace, jint depth, void* ucontext) {
514 515 516 517 518

// This is if'd out because we no longer use thread suspension.
// However if someone wanted to backport this to a 5.0 jvm then this
// code would be important.
#if 0
D
duke 已提交
519 520 521 522 523 524 525 526 527
  if (SafepointSynchronize::is_synchronizing()) {
    // The safepoint mechanism is trying to synchronize all the threads.
    // Since this can involve thread suspension, it is not safe for us
    // to be here. We can reduce the deadlock risk window by quickly
    // returning to the SIGPROF handler. However, it is still possible
    // for VMThread to catch us here or in the SIGPROF handler. If we
    // are suspended while holding a resource and another thread blocks
    // on that resource in the SIGPROF handler, then we will have a
    // three-thread deadlock (VMThread, this thread, the other thread).
528
    trace->num_frames = ticks_safepoint; // -10
D
duke 已提交
529 530
    return;
  }
531
#endif
D
duke 已提交
532 533 534 535 536 537 538 539

  JavaThread* thread;

  if (trace->env_id == NULL ||
    (thread = JavaThread::thread_from_jni_environment(trace->env_id)) == NULL ||
    thread->is_exiting()) {

    // bad env_id, thread has exited or thread is exiting
540
    trace->num_frames = ticks_thread_exit; // -8
D
duke 已提交
541 542 543 544 545
    return;
  }

  if (thread->in_deopt_handler()) {
    // thread is in the deoptimization handler so return no frames
546
    trace->num_frames = ticks_deopt; // -9
D
duke 已提交
547 548 549 550 551 552 553
    return;
  }

  assert(JavaThread::current() == thread,
         "AsyncGetCallTrace must be called by the current interrupted thread");

  if (!JvmtiExport::should_post_class_load()) {
554
    trace->num_frames = ticks_no_class_load; // -1
D
duke 已提交
555 556 557 558
    return;
  }

  if (Universe::heap()->is_gc_active()) {
559
    trace->num_frames = ticks_GC_active; // -2
D
duke 已提交
560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581
    return;
  }

  switch (thread->thread_state()) {
  case _thread_new:
  case _thread_uninitialized:
  case _thread_new_trans:
    // We found the thread on the threads list above, but it is too
    // young to be useful so return that there are no Java frames.
    trace->num_frames = 0;
    break;
  case _thread_in_native:
  case _thread_in_native_trans:
  case _thread_blocked:
  case _thread_blocked_trans:
  case _thread_in_vm:
  case _thread_in_vm_trans:
    {
      frame fr;

      // param isInJava == false - indicate we aren't in Java code
      if (!thread->pd_get_top_frame_for_signal_handler(&fr, ucontext, false)) {
582 583
        trace->num_frames = ticks_unknown_not_Java;  // -3 unknown frame
      } else {
D
duke 已提交
584
        if (!thread->has_last_Java_frame()) {
585
          trace->num_frames = 0; // No Java frames
D
duke 已提交
586
        } else {
587 588 589 590 591 592 593 594 595 596
          trace->num_frames = ticks_not_walkable_not_Java;    // -4 non walkable frame by default
          forte_fill_call_trace_given_top(thread, trace, depth, fr);

          // This assert would seem to be valid but it is not.
          // It would be valid if we weren't possibly racing a gc
          // thread. A gc thread can make a valid interpreted frame
          // look invalid. It's a small window but it does happen.
          // The assert is left here commented out as a reminder.
          // assert(trace->num_frames != ticks_not_walkable_not_Java, "should always be walkable");

D
duke 已提交
597 598 599 600 601 602 603 604 605 606 607
        }
      }
    }
    break;
  case _thread_in_Java:
  case _thread_in_Java_trans:
    {
      frame fr;

      // param isInJava == true - indicate we are in Java code
      if (!thread->pd_get_top_frame_for_signal_handler(&fr, ucontext, true)) {
608
        trace->num_frames = ticks_unknown_Java;  // -5 unknown frame
D
duke 已提交
609
      } else {
610
        trace->num_frames = ticks_not_walkable_Java;  // -6, non walkable frame by default
D
duke 已提交
611 612 613 614 615 616
        forte_fill_call_trace_given_top(thread, trace, depth, fr);
      }
    }
    break;
  default:
    // Unknown thread state
617
    trace->num_frames = ticks_unknown_state; // -7
D
duke 已提交
618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655
    break;
  }
}


#ifndef _WINDOWS
// Support for the Forte(TM) Peformance Tools collector.
//
// The method prototype is derived from libcollector.h. For more
// information, please see the libcollect man page.

// Method to let libcollector know about a dynamically loaded function.
// Because it is weakly bound, the calls become NOP's when the library
// isn't present.
void    collector_func_load(char* name,
                            void* null_argument_1,
                            void* null_argument_2,
                            void *vaddr,
                            int size,
                            int zero_argument,
                            void* null_argument_3);
#pragma weak collector_func_load
#define collector_func_load(x0,x1,x2,x3,x4,x5,x6) \
        ( collector_func_load ? collector_func_load(x0,x1,x2,x3,x4,x5,x6),0 : 0 )
#endif // !_WINDOWS

} // end extern "C"
#endif // !IA64

void Forte::register_stub(const char* name, address start, address end) {
#if !defined(_WINDOWS) && !defined(IA64)
  assert(pointer_delta(end, start, sizeof(jbyte)) < INT_MAX,
    "Code size exceeds maximum range")

  collector_func_load((char*)name, NULL, NULL, start,
    pointer_delta(end, start, sizeof(jbyte)), 0, NULL);
#endif // !_WINDOWS && !IA64
}