diff options
author | Lars Knoll <lars.knoll@digia.com> | 2012-12-13 12:09:04 +0100 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@digia.com> | 2012-12-13 12:38:11 +0100 |
commit | 9edd6967753c16512c8c589f3dedcae02687070a (patch) | |
tree | a8c4460d5c556fa9b087c229ba88dd68980ce9ef /moth | |
parent | d6fcbdbf5182dcd549ef685cfeb2e3e90d3e81c7 (diff) |
Correctly set up nested functions
Make sure we have the correct set of nested functions in
both IR::Function and VM::Function. This is required so
that closures can work correctly.
Change-Id: I42493d5ee503090653b71650c8d19e06c4bcfdda
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'moth')
-rw-r--r-- | moth/qv4isel_moth.cpp | 32 | ||||
-rw-r--r-- | moth/qv4isel_moth_p.h | 2 |
2 files changed, 23 insertions, 11 deletions
diff --git a/moth/qv4isel_moth.cpp b/moth/qv4isel_moth.cpp index 5b00ccf552..14fd1cbbd3 100644 --- a/moth/qv4isel_moth.cpp +++ b/moth/qv4isel_moth.cpp @@ -194,12 +194,24 @@ InstructionSelection::~InstructionSelection() { } -VM::Function *InstructionSelection::run(IR::Function *function) +void InstructionSelection::run(VM::Function *vmFunction, IR::Function *function) { qSwap(_function, function); + + IR::BasicBlock *block; + + QHash<IR::BasicBlock *, QVector<ptrdiff_t> > patches; + QHash<IR::BasicBlock *, ptrdiff_t> addrs; + // FIXME: make the size dynamic. This requires changing the patching. - _code = new uchar[getpagesize() * 4000]; - _ccode = _code; + uchar *code = new uchar[getpagesize() * 4000]; + uchar *ccode = code; + + qSwap(block, _block); + qSwap(patches, _patches); + qSwap(addrs, _addrs); + qSwap(code, _code); + qSwap(ccode, _ccode); CompressTemps().run(_function); @@ -235,14 +247,14 @@ VM::Function *InstructionSelection::run(IR::Function *function) _patches.clear(); _addrs.clear(); - VM::Function *vmFunc = vmFunction(function); - vmFunc->code = VME::exec; - vmFunc->codeData = _code; + vmFunction->code = VME::exec; + vmFunction->codeData = _code; - _block = 0; - _code = 0; - _ccode = 0; - return vmFunc; + qSwap(block, _block); + qSwap(patches, _patches); + qSwap(addrs, _addrs); + qSwap(code, _code); + qSwap(ccode, _ccode); } void InstructionSelection::callActivationProperty(IR::Call *c, int targetTempIndex) diff --git a/moth/qv4isel_moth_p.h b/moth/qv4isel_moth_p.h index e7c85174c3..dece41323f 100644 --- a/moth/qv4isel_moth_p.h +++ b/moth/qv4isel_moth_p.h @@ -15,7 +15,7 @@ public: InstructionSelection(VM::ExecutionEngine *engine, IR::Module *module); ~InstructionSelection(); - virtual VM::Function *run(IR::Function *function); + virtual void run(VM::Function *vmFunction, IR::Function *function); protected: virtual void visitExp(IR::Exp *); |