From bfd0ead12d2876dc1a735f3b7c941547e5c3beea Mon Sep 17 00:00:00 2001 From: Juan Wajnerman <jwajnerman@manas.com.ar> Date: Sat, 1 Feb 2014 18:25:17 -0300 Subject: [PATCH] Switch to MC-JIT. Now the codegen specs can use exceptions and trampolines. --- libs/llvm/jit_compiler.cr | 4 ++-- libs/llvm/llvm.cr | 4 ++-- spec/compiler/codegen/fun_spec.cr | 8 +++----- src/compiler/crystal/codegen.cr | 2 +- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/libs/llvm/jit_compiler.cr b/libs/llvm/jit_compiler.cr index 248e900b98..a46de43ebb 100644 --- a/libs/llvm/jit_compiler.cr +++ b/libs/llvm/jit_compiler.cr @@ -1,7 +1,7 @@ class LLVM::JITCompiler def initialize(mod) - if LibLLVM.create_jit_compiler_for_module(out @jit, mod.llvm_module, 3, out error) != 0 - # if LibLLVM.create_mc_jit_compiler_for_module(out @jit, mod.llvm_module, nil, 0_u32, out error) != 0 + # if LibLLVM.create_jit_compiler_for_module(out @jit, mod.llvm_module, 3, out error) != 0 + if LibLLVM.create_mc_jit_compiler_for_module(out @jit, mod.llvm_module, nil, 0_u32, out error) != 0 raise String.new(error) end end diff --git a/libs/llvm/llvm.cr b/libs/llvm/llvm.cr index 8b46f10884..954a7f2339 100644 --- a/libs/llvm/llvm.cr +++ b/libs/llvm/llvm.cr @@ -6,8 +6,8 @@ module LLVM LibLLVM.initialize_x86_target LibLLVM.initialize_x86_target_mc LibLLVM.initialize_x86_asm_printer - LibLLVM.link_in_jit - # LibLLVM.link_in_mc_jit + # LibLLVM.link_in_jit + LibLLVM.link_in_mc_jit end def self.dump(value) diff --git a/spec/compiler/codegen/fun_spec.cr b/spec/compiler/codegen/fun_spec.cr index ae4a8eb5f6..3e373e61d6 100644 --- a/spec/compiler/codegen/fun_spec.cr +++ b/spec/compiler/codegen/fun_spec.cr @@ -25,16 +25,14 @@ describe "Code gen: fun" do ").to_i.should eq(3) end - pending "call fun pointer of instance method" do - run(" - require "prelude" + it "call fun pointer of instance method" do + run(%( class Foo def initialize @x = 1 end def coco - puts "Hola" @x end end @@ -42,7 +40,7 @@ describe "Code gen: fun" do foo = Foo.new f = ->foo.coco f.call - ").to_i.should eq(1) + )).to_i.should eq(1) end it "codegens fun with another var" do diff --git a/src/compiler/crystal/codegen.cr b/src/compiler/crystal/codegen.cr index d700f3b847..4e46fb0fc7 100644 --- a/src/compiler/crystal/codegen.cr +++ b/src/compiler/crystal/codegen.cr @@ -34,7 +34,7 @@ module Crystal engine.run_function llvm_mod.functions[MAIN_NAME], [argc, argv] end - def build(node, single_module = false, llvm_mod = LLVM::Module.new("main")) + def build(node, single_module = false, llvm_mod = LLVM::Module.new("main_module")) visitor = CodeGenVisitor.new(self, node, llvm_mod, single_module) begin node.accept visitor -- GitLab