From f6908f513fd2db17ad81a54b4a14194895e780ea Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 13 Apr 2010 18:43:48 -0700 Subject: [PATCH] llvm: fix load errors --- extra/llvm/core/core.factor | 2 +- extra/llvm/engine/engine.factor | 2 +- extra/llvm/invoker/invoker.factor | 2 +- extra/llvm/jit/jit.factor | 23 +++++++++++------------ extra/llvm/types/types.factor | 2 +- 5 files changed, 15 insertions(+), 16 deletions(-) diff --git a/extra/llvm/core/core.factor b/extra/llvm/core/core.factor index 0ab43c6ab6..5778a00ffb 100644 --- a/extra/llvm/core/core.factor +++ b/extra/llvm/core/core.factor @@ -1,6 +1,6 @@ ! Copyright (C) 2009 Matthew Willis. ! See http://factorcode.org/license.txt for BSD license. -USING: alien.libraries alien.syntax system sequences combinators kernel alien.c-types ; +USING: alien alien.libraries alien.syntax system sequences combinators kernel alien.c-types ; IN: llvm.core diff --git a/extra/llvm/engine/engine.factor b/extra/llvm/engine/engine.factor index 95e425c425..bb39f86f73 100644 --- a/extra/llvm/engine/engine.factor +++ b/extra/llvm/engine/engine.factor @@ -1,6 +1,6 @@ ! Copyright (C) 2009 Matthew Willis. ! See http://factorcode.org/license.txt for BSD license. -USING: alien.libraries alien.syntax llvm.core ; +USING: alien.c-types alien.libraries alien.syntax llvm.core ; IN: llvm.engine << diff --git a/extra/llvm/invoker/invoker.factor b/extra/llvm/invoker/invoker.factor index cc3480fe49..27fdeeb618 100644 --- a/extra/llvm/invoker/invoker.factor +++ b/extra/llvm/invoker/invoker.factor @@ -45,7 +45,7 @@ TUPLE: function name alien return params ; ] [ ] make swap function-effect [ define-declared ] with-compilation-unit ; : install-module ( name -- ) - thejit get mps>> at [ + current-jit mps>> at [ module>> functions [ install-function ] each ] [ "no such module" throw ] if* ; diff --git a/extra/llvm/jit/jit.factor b/extra/llvm/jit/jit.factor index f58851fe6f..fc755fd00f 100644 --- a/extra/llvm/jit/jit.factor +++ b/extra/llvm/jit/jit.factor @@ -5,8 +5,6 @@ kernel llvm.core llvm.engine llvm.wrappers namespaces ; IN: llvm.jit -SYMBOL: thejit - TUPLE: jit ee mps ; : empty-engine ( -- engine ) @@ -15,8 +13,11 @@ TUPLE: jit ee mps ; : ( -- jit ) jit new empty-engine >>ee H{ } clone >>mps ; +: current-jit ( -- jit ) + \ current-jit global [ drop ] cache ; + : (remove-functions) ( function -- ) - thejit get ee>> value>> over LLVMFreeMachineCodeForFunction + current-jit ee>> value>> over LLVMFreeMachineCodeForFunction LLVMGetNextFunction dup ALIEN: 0 = [ drop ] [ (remove-functions) ] if ; : remove-functions ( module -- ) @@ -24,26 +25,24 @@ TUPLE: jit ee mps ; LLVMGetFirstFunction dup ALIEN: 0 = [ drop ] [ (remove-functions) ] if ; : remove-provider ( provider -- ) - thejit get ee>> value>> swap value>> f f + current-jit ee>> value>> swap value>> f f [ LLVMRemoveModuleProvider drop ] 2keep *void* [ llvm-throw ] when* *void* module new swap >>value [ value>> remove-functions ] with-disposal ; : remove-module ( name -- ) - dup thejit get mps>> at [ + dup current-jit mps>> at [ remove-provider - thejit get mps>> delete-at + current-jit mps>> delete-at ] [ drop ] if* ; : add-module ( module name -- ) [ ] dip [ remove-module ] keep - thejit get ee>> value>> pick + current-jit ee>> value>> pick [ [ value>> LLVMAddModuleProvider ] [ t >>disposed drop ] bi ] with-disposal - thejit get mps>> set-at ; + current-jit mps>> set-at ; : function-pointer ( name -- alien ) - thejit get ee>> value>> dup + current-jit ee>> value>> dup rot f [ LLVMFindFunction drop ] keep - *void* LLVMGetPointerToGlobal ; - -thejit [ ] initialize \ No newline at end of file + *void* LLVMGetPointerToGlobal ; \ No newline at end of file diff --git a/extra/llvm/types/types.factor b/extra/llvm/types/types.factor index e93cf7a44b..c312e7a173 100644 --- a/extra/llvm/types/types.factor +++ b/extra/llvm/types/types.factor @@ -229,7 +229,7 @@ NoFunctionParams = "(" WhiteSpace ")" => [[ drop { } ]] VarArgs = WhiteSpace "..." WhiteSpace => [[ drop ... ]] ParamListContinued = "," (Type | VarArgs):t => [[ t ]] ParamList = "(" Type:t (ParamListContinued*):ts ")" => [[ ts t prefix ]] -Function = T:t WhiteSpace ( ParamList | NoFunctionParams ):ts => [[ ... ts member? dup [ ... ts delete ] when t ts >array rot ]] +Function = T:t WhiteSpace ( ParamList | NoFunctionParams ):ts => [[ ... ts member? dup [ ... ts remove! drop ] when t ts >array rot ]] PackedStructure = "<" WhiteSpace "{" Type:ty (StructureTypesList)*:ts "}" WhiteSpace ">" => [[ ts ty prefix >array t ]] UpReference = "\\" Number:n => [[ n ]] Name = '%' ([a-zA-Z][a-zA-Z0-9]*):id => [[ id flatten >string ]]