Expand list of synchronized types and functions in LLVM JIT provider.
authorAndres Freund <[email protected]>
Mon, 5 Feb 2018 17:09:28 +0000 (09:09 -0800)
committerAndres Freund <[email protected]>
Thu, 22 Mar 2018 21:45:59 +0000 (14:45 -0700)
Author: Andres Freund
Discussion: https://postgr.es/m/20170901064131[email protected]

src/backend/jit/llvm/llvmjit.c
src/backend/jit/llvm/llvmjit_types.c
src/include/jit/llvmjit.h

index 8cf8aaaa3a1dc7ecf6f594c47cd5532f5ccbdf97..eaede90cca0f6383e8d6581b50a3de61f9654ea0 100644 (file)
@@ -45,9 +45,38 @@ typedef struct LLVMJitHandle
 
 /* types & functions commonly needed for JITing */
 LLVMTypeRef TypeSizeT;
+LLVMTypeRef TypePGFunction;
+LLVMTypeRef StructHeapTupleFieldsField3;
+LLVMTypeRef StructHeapTupleFields;
+LLVMTypeRef StructHeapTupleHeaderData;
+LLVMTypeRef StructHeapTupleDataChoice;
+LLVMTypeRef StructHeapTupleData;
+LLVMTypeRef StructMinimalTupleData;
+LLVMTypeRef StructItemPointerData;
+LLVMTypeRef StructBlockId;
+LLVMTypeRef StructFormPgAttribute;
+LLVMTypeRef StructTupleConstr;
+LLVMTypeRef StructtupleDesc;
+LLVMTypeRef StructTupleTableSlot;
+LLVMTypeRef StructMemoryContextData;
+LLVMTypeRef StructPGFinfoRecord;
+LLVMTypeRef StructFmgrInfo;
+LLVMTypeRef StructFunctionCallInfoData;
+LLVMTypeRef StructExprContext;
+LLVMTypeRef StructExprEvalStep;
+LLVMTypeRef StructExprState;
+LLVMTypeRef StructAggState;
+LLVMTypeRef StructAggStatePerGroupData;
+LLVMTypeRef StructAggStatePerTransData;
 
 LLVMValueRef AttributeTemplate;
 LLVMValueRef FuncStrlen;
+LLVMValueRef FuncSlotGetsomeattrs;
+LLVMValueRef FuncHeapGetsysattr;
+LLVMValueRef FuncMakeExpandedObjectReadOnlyInternal;
+LLVMValueRef FuncExecEvalArrayRefSubscript;
+LLVMValueRef FuncExecAggTransReparent;
+LLVMValueRef FuncExecAggInitGroup;
 
 
 static bool llvm_session_initialized = false;
@@ -647,9 +676,27 @@ llvm_create_types(void)
        llvm_layout = pstrdup(LLVMGetDataLayoutStr(mod));
 
        TypeSizeT = load_type(mod, "TypeSizeT");
+       TypePGFunction = load_type(mod, "TypePGFunction");
+       StructExprContext = load_type(mod, "StructExprContext");
+       StructExprEvalStep = load_type(mod, "StructExprEvalStep");
+       StructExprState = load_type(mod, "StructExprState");
+       StructFunctionCallInfoData = load_type(mod, "StructFunctionCallInfoData");
+       StructMemoryContextData = load_type(mod, "StructMemoryContextData");
+       StructTupleTableSlot = load_type(mod, "StructTupleTableSlot");
+       StructHeapTupleData = load_type(mod, "StructHeapTupleData");
+       StructtupleDesc = load_type(mod, "StructtupleDesc");
+       StructAggState = load_type(mod, "StructAggState");
+       StructAggStatePerGroupData = load_type(mod, "StructAggStatePerGroupData");
+       StructAggStatePerTransData = load_type(mod, "StructAggStatePerTransData");
 
        AttributeTemplate = LLVMGetNamedFunction(mod, "AttributeTemplate");
        FuncStrlen = LLVMGetNamedFunction(mod, "strlen");
