+
+
+/* codegen_get_pv_from_pc_nocheck **********************************************
+
+ Find the PV for the given PC by searching in the AVL tree of
+ methods. This method does not check the return value and is used
+ by the profiler.
+
+*******************************************************************************/
+
+u1 *codegen_get_pv_from_pc_nocheck(u1 *pc)
+{
+ methodtree_element mtepc;
+ methodtree_element *mte;
+
+ /* allocation of the search structure on the stack is much faster */
+
+ mtepc.startpc = pc;
+ mtepc.endpc = pc;
+
+ mte = avl_find(methodtree, &mtepc);
+
+ if (mte == NULL)
+ return NULL;
+ else
+ return mte->startpc;
+}
+
+
+/* codegen_set_replacement_point_notrap ****************************************
+
+ Record the position of a non-trappable replacement point.
+
+*******************************************************************************/
+
+#if defined(ENABLE_REPLACEMENT)
+#if !defined(NDEBUG)
+void codegen_set_replacement_point_notrap(codegendata *cd, s4 type)
+#else
+void codegen_set_replacement_point_notrap(codegendata *cd)
+#endif
+{
+ assert(cd->replacementpoint);
+ assert(cd->replacementpoint->type == type);
+ assert(cd->replacementpoint->flags & RPLPOINT_FLAG_NOTRAP);
+
+ cd->replacementpoint->pc = (u1*) (ptrint) (cd->mcodeptr - cd->mcodebase);
+
+ cd->replacementpoint++;
+}
+#endif /* defined(ENABLE_REPLACEMENT) */
+
+
+/* codegen_set_replacement_point ***********************************************
+
+ Record the position of a trappable replacement point.
+
+*******************************************************************************/
+
+#if defined(ENABLE_REPLACEMENT)
+#if !defined(NDEBUG)
+void codegen_set_replacement_point(codegendata *cd, s4 type)
+#else
+void codegen_set_replacement_point(codegendata *cd)
+#endif
+{
+ assert(cd->replacementpoint);
+ assert(cd->replacementpoint->type == type);
+ assert(!(cd->replacementpoint->flags & RPLPOINT_FLAG_NOTRAP));
+
+ cd->replacementpoint->pc = (u1*) (ptrint) (cd->mcodeptr - cd->mcodebase);
+
+ cd->replacementpoint++;
+
+ /* XXX assert(cd->lastmcodeptr <= cd->mcodeptr); */
+
+ cd->lastmcodeptr = cd->mcodeptr + PATCHER_CALL_SIZE;
+}
+#endif /* defined(ENABLE_REPLACEMENT) */