[llvm-commits] CVS: llvm/lib/ExecutionEngine/JIT/Intercept.cpp JIT.cpp JIT.h
Chris Lattner
lattner at cs.uiuc.edu
Fri Dec 26 00:14:01 PST 2003
Changes in directory llvm/lib/ExecutionEngine/JIT:
Intercept.cpp updated: 1.12 -> 1.13
JIT.cpp updated: 1.30 -> 1.31
JIT.h updated: 1.21 -> 1.22
---
Log message:
No longer run atExit functions from run()
rename run to runFunction
Genericize the runFunction code a little bit, though it still stinks
---
Diffs of the changes: (+26 -22)
Index: llvm/lib/ExecutionEngine/JIT/Intercept.cpp
diff -u llvm/lib/ExecutionEngine/JIT/Intercept.cpp:1.12 llvm/lib/ExecutionEngine/JIT/Intercept.cpp:1.13
--- llvm/lib/ExecutionEngine/JIT/Intercept.cpp:1.12 Fri Dec 19 19:46:27 2003
+++ llvm/lib/ExecutionEngine/JIT/Intercept.cpp Fri Dec 26 00:13:47 2003
@@ -28,7 +28,7 @@
/// calls to atexit(3), which we intercept and store in
/// AtExitHandlers.
///
-void JIT::runAtExitHandlers() {
+static void runAtExitHandlers() {
while (!AtExitHandlers.empty()) {
void (*Fn)() = AtExitHandlers.back();
AtExitHandlers.pop_back();
@@ -45,7 +45,7 @@
// jit_exit - Used to intercept the "exit" library call.
static void jit_exit(int Status) {
- JIT::runAtExitHandlers(); // Run atexit handlers...
+ runAtExitHandlers(); // Run atexit handlers...
exit(Status);
}
Index: llvm/lib/ExecutionEngine/JIT/JIT.cpp
diff -u llvm/lib/ExecutionEngine/JIT/JIT.cpp:1.30 llvm/lib/ExecutionEngine/JIT/JIT.cpp:1.31
--- llvm/lib/ExecutionEngine/JIT/JIT.cpp:1.30 Sat Dec 20 04:19:18 2003
+++ llvm/lib/ExecutionEngine/JIT/JIT.cpp Fri Dec 26 00:13:47 2003
@@ -51,22 +51,31 @@
/// 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;
- 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");
+ 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);
+ }
- // 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;
}
Index: llvm/lib/ExecutionEngine/JIT/JIT.h
diff -u llvm/lib/ExecutionEngine/JIT/JIT.h:1.21 llvm/lib/ExecutionEngine/JIT/JIT.h:1.22
--- llvm/lib/ExecutionEngine/JIT/JIT.h:1.21 Fri Dec 19 21:36:47 2003
+++ llvm/lib/ExecutionEngine/JIT/JIT.h Fri Dec 26 00:13:47 2003
@@ -50,8 +50,8 @@
/// run - Start execution with the specified function and arguments.
///
- virtual GenericValue run(Function *F,
- const std::vector<GenericValue> &ArgValues);
+ virtual GenericValue runFunction(Function *F,
+ const std::vector<GenericValue> &ArgValues);
/// getPointerToNamedFunction - This method returns the address of the
/// specified function by using the dlsym function call. As such it is only
@@ -63,11 +63,6 @@
// which causes lazy compilation of the target function.
//
static void CompilationCallback();
-
- /// runAtExitHandlers - Before exiting the program, at_exit functions must be
- /// called. This method calls them.
- ///
- static void runAtExitHandlers();
/// getPointerToFunction - This returns the address of the specified function,
/// compiling it if necessary.
More information about the llvm-commits
mailing list