Skip to content

Commit

Permalink
Fixes shouldProtectProducer(), variable names and comments
Browse files Browse the repository at this point in the history
Issue: #17
Issue: #92
  • Loading branch information
0x7CFE committed Jul 10, 2016
1 parent c6385ad commit 9c8d492
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/MethodCompiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ Value* MethodCompiler::protectPointer(TJITContext& jit, Value* value)

Value* MethodCompiler::protectProducerNode(TJITContext& jit, st::ControlNode* node, Value* value)
{
if (shouldProtectProducer(jit, jit.currentNode))
if (shouldProtectProducer(jit, node))
return protectPointer(jit, value);
else
return value; // return value as is
Expand Down Expand Up @@ -975,8 +975,8 @@ void MethodCompiler::doMarkArguments(TJITContext& jit)
Value* const argumentsArray = jit.builder->CreateBitCast(argumentsObject, m_baseTypes.objectArray->getPointerTo());

Value* const argumentsPointer = jit.builder->CreateBitCast(argumentsObject, jit.builder->getInt8PtrTy());
Function* gcrootIntrinsic = getDeclaration(m_JITModule, Intrinsic::lifetime_start);
jit.builder->CreateCall2(gcrootIntrinsic, jit.builder->getInt64(sizeInBytes), argumentsPointer);
Function* lifetimeStartIntrinsic = getDeclaration(m_JITModule, Intrinsic::lifetime_start);
jit.builder->CreateCall2(lifetimeStartIntrinsic, jit.builder->getInt64(sizeInBytes), argumentsPointer);

setNodeValue(jit, jit.currentNode, argumentsArray);
}
Expand Down Expand Up @@ -1190,6 +1190,7 @@ void MethodCompiler::doSendBinary(TJITContext& jit)
jit.builder->SetInsertPoint(sendBinaryBlock);
// We need to create an arguments array and fill it with argument objects
// Then send the message just like ordinary one
// TODO direct call in case of inferred context

// Now creating the argument array
TObjectAndSize array = createArray(jit, 2);
Expand Down Expand Up @@ -1308,16 +1309,16 @@ void MethodCompiler::doSendInferredMessage(TJITContext& jit, type::InferContext&

jit.builder->CreateCall3(setObjectField, newContextObject, jit.builder->getInt32(0), directMethodObject);
jit.builder->CreateCall3(setObjectField, newContextObject, jit.builder->getInt32(1), messageArgumentsObject);
// Note: temporaries (2) will be allocated on the stack frame of the message handler
jit.builder->CreateCall3(setObjectField, newContextObject, jit.builder->getInt32(3), contextObject);
// Note: temporaries will be allocated on the stack frame of the message handler

Value* const newContext = jit.builder->CreateBitCast(newContextObject, m_baseTypes.context->getPointerTo());
Value* const result = jit.builder->CreateCall(directFunction, newContext);

AllocaInst* const allocaInst = dyn_cast<AllocaInst>(jit.currentNode->getArgument()->getValue()->stripPointerCasts());
Function* const gcrootIntrinsic = getDeclaration(m_JITModule, Intrinsic::lifetime_end);
Function* const lifetimeEndIntrinsic = getDeclaration(m_JITModule, Intrinsic::lifetime_end);
Value* const argumentsPointer = jit.builder->CreateBitCast(arguments, jit.builder->getInt8PtrTy());
jit.builder->CreateCall2(gcrootIntrinsic, jit.builder->CreateZExt(allocaInst->getArraySize(), jit.builder->getInt64Ty()), argumentsPointer);
jit.builder->CreateCall2(lifetimeEndIntrinsic, jit.builder->CreateZExt(allocaInst->getArraySize(), jit.builder->getInt64Ty()), argumentsPointer);

Value* const targetContext = jit.builder->CreateExtractValue(result, 1, "targetContext");
Value* const isBlockReturn = jit.builder->CreateIsNotNull(targetContext);
Expand Down

0 comments on commit 9c8d492

Please sign in to comment.