From b94d283bbb1750d38afba2d40d8d19a91a314ebf Mon Sep 17 00:00:00 2001 From: Jason Hall Date: Fri, 22 Feb 2019 21:42:25 +0000 Subject: [PATCH] Modify MetronomeAlarm for moving into OMR Signed-off-by: Jason Hall --- runtime/gc_realtime/MetronomeAlarm.cpp | 44 ++++++++++---------------- runtime/gc_realtime/MetronomeAlarm.hpp | 8 ++--- 2 files changed, 20 insertions(+), 32 deletions(-) diff --git a/runtime/gc_realtime/MetronomeAlarm.cpp b/runtime/gc_realtime/MetronomeAlarm.cpp index 160254925b5..e9f6804eed2 100644 --- a/runtime/gc_realtime/MetronomeAlarm.cpp +++ b/runtime/gc_realtime/MetronomeAlarm.cpp @@ -20,22 +20,10 @@ * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception *******************************************************************************/ -#include "ProcessorInfo.hpp" -#include "AtomicOperations.hpp" -#include "ClassModel.hpp" -#include "Dispatcher.hpp" #include "EnvironmentBase.hpp" -#include "GCExtensions.hpp" -#include "Heap.hpp" -#include "MemoryPoolSegregated.hpp" -#include "MemorySubSpace.hpp" -#include "modronapi.hpp" -#include "ObjectModel.hpp" -#include "OSInterface.hpp" -#include "RootScanner.hpp" -#include "Task.hpp" #include "MetronomeAlarmThread.hpp" -#include "RealtimeGC.hpp" +#include "OSInterface.hpp" +#include "Scheduler.hpp" #include "MetronomeAlarm.hpp" @@ -71,7 +59,7 @@ MM_HRTAlarm::newInstance(MM_EnvironmentBase *env) { MM_HRTAlarm * alarm; - alarm = (MM_HRTAlarm *)env->getForge()->allocate(sizeof(MM_HRTAlarm), MM_AllocationCategory::FIXED, J9_GET_CALLSITE()); + alarm = (MM_HRTAlarm *)env->getForge()->allocate(sizeof(MM_HRTAlarm), MM_AllocationCategory::FIXED, OMR_GET_CALLSITE()); if (alarm) { new(alarm) MM_HRTAlarm(); } @@ -83,7 +71,7 @@ MM_RTCAlarm::newInstance(MM_EnvironmentBase *env) { MM_RTCAlarm * alarm; - alarm = (MM_RTCAlarm *)env->getForge()->allocate(sizeof(MM_RTCAlarm), MM_AllocationCategory::FIXED, J9_GET_CALLSITE()); + alarm = (MM_RTCAlarm *)env->getForge()->allocate(sizeof(MM_RTCAlarm), MM_AllocationCategory::FIXED, OMR_GET_CALLSITE()); if (alarm) { new(alarm) MM_RTCAlarm(); } @@ -95,7 +83,7 @@ MM_ITAlarm::newInstance(MM_EnvironmentBase *env) { MM_ITAlarm * alarm; - alarm = (MM_ITAlarm *)env->getForge()->allocate(sizeof(MM_ITAlarm), MM_AllocationCategory::FIXED, J9_GET_CALLSITE()); + alarm = (MM_ITAlarm *)env->getForge()->allocate(sizeof(MM_ITAlarm), MM_AllocationCategory::FIXED, OMR_GET_CALLSITE()); if (alarm) { new(alarm) MM_ITAlarm(); } @@ -128,7 +116,7 @@ MM_Alarm::factory(MM_EnvironmentBase *env, MM_OSInterface* osInterface) bool MM_HRTAlarm::initialize(MM_EnvironmentBase *env, MM_MetronomeAlarmThread* alarmThread) { - _extensions = MM_GCExtensions::getExtensions(env); + _extensions = MM_GCExtensionsBase::getExtensions(env->getOmrVM()); return alarmThread->startThread(env); } @@ -145,32 +133,32 @@ MM_HRTAlarm::initialize(MM_EnvironmentBase *env, MM_MetronomeAlarmThread* alarmT bool MM_RTCAlarm::initialize(MM_EnvironmentBase *env, MM_MetronomeAlarmThread* alarmThread) { - _extensions = MM_GCExtensions::getExtensions(env); + _extensions = MM_GCExtensionsBase::getExtensions(env->getOmrVM()); #if defined(LINUX) && !defined(J9ZTPF) - PORT_ACCESS_FROM_ENVIRONMENT(env); + OMRPORT_ACCESS_FROM_ENVIRONMENT(env); RTCfd = open("/dev/rtc", O_RDONLY); if (RTCfd == -1) { if (_extensions->verbose >= 2) { - j9tty_printf(PORTLIB, "Unable to open /dev/rtc\n"); + omrtty_printf("Unable to open /dev/rtc\n"); } goto error; } if ((ioctl(RTCfd, RTC_IRQP_SET, _extensions->RTC_Frequency) == -1)) { if (_extensions->verbose >= 2) { - j9tty_printf(PORTLIB, "Unable to set IRQP for /dev/rtc\n"); + omrtty_printf("Unable to set IRQP for /dev/rtc\n"); } goto error; } if (ioctl(RTCfd, RTC_IRQP_READ, &_extensions->RTC_Frequency)) { if (_extensions->verbose >= 2) { - j9tty_printf(PORTLIB, "Unable to read IRQP for /dev/rtc\n"); + omrtty_printf("Unable to read IRQP for /dev/rtc\n"); } goto error; } if (ioctl(RTCfd, RTC_PIE_ON, 0) == -1) { if (_extensions->verbose >= 2) { - j9tty_printf(PORTLIB, "Unable to enable PIE for /dev/rtc\n"); + omrtty_printf("Unable to enable PIE for /dev/rtc\n"); } goto error; } @@ -179,7 +167,7 @@ MM_RTCAlarm::initialize(MM_EnvironmentBase *env, MM_MetronomeAlarmThread* alarmT error: if (_extensions->verbose >= 1) { - j9tty_printf(PORTLIB, "Unable to use /dev/rtc for time-based scheduling\n"); + omrtty_printf("Unable to use /dev/rtc for time-based scheduling\n"); } return false; #else @@ -213,7 +201,7 @@ itAlarmThunk(UINT uTimerID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PT bool MM_ITAlarm::initialize(MM_EnvironmentBase *env, MM_MetronomeAlarmThread* alarmThread) { - _extensions = MM_GCExtensions::getExtensions(env); + _extensions = MM_GCExtensionsBase::getExtensions(env->getOmrVM()); if (!alarmThread->startThread(env)) { return false; } @@ -248,7 +236,7 @@ void MM_RTCAlarm::sleep() { #if defined(LINUX) && !defined(J9ZTPF) - UDATA data; + uintptr_t data; ssize_t readAmount = read(RTCfd, &data, sizeof(data)); if (readAmount == -1) { perror("blocking read failed"); @@ -275,7 +263,7 @@ void MM_RTCAlarm::describe(OMRPortLibrary* port, char *buffer, I_32 bufferSize) void MM_HRTAlarm::describe(OMRPortLibrary* port, char *buffer, I_32 bufferSize) { OMRPORT_ACCESS_FROM_OMRPORT(port); - omrstr_printf(buffer, bufferSize, "High Resolution Timer (Period = %d us)", _extensions->hrtPeriodMicro); + omrstr_printf(buffer, bufferSize, "High Resolution Timer (Period = %d us)", _extensions->hrtPeriodMicro); } void MM_ITAlarm::describe(OMRPortLibrary* port, char *buffer, I_32 bufferSize) { diff --git a/runtime/gc_realtime/MetronomeAlarm.hpp b/runtime/gc_realtime/MetronomeAlarm.hpp index c47efde71d3..77ad7285113 100644 --- a/runtime/gc_realtime/MetronomeAlarm.hpp +++ b/runtime/gc_realtime/MetronomeAlarm.hpp @@ -33,11 +33,11 @@ class MM_EnvironmentBase; class MM_ProcessorInfo; class MM_MetronomeAlarmThread; -#include "j9.h" -#include "j9cfg.h" +#include "omr.h" +#include "omrcfg.h" #include "Base.hpp" -#include "GCExtensions.hpp" +#include "GCExtensionsBase.hpp" #if defined(WIN32) #include "omrmutex.h" @@ -67,7 +67,7 @@ class MM_Alarm : protected MM_BaseVirtual } virtual void tearDown(MM_EnvironmentBase *env); - MM_GCExtensions *_extensions; + MM_GCExtensionsBase *_extensions; public: virtual void kill(MM_EnvironmentBase *envModron);