From 38f4f64124c88933acc76325a256950d468022fa Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Tue, 9 Dec 2014 18:40:40 +0000 Subject: [PATCH] jit-playback.c: Move dlopen code into a new function gcc/jit/ChangeLog: * jit-playback.c (gcc::jit::playback::context::compile): Move the dlopen code into... (gcc::jit::playback::context::dlopen_built_dso): ...this new function. * jit-playback.h (gcc::jit::playback::context::dlopen_built_dso): New function. From-SVN: r218527 --- gcc/jit/ChangeLog | 9 ++++++++ gcc/jit/jit-playback.c | 48 +++++++++++++++++++++++++----------------- gcc/jit/jit-playback.h | 3 +++ 3 files changed, 41 insertions(+), 19 deletions(-) diff --git a/gcc/jit/ChangeLog b/gcc/jit/ChangeLog index afe1e66b493..2d2795dcd0a 100644 --- a/gcc/jit/ChangeLog +++ b/gcc/jit/ChangeLog @@ -1,3 +1,12 @@ +2014-12-09 David Malcolm + + * jit-playback.c (gcc::jit::playback::context::compile): Move the + dlopen code into... + (gcc::jit::playback::context::dlopen_built_dso): ...this new + function. + * jit-playback.h (gcc::jit::playback::context::dlopen_built_dso): + New function. + 2014-12-08 David Malcolm * libgccjit++.h: Indent the forward declarations of the classes to diff --git a/gcc/jit/jit-playback.c b/gcc/jit/jit-playback.c index cf50fb3ee7d..a6de2443d66 100644 --- a/gcc/jit/jit-playback.c +++ b/gcc/jit/jit-playback.c @@ -1586,7 +1586,6 @@ result * playback::context:: compile () { - void *handle = NULL; const char *ctxt_progname; result *result_obj = NULL; @@ -1648,24 +1647,7 @@ compile () if (errors_occurred ()) return NULL; - /* dlopen the .so file. */ - { - auto_timevar load_timevar (TV_LOAD); - - const char *error; - - /* Clear any existing error. */ - dlerror (); - - handle = dlopen (m_path_so_file, RTLD_NOW | RTLD_LOCAL); - if ((error = dlerror()) != NULL) { - add_error (NULL, "%s", error); - } - if (handle) - result_obj = new result (handle); - else - result_obj = NULL; - } + result_obj = dlopen_built_dso (); return result_obj; } @@ -1916,6 +1898,34 @@ convert_to_dso (const char *ctxt_progname) } } +/* Dynamically-link the built DSO file into this process, using dlopen. + Wrap it up within a jit::result *, and return that. + Return NULL if any errors occur, reporting them on this context. */ + +result * +playback::context:: +dlopen_built_dso () +{ + auto_timevar load_timevar (TV_LOAD); + void *handle = NULL; + const char *error = NULL; + result *result_obj = NULL; + + /* Clear any existing error. */ + dlerror (); + + handle = dlopen (m_path_so_file, RTLD_NOW | RTLD_LOCAL); + if ((error = dlerror()) != NULL) { + add_error (NULL, "%s", error); + } + if (handle) + result_obj = new result (handle); + else + result_obj = NULL; + + return result_obj; +} + /* Top-level hook for playing back a recording context. This plays back m_recording_ctxt, and, if no errors diff --git a/gcc/jit/jit-playback.h b/gcc/jit/jit-playback.h index b2b983a6866..f2968a88225 100644 --- a/gcc/jit/jit-playback.h +++ b/gcc/jit/jit-playback.h @@ -250,6 +250,9 @@ private: void convert_to_dso (const char *ctxt_progname); + result * + dlopen_built_dso (); + private: ::gcc::jit::recording::context *m_recording_ctxt; -- 2.30.2