Skip to content

Commit f3d6904

Browse files
authored
less jl_get_global reflection (JuliaLang#53250)
1 parent 9523361 commit f3d6904

12 files changed

+40
-332
lines changed

base/filesystem.jl

+6-2
Original file line numberDiff line numberDiff line change
@@ -195,9 +195,13 @@ end
195195

196196
function read(f::File, ::Type{UInt8})
197197
check_open(f)
198-
ret = ccall(:jl_fs_read_byte, Int32, (OS_HANDLE,), f.handle)
198+
p = Ref{UInt8}()
199+
ret = ccall(:jl_fs_read, Int32, (OS_HANDLE, Ptr{Cvoid}, Csize_t),
200+
f.handle, p, 1)
199201
uv_error("read", ret)
200-
return ret % UInt8
202+
@assert ret <= sizeof(p) == 1
203+
ret < 1 && throw(EOFError())
204+
return p[] % UInt8
201205
end
202206

203207
function read(f::File, ::Type{Char})

src/jl_exported_funcs.inc

-5
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@
112112
XX(jl_enter_handler) \
113113
XX(jl_enter_threaded_region) \
114114
XX(jl_environ) \
115-
XX(jl_eof_error) \
116115
XX(jl_eqtable_get) \
117116
XX(jl_eqtable_pop) \
118117
XX(jl_eqtable_put) \
@@ -239,8 +238,6 @@
239238
XX(jl_method_lookup_by_tt) \
240239
XX(jl_method_lookup) \
241240
XX(jl_gf_invoke_lookup_worlds) \
242-
XX(jl_git_branch) \
243-
XX(jl_git_commit) \
244241
XX(jl_global_event_loop) \
245242
XX(jl_has_empty_intersection) \
246243
XX(jl_has_free_typevars) \
@@ -436,7 +433,6 @@
436433
XX(jl_stderr_obj) \
437434
XX(jl_stderr_stream) \
438435
XX(jl_stdin_stream) \
439-
XX(jl_stdout_obj) \
440436
XX(jl_stdout_stream) \
441437
XX(jl_stored_inline) \
442438
XX(jl_string_ptr) \
@@ -516,7 +512,6 @@
516512
XX(jl_vprintf) \
517513
XX(jl_wakeup_thread) \
518514
XX(jl_write_compiler_output) \
519-
XX(jl_yield) \
520515

521516
#define JL_RUNTIME_EXPORTED_FUNCS_WIN(XX) \
522517
XX(jl_setjmp) \

src/jl_uv.c

-19
Original file line numberDiff line numberDiff line change
@@ -662,25 +662,6 @@ JL_DLLEXPORT int jl_fs_read(uv_os_fd_t handle, char *data, size_t len)
662662
return ret;
663663
}
664664

