[macruby-changes] [2455] MacRuby/branches/llvm26
source_changes at macosforge.org
source_changes at macosforge.org
Wed Sep 2 01:41:20 PDT 2009
Revision: 2455
http://trac.macosforge.org/projects/ruby/changeset/2455
Author: lsansonetti at apple.com
Date: 2009-09-02 01:41:17 -0700 (Wed, 02 Sep 2009)
Log Message:
-----------
fix the JIT in 64-bit
Modified Paths:
--------------
MacRuby/branches/llvm26/compiler.cpp
MacRuby/branches/llvm26/vm.cpp
Modified: MacRuby/branches/llvm26/compiler.cpp
===================================================================
--- MacRuby/branches/llvm26/compiler.cpp 2009-09-02 02:58:41 UTC (rev 2454)
+++ MacRuby/branches/llvm26/compiler.cpp 2009-09-02 08:41:17 UTC (rev 2455)
@@ -6,7 +6,7 @@
* Copyright (C) 2008-2009, Apple Inc. All rights reserved.
*/
-#define ROXOR_COMPILER_DEBUG 1
+#define ROXOR_COMPILER_DEBUG 0
#include "llvm.h"
#include "ruby/ruby.h"
@@ -23,7 +23,7 @@
llvm::Module *RoxorCompiler::module = NULL;
RoxorCompiler *RoxorCompiler::shared = NULL;
-RoxorCompiler::RoxorCompiler()
+RoxorCompiler::RoxorCompiler(void)
{
fname = NULL;
inside_eval = false;
@@ -317,8 +317,8 @@
}
Function::ArgumentListType::iterator
-RoxorCompiler::compile_optional_arguments(Function::ArgumentListType::iterator iter,
- NODE *node)
+RoxorCompiler::compile_optional_arguments(
+ Function::ArgumentListType::iterator iter, NODE *node)
{
assert(nd_type(node) == NODE_OPT_ARG);
Modified: MacRuby/branches/llvm26/vm.cpp
===================================================================
--- MacRuby/branches/llvm26/vm.cpp 2009-09-02 02:58:41 UTC (rev 2454)
+++ MacRuby/branches/llvm26/vm.cpp 2009-09-02 08:41:17 UTC (rev 2455)
@@ -6,8 +6,8 @@
* Copyright (C) 2008-2009, Apple Inc. All rights reserved.
*/
-#define ROXOR_VM_DEBUG 1
-#define ROXOR_COMPILER_DEBUG 1
+#define ROXOR_VM_DEBUG 0
+#define ROXOR_COMPILER_DEBUG 0
#include <llvm/Module.h>
#include <llvm/DerivedTypes.h>
@@ -224,20 +224,13 @@
abort();
}
-#if 0
- std::string str =
- ee->getTargetData()->getStringRepresentation();
- RoxorCompiler::module->setDataLayout(str);
- RoxorCompiler::module->setTargetTriple(LLVM_HOSTTRIPLE);
-#endif
-
fpm = new FunctionPassManager(emp);
fpm->add(new TargetData(*ee->getTargetData()));
+ // Do simple "peephole" optimizations and bit-twiddling optzns.
+ fpm->add(createInstructionCombiningPass());
// Eliminate unnecessary alloca.
fpm->add(createPromoteMemoryToRegisterPass());
- // Do simple "peephole" optimizations and bit-twiddling optzns.
- fpm->add(createInstructionCombiningPass());
// Reassociate expressions.
fpm->add(createReassociatePass());
// Eliminate Common SubExpressions.
@@ -391,8 +384,10 @@
return iter->second;
}
+ if (verifyModule(*RoxorCompiler::module, PrintMessageAction)) {
+ }
+
#if ROXOR_COMPILER_DEBUG
-RoxorCompiler::module->dump();
if (verifyModule(*RoxorCompiler::module, PrintMessageAction)) {
printf("Error during module verification\n");
exit(1);
@@ -403,7 +398,6 @@
// Optimize & compile.
optimize(func);
-RoxorCompiler::module->dump();
IMP imp = (IMP)ee->getPointerToFunction(func);
JITcache[func] = imp;
@@ -4759,7 +4753,13 @@
GET_CORE()->optimize(f);
// Dump the bitcode.
- std::ofstream out(output);
+ std::string err;
+ raw_fd_ostream out(output, err, raw_fd_ostream::F_Binary);
+ if (!err.empty()) {
+ fprintf(stderr, "error when opening the output bitcode file: %s\n",
+ err.c_str());
+ abort();
+ }
WriteBitcodeToFile(RoxorCompiler::module, out);
out.close();
}
@@ -5420,6 +5420,13 @@
return NO; // TODO call old IMP
}
+// We can't trust LLVM to pick the right target at runtime.
+#if __LP64__
+# define TARGET_TRIPLE "x86_64-apple-darwin"
+#else
+# define TARGET_TRIPLE "i386-apple-darwin"
+#endif
+
extern "C"
void
Init_PreVM(void)
@@ -5427,6 +5434,7 @@
llvm::DwarfExceptionHandling = true; // required!
RoxorCompiler::module = new llvm::Module("Roxor", getGlobalContext());
+ RoxorCompiler::module->setTargetTriple(TARGET_TRIPLE);
RoxorCore::shared = new RoxorCore();
RoxorVM::main = new RoxorVM();
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090902/d28b32cd/attachment.html>
More information about the macruby-changes
mailing list