Beispiel #1
0
    public static void init(Stream codeStream)
    {
        CRunTime.memory           = null;
        CRunTime.objectRepository = null;
        //System.gc();

        int memorySize = 512 * 1024 * 10;    // (int)(51200000 * 4 /* Runtime.getRuntime().freeMemory() */ * CibylConfig.cibylMemoryProportion);

        if (CibylConfig.memorySize != 0)
        {
            memorySize = CibylConfig.memorySize;
        }

        if (CibylConfig.faultMemoryIn)
        {
            memorySize = (int)CRunTime.faultMemoryIn(CibylConfig.memorySize);
        }

        /* See to it that the memory is aligned to 8. This caused a very
         * fun bug before in printf when called with "%f".
         *
         * Also setup the event stack at the very top of the memory
         */
        memorySize -= (memorySize & 7);
        CRunTime.eventStackPointer = memorySize - 8;

        int len = (int)codeStream.Length / 4;

        if (len < 5)
        {
            /* This binary is broken - we need the header data */
            throw new Exception("Data input is too small");
        }

        CRunTime.init(codeStream, memorySize);
    }