+       FuncSlotGetsomeattrs = LLVMGetNamedFunction(mod, "slot_getsomeattrs");
+       FuncHeapGetsysattr = LLVMGetNamedFunction(mod, "heap_getsysattr");
+       FuncMakeExpandedObjectReadOnlyInternal = LLVMGetNamedFunction(mod, "MakeExpandedObjectReadOnlyInternal");
+       FuncExecEvalArrayRefSubscript = LLVMGetNamedFunction(mod, "ExecEvalArrayRefSubscript");
+       FuncExecAggTransReparent = LLVMGetNamedFunction(mod, "ExecAggTransReparent");
+       FuncExecAggInitGroup = LLVMGetNamedFunction(mod, "ExecAggInitGroup");
 
        /*
         * Leave the module alive, otherwise references to function would be
index 90c1d55cbae94e7e0b15be6c79cab6822ad845c3..e40dff3886323b23216bbe4f8fcc6f7b633cca19 100644 (file)
 
 #include "postgres.h"
 
+#include "access/htup.h"
+#include "access/htup_details.h"
+#include "access/tupdesc.h"
+#include "catalog/pg_attribute.h"
+#include "executor/execExpr.h"
+#include "executor/nodeAgg.h"
+#include "executor/tuptable.h"
 #include "fmgr.h"
+#include "nodes/execnodes.h"
+#include "nodes/memnodes.h"
+#include "utils/expandeddatum.h"
+#include "utils/palloc.h"
+
 
 /*
  * List of types needed for JITing. These have to be non-static, otherwise
  * anything, that's harmless.
  */
 size_t         TypeSizeT;
+PGFunction     TypePGFunction;
+
+AggState       StructAggState;
+AggStatePerGroupData StructAggStatePerGroupData;
+AggStatePerTransData StructAggStatePerTransData;
+ExprContext StructExprContext;
+ExprEvalStep StructExprEvalStep;
+ExprState      StructExprState;
+FunctionCallInfoData StructFunctionCallInfoData;
+HeapTupleData StructHeapTupleData;
+MemoryContextData StructMemoryContextData;
+TupleTableSlot StructTupleTableSlot;
+struct tupleDesc StructtupleDesc;
 
 
 /*
@@ -56,5 +81,11 @@ AttributeTemplate(PG_FUNCTION_ARGS)
  */
 void      *referenced_functions[] =
 {
-       strlen
+       strlen,
+       slot_getsomeattrs,
+       heap_getsysattr,
+       MakeExpandedObjectReadOnlyInternal,
+       ExecEvalArrayRefSubscript,
+       ExecAggTransReparent,
+       ExecAggInitGroup
 };
index bd201bb7ca142483bd498a3af755e926a69acf55..6327be1e3cf982830015a053973b637a4b37da2b 100644 (file)
@@ -56,9 +56,27 @@ typedef struct LLVMJitContext
 
 /* type and struct definitions */
 extern LLVMTypeRef TypeSizeT;
+extern LLVMTypeRef TypePGFunction;
+extern LLVMTypeRef StructtupleDesc;
+extern LLVMTypeRef StructHeapTupleData;
+extern LLVMTypeRef StructTupleTableSlot;
+extern LLVMTypeRef StructMemoryContextData;
+extern LLVMTypeRef StructFunctionCallInfoData;
+extern LLVMTypeRef StructExprContext;
+extern LLVMTypeRef StructExprEvalStep;
+extern LLVMTypeRef StructExprState;
+extern LLVMTypeRef StructAggState;
+extern LLVMTypeRef StructAggStatePerTransData;
+extern LLVMTypeRef StructAggStatePerGroupData;
 
 extern LLVMValueRef AttributeTemplate;
 extern LLVMValueRef FuncStrlen;
+extern LLVMValueRef FuncSlotGetsomeattrs;
+extern LLVMValueRef FuncHeapGetsysattr;
+extern LLVMValueRef FuncMakeExpandedObjectReadOnlyInternal;
+extern LLVMValueRef FuncExecEvalArrayRefSubscript;
+extern LLVMValueRef FuncExecAggTransReparent;
+extern LLVMValueRef FuncExecAggInitGroup;
 
 
 extern void llvm_enter_fatal_on_oom(void);