[macruby-changes] [1969] MacRuby/branches/experimental
source_changes at macosforge.org
source_changes at macosforge.org
Wed Jul 1 18:31:23 PDT 2009
Revision: 1969
http://trac.macosforge.org/projects/ruby/changeset/1969
Author: lsansonetti at apple.com
Date: 2009-07-01 18:31:22 -0700 (Wed, 01 Jul 2009)
Log Message:
-----------
AOT compiler: fixed dvars
Modified Paths:
--------------
MacRuby/branches/experimental/compiler.cpp
MacRuby/branches/experimental/vm.cpp
Modified: MacRuby/branches/experimental/compiler.cpp
===================================================================
--- MacRuby/branches/experimental/compiler.cpp 2009-07-01 23:53:26 UTC (rev 1968)
+++ MacRuby/branches/experimental/compiler.cpp 2009-07-02 01:31:22 UTC (rev 1969)
@@ -2585,21 +2585,6 @@
std::vector<Value *> params;
- params.push_back(NULL); // will be filled later
- params.push_back(NULL); // idem
- int vars_count = 0;
- for (std::map<ID, Value *>::iterator iter = lvars.begin();
- iter != lvars.end(); ++iter) {
- ID name = iter->first;
- Value *slot = iter->second;
- if (std::find(dvars.begin(), dvars.end(), name) == dvars.end()) {
- params.push_back(compile_id(name));
- params.push_back(slot);
- vars_count++;
- }
- }
- params[1] = ConstantInt::get(Type::Int32Ty, vars_count);
-
// searches all ReturnInst in the function we just created and add before
// a call to the function to save the local variables if necessary
// (we can't do this before finishing compiling the whole function
@@ -2611,9 +2596,26 @@
inst_it != block_it->end();
++inst_it) {
if (dyn_cast<ReturnInst>(inst_it)) {
- // LoadInst needs to be inserted in a BasicBlock
- // so we has to wait before putting it in params
- params[0] = new LoadInst(current_var_uses, "", inst_it);
+ if (params.empty()) {
+ params.push_back(new LoadInst(current_var_uses, "", inst_it));
+ params.push_back(NULL); // filled right after.
+ int vars_count = 0;
+ for (std::map<ID, Value *>::iterator iter = lvars.begin();
+ iter != lvars.end(); ++iter) {
+ ID name = iter->first;
+ Value *slot = iter->second;
+ if (std::find(dvars.begin(), dvars.end(), name) == dvars.end()) {
+ Value *id_val = compile_id(name);
+ if (Instruction::classof(id_val)) {
+ cast<Instruction>(id_val)->moveBefore(inst_it);
+ }
+ params.push_back(id_val);
+ params.push_back(slot);
+ vars_count++;
+ }
+ }
+ params[1] = ConstantInt::get(Type::Int32Ty, vars_count);
+ }
// TODO: only call the function if current_use is not NULL
CallInst::Create(keepVarsFunc, params.begin(), params.end(), "",
Modified: MacRuby/branches/experimental/vm.cpp
===================================================================
--- MacRuby/branches/experimental/vm.cpp 2009-07-01 23:53:26 UTC (rev 1968)
+++ MacRuby/branches/experimental/vm.cpp 2009-07-02 01:31:22 UTC (rev 1969)
@@ -2950,13 +2950,18 @@
rb_vm_block_t *b = GET_VM()->uncache_or_create_block(function, &cached,
dvars_size);
+ bool aot_block = false;
+ if ((flags & VM_BLOCK_AOT) == VM_BLOCK_AOT) {
+ flags ^= VM_BLOCK_AOT;
+ aot_block = true;
+ }
+
if (!cached) {
if ((flags & VM_BLOCK_IFUNC) == VM_BLOCK_IFUNC) {
b->imp = (IMP)function;
}
else {
- if ((flags & VM_BLOCK_AOT) == VM_BLOCK_AOT) {
- flags ^= VM_BLOCK_AOT;
+ if (aot_block) {
b->imp = (IMP)function;
}
else {
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090701/30fa028c/attachment.html>
More information about the macruby-changes
mailing list