⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 nativecore.c

📁 Nucleus_2_kvm_Hello 是kvm移植到Nucleus系统的源代码。。。好东西啊
💻 C
📖 第 1 页 / 共 4 页
字号:
    START_TEMPORARY_ROOTS        DECLARE_TEMPORARY_ROOT(JAVATHREAD, javaThread,                               popStackAsType(JAVATHREAD));        javaThread->priority = (priority > MAX_PRIORITY ? MAX_PRIORITY :                   (priority < MIN_PRIORITY ? MIN_PRIORITY : priority));        VMthread = getVMthread(&javaThread);        /* The actual VM-level timeslice of the thread is calculated by         * multiplying the given priority */        VMthread->timeslice = javaThread->priority * TIMESLICEFACTOR;    END_TEMPORARY_ROOTS}/*========================================================================= * Native functions of class java.lang.Runtime *=======================================================================*//*========================================================================= * FUNCTION:      exit(I)V (VIRTUAL) * CLASS:         java.lang.Runtime * TYPE:          virtual native function * OVERVIEW:      Stop the VM and exit immediately. * INTERFACE (operand stack manipulation): *   parameters:  <none> *   returns:     <nothing> *=======================================================================*/void Java_java_lang_Runtime_exitInternal(void){    long value = popStack();    oneLess; /* Discard runtime object */    ERROR_THROW(value);}/*========================================================================= * FUNCTION:      freeMemory()J (VIRTUAL) * CLASS:         java.lang.Runtime * TYPE:          virtual native function * OVERVIEW:      Return the amount of free memory in the dynamic heap. * INTERFACE (operand stack manipulation): *   parameters:  <none> *   return:      the amount of free dynamic heap memory as long *=======================================================================*/void Java_java_lang_Runtime_freeMemory(void){    long result = memoryFree();    ulong64 result64;    ll_uint_to_long(result64, result);    oneLess; /* Discard runtime object */    pushLong(result64);}/*========================================================================= * FUNCTION:      totalMemory()J (VIRTUAL) * CLASS:         java.lang.Runtime * TYPE:          virtual native function * OVERVIEW:      Return the total amount of dynamic heap memory. * INTERFACE (operand stack manipulation): *   parameters:  <none> *   return:      the total amount of dynamic heap memory as long *=======================================================================*/void Java_java_lang_Runtime_totalMemory(void){    long result = getHeapSize();    ulong64 result64;    ll_uint_to_long(result64, result);    oneLess; /* Discard runtime object */    pushLong(result64);}/*========================================================================= * FUNCTION:      gc() (VIRTUAL) * CLASS:         java.lang.Runtime * TYPE:          virtual native function * OVERVIEW:      Invoke the garbage collector. * INTERFACE (operand stack manipulation): *   parameters:  <none> *   return:      <nothing> *=======================================================================*/void Java_java_lang_Runtime_gc(void){    oneLess; /* Discard runtime object */    /*  Garbage collect now, keeping the heap size the same as currently */    garbageCollect(0);}/*========================================================================= * Native functions of class java.lang.System *=======================================================================*//*========================================================================= * FUNCTION:      arraycopy()B (STATIC) * CLASS:         java.lang.System * TYPE:          static native function * OVERVIEW:      Copies a region of one array to another. *                Copies a region of one array, src, beginning at the *                array cell at src_position, to another array, dst, *                beginning at the dst_position.length cells are copied. *                No memory is allocated for the destination array, dst. *                This memory must already be allocated. * * INTERFACE (operand stack manipulation): *   parameters:  <none> *   return:      <none> *=======================================================================*/void Java_java_lang_System_arraycopy(void){    long length = popStack();    long dstPos = popStack();    ARRAY dst   = popStackAsType(ARRAY);    long srcPos = popStack();    ARRAY src   = popStackAsType(ARRAY);    ARRAY_CLASS srcClass, dstClass;    long srcEnd, dstEnd;    if ((src == NULL) || (dst == NULL)) {        raiseException(NullPointerException);        return;    }    srcClass = src->ofClass;    dstClass = dst->ofClass;    if (    (!IS_ARRAY_CLASS((CLASS)srcClass))         || (!IS_ARRAY_CLASS((CLASS)dstClass))         /* both must be arrays of Objects, or arrays of primitives */         || (srcClass->gcType != dstClass->gcType)         /* If arrays of primitives, must be the same primitive */         || (srcClass->gcType == GCT_ARRAY               && (srcClass->u.elemClass != dstClass->u.elemClass))            ) {        raiseException("java/lang/ArrayStoreException");        return;    }    srcEnd = length + srcPos;    dstEnd = length + dstPos;    if (     (length < 0) || (srcPos < 0) || (dstPos < 0)          || (length > 0 && (srcEnd < 0 || dstEnd < 0))          || (srcEnd > (long)src->length)          || (dstEnd > (long)dst->length)) {        raiseException("java/lang/ArrayIndexOutOfBoundsException");        return;    }    if (src->ofClass->gcType == GCT_ARRAY) {        /* We've already determined that src and dst are primitives of the         * same type */        long itemSize = src->ofClass->itemSize;        memmove(&((BYTEARRAY)dst)->bdata[dstPos * itemSize],                &((BYTEARRAY)src)->bdata[srcPos * itemSize],                itemSize * length);    } else {        CLASS srcElementClass = srcClass->u.elemClass;        CLASS dstElementClass = dstClass->u.elemClass;        if (!isAssignableTo(srcElementClass, dstElementClass)) {            /* We have to check each element to make sure it can be             * put into an array of dstElementClass */            long i;            for (i = 0; i < length; i++) {                OBJECT item = (OBJECT)src->data[srcPos + i].cellp;                if ((item != NULL) && !isAssignableTo(item->ofClass, dstElementClass)) {                    raiseException("java/lang/ArrayStoreException");                    break;                } else {                    dst->data[dstPos + i].cellp = (cell *)item;                }            }        } else {            memmove(&dst->data[dstPos], &src->data[srcPos],                    length << log2CELL);        }    }}/*========================================================================= * FUNCTION:      currentTimeMillis()I (STATIC) * CLASS:         java.lang.System * TYPE:          static native function * OVERVIEW:      Return current time in milliseconds. * INTERFACE (operand stack manipulation): *   parameters:  <none> *   returns:     current time in centisecs in operand stack as integer. *=======================================================================*/#ifdef BEDETERMINISTICulong64 last;void Java_java_lang_System_currentTimeMillis(void){    /* Debugging use only.  The value     * has no meaning in the real world.     */    last += 1000;    pushLong(last);}#elsevoid Java_java_lang_System_currentTimeMillis(void){    ulong64 result = CurrentTime_md();    pushLong(result);}#endif /* BEDETERMINISTIC *//*========================================================================= * FUNCTION:      getProperty0(Ljava.lang.String)Ljava.lang.String (STATIC) * CLASS:         java.lang.System * TYPE:          static native function * OVERVIEW:      Return a property * INTERFACE (operand stack manipulation): *   parameters:  A string *   returns:     A string *=======================================================================*/void Java_java_lang_System_getProperty0(void){    STRING_INSTANCE string = topStackAsType(STRING_INSTANCE);    STRING_INSTANCE result = NULL;    if (string->length < STRINGBUFFERSIZE - 1) {         char* key = getStringContents(string);        char* value = getSystemProperty(key);        if (value != NULL) {             result = instantiateString(value, strlen(value));        }    }    topStackAsType(STRING_INSTANCE) = result;}/*========================================================================= * Native functions in com.sun.cldc.io.* *=======================================================================*//*========================================================================= * FUNCTION:      putchar(C)V (STATIC) * CLASS:         com/sun/cldc/io/j2me/debug/PrivateOutputStream * TYPE:          static native function * OVERVIEW:      Print a byte to the stdout file * INTERFACE (operand stack manipulation): *   parameters:  <none> *   returns:     <nothing> *=======================================================================*/void Java_com_sun_cldc_io_j2me_debug_PrivateOutputStream_putchar(void){    int c = popStack();    putchar(c);}/*========================================================================= * Native functions of class java.util.Calendar *=======================================================================*//*========================================================================= * FUNCTION:      init * CLASS:         java.util.Calendar * TYPE:          virtual native function * OVERVIEW:      Initialize Calendar object by calling a platform *                specific initialization function. * INTERFACE (operand stack manipulation): *   parameters:  see java.util.Calendar *   returns:     ditto *====================================================================*/void Java_java_util_Calendar_init(void){    unsigned long *date;    ARRAY dateArray = popStackAsType(ARRAY);    oneLess; /* Ignore "this" */    /* initialize the dateArray */    memset(&dateArray->data[0], 0,           MAXCALENDARFLDS*sizeof(dateArray->data[0]));    date = Calendar_md();    /* copy over the date array back */    memcpy(&dateArray->data[0], date,           MAXCALENDARFLDS*sizeof(dateArray->data[0]));}/*========================================================================= * FUNCTION:      fillInStackTrace * CLASS:         java.lang.Throwable * TYPE:          virtual native function * OVERVIEW:      save information about the current stack *                including the method pointers for each stack frame * INTERFACE (operand stack manipulation): *   parameters:  this *   returns:     this *====================================================================*/void Java_java_lang_Throwable_fillInStackTrace() {#if PRINT_BACKTRACE    START_TEMPORARY_ROOTS        DECLARE_TEMPORARY_ROOT(THROWABLE_INSTANCE, exception,                               topStackAsType(THROWABLE_INSTANCE));        fillInStackTrace(&exception);    END_TEMPORARY_ROOTS#else    lessStack(1);#endif}/*========================================================================= * FUNCTION:      printStackTrace0 * CLASS:         java.lang.Throwable

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -