Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Block chain compilation works

  • Loading branch information...
commit 47d31c842b314b7ea69c7096d5cacdebc66afcc7 1 parent 4429611
@alexp-sssup alexp-sssup authored
View
26 scripting/abc.h
@@ -228,17 +228,22 @@ struct BlockStudy
//Link to the next/prev block in a block chain
BlockStudy* nextInChain;
BlockStudy* prevInChain;
- //The LLVM function object
- llvm::Function* llvmf;
enum BLOCK_TYPE { JIT_CANDIDATE=0, JIT_OK, JIT_FAILED };
BLOCK_TYPE blockType;
typedef intptr_t (*synt_block)(call_context* cc);
synt_block compiledCode;
+ //The LLVM function object
+ llvm::Function* llvmf;
BlockStudy(uint32_t a):start(a),end(a+1),usageCount(1),nextInChain(this),prevInChain(this),
- blockType(JIT_CANDIDATE),compiledCode(NULL)
+ blockType(JIT_CANDIDATE),compiledCode(NULL),llvmf(NULL)
+ {
+ }
+ BlockStudy(const BlockStudy& b):start(b.start),end(b.end),usageCount(b.usageCount),nextInChain(this),prevInChain(this),
+ blockType(JIT_CANDIDATE),compiledCode(NULL),llvmf(NULL)
{
}
+ ~BlockStudy();
bool isAddressInside(uint32_t ip) const
{
return (ip>=start && ip<end);
@@ -248,6 +253,21 @@ struct BlockStudy
{
return start<r;
}
+ BlockStudy& operator=(const BlockStudy& b)
+ {
+ start=b.start;
+ end=b.end;
+ usageCount=b.usageCount;
+ //The chains are unlinked
+ nextInChain=this;
+ prevInChain=this;
+
+ //Also the compilation status is resetted
+ blockType=JIT_CANDIDATE;
+ compiledCode=NULL;
+ llvmf=NULL;
+ return *this;
+ }
void linkToBlock(BlockStudy* b)
{
assert(b->nextInChain==b && b->prevInChain==b);
View
28 scripting/abc_codesynt.cpp
@@ -1466,36 +1466,29 @@ void method_info::doAnalysis(llvm::Function* llvmf, std::map<unsigned int,block_
for(;bit!=blocks.end();++bit)
{
block_info& cur=bit->second;
- //cout << "block @ " << bit->first << endl;
cur.locals_start_obj.resize(cur.locals_start.size(),NULL);
for(unsigned int i=0;i<cur.locals_start.size();i++)
{
switch(cur.locals_start[i])
{
case STACK_NONE:
- //cout << "none ";
break;
case STACK_OBJECT:
- //cout << "object ";
cur.locals_start_obj[i]=Builder.CreateAlloca(voidptr_type);
break;
case STACK_INT:
- //cout << "int ";
cur.locals_start_obj[i]=Builder.CreateAlloca(int_type);
break;
case STACK_NUMBER:
- //cout << "number ";
cur.locals_start_obj[i]=Builder.CreateAlloca(number_type);
break;
case STACK_BOOLEAN:
- //cout << "boolean ";
cur.locals_start_obj[i]=Builder.CreateAlloca(bool_type);
break;
default:
throw RunTimeException("Unsupported object type");
}
}
- //cout << endl;
}
}
@@ -1623,7 +1616,6 @@ void method_info::compileCallPropVoid(int t, int t2, vector<stack_entry>& static
//callProperty returns also the method_info of the called function by reference
llvm::Value* called_mi=Builder.CreateAlloca(voidptr_type);
- cout << "callPropVoid " << ex->FindFunctionNamed("callPropVoid")->arg_size() << endl;
Builder.CreateCall4(ex->FindFunctionNamed("callPropVoid"), callContext, constant, constant2, called_mi);
}
@@ -2767,7 +2759,6 @@ BlockStudy::synt_block method_info::compileBlockChain(BlockStudy* block)
{
block->llvmf->eraseFromParent();
block->llvmf=NULL;
- //cout << "Failed to compile " << profName << endl;
return NULL;
}
cur = cur->nextInChain;
@@ -2815,14 +2806,27 @@ BlockStudy::synt_block method_info::compileBlockChain(BlockStudy* block)
//block->llvmf->dump();
getVm()->FPM->run(*block->llvmf);
BlockStudy::synt_block ret=(BlockStudy::synt_block)ex->getPointerToFunction(block->llvmf);
- /*if(profName=="MontgomeryReduction::::reduce")
+ if(profName=="MontgomeryReduction::::reduce")
{
- cout << profName << " start: " << block->start << " end: " << block->end << endl;
+ cout << profName << endl;
+ BlockStudy* cur=block;
+ do
+ {
+ cout << "start: " << cur->start << " end: " << cur->end << endl;
+ cur=cur->nextInChain;
+ }
+ while(cur!=block);
block->llvmf->dump();
- }*/
+ }
return ret;
}
+BlockStudy::~BlockStudy()
+{
+ resetCompiledCode(this);
+ unlinkBlock();
+}
+
void BlockStudy::resetCompiledCode(BlockStudy* stop)
{
if(blockType==JIT_OK)
View
4 scripting/abc_interpreter.cpp
@@ -1529,10 +1529,14 @@ ASObject* ABCVm::executeFunction(SyntheticFunction* function, call_context* cont
{
assert(instructionPointer+1>currentBlock->end);
currentBlock->end=(instructionPointer+1);
+ currentBlock->resetCompiledCode(currentBlock);
}
}
else //Block changed or new block
+ {
+ //cout << "block changed" << endl;
currentBlock=mi->getBlockStudyAtAddress(instructionPointer, method_info::CREATE);
+ }
if(branchTaken) //Block changed for a branch
currentBlock=NULL;
View
3  scripting/toplevel.cpp
@@ -2244,8 +2244,7 @@ ASObject* SyntheticFunction::call(ASObject* obj, ASObject* const* args, uint32_t
return NULL;
}
- //if(hit_count==hit_threshold)
- if(mi->profName=="MontgomeryReduction::::reduce")
+ if(hit_count==hit_threshold)
{
// cout << "Studying " << mi->profName << endl;
mi->studyFunction=true;
View
4 swf.cpp
@@ -393,12 +393,12 @@ SystemState::~SystemState()
delete it->second;
//it->second->decRef()
}
- //The Vm must be destroyed this late to clean all managed integers and numbers
- delete currentVm;
//Also destroy all tags
for(unsigned int i=0;i<tagsStorage.size();i++)
delete tagsStorage[i];
+ //The Vm must be destroyed this late to clean all managed integers and numbers
+ delete currentVm;
delete renderThread;
renderThread=NULL;
Please sign in to comment.
Something went wrong with that request. Please try again.