Skip to content

Commit

Permalink
less jl_get_global reflection (JuliaLang#53250)
Browse files Browse the repository at this point in the history
  • Loading branch information
vtjnash authored Feb 10, 2024
1 parent 9523361 commit f3d6904
Show file tree
Hide file tree
Showing 12 changed files with 40 additions and 332 deletions.
8 changes: 6 additions & 2 deletions base/filesystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,13 @@ end

function read(f::File, ::Type{UInt8})
check_open(f)
ret = ccall(:jl_fs_read_byte, Int32, (OS_HANDLE,), f.handle)
p = Ref{UInt8}()
ret = ccall(:jl_fs_read, Int32, (OS_HANDLE, Ptr{Cvoid}, Csize_t),
f.handle, p, 1)
uv_error("read", ret)
return ret % UInt8
@assert ret <= sizeof(p) == 1
ret < 1 && throw(EOFError())
return p[] % UInt8
end

function read(f::File, ::Type{Char})
Expand Down
5 changes: 0 additions & 5 deletions src/jl_exported_funcs.inc
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@
XX(jl_enter_handler) \
XX(jl_enter_threaded_region) \
XX(jl_environ) \
XX(jl_eof_error) \
XX(jl_eqtable_get) \
XX(jl_eqtable_pop) \
XX(jl_eqtable_put) \
Expand Down Expand Up @@ -239,8 +238,6 @@
XX(jl_method_lookup_by_tt) \
XX(jl_method_lookup) \
XX(jl_gf_invoke_lookup_worlds) \
XX(jl_git_branch) \
XX(jl_git_commit) \
XX(jl_global_event_loop) \
XX(jl_has_empty_intersection) \
XX(jl_has_free_typevars) \
Expand Down Expand Up @@ -436,7 +433,6 @@
XX(jl_stderr_obj) \
XX(jl_stderr_stream) \
XX(jl_stdin_stream) \
XX(jl_stdout_obj) \
XX(jl_stdout_stream) \
XX(jl_stored_inline) \
XX(jl_string_ptr) \
Expand Down Expand Up @@ -516,7 +512,6 @@
XX(jl_vprintf) \
XX(jl_wakeup_thread) \
XX(jl_write_compiler_output) \
XX(jl_yield) \

#define JL_RUNTIME_EXPORTED_FUNCS_WIN(XX) \
XX(jl_setjmp) \
Expand Down
19 changes: 0 additions & 19 deletions src/jl_uv.c
Original file line number Diff line number Diff line change
Expand Up @@ -662,25 +662,6 @@ JL_DLLEXPORT int jl_fs_read(uv_os_fd_t handle, char *data, size_t len)
return ret;
}

JL_DLLEXPORT int jl_fs_read_byte(uv_os_fd_t handle)
{
uv_fs_t req;
unsigned char c;
uv_buf_t buf[1];
buf[0].base = (char*)&c;
buf[0].len = 1;
int ret = uv_fs_read(unused_uv_loop_arg, &req, handle, buf, 1, -1, NULL);
uv_fs_req_cleanup(&req);
switch (ret) {
case -1: return ret;
case 0: jl_eof_error();
case 1: return (int)c;
default:
assert(0 && "jl_fs_read_byte: Invalid return value from uv_fs_read");
return -1;
}
}