665-
JL_DLLEXPORT int jl_fs_read_byte(uv_os_fd_t handle)
666-
{
667-
uv_fs_t req;
668-
unsigned char c;
669-
uv_buf_t buf[1];
670-
buf[0].base = (char*)&c;
671-
buf[0].len = 1;
672-
int ret = uv_fs_read(unused_uv_loop_arg, &req, handle, buf, 1, -1, NULL);
673-
uv_fs_req_cleanup(&req);
674-
switch (ret) {
675-
case -1: return ret;
676-
case 0: jl_eof_error();
677-
case 1: return (int)c;
678-
default:
679-
assert(0 && "jl_fs_read_byte: Invalid return value from uv_fs_read");
680-
return -1;
681-
}
682-
}
683-
684665
JL_DLLEXPORT int jl_fs_close(uv_os_fd_t handle)
685666
{
686667
uv_fs_t req;

src/jlapi.c

-49
Original file line numberDiff line numberDiff line change
@@ -437,20 +437,6 @@ JL_DLLEXPORT jl_value_t *jl_call3(jl_function_t *f, jl_value_t *a,
437437
return v;
438438
}
439439

440-
/**
441-
* @brief Yield to the Julia scheduler.
442-
*
443-
* Yields control to the Julia scheduler, allowing other Julia tasks to run.
444-
*/
445-
JL_DLLEXPORT void jl_yield(void)
446-
{
447-
static jl_function_t *yieldfunc = NULL;
448-
if (yieldfunc == NULL)
449-
yieldfunc = (jl_function_t*)jl_get_global(jl_base_module, jl_symbol("yield"));
450-
if (yieldfunc != NULL)
451-
jl_call0(yieldfunc);
452-
}
453-
454440
/**
455441
* @brief Get a field from a Julia object.
456442
*
@@ -619,41 +605,6 @@ JL_DLLEXPORT const char *jl_ver_string(void)
619605
return JULIA_VERSION_STRING;
620606
}
621607

622-
// return char* from String field in Base.GIT_VERSION_INFO
623-
static const char *git_info_string(const char *fld)
624-
{
625-
static jl_value_t *GIT_VERSION_INFO = NULL;
626-
if (!GIT_VERSION_INFO)
627-
GIT_VERSION_INFO = jl_get_global(jl_base_module, jl_symbol("GIT_VERSION_INFO"));
628-
jl_value_t *f = jl_get_field(GIT_VERSION_INFO, fld);
629-
assert(jl_is_string(f));
630-
return jl_string_data(f);
631-
}
632-
633-
/**
634-
* @brief Get the name of the Git branch for the Julia build.
635-
*
636-
* @return A C string containing the name of the Git branch.
637-
*/
638-
JL_DLLEXPORT const char *jl_git_branch(void)
639-
{
640-
static const char *branch = NULL;
641-
if (!branch) branch = git_info_string("branch");
642-
return branch;
643-
}
644-
645-
/**
646-
* @brief Get the Git commit hash for the Julia build.
647-
*
648-
* @return A C string containing the Git commit hash.
649-
*/
650-
JL_DLLEXPORT const char *jl_git_commit(void)
651-
{
652-
static const char *commit = NULL;
653-
if (!commit) commit = git_info_string("commit");
654-
return commit;
655-
}
656-
657608
/**
658609
* @brief Convert a Julia value to a tagged value.
659610
*

src/jsvm-emscripten/asyncify_setup.js

-144
This file was deleted.

src/jsvm-emscripten/task.js

-15
This file was deleted.

src/julia.h

-7
Original file line numberDiff line numberDiff line change
@@ -2003,7 +2003,6 @@ JL_DLLEXPORT void JL_NORETURN jl_bounds_error_tuple_int(jl_value_t **v,
20032003
JL_DLLEXPORT void JL_NORETURN jl_bounds_error_unboxed_int(void *v, jl_value_t *vt, size_t i);
20042004
JL_DLLEXPORT void JL_NORETURN jl_bounds_error_ints(jl_value_t *v JL_MAYBE_UNROOTED,
20052005
size_t *idxs, size_t nidxs);
2006-
JL_DLLEXPORT void JL_NORETURN jl_eof_error(void);
20072006

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

2176-
// interfacing with Task runtime
2177-
JL_DLLEXPORT void jl_yield(void);
2178-
21792175
// async signal handling ------------------------------------------------------
21802176

21812177
JL_DLLEXPORT void jl_install_sigint_handler(void);
@@ -2409,7 +2405,6 @@ JL_DLLEXPORT int jl_termios_size(void);
24092405

24102406
// showing and std streams
24112407
JL_DLLEXPORT void jl_flush_cstdio(void) JL_NOTSAFEPOINT;
2412-
JL_DLLEXPORT jl_value_t *jl_stdout_obj(void) JL_NOTSAFEPOINT;
24132408
JL_DLLEXPORT jl_value_t *jl_stderr_obj(void) JL_NOTSAFEPOINT;
24142409
JL_DLLEXPORT size_t jl_static_show(JL_STREAM *out, jl_value_t *v) JL_NOTSAFEPOINT;
24152410
JL_DLLEXPORT size_t jl_static_show_func_sig(JL_STREAM *s, jl_value_t *type) JL_NOTSAFEPOINT;
@@ -2510,8 +2505,6 @@ JL_DLLEXPORT extern int jl_ver_minor(void);
25102505
JL_DLLEXPORT extern int jl_ver_patch(void);
25112506
JL_DLLEXPORT extern int jl_ver_is_release(void);
25122507
JL_DLLEXPORT extern const char *jl_ver_string(void);
2513-
JL_DLLEXPORT const char *jl_git_branch(void);
2514-
JL_DLLEXPORT const char *jl_git_commit(void);
25152508

25162509
// nullable struct representations
25172510
typedef struct {

src/julia_threads.h

+1-18
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ JL_DLLEXPORT int8_t jl_threadpoolid(int16_t tid) JL_NOTSAFEPOINT;
3030
// JL_HAVE_ASM -- mostly setjmp
3131
// JL_HAVE_ASM && JL_HAVE_UNW_CONTEXT -- libunwind-based
3232
// JL_HAVE_UNW_CONTEXT -- libunwind-based
33-
// JL_HAVE_ASYNCIFY -- task switching based on the binary asyncify transform
3433
// JL_HAVE_UCONTEXT -- posix standard API, requires syscall for resume
3534
// JL_HAVE_SIGALTSTACK -- requires several syscall for start, setjmp for resume
3635

@@ -45,8 +44,7 @@ typedef struct {
4544
#if !defined(JL_HAVE_UCONTEXT) && \
4645
!defined(JL_HAVE_ASM) && \
4746
!defined(JL_HAVE_UNW_CONTEXT) && \
48-
!defined(JL_HAVE_SIGALTSTACK) && \
49-
!defined(JL_HAVE_ASYNCIFY)
47+
!defined(JL_HAVE_SIGALTSTACK)
5048
#if (defined(_CPU_X86_64_) || defined(_CPU_X86_) || defined(_CPU_AARCH64_) || \
5149
defined(_CPU_ARM_) || defined(_CPU_PPC64_))
5250
#define JL_HAVE_ASM
@@ -57,8 +55,6 @@ typedef struct {
5755
//#define JL_HAVE_UNW_CONTEXT
5856
//#elif defined(_OS_LINUX_)
5957
//#define JL_HAVE_UNW_CONTEXT
60-
#elif defined(_OS_EMSCRIPTEN_)
61-
#define JL_HAVE_ASYNCIFY
6258
#elif !defined(JL_HAVE_ASM)
6359
#define JL_HAVE_UNW_CONTEXT // optimistically?
6460
#endif
@@ -67,19 +63,6 @@ typedef struct {
6763
#if (!defined(JL_HAVE_UNW_CONTEXT) && defined(JL_HAVE_ASM)) || defined(JL_HAVE_SIGALTSTACK)
6864
typedef jl_stack_context_t _jl_ucontext_t;
6965
#endif
70-
#if defined(JL_HAVE_ASYNCIFY)
71-
#if defined(_COMPILER_TSAN_ENABLED_)
72-
#error TSAN not currently supported with asyncify
73-
#endif
74-
typedef struct {
75-
// This is the extent of the asyncify stack, but because the top of the
76-
// asyncify stack (stacktop) is also the bottom of the C stack, we can
77-
// reuse stacktop for both. N.B.: This matches the layout of the
78-
// __asyncify_data struct.
79-
void *stackbottom;
80-
void *stacktop;
81-
} _jl_ucontext_t;
82-
#endif
8366
#pragma GCC visibility push(default)
8467
#if defined(JL_HAVE_UNW_CONTEXT)
8568
#define UNW_LOCAL_ONLY

0 commit comments

Comments
 (0)