bool MM_VerboseHandlerOutput::initialize(MM_EnvironmentBase *env, MM_VerboseManager *manager) { _omrVM = env->getOmrVM(); _mmPrivateHooks = J9_HOOK_INTERFACE(_extensions->privateHookInterface); _mmOmrHooks = J9_HOOK_INTERFACE(_extensions->omrHookInterface); _manager = manager; return true; }
static void hookNormalEvent(J9HookInterface **hook, uintptr_t eventNum, void *voidEventData, void *userData) { uintptr_t increment = 1; if (J9_HOOK_INTERFACE(sampleHookInterface) != hook) { /* force the count to be wrong */ increment = 8096; } switch (eventNum) { case TESTHOOK_EVENT1: ((TestHookEvent1 *)voidEventData)->count += increment; break; case TESTHOOK_EVENT2: ((TestHookEvent2 *)voidEventData)->count += increment; break; case TESTHOOK_EVENT3: ((TestHookEvent3 *)voidEventData)->count += increment; break; case TESTHOOK_EVENT4: ((TestHookEvent4 *)voidEventData)->count += increment; break; } }
/** * Initializes the MM_VerboseManager instance. */ bool MM_VerboseManager::initialize(MM_EnvironmentBase *env) { OMRPORT_ACCESS_FROM_OMRPORT(env->getPortLibrary()); MM_GCExtensionsBase *extensions = MM_GCExtensionsBase::getExtensions(env->getOmrVM()); _mmPrivateHooks = J9_HOOK_INTERFACE(extensions->privateHookInterface); _omrHooks = J9_HOOK_INTERFACE(extensions->omrHookInterface); _writerChain = MM_VerboseWriterChain::newInstance(env); if (NULL == _writerChain) { return false; } if(NULL == (_verboseHandlerOutput = createVerboseHandlerOutputObject(env))) { return false; } _lastOutputTime = omrtime_hires_clock(); return true; }
static void hookOrderedEvent(J9HookInterface **hook, uintptr_t eventNum, void *voidEventData, void *userData) { uintptr_t increment = 1; intptr_t prevAgent = 0; intptr_t thisAgent = (intptr_t)userData; if (J9_HOOK_INTERFACE(sampleHookInterface) != hook) { /* force the count to be wrong */ increment = 8096; } switch (eventNum) { case TESTHOOK_EVENT1: prevAgent = ((TestHookEvent1 *)voidEventData)->prevAgent; ((TestHookEvent1 *)voidEventData)->prevAgent = thisAgent; break; case TESTHOOK_EVENT2: prevAgent = ((TestHookEvent2 *)voidEventData)->prevAgent; ((TestHookEvent2 *)voidEventData)->prevAgent = thisAgent; break; case TESTHOOK_EVENT3: prevAgent = ((TestHookEvent3 *)voidEventData)->prevAgent; ((TestHookEvent3 *)voidEventData)->prevAgent = thisAgent; break; case TESTHOOK_EVENT4: prevAgent = ((TestHookEvent4 *)voidEventData)->prevAgent; ((TestHookEvent4 *)voidEventData)->prevAgent = thisAgent; break; } if (prevAgent > thisAgent) { /* force the count to be wrong */ increment = 42; } switch (eventNum) { case TESTHOOK_EVENT1: ((TestHookEvent1 *)voidEventData)->count += increment; break; case TESTHOOK_EVENT2: ((TestHookEvent2 *)voidEventData)->count += increment; break; case TESTHOOK_EVENT3: ((TestHookEvent3 *)voidEventData)->count += increment; break; case TESTHOOK_EVENT4: ((TestHookEvent4 *)voidEventData)->count += increment; break; } }
/** * Initialize a new ConcurrentGCIncrementalUpdate object. * Instantiate card table and concurrent RAS objects(if required) and initialize all * monitors required by concurrent. Allocate and initialize the concurrent helper thread * table. * * @return TRUE if initialization completed OK;FALSE otheriwse */ bool MM_ConcurrentGCIncrementalUpdate::initialize(MM_EnvironmentBase *env) { J9HookInterface** mmPrivateHooks = J9_HOOK_INTERFACE(_extensions->privateHookInterface); if (!MM_ConcurrentGC::initialize(env)) { goto error_no_memory; } if (!createCardTable(env)) { goto error_no_memory; } /* Register on any hook we are interested in */ (*mmPrivateHooks)->J9HookRegisterWithCallSite(mmPrivateHooks, J9HOOK_MM_PRIVATE_CARD_CLEANING_PASS_2_START, hookCardCleanPass2Start, OMR_GET_CALLSITE(), (void *)this); return true; error_no_memory: return false; }
int32_t verifyHookable(OMRPortLibrary *portLib, uintptr_t *passCount, uintptr_t *failCount) { int32_t rc = 0; J9HookInterface **hookInterface = J9_HOOK_INTERFACE(sampleHookInterface); OMRPORT_ACCESS_FROM_OMRPORT(portLib); omrtty_printf("Testing hookable interface...\n"); if (J9HookInitializeInterface(hookInterface, portLib, sizeof(sampleHookInterface))) { (*failCount)++; rc = -1; } else { (*passCount)++; rc = testHookInterface(portLib, passCount, failCount, hookInterface); (*hookInterface)->J9HookShutdownInterface(hookInterface); } omrtty_printf("Finished testing hookable interface.\n"); return rc; }