Commit 38f4f641 by David Malcolm Committed by David Malcolm

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
parent cee66c68
2014-12-09 David Malcolm <dmalcolm@redhat.com>
* 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 <dmalcolm@redhat.com> 2014-12-08 David Malcolm <dmalcolm@redhat.com>
* libgccjit++.h: Indent the forward declarations of the classes to * libgccjit++.h: Indent the forward declarations of the classes to
......
...@@ -1586,7 +1586,6 @@ result * ...@@ -1586,7 +1586,6 @@ result *
playback::context:: playback::context::
compile () compile ()
{ {
void *handle = NULL;
const char *ctxt_progname; const char *ctxt_progname;
result *result_obj = NULL; result *result_obj = NULL;
...@@ -1648,24 +1647,7 @@ compile () ...@@ -1648,24 +1647,7 @@ compile ()
if (errors_occurred ()) if (errors_occurred ())
return NULL; return NULL;
/* dlopen the .so file. */ result_obj = dlopen_built_dso ();
{
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;
}
return result_obj; return result_obj;
} }
...@@ -1916,6 +1898,34 @@ convert_to_dso (const char *ctxt_progname) ...@@ -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. /* Top-level hook for playing back a recording context.
This plays back m_recording_ctxt, and, if no errors This plays back m_recording_ctxt, and, if no errors
......
...@@ -250,6 +250,9 @@ private: ...@@ -250,6 +250,9 @@ private:
void void
convert_to_dso (const char *ctxt_progname); convert_to_dso (const char *ctxt_progname);
result *
dlopen_built_dso ();
private: private:
::gcc::jit::recording::context *m_recording_ctxt; ::gcc::jit::recording::context *m_recording_ctxt;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment