1 В избранное 0 Ответвления 0

OSCHINA-MIRROR/arosy-OpenJVM

Клонировать/Скачать
main.cpp 1.9 КБ
Копировать Редактировать Web IDE Исходные данные Просмотреть построчно История
wangchong Отправлено 20.11.2021 19:32 e3d39a4
#include "include/jvm/Stream/ClassRead.h"
#include "include/jvm/classFile/ClassFileParser.h"
#include "include/jvm/oop/InstanceKlass.h"
#include "include/jvm/intepreter/BytecodeStream.h"
#include "include/jvm/classFile/BootClassLoader.h"
#include "include/jvm/native/JavaNaticeInterface.h"
#include "include/jvm/runtime/JavaThread.h"
#include "include/jvm/memory/MethodArea.h"
#include "include/jvm/memory/MemoryPool.h"
#include "include/jvm/memory/Heap.h"
#include "include/jvm/util/BlockingQueue.h"
#include "include/jvm/runtime/ThreadPool.h"
#include "src/jvm/test/Test.h"
#include "include/jvm/intepreter/CodeRunBase.h"
#include <unistd.h>
#include "include/jvm/native/CodeRunNative.h"
void startVM();
void threadPoolTest();
int main() {
startVM();
// threadPoolTest();
};
void startVM() {
CodeRunBase::initCodeRun();
CodeRunNative::initCodeRun();
MemoryPool::initMemoryPool(1024 * 1024);
MethodArea::initMemoryPool(1024 * 1024);//初始化方法区
Heap::initMemoryPool(1024 * 2);//初始化堆
string myPath = "jvm/HelloWorld.class";
InstanceKlass *klass = BootClassLoader::loadKlass(myPath);//加载main方法所在类
// InstanceKlass *klass = BootClassLoader::loadKlass(ClassRead::readByPath("/Users/eba/Documents/HelloWorld.class"));
MethodInfo *m = JavaNaticeInterface::getMethod(klass, "main", "([Ljava/lang/String;)V");//找到main方法
JavaThread *curThread = new JavaThread;//创建线程
Threads::threadList.push_back(curThread);
Threads::curThread = curThread;
JavaNaticeInterface::callStaticMethod(m);//执行main方法
}
void threadPoolTest() {
ThreadPool *pool = new ThreadPool(1, 3, -1);
for (int i = 0; i < 1000; ++i) {
ThreadRunnable *tr = new Test(i);
pool->execute(tr);
}
printf("%s\n", "main");
while (true) {
sleep(2);
// ThreadRunnable *tr = new Test(99999999);
// pool->execute(tr);
}
}

Опубликовать ( 0 )

Вы можете оставить комментарий после Вход в систему

1
https://api.gitlife.ru/oschina-mirror/arosy-OpenJVM.git
git@api.gitlife.ru:oschina-mirror/arosy-OpenJVM.git
oschina-mirror
arosy-OpenJVM
arosy-OpenJVM
master