JL_DLLEXPORT int jl_fs_close(uv_os_fd_t handle)
{
uv_fs_t req;
Expand Down
49 changes: 0 additions & 49 deletions src/jlapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -437,20 +437,6 @@ JL_DLLEXPORT jl_value_t *jl_call3(jl_function_t *f, jl_value_t *a,
return v;
}

/**
* @brief Yield to the Julia scheduler.
*
* Yields control to the Julia scheduler, allowing other Julia tasks to run.
*/
JL_DLLEXPORT void jl_yield(void)
{
static jl_function_t *yieldfunc = NULL;
if (yieldfunc == NULL)
yieldfunc = (jl_function_t*)jl_get_global(jl_base_module, jl_symbol("yield"));
if (yieldfunc != NULL)
jl_call0(yieldfunc);
}

/**
* @brief Get a field from a Julia object.
*
Expand Down Expand Up @@ -619,41 +605,6 @@ JL_DLLEXPORT const char *jl_ver_string(void)
return JULIA_VERSION_STRING;
}

// return char* from String field in Base.GIT_VERSION_INFO
static const char *git_info_string(const char *fld)
{
static jl_value_t *GIT_VERSION_INFO = NULL;
if (!GIT_VERSION_INFO)
GIT_VERSION_INFO = jl_get_global(jl_base_module, jl_symbol("GIT_VERSION_INFO"));
jl_value_t *f = jl_get_field(GIT_VERSION_INFO, fld);
assert(jl_is_string(f));
return jl_string_data(f);
}

/**
* @brief Get the name of the Git branch for the Julia build.
*
* @return A C string containing the name of the Git branch.
*/
JL_DLLEXPORT const char *jl_git_branch(void)
{
static const char *branch = NULL;
if (!branch) branch = git_info_string("branch");
return branch;
}

/**
* @brief Get the Git commit hash for the Julia build.
*
* @return A C string containing the Git commit hash.
*/
JL_DLLEXPORT const char *jl_git_commit(void)
{
static const char *commit = NULL;
if (!commit) commit = git_info_string("commit");
return commit;
}

/**
* @brief Convert a Julia value to a tagged value.
*
Expand Down
144 changes: 0 additions & 144 deletions src/jsvm-emscripten/asyncify_setup.js

This file was deleted.

15 changes: 0 additions & 15 deletions src/jsvm-emscripten/task.js

This file was deleted.

7 changes: 0 additions & 7 deletions src/julia.h
Original file line number Diff line number Diff line change
Expand Up @@ -2003,7 +2003,6 @@ JL_DLLEXPORT void JL_NORETURN jl_bounds_error_tuple_int(jl_value_t **v,
JL_DLLEXPORT void JL_NORETURN jl_bounds_error_unboxed_int(void *v, jl_value_t *vt, size_t i);
JL_DLLEXPORT void JL_NORETURN jl_bounds_error_ints(jl_value_t *v JL_MAYBE_UNROOTED,
size_t *idxs, size_t nidxs);
JL_DLLEXPORT void JL_NORETURN jl_eof_error(void);

// Return the exception currently being handled, or `jl_nothing`.
//
Expand Down Expand Up @@ -2173,9 +2172,6 @@ JL_DLLEXPORT jl_value_t *jl_call2(jl_function_t *f JL_MAYBE_UNROOTED, jl_value_t
JL_DLLEXPORT jl_value_t *jl_call3(jl_function_t *f JL_MAYBE_UNROOTED, jl_value_t *a JL_MAYBE_UNROOTED,
jl_value_t *b JL_MAYBE_UNROOTED, jl_value_t *c JL_MAYBE_UNROOTED);

// interfacing with Task runtime
JL_DLLEXPORT void jl_yield(void);

// async signal handling ------------------------------------------------------

JL_DLLEXPORT void jl_install_sigint_handler(void);
Expand Down Expand Up @@ -2409,7 +2405,6 @@ JL_DLLEXPORT int jl_termios_size(void);

// showing and std streams
JL_DLLEXPORT void jl_flush_cstdio(void) JL_NOTSAFEPOINT;
JL_DLLEXPORT jl_value_t *jl_stdout_obj(void) JL_NOTSAFEPOINT;
JL_DLLEXPORT jl_value_t *jl_stderr_obj(void) JL_NOTSAFEPOINT;
JL_DLLEXPORT size_t jl_static_show(JL_STREAM *out, jl_value_t *v) JL_NOTSAFEPOINT;
JL_DLLEXPORT size_t jl_static_show_func_sig(JL_STREAM *s, jl_value_t *type) JL_NOTSAFEPOINT;
Expand Down Expand Up @@ -2510,8 +2505,6 @@ JL_DLLEXPORT extern int jl_ver_minor(void);
JL_DLLEXPORT extern int jl_ver_patch(void);
JL_DLLEXPORT extern int jl_ver_is_release(void);
JL_DLLEXPORT extern const char *jl_ver_string(void);
JL_DLLEXPORT const char *jl_git_branch(void);
JL_DLLEXPORT const char *jl_git_commit(void);

// nullable struct representations
typedef struct {
Expand Down
19 changes: 1 addition & 18 deletions src/julia_threads.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ JL_DLLEXPORT int8_t jl_threadpoolid(int16_t tid) JL_NOTSAFEPOINT;
// JL_HAVE_ASM -- mostly setjmp
// JL_HAVE_ASM && JL_HAVE_UNW_CONTEXT -- libunwind-based
// JL_HAVE_UNW_CONTEXT -- libunwind-based
// JL_HAVE_ASYNCIFY -- task switching based on the binary asyncify transform
// JL_HAVE_UCONTEXT -- posix standard API, requires syscall for resume
// JL_HAVE_SIGALTSTACK -- requires several syscall for start, setjmp for resume

Expand All @@ -45,8 +44,7 @@ typedef struct {
#if !defined(JL_HAVE_UCONTEXT) && \
!defined(JL_HAVE_ASM) && \
!defined(JL_HAVE_UNW_CONTEXT) && \
!defined(JL_HAVE_SIGALTSTACK) && \
!defined(JL_HAVE_ASYNCIFY)
!defined(JL_HAVE_SIGALTSTACK)
#if (defined(_CPU_X86_64_) || defined(_CPU_X86_) || defined(_CPU_AARCH64_) || \
defined(_CPU_ARM_) || defined(_CPU_PPC64_))
#define JL_HAVE_ASM
Expand All @@ -57,8 +55,6 @@ typedef struct {
//#define JL_HAVE_UNW_CONTEXT
//#elif defined(_OS_LINUX_)
//#define JL_HAVE_UNW_CONTEXT
#elif defined(_OS_EMSCRIPTEN_)
#define JL_HAVE_ASYNCIFY
#elif !defined(JL_HAVE_ASM)
#define JL_HAVE_UNW_CONTEXT // optimistically?
#endif
Expand All @@ -67,19 +63,6 @@ typedef struct {
#if (!defined(JL_HAVE_UNW_CONTEXT) && defined(JL_HAVE_ASM)) || defined(JL_HAVE_SIGALTSTACK)
typedef jl_stack_context_t _jl_ucontext_t;
#endif
#if defined(JL_HAVE_ASYNCIFY)
#if defined(_COMPILER_TSAN_ENABLED_)
#error TSAN not currently supported with asyncify
#endif
typedef struct {
// This is the extent of the asyncify stack, but because the top of the
// asyncify stack (stacktop) is also the bottom of the C stack, we can
// reuse stacktop for both. N.B.: This matches the layout of the
// __asyncify_data struct.
void *stackbottom;
void *stacktop;
} _jl_ucontext_t;
#endif
#pragma GCC visibility push(default)
#if defined(JL_HAVE_UNW_CONTEXT)
#define UNW_LOCAL_ONLY
Expand Down
Loading

0 comments on commit f3d6904

Please sign in to comment.