summaryrefslogtreecommitdiffstats
path: root/llvm/lib/ExecutionEngine/JIT/JIT.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-12-26 06:13:47 +0000
committerChris Lattner <sabre@nondot.org>2003-12-26 06:13:47 +0000
commit385a90aa6d272a996997ec9bfe44865b1d2b6445 (patch)
tree02f5d3a89553e0ddcd78ad63cee54fdc94fc7c30 /llvm/lib/ExecutionEngine/JIT/JIT.cpp
parentd94296c620f44a06a7a909ba513d6e356f0bb3e9 (diff)
downloadbcm5719-llvm-385a90aa6d272a996997ec9bfe44865b1d2b6445.tar.gz
bcm5719-llvm-385a90aa6d272a996997ec9bfe44865b1d2b6445.zip
No longer run atExit functions from run()
rename run to runFunction Genericize the runFunction code a little bit, though it still stinks llvm-svn: 10610
Diffstat (limited to 'llvm/lib/ExecutionEngine/JIT/JIT.cpp')
-rw-r--r--llvm/lib/ExecutionEngine/JIT/JIT.cpp37
1 files changed, 23 insertions, 14 deletions
diff --git a/llvm/lib/ExecutionEngine/JIT/JIT.cpp b/llvm/lib/ExecutionEngine/JIT/JIT.cpp
index d39741438aa..6a067fd0542 100644
--- a/llvm/lib/ExecutionEngine/JIT/JIT.cpp
+++ b/llvm/lib/ExecutionEngine/JIT/JIT.cpp
@@ -51,22 +51,31 @@ JIT::~JIT() {
/// run - Start execution with the specified function and arguments.
///
-GenericValue JIT::run(Function *F, const std::vector<GenericValue> &ArgValues) {
+GenericValue JIT::runFunction(Function *F,
+ const std::vector<GenericValue> &ArgValues) {
assert (F && "Function *F was null at entry to run()");
+ GenericValue rv;
+
+ if (ArgValues.size() == 3) {
+ int (*PF)(int, char **, const char **) =
+ (int(*)(int, char **, const char **))getPointerToFunction(F);
+ assert(PF && "Pointer to fn's code was null after getPointerToFunction");
+
+ // Call the function.
+ int ExitCode = PF(ArgValues[0].IntVal, (char **) GVTOP (ArgValues[1]),
+ (const char **) GVTOP (ArgValues[2]));
+
+ rv.IntVal = ExitCode;
+ } else {
+ // FIXME: This code should handle a couple of common cases efficiently, but
+ // it should also implement the general case by code-gening a new anonymous
+ // nullary function to call.
+ assert(ArgValues.size() == 1);
+ void (*PF)(int) = (void(*)(int))getPointerToFunction(F);
+ assert(PF && "Pointer to fn's code was null after getPointerToFunction");
+ PF(ArgValues[0].IntVal);
+ }
- int (*PF)(int, char **, const char **) =
- (int(*)(int, char **, const char **))getPointerToFunction(F);
- assert(PF != 0 && "Pointer to fn's code was null after getPointerToFunction");
-
- // Call the function.
- int ExitCode = PF(ArgValues[0].IntVal, (char **) GVTOP (ArgValues[1]),
- (const char **) GVTOP (ArgValues[2]));
-
- // Run any atexit handlers now!
- runAtExitHandlers();
-
- GenericValue rv;
- rv.IntVal = ExitCode;
return rv;
}
OpenPOWER on IntegriCloud