Forum | Documentation | Website | Blog

Skip to content
Snippets Groups Projects
Commit f5a0e540 authored by Ary Borenszweig's avatar Ary Borenszweig
Browse files

Extracted duplicated trampoline_init logic to a method

parent ec12a7c5
No related merge requests found
...@@ -708,14 +708,7 @@ module Crystal ...@@ -708,14 +708,7 @@ module Crystal
@last = (check_main_fun fun_literal_name, the_fun).fun @last = (check_main_fun fun_literal_name, the_fun).fun
if is_closure if is_closure
tramp_ptr = array_malloc(LLVM::Int8, int(32)) trampoline_init node.type, @last, context.closure_ptr.not_nil!
call @mod.trampoline_init(@llvm_mod), [
tramp_ptr,
bit_cast(@last, pointer_type(LLVM::Int8)),
bit_cast(context.closure_ptr.not_nil!, pointer_type(LLVM::Int8))
]
@last = call @mod.trampoline_adjust(@llvm_mod), [tramp_ptr]
@last = cast_to @last, node.type
end end
false false
...@@ -734,14 +727,7 @@ module Crystal ...@@ -734,14 +727,7 @@ module Crystal
if call_self if call_self
wrapper = trampoline_wrapper(node.call.target_def, last_fun) wrapper = trampoline_wrapper(node.call.target_def, last_fun)
tramp_ptr = array_malloc(LLVM::Int8, int(32)) trampoline_init node.type, wrapper.fun, call_self
call @mod.trampoline_init(@llvm_mod), [
tramp_ptr,
bit_cast(wrapper.fun, pointer_type(LLVM::Int8)),
bit_cast(call_self, pointer_type(LLVM::Int8))
]
@last = call @mod.trampoline_adjust(@llvm_mod), [tramp_ptr]
@last = cast_to @last, node.type
end end
false false
...@@ -770,6 +756,17 @@ module Crystal ...@@ -770,6 +756,17 @@ module Crystal
end end
end end
def trampoline_init(type, wrapper, nest)
tramp_ptr = array_malloc(LLVM::Int8, int(32))
call @mod.trampoline_init(@llvm_mod), [
tramp_ptr,
bit_cast(wrapper, pointer_type(LLVM::Int8)),
bit_cast(nest, pointer_type(LLVM::Int8))
]
@last = call @mod.trampoline_adjust(@llvm_mod), [tramp_ptr]
@last = cast_to @last, type
end
def visit(node : Expressions) def visit(node : Expressions)
node.expressions.each do |exp| node.expressions.each do |exp|
accept exp accept exp
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment