offset = VM_Entrypoints.threadStackField.getOffsetAsInt(); p("static const int VM_Thread_stack_offset = " + offset + ";\n"); offset = VM_Entrypoints.stackLimitField.getOffsetAsInt(); p("static const int VM_Thread_stackLimit_offset = " + offset + ";\n"); offset = VM_Entrypoints.threadHardwareExceptionRegistersField.getOffsetAsInt(); p("static const int VM_Thread_hardwareExceptionRegisters_offset = " + offset + ";\n"); offset = VM_Entrypoints.jniEnvField.getOffsetAsInt(); p("static const int VM_Thread_jniEnv_offset = " + offset + ";\n");
offset = VM_Entrypoints.threadStackField.getOffset(); pln("VM_Thread_stack_offset = ", offset); offset = VM_Entrypoints.stackLimitField.getOffset(); pln("VM_Thread_stackLimit_offset = ", offset); offset = VM_Entrypoints.threadHardwareExceptionRegistersField.getOffset(); pln("VM_Thread_hardwareExceptionRegisters_offset = ", offset); offset = VM_Entrypoints.jniEnvField.getOffset(); pln("VM_Thread_jniEnv_offset = ", offset);
  static void emitVirtualMachineDeclarations (int bootImageAddress) {    // load address for the boot image    //    p("static const int bootImageAddress                        = 0x"        + Integer.toHexString(bootImageAddress) + ";\n");    // values in VM_Constants, from VM_Configuration    //    //-#if RVM_FOR_POWERPC    if (VM.BuildForPowerPC) {      p("static const int VM_Constants_JTOC_POINTER               = "          + VM_Constants.JTOC_POINTER + ";\n");      p("static const int VM_Constants_FRAME_POINTER              = "          + VM_Constants.FRAME_POINTER + ";\n");      p("static const int VM_Constants_PROCESSOR_REGISTER         = "          + VM_Constants.PROCESSOR_REGISTER + ";\n");      p("static const int VM_Constants_FIRST_VOLATILE_GPR         = "          + VM_Constants.FIRST_VOLATILE_GPR + ";\n");      p("static const int VM_Constants_DIVIDE_BY_ZERO_MASK        = "          + VM_Constants.DIVIDE_BY_ZERO_MASK + ";\n");      p("static const int VM_Constants_DIVIDE_BY_ZERO_TRAP        = "          + VM_Constants.DIVIDE_BY_ZERO_TRAP + ";\n");      p("static const int VM_Constants_MUST_IMPLEMENT_MASK        = "          + VM_Constants.MUST_IMPLEMENT_MASK + ";\n");      p("static const int VM_Constants_MUST_IMPLEMENT_TRAP        = "          + VM_Constants.MUST_IMPLEMENT_TRAP + ";\n");      p("static const int VM_Constants_STORE_CHECK_MASK           = "          + VM_Constants.STORE_CHECK_MASK + ";\n");      p("static const int VM_Constants_STORE_CHECK_TRAP           = "          + VM_Constants.STORE_CHECK_TRAP + ";\n");      p("static const int VM_Constants_ARRAY_INDEX_MASK           = "          + VM_Constants.ARRAY_INDEX_MASK + ";\n");      p("static const int VM_Constants_ARRAY_INDEX_TRAP           = "          + VM_Constants.ARRAY_INDEX_TRAP + ";\n");      p("static const int VM_Constants_ARRAY_INDEX_REG_MASK       = "          + VM_Constants.ARRAY_INDEX_REG_MASK + ";\n");      p("static const int VM_Constants_ARRAY_INDEX_REG_SHIFT      = "          + VM_Constants.ARRAY_INDEX_REG_SHIFT + ";\n");      p("static const int VM_Constants_CONSTANT_ARRAY_INDEX_MASK  = "          + VM_Constants.CONSTANT_ARRAY_INDEX_MASK + ";\n");      p("static const int VM_Constants_CONSTANT_ARRAY_INDEX_TRAP  = "          + VM_Constants.CONSTANT_ARRAY_INDEX_TRAP + ";\n");      p("static const int VM_Constants_CONSTANT_ARRAY_INDEX_INFO  = "          + VM_Constants.CONSTANT_ARRAY_INDEX_INFO + ";\n");      p("static const int VM_Constants_WRITE_BUFFER_OVERFLOW_MASK = "          + VM_Constants.WRITE_BUFFER_OVERFLOW_MASK + ";\n");      p("static const int VM_Constants_WRITE_BUFFER_OVERFLOW_TRAP = "          + VM_Constants.WRITE_BUFFER_OVERFLOW_TRAP + ";\n");      p("static const int VM_Constants_STACK_OVERFLOW_MASK        = "          + VM_Constants.STACK_OVERFLOW_MASK + ";\n");      p("static const int VM_Constants_STACK_OVERFLOW_HAVE_FRAME_TRAP = "          + VM_Constants.STACK_OVERFLOW_HAVE_FRAME_TRAP + ";\n");      p("static const int VM_Constants_STACK_OVERFLOW_TRAP        = "          + VM_Constants.STACK_OVERFLOW_TRAP + ";\n");      p("static const int VM_Constants_CHECKCAST_MASK             = "          + VM_Constants.CHECKCAST_MASK + ";\n");      p("static const int VM_Constants_CHECKCAST_TRAP             = "          + VM_Constants.CHECKCAST_TRAP + ";\n");      p("static const int VM_Constants_REGENERATE_MASK            = "          + VM_Constants.REGENERATE_MASK + ";\n");      p("static const int VM_Constants_REGENERATE_TRAP            = "          + VM_Constants.REGENERATE_TRAP + ";\n");      p("static const int VM_Constants_NULLCHECK_MASK             = "          + VM_Constants.NULLCHECK_MASK + ";\n");      p("static const int VM_Constants_NULLCHECK_TRAP             = "          + VM_Constants.NULLCHECK_TRAP + ";\n");      p("static const int VM_Constants_JNI_STACK_TRAP_MASK             = "          + VM_Constants.JNI_STACK_TRAP_MASK + ";\n");      p("static const int VM_Constants_JNI_STACK_TRAP             = "          + VM_Constants.JNI_STACK_TRAP + ";\n");      p("static const int VM_Constants_STACKFRAME_NEXT_INSTRUCTION_OFFSET = "          + VM_Constants.STACKFRAME_NEXT_INSTRUCTION_OFFSET + ";\n");          p("static const int VM_Constants_STACKFRAME_ALIGNMENT = "                  + VM_Constants.STACKFRAME_ALIGNMENT + " ;\n");    }    //-#endif    //-#if RVM_FOR_IA32    if (VM.BuildForIA32) {      p("static const int VM_Constants_EAX                    = "          + VM_Constants.EAX + ";\n");      p("static const int VM_Constants_ECX                    = "          + VM_Constants.ECX + ";\n");      p("static const int VM_Constants_EDX                    = "          + VM_Constants.EDX + ";\n");      p("static const int VM_Constants_EBX                    = "          + VM_Constants.EBX + ";\n");      p("static const int VM_Constants_ESP                    = "          + VM_Constants.ESP + ";\n");      p("static const int VM_Constants_EBP                    = "          + VM_Constants.EBP + ";\n");      p("static const int VM_Constants_ESI                    = "          + VM_Constants.ESI + ";\n");      p("static const int VM_Constants_EDI                    = "          + VM_Constants.EDI + ";\n");      p("static const int VM_Constants_STACKFRAME_BODY_OFFSET             = "          + VM_Constants.STACKFRAME_BODY_OFFSET + ";\n");      p("static const int VM_Constants_STACKFRAME_RETURN_ADDRESS_OFFSET   = "          + VM_Constants.STACKFRAME_RETURN_ADDRESS_OFFSET   + ";\n");          p("static const int VM_Constants_RVM_TRAP_BASE  = "          + VM_Constants.RVM_TRAP_BASE   + ";\n");        }    //-#endif    p("static const int VM_Constants_STACK_SIZE_GUARD          = "        + VM_Constants.STACK_SIZE_GUARD + ";\n");    //-#if RVM_WITH_FLEXIBLE_STACK_SIZES    p("static const int VM_Constants_STACK_SIZE_MIN      = "        + VM_Constants.STACK_SIZE_MIN + ";\n");    p("static const int VM_Constants_STACK_SIZE_NORMAL_DEFAULT  = "        + VM_Constants.STACK_SIZE_NORMAL_DEFAULT + ";\n");    p("static const int VM_Constants_STACK_SIZE_GROW_MIN       = "        + VM_Constants.STACK_SIZE_GROW_MIN + ";\n");    p("static const int VM_Constants_STACK_SIZE_GROW_DEFAULT   = "        + VM_Constants.STACK_SIZE_GROW_DEFAULT + ";\n");    p("static const int VM_Constants_STACK_SIZE_MAX_DEFAULT    = "        + VM_Constants.STACK_SIZE_MAX_DEFAULT + ";\n");    //-#endif // RVM_WITH_FLEXIBLE_STACK_SIZES    p("static const int VM_Constants_INVISIBLE_METHOD_ID       = "        + VM_Constants.INVISIBLE_METHOD_ID + ";\n");    p("static const int VM_ThinLockConstants_TL_THREAD_ID_SHIFT= "        + VM_ThinLockConstants.TL_THREAD_ID_SHIFT + ";\n");    p("static const int VM_Constants_STACKFRAME_HEADER_SIZE    = "        + VM_Constants.STACKFRAME_HEADER_SIZE + ";\n");    p("static const int VM_Constants_STACKFRAME_METHOD_ID_OFFSET = "        + VM_Constants.STACKFRAME_METHOD_ID_OFFSET + ";\n");    p("static const int VM_Constants_STACKFRAME_FRAME_POINTER_OFFSET    = "        + VM_Constants.STACKFRAME_FRAME_POINTER_OFFSET + ";\n");    p("static const int VM_Constants_STACKFRAME_SENTINEL_FP             = "        + VM_Constants.STACKFRAME_SENTINEL_FP.toInt() + ";\n");    p("\n");    // values in VM_ObjectModel    //    pln("static const int VM_ObjectModel_ARRAY_LENGTH_OFFSET = " +                        VM_ObjectModel.getArrayLengthOffset().toInt() + "\n;");    // values in VM_Scheduler    //    p("static const int VM_Scheduler_PRIMORDIAL_PROCESSOR_ID = "        + VM_Scheduler.PRIMORDIAL_PROCESSOR_ID + ";\n");    p("static const int VM_Scheduler_PRIMORDIAL_THREAD_INDEX = "        + VM_Scheduler.PRIMORDIAL_THREAD_INDEX + ";\n");    p("\n");    // values in VM_ThreadEventConstants    //    p("static const double VM_ThreadEventConstants_WAIT_INFINITE = " +        VM_ThreadEventConstants.WAIT_INFINITE + ";\n");    // values in VM_ThreadIOQueue    //    p("static const int VM_ThreadIOQueue_READ_OFFSET = " +         VM_ThreadIOQueue.READ_OFFSET + ";\n");    p("static const int VM_ThreadIOQueue_WRITE_OFFSET = " +         VM_ThreadIOQueue.WRITE_OFFSET + ";\n");    p("static const int VM_ThreadIOQueue_EXCEPT_OFFSET = " +         VM_ThreadIOQueue.EXCEPT_OFFSET + ";\n");    p("\n");    // values in VM_ThreadIOConstants    //    p("static const int VM_ThreadIOConstants_FD_READY = " +        VM_ThreadIOConstants.FD_READY + ";\n");    p("static const int VM_ThreadIOConstants_FD_READY_BIT = " +        VM_ThreadIOConstants.FD_READY_BIT + ";\n");    p("static const int VM_ThreadIOConstants_FD_INVALID = " +        VM_ThreadIOConstants.FD_INVALID + ";\n");    p("static const int VM_ThreadIOConstants_FD_INVALID_BIT = " +        VM_ThreadIOConstants.FD_INVALID_BIT + ";\n");    p("static const int VM_ThreadIOConstants_FD_MASK = " +        VM_ThreadIOConstants.FD_MASK + ";\n");    p("\n");    // values in VM_ThreadProcessWaitQueue    //    p("static const int VM_ThreadProcessWaitQueue_PROCESS_FINISHED = " +        VM_ThreadProcessWaitQueue.PROCESS_FINISHED + ";\n");    // values in VM_Runtime    //    p("static const int VM_Runtime_TRAP_UNKNOWN        = "        + VM_Runtime.TRAP_UNKNOWN + ";\n");    p("static const int VM_Runtime_TRAP_NULL_POINTER   = "        + VM_Runtime.TRAP_NULL_POINTER + ";\n");    p("static const int VM_Runtime_TRAP_ARRAY_BOUNDS   = "        + VM_Runtime.TRAP_ARRAY_BOUNDS + ";\n");    p("static const int VM_Runtime_TRAP_DIVIDE_BY_ZERO = "        + VM_Runtime.TRAP_DIVIDE_BY_ZERO + ";\n");    p("static const int VM_Runtime_TRAP_STACK_OVERFLOW = "        + VM_Runtime.TRAP_STACK_OVERFLOW + ";\n");    p("static const int VM_Runtime_TRAP_CHECKCAST      = "        + VM_Runtime.TRAP_CHECKCAST + ";\n");    p("static const int VM_Runtime_TRAP_REGENERATE     = "        + VM_Runtime.TRAP_REGENERATE + ";\n");    p("static const int VM_Runtime_TRAP_JNI_STACK     = "        + VM_Runtime.TRAP_JNI_STACK + ";\n");    p("static const int VM_Runtime_TRAP_MUST_IMPLEMENT = "        + VM_Runtime.TRAP_MUST_IMPLEMENT + ";\n");    p("static const int VM_Runtime_TRAP_STORE_CHECK = "        + VM_Runtime.TRAP_STORE_CHECK + ";\n");    pln();    // values in VM_FileSystem    //    p("static const int VM_FileSystem_OPEN_READ                 = "        + VM_FileSystem.OPEN_READ + ";\n");    p("static const int VM_FileSystem_OPEN_WRITE                 = "        + VM_FileSystem.OPEN_WRITE + ";\n");    p("static const int VM_FileSystem_OPEN_MODIFY                 = "        + VM_FileSystem.OPEN_MODIFY + ";\n");    p("static const int VM_FileSystem_OPEN_APPEND                 = "        + VM_FileSystem.OPEN_APPEND + ";\n");    p("static const int VM_FileSystem_SEEK_SET                 = "        + VM_FileSystem.SEEK_SET + ";\n");    p("static const int VM_FileSystem_SEEK_CUR                 = "        + VM_FileSystem.SEEK_CUR + ";\n");    p("static const int VM_FileSystem_SEEK_END                 = "        + VM_FileSystem.SEEK_END + ";\n");    p("static const int VM_FileSystem_STAT_EXISTS                 = "        + VM_FileSystem.STAT_EXISTS + ";\n");    p("static const int VM_FileSystem_STAT_IS_FILE                 = "        + VM_FileSystem.STAT_IS_FILE + ";\n");    p("static const int VM_FileSystem_STAT_IS_DIRECTORY                 = "        + VM_FileSystem.STAT_IS_DIRECTORY + ";\n");    p("static const int VM_FileSystem_STAT_IS_READABLE                 = "        + VM_FileSystem.STAT_IS_READABLE + ";\n");    p("static const int VM_FileSystem_STAT_IS_WRITABLE                 = "        + VM_FileSystem.STAT_IS_WRITABLE + ";\n");    p("static const int VM_FileSystem_STAT_LAST_MODIFIED                 = "        + VM_FileSystem.STAT_LAST_MODIFIED + ";\n");    p("static const int VM_FileSystem_STAT_LENGTH                 = "        + VM_FileSystem.STAT_LENGTH + ";\n");    // Value in org.mmtk.vm.Constants:    p("static const int MMTk_Constants_BYTES_IN_PAGE            = "        + org.mmtk.utility.Constants.BYTES_IN_PAGE + ";\n");    // fields in VM_Processor    //    int offset;    offset = VM_Entrypoints.timeSliceExpiredField.getOffsetAsInt();    p("static const int VM_Processor_timeSliceExpired_offset = "        + offset + ";\n");    offset = VM_Entrypoints.takeYieldpointField.getOffsetAsInt();    p("static const int VM_Processor_takeYieldpoint_offset = "        + offset + ";\n");    offset = VM_Entrypoints.activeThreadStackLimitField.getOffsetAsInt();    p("static const int VM_Processor_activeThreadStackLimit_offset = "                     + offset + ";\n");    offset = VM_Entrypoints.pthreadIDField.getOffsetAsInt();    p("static const int VM_Processor_pthread_id_offset = "                     + offset + ";\n");    offset = VM_Entrypoints.timerTicksField.getOffsetAsInt();    p("static const int VM_Processor_timerTicks_offset = "                     + offset + ";\n");    offset = VM_Entrypoints.reportedTimerTicksField.getOffsetAsInt();    p("static const int VM_Processor_reportedTimerTicks_offset = "                    + offset + ";\n");    offset = VM_Entrypoints.activeThreadField.getOffsetAsInt();    p("static const int VM_Processor_activeThread_offset = "                     + offset + ";\n");    offset = VM_Entrypoints.threadIdField.getOffsetAsInt();    p("static const int VM_Processor_threadId_offset = "                     + offset + ";\n");    //-#if RVM_FOR_IA32    offset = VM_Entrypoints.framePointerField.getOffsetAsInt();    p("static const int VM_Processor_framePointer_offset = "                     + offset + ";\n");    offset = VM_Entrypoints.jtocField.getOffsetAsInt();    p("static const int VM_Processor_jtoc_offset = "                     + offset + ";\n");    offset = VM_Entrypoints.arrayIndexTrapParamField.getOffsetAsInt();    p("static const int VM_Processor_arrayIndexTrapParam_offset = "                     + offset + ";\n");    //-#endif    // fields in VM_Thread    //    offset = VM_Entrypoints.threadStackField.getOffsetAsInt();    p("static const int VM_Thread_stack_offset = " + offset + ";\n");    offset = VM_Entrypoints.stackLimitField.getOffsetAsInt();    p("static const int VM_Thread_stackLimit_offset = " + offset + ";\n");    offset = VM_Entrypoints.threadHardwareExceptionRegistersField.getOffsetAsInt();    p("static const int VM_Thread_hardwareExceptionRegisters_offset = "                     + offset + ";\n");    offset = VM_Entrypoints.jniEnvField.getOffsetAsInt();    p("static const int VM_Thread_jniEnv_offset = "                     + offset + ";\n");    // fields in VM_Registers    //    offset = VM_Entrypoints.registersGPRsField.getOffsetAsInt();    p("static const int VM_Registers_gprs_offset = " + offset + ";\n");    offset = VM_Entrypoints.registersFPRsField.getOffsetAsInt();    p("static const int VM_Registers_fprs_offset = " + offset + ";\n");    offset = VM_Entrypoints.registersIPField.getOffsetAsInt();    p("static const int VM_Registers_ip_offset = " + offset + ";\n");    //-#if RVM_FOR_IA32    offset = VM_Entrypoints.registersFPField.getOffsetAsInt();    p("static const int VM_Registers_fp_offset = " + offset + ";\n");    //-#endif    //-#if RVM_FOR_POWERPC    offset = VM_Entrypoints.registersLRField.getOffsetAsInt();    p("static const int VM_Registers_lr_offset = " + offset + ";\n");    //-#endif    offset = VM_Entrypoints.registersInUseField.getOffsetAsInt();    p("static const int VM_Registers_inuse_offset = " +                      offset + ";\n");    // fields in VM_JNIEnvironment    offset = VM_Entrypoints.JNIExternalFunctionsField.getOffsetAsInt();    p("static const int VM_JNIEnvironment_JNIExternalFunctions_offset = " +      offset + ";\n");    // fields in java.net.InetAddress    //    offset = VM_Entrypoints.inetAddressAddressField.getOffsetAsInt();    p("static const int java_net_InetAddress_address_offset = "                     + offset + ";\n");    offset = VM_Entrypoints.inetAddressFamilyField.getOffsetAsInt();    p("static const int java_net_InetAddress_family_offset = "                     + offset + ";\n");    // fields in java.net.SocketImpl    //    offset = VM_Entrypoints.socketImplAddressField.getOffsetAsInt();    p("static const int java_net_SocketImpl_address_offset = "                     + offset + ";\n");    offset = VM_Entrypoints.socketImplPortField.getOffsetAsInt();    p("static const int java_net_SocketImpl_port_offset = "                     + offset + ";\n");    // fields in com.ibm.JikesRVM.memoryManagers.JMTk.BasePlan    offset = VM_Entrypoints.gcStatusField.getOffsetAsInt();    p("static const int com_ibm_JikesRVM_memoryManagers_JMTk_BasePlan_gcStatusOffset = "                     + offset + ";\n");  }