[vmkit-commits] [vmkit] r199098 - Implements GetPrimitiveArrayCritical ReleasePrimitiveArrayCritical.
Gaël Thomas
gael.thomas at lip6.fr
Mon Jan 13 03:59:37 PST 2014
:)
Thanks!
Gaël
2014/1/13 Nicolas Geoffray <nicolas.geoffray at gmail.com>:
>
>
>
> On Mon, Jan 13, 2014 at 11:26 AM, Gael Thomas <gael.thomas at lip6.fr> wrote:
>>
>> Author: gthomas
>> Date: Mon Jan 13 05:26:16 2014
>> New Revision: 199098
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=199098&view=rev
>> Log:
>> Implements GetPrimitiveArrayCritical ReleasePrimitiveArrayCritical.
>> Implements dup* bytecodes.
>> Simplify allocation of stacks/locals.
>> Fix a memory bug in meta stack management for the control flow.
>> Fix a memory bug in J3Class::clone.
>>
>>
>> Modified:
>> vmkit/branches/mcjit/include/j3/j3codegenvar.h
>> vmkit/branches/mcjit/lib/j3/openjdk/j3lib.cc
>> vmkit/branches/mcjit/lib/j3/vm/j3.cc
>> vmkit/branches/mcjit/lib/j3/vm/j3class.cc
>> vmkit/branches/mcjit/lib/j3/vm/j3codegen.cc
>> vmkit/branches/mcjit/lib/j3/vm/j3codegenvar.cc
>> vmkit/branches/mcjit/lib/j3/vm/j3jni.cc
>>
>> Modified: vmkit/branches/mcjit/include/j3/j3codegenvar.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/include/j3/j3codegenvar.h?rev=199098&r1=199097&r2=199098&view=diff
>>
>> ==============================================================================
>> --- vmkit/branches/mcjit/include/j3/j3codegenvar.h (original)
>> +++ vmkit/branches/mcjit/include/j3/j3codegenvar.h Mon Jan 13 05:26:16
>> 2014
>> @@ -27,8 +27,7 @@ namespace j3 {
>> uint32_t topStack;
>> uint32_t maxStack;
>>
>> - static uint32_t reservedSize(uint32_t max);
>> - void init(J3CodeGen* _codeGen, uint32_t
>> max, void* space);
>> + void init(J3CodeGen* _codeGen, uint32_t
>> max);
>>
>> void killUnused();
>>
>>
>> Modified: vmkit/branches/mcjit/lib/j3/openjdk/j3lib.cc
>> URL:
>> http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/j3/openjdk/j3lib.cc?rev=199098&r1=199097&r2=199098&view=diff
>>
>> ==============================================================================
>> --- vmkit/branches/mcjit/lib/j3/openjdk/j3lib.cc (original)
>> +++ vmkit/branches/mcjit/lib/j3/openjdk/j3lib.cc Mon Jan 13 05:26:16 2014
>> @@ -33,8 +33,9 @@ static char* buildPath(const char* base,
>> void J3Lib::processOptions(J3* vm) {
>> const char* jh = getenv("JAVA_HOME");
>> jh = jh ? jh : OPENJDK_HOME"/jre";
>> + jh = strdup(jh);
>>
>> - vm->options()->javaHome = jh ? jh : OPENJDK_HOME;
>> + vm->options()->javaHome = jh;
>> vm->options()->bootClasspath = buildPath(jh, "/lib/rt.jar");
>> vm->options()->systemLibraryPath = buildPath(jh,
>> OPENJDK_LIBPATH_SUFFIX);
>> vm->options()->extDirs = buildPath(jh, "/lib/ext");
>>
>> Modified: vmkit/branches/mcjit/lib/j3/vm/j3.cc
>> URL:
>> http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/j3/vm/j3.cc?rev=199098&r1=199097&r2=199098&view=diff
>>
>> ==============================================================================
>> --- vmkit/branches/mcjit/lib/j3/vm/j3.cc (original)
>> +++ vmkit/branches/mcjit/lib/j3/vm/j3.cc Mon Jan 13 05:26:16 2014
>> @@ -158,7 +158,7 @@ void J3::run() {
>> if(options()->debugLifeCycle)
>> fprintf(stderr, " Launching the application\n");
>>
>> - options()->debugExecute = 0;
>> + //options()->debugExecute = 0;
>>
>> #if 0
>> J3Class* loaderClass = z_class("java/lang/ClassLoader");
>> @@ -340,5 +340,3 @@ void J3::forceSymbolDefinition() {
>> } catch(void* e) {
>> }
>> }
>> -
>> -
>>
>> Modified: vmkit/branches/mcjit/lib/j3/vm/j3class.cc
>> URL:
>> http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/j3/vm/j3class.cc?rev=199098&r1=199097&r2=199098&view=diff
>>
>> ==============================================================================
>> --- vmkit/branches/mcjit/lib/j3/vm/j3class.cc (original)
>> +++ vmkit/branches/mcjit/lib/j3/vm/j3class.cc Mon Jan 13 05:26:16 2014
>> @@ -331,7 +331,7 @@ uint16_t J3Class::modifiers() {
>>
>> J3ObjectHandle* J3Class::clone(J3ObjectHandle* obj) {
>> J3ObjectHandle* res = J3ObjectHandle::doNewObject(this);
>> - obj->rawObjectCopyTo(0, res, 0, structSize());
>> + obj->rawObjectCopyTo(0, res, 0, structSize() - sizeof(J3Object));
>> return res;
>> }
>>
>>
>> Modified: vmkit/branches/mcjit/lib/j3/vm/j3codegen.cc
>> URL:
>> http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/j3/vm/j3codegen.cc?rev=199098&r1=199097&r2=199098&view=diff
>>
>> ==============================================================================
>> --- vmkit/branches/mcjit/lib/j3/vm/j3codegen.cc (original)
>> +++ vmkit/branches/mcjit/lib/j3/vm/j3codegen.cc Mon Jan 13 05:26:16 2014
>> @@ -41,9 +41,10 @@ J3CodeGen::J3CodeGen(vmkit::BumpAllocato
>>
>> #if 0
>> /* usefull to debug a single function */
>> - if( cl->name() == vm->names()->get("java/lang/CharacterData") &&
>> - method->name() == vm->names()->get("of")
>> &&
>> - method->signature()->name() ==
>> vm->names()->get("(I)Ljava/lang/CharacterData;") ) {
>> + if( cl->name() ==
>> vm->names()->get("sun/util/calendar/BaseCalendar") &&
>> + method->name() ==
>> vm->names()->get("getFixedDate") &&
>> + method->signature()->name() ==
>> vm->names()->get("(IIILsun/util/calendar/BaseCalendar$Date;)J") ) {
>> +
>> vm->options()->debugTranslate = 3;
>> }
>> #endif
>> @@ -107,7 +108,7 @@ J3CodeGen::J3CodeGen(vmkit::BumpAllocato
>> else
>> generateJava();
>>
>> - if(vm->options()->debugTranslate > 3)
>> + if(vm->options()->debugTranslate > 4)
>> llvmFunction->dump();
>> }
>>
>> @@ -399,8 +400,9 @@ void J3CodeGen::invoke(uint32_t access,
>> res = builder->CreateInvoke(func, after,
>> exceptions.nodes[curExceptionNode]->landingPad, args);
>> bb = after;
>> builder->SetInsertPoint(bb);
>> - } else
>> + } else {
>> res = builder->CreateCall(func, args);
>> + }
>>
>> if(!res->getType()->isVoidTy())
>> stack.push(flatten(res));
>> @@ -784,7 +786,7 @@ llvm::BasicBlock* J3CodeGen::forwardBran
>> llvm::BasicBlock* res = newBB(id);
>>
>> if(doAlloc) {
>> - opInfos[pc].metaStack =
>> (llvm::Type**)allocator->allocate(sizeof(llvm::Type*)*stack.topStack);
>> + opInfos[pc].metaStack =
>> (llvm::Type**)allocator->allocate(sizeof(llvm::Type*)*stack.maxStack);
>> memcpy(opInfos[pc].metaStack, stack.metaStack,
>> sizeof(llvm::Type*)*stack.topStack);
>> }
>>
>> @@ -858,6 +860,7 @@ void J3CodeGen::translate() {
>> while(codeReader->remaining()) {
>> llvm::Value* val1;
>> llvm::Value* val2;
>> + llvm::Value* val3;
>>
>> javaPC = codeReader->tell();
>>
>> @@ -1159,7 +1162,16 @@ void J3CodeGen::translate() {
>> stack.push(val1); stack.push(val2);
>> stack.push(val1);
>> break;
>>
>> - case J3Cst::BC_dup_x2: nyi(); /*
>> 0x5b */
>> + case J3Cst::BC_dup_x2: /*
>> 0x5b */
>> + val1 = stack.pop();
>> + val2 = stack.pop();
>> + if(val2->getType()->isDoubleTy() ||
>> val2->getType()->isIntegerTy(64)) {
>> + stack.push(val1);
>> stack.push(val2); stack.push(val1);
>> + } else {
>> + val3 = stack.pop();
>> + stack.push(val1);
>> stack.push(val3); stack.push(val2); stack.push(val1);
>> + }
>> + break;
>>
>> case J3Cst::BC_dup2: /*
>> 0x5c */
>> val1 = stack.top();
>> @@ -1171,9 +1183,32 @@ void J3CodeGen::translate() {
>> }
>> break;
>>
>> - case J3Cst::BC_dup2_x1: nyi(); /*
>> 0x5d */
>> - case J3Cst::BC_dup2_x2: nyi(); /*
>> 0x5e */
>> - case J3Cst::BC_swap: nyi(); /*
>> 0x5f */
>> + case J3Cst::BC_dup2_x1: /*
>> 0x5d */
>> + val1 = stack.pop();
>> + val2 = stack.pop();
>> + if(val1->getType()->isDoubleTy() ||
>> val1->getType()->isIntegerTy(64)) {
>> + stack.push(val1);
>> stack.push(val2); stack.push(val1);
>> + } else {
>> + val3 = stack.pop();
>> + stack.push(val2);
>> stack.push(val1); stack.push(val3); stack.push(val2); stack.push(val1);
>> + }
>> + break;
>> +
>> + case J3Cst::BC_dup2_x2: /*
>> 0x5e */
>> + val1 = stack.pop();
>> + val2 = stack.pop();
>> + val3 = stack.pop();
>> + if(val1->getType()->isDoubleTy() ||
>> val1->getType()->isIntegerTy(64)) {
>> + stack.push(val1);
>> stack.push(val3); stack.push(val2); stack.push(val1);
>> + } else {
>> + llvm::Value* val4 = stack.pop();
>> + stack.push(val2);
>> stack.push(val1); stack.push(val4); stack.push(val3); stack.push(val2);
>> stack.push(val1);
>> + }
>> + break;
>> +
>> + case J3Cst::BC_swap: /*
>> 0x5f */
>> + val1 = stack.pop(); val2 = stack.pop();
>> stack.push(val1); stack.push(val2);
>> + break;
>>
>> case J3Cst::BC_iadd: /*
>> 0x60 */
>> case J3Cst::BC_ladd: /*
>> 0x61 */
>> @@ -1609,9 +1644,9 @@ void J3CodeGen::generateJava() {
>> uint32_t nbLocals = reader.readU2();
>> uint32_t codeLength = reader.readU4();
>>
>> - locals.init(this, nbLocals,
>> allocator->allocate(J3CodeGenVar::reservedSize(nbLocals)));
>> - stack.init(this, maxStack,
>> allocator->allocate(J3CodeGenVar::reservedSize(maxStack)));
>> - ret.init(this, 1,
>> allocator->allocate(J3CodeGenVar::reservedSize(1)));
>> + locals.init(this, nbLocals);
>> + stack.init(this, maxStack);
>> + ret.init(this, 1);
>>
>> genDebugEnterLeave(0);
>>
>>
>> Modified: vmkit/branches/mcjit/lib/j3/vm/j3codegenvar.cc
>> URL:
>> http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/j3/vm/j3codegenvar.cc?rev=199098&r1=199097&r2=199098&view=diff
>>
>> ==============================================================================
>> --- vmkit/branches/mcjit/lib/j3/vm/j3codegenvar.cc (original)
>> +++ vmkit/branches/mcjit/lib/j3/vm/j3codegenvar.cc Mon Jan 13 05:26:16
>> 2014
>> @@ -40,16 +40,13 @@ void J3CodeGenVar::killUnused() {
>> killUnused(refStack, 1);
>> }
>>
>> -uint32_t J3CodeGenVar::reservedSize(uint32_t max) {
>> - return max*5*sizeof(llvm::AllocaInst*) + max*sizeof(llvm::Type*);
>> -}
>> -
>> uint32_t J3CodeGenVar::metaStackSize() {
>> return topStack*sizeof(llvm::Type*);
>> }
>>
>> -void J3CodeGenVar::init(J3CodeGen* _codeGen, uint32_t max, void* space) {
>> +void J3CodeGenVar::init(J3CodeGen* _codeGen, uint32_t max) {
>> codeGen = _codeGen;
>> + void* space =
>> codeGen->allocator->allocate(max*5*sizeof(llvm::AllocaInst*) +
>> max*sizeof(llvm::Type*));
>> maxStack = max;
>> intStack = (llvm::AllocaInst**)space;
>> longStack = intStack + max;
>>
>> Modified: vmkit/branches/mcjit/lib/j3/vm/j3jni.cc
>> URL:
>> http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/j3/vm/j3jni.cc?rev=199098&r1=199097&r2=199098&view=diff
>>
>> ==============================================================================
>> --- vmkit/branches/mcjit/lib/j3/vm/j3jni.cc (original)
>> +++ vmkit/branches/mcjit/lib/j3/vm/j3jni.cc Mon Jan 13 05:26:16 2014
>> @@ -570,8 +570,15 @@ void JNICALL GetStringUTFRegion(JNIEnv*
>> leaveJVM();
>> }
>>
>> -void* JNICALL GetPrimitiveArrayCritical(JNIEnv* env, jarray array,
>> jboolean* isCopy) { enterJVM(); leaveJVM(); NYI(); }
>> -void JNICALL ReleasePrimitiveArrayCritical(JNIEnv* env, jarray array,
>> void* carray, jint mode) { enterJVM(); leaveJVM(); NYI(); }
>> +void* JNICALL GetPrimitiveArrayCritical(JNIEnv* env, jarray array,
>> jboolean* isCopy) {
>> + //GC::disable(); ?
>
>
> Hmmm, are you sure you want to comment this line?
>
>>
>> + if(isCopy)
>> + isCopy = 0;
>
>
> *isCopy = JNI_TRUE?
>
>>
>> + return array ? array->array()->content() : 0;
>> +}
>> +
>> +void JNICALL ReleasePrimitiveArrayCritical(JNIEnv* env, jarray array,
>> void* carray, jint mode) {
>> +}
>>
>> const jchar* JNICALL GetStringCritical(JNIEnv* env, jstring string,
>> jboolean* isCopy) { enterJVM(); leaveJVM(); NYI(); }
>> void JNICALL ReleaseStringCritical(JNIEnv* env, jstring string, const
>> jchar* cstring) { enterJVM(); leaveJVM(); NYI(); }
>>
>>
>> _______________________________________________
>> vmkit-commits mailing list
>> vmkit-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/vmkit-commits
>
>
--
-------------------------------------------------------------------
Gaël Thomas, Associate Professor, UPMC
http://pagesperso-systeme.lip6.fr/Gael.Thomas/
-------------------------------------------------------------------
More information about the vmkit-commits
mailing list