From 5d6c2cee43537791f740f019310676774bf9fb17 Mon Sep 17 00:00:00 2001 From: KDr2 Date: Fri, 18 Jun 2021 06:09:59 +0000 Subject: [PATCH 01/17] use memory layout info to copy task --- Project.toml | 5 +- src/Libtask.jl | 10 +++ src/ctask.jl | 61 +++++++++++++- src/memlayout/linux-x64-v1_3_1.jl | 26 ++++++ src/memlayout/linux-x64-v1_4_2.jl | 26 ++++++ src/memlayout/linux-x64-v1_5_3.jl | 26 ++++++ src/memlayout/linux-x64-v1_5_4.jl | 25 ++++++ src/memlayout/linux-x64-v1_6_1.jl | 24 ++++++ src/memlayout/linux-x64-v1_8_0.jl | 27 +++++++ src/memlayout/main.jl | 10 +++ src/memlayout/memlayout.cpp | 127 ++++++++++++++++++++++++++++++ 11 files changed, 363 insertions(+), 4 deletions(-) create mode 100644 src/memlayout/linux-x64-v1_3_1.jl create mode 100644 src/memlayout/linux-x64-v1_4_2.jl create mode 100644 src/memlayout/linux-x64-v1_5_3.jl create mode 100644 src/memlayout/linux-x64-v1_5_4.jl create mode 100644 src/memlayout/linux-x64-v1_6_1.jl create mode 100644 src/memlayout/linux-x64-v1_8_0.jl create mode 100644 src/memlayout/main.jl create mode 100644 src/memlayout/memlayout.cpp diff --git a/Project.toml b/Project.toml index 75bccfc5..6d6f1fc6 100644 --- a/Project.toml +++ b/Project.toml @@ -6,17 +6,18 @@ repo = "https://github.com/TuringLang/Libtask.jl.git" version = "0.5.3" [deps] +Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb" Libtask_jll = "3ae2931a-708c-5973-9c38-ccf7496fb450" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" [compat] -Libtask_jll = "0.4" +Libtask_jll = "0.5" julia = "1.3" [extras] -Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf" +Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [targets] test = ["Test", "BenchmarkTools"] diff --git a/src/Libtask.jl b/src/Libtask.jl index e647e65d..22897916 100644 --- a/src/Libtask.jl +++ b/src/Libtask.jl @@ -1,9 +1,19 @@ module Libtask +using Libdl using Libtask_jll export CTask, consume, produce, TArray, tzeros, tfill, TRef +function __init__() + @static if VERSION < v"1.6.0" + push!(Libdl.DL_LOAD_PATH, + Libtask_jll.get_libtask_julia_path() |> dirname) + Libdl.dlopen(Libtask_jll.libtask_julia_path) + end +end + +include("memlayout/main.jl") include("ctask.jl") include("tarray.jl") include("tref.jl") diff --git a/src/ctask.jl b/src/ctask.jl index 8665c7b5..d7fa01d9 100644 --- a/src/ctask.jl +++ b/src/ctask.jl @@ -49,7 +49,23 @@ function enable_stack_copying(t::Task) if istaskfailed(t) error("only runnable or finished tasks' stack can be copied.") end - return ccall((:jl_enable_stack_copying, libtask_julia), Any, (Any,), t)::Task + # return ccall((:jl_enable_stack_copying, libtask_julia), Any, (Any,), t)::Task + copy_stack = ccall((:jl_getfield_int32_t, libtask_julia), + Int32, (Any, Csize_t), t, TASK_OFFSETS[:copy_stack]) + if copy_stack == 0 + ccall((:jl_setfield_int32_t, libtask_julia), + Any, (Any, Csize_t, Int32), + t, TASK_OFFSETS[:copy_stack], 1) + + ccall((:jl_setfield_size_t, libtask_julia), + Any, (Any, Csize_t, Csize_t), + t, TASK_OFFSETS[:bufsz], 0) + + ccall((:jl_reset_task_ctx, libtask_julia), + Any, (Any, Csize_t, Csize_t, Csize_t), + t, TASK_OFFSETS[:ctx], TASK_OFFSETS[:sizeof_ctx], TASK_OFFSETS[:tls_base_context]) + end + return t end """ @@ -101,7 +117,48 @@ function Base.copy(ctask::CTask) error("only runnable or finished tasks can be copied.") end - newtask = ccall((:jl_clone_task, libtask_julia), Any, (Any,), task)::Task + # memory copy + # newtask = ccall((:jl_clone_task, libtask_julia), Any, (Any,), task)::Task + newtask = ccall((:jl_clone_task_opaque, libtask_julia), + Any, (Any, Csize_t), task, TASK_OFFSETS[:END])::Task + haskey(TASK_OFFSETS, :exception) && ccall( + (:jl_setfield_nothing, libtask_julia), + Any, (Any, Csize_t), newtask, TASK_OFFSETS[:exception]) + haskey(TASK_OFFSETS, :backtrace) && ccall( + (:jl_setfield_nothing, libtask_julia), + Any, (Any, Csize_t), newtask, TASK_OFFSETS[:backtrace]) + haskey(TASK_OFFSETS, :excstack) && ccall( + (:jl_setfield_null, libtask_julia), + Any, (Any, Csize_t), newtask, TASK_OFFSETS[:excstack]) + haskey(TASK_OFFSETS, :tls) && ccall( + (:jl_setfield_nothing, libtask_julia), + Any, (Any, Csize_t), newtask, TASK_OFFSETS[:tls]) + haskey(TASK_OFFSETS, :result) && ccall( + (:jl_setfield_nothing, libtask_julia), + Any, (Any, Csize_t), newtask, TASK_OFFSETS[:result]) + haskey(TASK_OFFSETS, :donenotify) && ccall( + (:jl_setfield_nothing, libtask_julia), + Any, (Any, Csize_t), newtask, TASK_OFFSETS[:donenotify]) + if haskey(TASK_OFFSETS, :stkbuf) && haskey(TASK_OFFSETS, :bufsz) + old_stkbuf = ccall((:jl_getfield_ptr, libtask_julia), + Ptr{Cvoid}, (Any, Csize_t), task, TASK_OFFSETS[:stkbuf]) + if old_stkbuf != C_NULL + ccall((:jl_setfield_size_t, libtask_julia), + Any, (Any, Csize_t, Csize_t), + task, TASK_OFFSETS[:bufsz], 0) + else + ccall((:jl_setfield_null, libtask_julia), + Any, (Any, Csize_t), + newtask, TASK_OFFSETS[:stkbuf]) + end + ccall((:jl_setfield_size_t, libtask_julia), + Any, (Any, Csize_t, Csize_t), + newtask, TASK_OFFSETS[:bufsz], 0) + end + haskey(TASK_OFFSETS, :locks) && ccall( + (:jl_memset_0, libtask_julia), + Cvoid, (Any, Csize_t, Csize_t), newtask, TASK_OFFSETS[:locks], TASK_OFFSETS[:END]) + # memory copy done task.storage[:n_copies] = 1 + n_copies(task) newtask.storage = copy(task.storage) diff --git a/src/memlayout/linux-x64-v1_3_1.jl b/src/memlayout/linux-x64-v1_3_1.jl new file mode 100644 index 00000000..51d357e1 --- /dev/null +++ b/src/memlayout/linux-x64-v1_3_1.jl @@ -0,0 +1,26 @@ +ALL_TASK_OFFSETS[("linux-x64", v"1.3.1")] = Dict( + :END => 616, + :backtrace => 56, + :bufsz => 296, + :copy_stack => 304, + :ctx => 88, + :donenotify => 32, + :eh => 312, + :exception => 48, + :excstack => 328, + :gcstack => 320, + :locks => 352, + :logstate => 64, + :next => 0, + :prio => 346, + :queue => 8, + :result => 40, + :start => 72, + :state => 24, + :sticky => 80, + :stkbuf => 288, + :tid => 344, + :timing_stack => 608, + :tls => 16, + :world_age => 336, +) diff --git a/src/memlayout/linux-x64-v1_4_2.jl b/src/memlayout/linux-x64-v1_4_2.jl new file mode 100644 index 00000000..cb1182fb --- /dev/null +++ b/src/memlayout/linux-x64-v1_4_2.jl @@ -0,0 +1,26 @@ +ALL_TASK_OFFSETS[("linux-x64", v"1.4.2")] = Dict( + :END => 616, + :backtrace => 56, + :bufsz => 296, + :copy_stack => 304, + :ctx => 88, + :donenotify => 32, + :eh => 312, + :exception => 48, + :excstack => 328, + :gcstack => 320, + :locks => 352, + :logstate => 64, + :next => 0, + :prio => 346, + :queue => 8, + :result => 40, + :start => 72, + :state => 24, + :sticky => 80, + :stkbuf => 288, + :tid => 344, + :timing_stack => 608, + :tls => 16, + :world_age => 336, +) diff --git a/src/memlayout/linux-x64-v1_5_3.jl b/src/memlayout/linux-x64-v1_5_3.jl new file mode 100644 index 00000000..14c8a9e4 --- /dev/null +++ b/src/memlayout/linux-x64-v1_5_3.jl @@ -0,0 +1,26 @@ +ALL_TASK_OFFSETS[("linux-x64", v"1.5.3")] = Dict( + :END => 616, + :backtrace => 56, + :bufsz => 296, + :copy_stack => 304, + :ctx => 88, + :donenotify => 32, + :eh => 312, + :exception => 48, + :excstack => 328, + :gcstack => 320, + :locks => 352, + :logstate => 64, + :next => 0, + :prio => 346, + :queue => 8, + :result => 40, + :start => 72, + :state => 24, + :sticky => 80, + :stkbuf => 288, + :tid => 344, + :timing_stack => 608, + :tls => 16, + :world_age => 336, +) diff --git a/src/memlayout/linux-x64-v1_5_4.jl b/src/memlayout/linux-x64-v1_5_4.jl new file mode 100644 index 00000000..39440054 --- /dev/null +++ b/src/memlayout/linux-x64-v1_5_4.jl @@ -0,0 +1,25 @@ +ALL_TASK_OFFSETS[("linux-x64", v"1.5.4")] = Dict( + :END => 608, + :backtrace => 56, + :bufsz => 296, + :copy_stack => 304, + :ctx => 88, + :donenotify => 32, + :eh => 312, + :exception => 48, + :excstack => 328, + :gcstack => 320, + :locks => 344, + :logstate => 64, + :next => 0, + :prio => 338, + :queue => 8, + :result => 40, + :start => 72, + :state => 24, + :sticky => 80, + :stkbuf => 288, + :tid => 336, + :timing_stack => 600, + :tls => 16, +) diff --git a/src/memlayout/linux-x64-v1_6_1.jl b/src/memlayout/linux-x64-v1_6_1.jl new file mode 100644 index 00000000..d9cb73c9 --- /dev/null +++ b/src/memlayout/linux-x64-v1_6_1.jl @@ -0,0 +1,24 @@ +ALL_TASK_OFFSETS[("linux-x64", v"1.6.1")] = Dict( + :END => 312, + :_isexception => 58, + :_state => 56, + :bufsz => 288, + :copy_stack => 296, + :ctx => 80, + :donenotify => 24, + :eh => 72, + :excstack => 64, + :gcstack => 304, + :logstate => 40, + :next => 0, + :prio => 62, + :queue => 8, + :result => 32, + :sizeof_ctx => 200, + :start => 48, + :sticky => 57, + :stkbuf => 280, + :tid => 60, + :tls => 16, + :tls_base_context => 6656, +) diff --git a/src/memlayout/linux-x64-v1_8_0.jl b/src/memlayout/linux-x64-v1_8_0.jl new file mode 100644 index 00000000..1f4dd8e8 --- /dev/null +++ b/src/memlayout/linux-x64-v1_8_0.jl @@ -0,0 +1,27 @@ +ALL_TASK_OFFSETS[("linux-x64", v"1.8.0")] = Dict( + :END => 368, + :_isexception => 58, + :_state => 56, + :bufsz => 352, + :ctx => 144, + :donenotify => 24, + :eh => 136, + :excstack => 128, + :gcstack => 96, + :logstate => 40, + :next => 0, + :prio => 122, + :ptls => 112, + :queue => 8, + :result => 32, + :rngState0 => 64, + :rngState1 => 72, + :rngState2 => 80, + :rngState3 => 88, + :start => 48, + :sticky => 57, + :stkbuf => 344, + :tid => 120, + :tls => 16, + :world_age => 104, +) diff --git a/src/memlayout/main.jl b/src/memlayout/main.jl new file mode 100644 index 00000000..fa56ffff --- /dev/null +++ b/src/memlayout/main.jl @@ -0,0 +1,10 @@ +const ALL_TASK_OFFSETS = Dict{Tuple{String, VersionNumber}, Dict{Symbol, Int}}() + +include("linux-x64-v1_3_1.jl") +include("linux-x64-v1_4_2.jl") +include("linux-x64-v1_5_3.jl") +include("linux-x64-v1_5_4.jl") +include("linux-x64-v1_6_1.jl") +include("linux-x64-v1_8_0.jl") + +const TASK_OFFSETS = ALL_TASK_OFFSETS[("linux-x64", v"1.6.1")] diff --git a/src/memlayout/memlayout.cpp b/src/memlayout/memlayout.cpp new file mode 100644 index 00000000..4951f2ec --- /dev/null +++ b/src/memlayout/memlayout.cpp @@ -0,0 +1,127 @@ +#include +#include +#include +#include + +#include + +#include "julia.h" + +std::string jl_ver(std::string sep=".") { + std::ostringstream oss; + oss << JULIA_VERSION_MAJOR << sep + << JULIA_VERSION_MINOR << sep + << JULIA_VERSION_PATCH; + return oss.str(); +} + +std::string platform() { +#ifdef _WIN32 +#ifdef _WIN64 + return "win-x64"; +#endif + return "win-x86"; +#endif +#ifdef __APPLE__ + return "darwin-x64"; +#endif +#ifdef __linux__ +#ifdef __x86_64 + return "linux-x64"; +#else + return "linux-x86"; +#endif +#endif +} + +std::map task_field_offsets() { + std::map data; + +#define field_info(f) data[#f] = offsetof(jl_task_t, f) + + field_info(next); // 131 142 153 154 160 170 + field_info(queue); // 131 142 153 154 160 170 + field_info(tls); // 131 142 153 154 160 170 + field_info(donenotify); // 131 142 153 154 160 170 + field_info(result); // 131 142 153 154 160 170 + +#if JULIA_VERSION_MAJOR == 1 && JULIA_VERSION_MINOR < 6 + field_info(state); // 131 142 153 154 + field_info(exception); // 131 142 153 154 + field_info(backtrace); // 131 142 153 154 +#endif + + field_info(logstate); // 131 142 153 154 160 170 + field_info(start); // 131 142 153 154 160 170 + field_info(sticky); // 131 142 153 154 160 170 + +#if JULIA_VERSION_MAJOR == 1 && JULIA_VERSION_MINOR > 5 + field_info(_state); // 160 170 + field_info(_isexception); // 160 170 +#endif + +#if JULIA_VERSION_MAJOR == 1 && JULIA_VERSION_MINOR > 6 + field_info(rngState0); // 170 + field_info(rngState1); // 170 + field_info(rngState2); // 170 + field_info(rngState3); // 170 +#endif + + // hidden state + field_info(gcstack); // 131 142 153 154 160 170 + +#if JULIA_VERSION_MAJOR == 1 && \ + (JULIA_VERSION_MINOR > 6 || JULIA_VERSION_MINOR < 5 || \ + (JULIA_VERSION_MINOR == 5 && JULIA_VERSION_PATCH < 4)) + field_info(world_age); // 131 142 153 170 +#endif + +#if JULIA_VERSION_MAJOR == 1 && JULIA_VERSION_MINOR > 6 + field_info(ptls); // 170 +#endif + field_info(tid); // 131 142 153 154 160 170 + field_info(prio); // 131 142 153 154 160 170 + field_info(excstack); // 131 142 153 154 160 170 + field_info(eh); // 131 142 153 154 160 170 + field_info(ctx); // 131 142 153 154 160 170 + +#if JULIA_VERSION_MAJOR == 1 && JULIA_VERSION_MINOR < 6 + field_info(locks); // 131 142 153 154 + field_info(timing_stack); // 131 142 153 154 +#endif + // field_info(copy_stack_ctx); + +#if defined(JL_TSAN_ENABLED) + field_info(tsan_state); // 170 +#endif + + field_info(stkbuf); // 131 142 153 154 160 170 + field_info(bufsz); // 131 142 153 154 160 170 + // field_info(copy_stack); + // field_info(started); + +#undef field_info + data["copy_stack"] = offsetof(jl_task_t, bufsz) + sizeof(size_t); + data["sizeof_ctx"] = sizeof(((jl_task_t*)0)->ctx); + data["tls_base_context"] = offsetof(struct _jl_tls_states_t, base_ctx); + return data; +} + +int main() { + std::ofstream ofs(platform() +"-v" + jl_ver("_") + ".jl", std::ofstream::out); + + ofs << "ALL_TASK_OFFSETS[(" + << '"' << platform() << '"' << ", " + << "v\"" << jl_ver() <<"\"" + <<")] = Dict(\n"; + ofs << " :END => " << sizeof(jl_task_t) << ",\n"; + + std::map data = task_field_offsets(); + for(auto kv: data) { + ofs << " :" << kv.first << " => " << kv.second << ",\n"; + } + ofs << ")\n"; + + ofs.close(); + return 0; +} From eff26b11bf61da7113446abb24e4a434d4e6ff57 Mon Sep 17 00:00:00 2001 From: KDr2 Date: Mon, 21 Jun 2021 08:19:45 +0000 Subject: [PATCH 02/17] offset selection --- src/ctask.jl | 63 +++++---------- ...x-x64-v1_3_1.jl => linux-x86_64-v1_3_1.jl} | 4 +- ...x-x64-v1_4_2.jl => linux-x86_64-v1_4_2.jl} | 4 +- ...x-x64-v1_5_3.jl => linux-x86_64-v1_5_3.jl} | 4 +- ...x-x64-v1_5_4.jl => linux-x86_64-v1_5_4.jl} | 4 +- ...x-x64-v1_6_1.jl => linux-x86_64-v1_6_1.jl} | 2 +- ...x-x64-v1_8_0.jl => linux-x86_64-v1_8_0.jl} | 5 +- src/memlayout/main.jl | 80 +++++++++++++++++-- src/memlayout/memlayout.cpp | 8 +- 9 files changed, 112 insertions(+), 62 deletions(-) rename src/memlayout/{linux-x64-v1_3_1.jl => linux-x86_64-v1_3_1.jl} (81%) rename src/memlayout/{linux-x64-v1_4_2.jl => linux-x86_64-v1_4_2.jl} (81%) rename src/memlayout/{linux-x64-v1_5_3.jl => linux-x86_64-v1_5_3.jl} (81%) rename src/memlayout/{linux-x64-v1_5_4.jl => linux-x86_64-v1_5_4.jl} (80%) rename src/memlayout/{linux-x64-v1_6_1.jl => linux-x86_64-v1_6_1.jl} (89%) rename src/memlayout/{linux-x64-v1_8_0.jl => linux-x86_64-v1_8_0.jl} (78%) diff --git a/src/ctask.jl b/src/ctask.jl index d7fa01d9..5d22ba95 100644 --- a/src/ctask.jl +++ b/src/ctask.jl @@ -49,21 +49,16 @@ function enable_stack_copying(t::Task) if istaskfailed(t) error("only runnable or finished tasks' stack can be copied.") end - # return ccall((:jl_enable_stack_copying, libtask_julia), Any, (Any,), t)::Task - copy_stack = ccall((:jl_getfield_int32_t, libtask_julia), - Int32, (Any, Csize_t), t, TASK_OFFSETS[:copy_stack]) + # return ccall((:jl_enable_stack_copying, libtask_julia), + # Any, (Any,), t)::Task + copy_stack = getfield_int32(t, :copy_stack) if copy_stack == 0 - ccall((:jl_setfield_int32_t, libtask_julia), - Any, (Any, Csize_t, Int32), - t, TASK_OFFSETS[:copy_stack], 1) - - ccall((:jl_setfield_size_t, libtask_julia), - Any, (Any, Csize_t, Csize_t), - t, TASK_OFFSETS[:bufsz], 0) - + setfield_int32(t, :copy_stack, 1) + setfield_size(t, :bufsz, 0) ccall((:jl_reset_task_ctx, libtask_julia), Any, (Any, Csize_t, Csize_t, Csize_t), - t, TASK_OFFSETS[:ctx], TASK_OFFSETS[:sizeof_ctx], TASK_OFFSETS[:tls_base_context]) + t, TASK_OFFSETS[:ctx], TASK_OFFSETS[:sizeof_ctx], + TASK_OFFSETS[:tls_base_context]) end return t end @@ -121,43 +116,23 @@ function Base.copy(ctask::CTask) # newtask = ccall((:jl_clone_task, libtask_julia), Any, (Any,), task)::Task newtask = ccall((:jl_clone_task_opaque, libtask_julia), Any, (Any, Csize_t), task, TASK_OFFSETS[:END])::Task - haskey(TASK_OFFSETS, :exception) && ccall( - (:jl_setfield_nothing, libtask_julia), - Any, (Any, Csize_t), newtask, TASK_OFFSETS[:exception]) - haskey(TASK_OFFSETS, :backtrace) && ccall( - (:jl_setfield_nothing, libtask_julia), - Any, (Any, Csize_t), newtask, TASK_OFFSETS[:backtrace]) - haskey(TASK_OFFSETS, :excstack) && ccall( - (:jl_setfield_null, libtask_julia), - Any, (Any, Csize_t), newtask, TASK_OFFSETS[:excstack]) - haskey(TASK_OFFSETS, :tls) && ccall( - (:jl_setfield_nothing, libtask_julia), - Any, (Any, Csize_t), newtask, TASK_OFFSETS[:tls]) - haskey(TASK_OFFSETS, :result) && ccall( - (:jl_setfield_nothing, libtask_julia), - Any, (Any, Csize_t), newtask, TASK_OFFSETS[:result]) - haskey(TASK_OFFSETS, :donenotify) && ccall( - (:jl_setfield_nothing, libtask_julia), - Any, (Any, Csize_t), newtask, TASK_OFFSETS[:donenotify]) + setfield_nothing(newtask, :exception) + setfield_nothing(newtask, :backtrace) + setfield_null(newtask, :excstack) + setfield_nothing(newtask, :tls) + setfield_nothing(newtask, :result) + setfield_nothing(newtask, :donenotify) + if haskey(TASK_OFFSETS, :stkbuf) && haskey(TASK_OFFSETS, :bufsz) - old_stkbuf = ccall((:jl_getfield_ptr, libtask_julia), - Ptr{Cvoid}, (Any, Csize_t), task, TASK_OFFSETS[:stkbuf]) + old_stkbuf = getfield_ptr(task, :stkbuf) if old_stkbuf != C_NULL - ccall((:jl_setfield_size_t, libtask_julia), - Any, (Any, Csize_t, Csize_t), - task, TASK_OFFSETS[:bufsz], 0) + setfield_size(task, :bufsz, 0) else - ccall((:jl_setfield_null, libtask_julia), - Any, (Any, Csize_t), - newtask, TASK_OFFSETS[:stkbuf]) + setfield_null(newtask, :stkbuf) end - ccall((:jl_setfield_size_t, libtask_julia), - Any, (Any, Csize_t, Csize_t), - newtask, TASK_OFFSETS[:bufsz], 0) + setfield_size(newtask, :bufsz, 0) end - haskey(TASK_OFFSETS, :locks) && ccall( - (:jl_memset_0, libtask_julia), - Cvoid, (Any, Csize_t, Csize_t), newtask, TASK_OFFSETS[:locks], TASK_OFFSETS[:END]) + memset_0(newtask, :locks; end_field=:END) # memory copy done task.storage[:n_copies] = 1 + n_copies(task) diff --git a/src/memlayout/linux-x64-v1_3_1.jl b/src/memlayout/linux-x86_64-v1_3_1.jl similarity index 81% rename from src/memlayout/linux-x64-v1_3_1.jl rename to src/memlayout/linux-x86_64-v1_3_1.jl index 51d357e1..cca19241 100644 --- a/src/memlayout/linux-x64-v1_3_1.jl +++ b/src/memlayout/linux-x86_64-v1_3_1.jl @@ -1,4 +1,4 @@ -ALL_TASK_OFFSETS[("linux-x64", v"1.3.1")] = Dict( +ALL_TASK_OFFSETS[("linux-x86_64", v"1.3.1")] = Dict( :END => 616, :backtrace => 56, :bufsz => 296, @@ -15,6 +15,7 @@ ALL_TASK_OFFSETS[("linux-x64", v"1.3.1")] = Dict( :prio => 346, :queue => 8, :result => 40, + :sizeof_ctx => 200, :start => 72, :state => 24, :sticky => 80, @@ -22,5 +23,6 @@ ALL_TASK_OFFSETS[("linux-x64", v"1.3.1")] = Dict( :tid => 344, :timing_stack => 608, :tls => 16, + :tls_base_context => 6640, :world_age => 336, ) diff --git a/src/memlayout/linux-x64-v1_4_2.jl b/src/memlayout/linux-x86_64-v1_4_2.jl similarity index 81% rename from src/memlayout/linux-x64-v1_4_2.jl rename to src/memlayout/linux-x86_64-v1_4_2.jl index cb1182fb..6a1cc083 100644 --- a/src/memlayout/linux-x64-v1_4_2.jl +++ b/src/memlayout/linux-x86_64-v1_4_2.jl @@ -1,4 +1,4 @@ -ALL_TASK_OFFSETS[("linux-x64", v"1.4.2")] = Dict( +ALL_TASK_OFFSETS[("linux-x86_64", v"1.4.2")] = Dict( :END => 616, :backtrace => 56, :bufsz => 296, @@ -15,6 +15,7 @@ ALL_TASK_OFFSETS[("linux-x64", v"1.4.2")] = Dict( :prio => 346, :queue => 8, :result => 40, + :sizeof_ctx => 200, :start => 72, :state => 24, :sticky => 80, @@ -22,5 +23,6 @@ ALL_TASK_OFFSETS[("linux-x64", v"1.4.2")] = Dict( :tid => 344, :timing_stack => 608, :tls => 16, + :tls_base_context => 6640, :world_age => 336, ) diff --git a/src/memlayout/linux-x64-v1_5_3.jl b/src/memlayout/linux-x86_64-v1_5_3.jl similarity index 81% rename from src/memlayout/linux-x64-v1_5_3.jl rename to src/memlayout/linux-x86_64-v1_5_3.jl index 14c8a9e4..2e92d6d7 100644 --- a/src/memlayout/linux-x64-v1_5_3.jl +++ b/src/memlayout/linux-x86_64-v1_5_3.jl @@ -1,4 +1,4 @@ -ALL_TASK_OFFSETS[("linux-x64", v"1.5.3")] = Dict( +ALL_TASK_OFFSETS[("linux-x86_64", v"1.5.3")] = Dict( :END => 616, :backtrace => 56, :bufsz => 296, @@ -15,6 +15,7 @@ ALL_TASK_OFFSETS[("linux-x64", v"1.5.3")] = Dict( :prio => 346, :queue => 8, :result => 40, + :sizeof_ctx => 200, :start => 72, :state => 24, :sticky => 80, @@ -22,5 +23,6 @@ ALL_TASK_OFFSETS[("linux-x64", v"1.5.3")] = Dict( :tid => 344, :timing_stack => 608, :tls => 16, + :tls_base_context => 6648, :world_age => 336, ) diff --git a/src/memlayout/linux-x64-v1_5_4.jl b/src/memlayout/linux-x86_64-v1_5_4.jl similarity index 80% rename from src/memlayout/linux-x64-v1_5_4.jl rename to src/memlayout/linux-x86_64-v1_5_4.jl index 39440054..505955d0 100644 --- a/src/memlayout/linux-x64-v1_5_4.jl +++ b/src/memlayout/linux-x86_64-v1_5_4.jl @@ -1,4 +1,4 @@ -ALL_TASK_OFFSETS[("linux-x64", v"1.5.4")] = Dict( +ALL_TASK_OFFSETS[("linux-x86_64", v"1.5.4")] = Dict( :END => 608, :backtrace => 56, :bufsz => 296, @@ -15,6 +15,7 @@ ALL_TASK_OFFSETS[("linux-x64", v"1.5.4")] = Dict( :prio => 338, :queue => 8, :result => 40, + :sizeof_ctx => 200, :start => 72, :state => 24, :sticky => 80, @@ -22,4 +23,5 @@ ALL_TASK_OFFSETS[("linux-x64", v"1.5.4")] = Dict( :tid => 336, :timing_stack => 600, :tls => 16, + :tls_base_context => 6648, ) diff --git a/src/memlayout/linux-x64-v1_6_1.jl b/src/memlayout/linux-x86_64-v1_6_1.jl similarity index 89% rename from src/memlayout/linux-x64-v1_6_1.jl rename to src/memlayout/linux-x86_64-v1_6_1.jl index d9cb73c9..adbe2774 100644 --- a/src/memlayout/linux-x64-v1_6_1.jl +++ b/src/memlayout/linux-x86_64-v1_6_1.jl @@ -1,4 +1,4 @@ -ALL_TASK_OFFSETS[("linux-x64", v"1.6.1")] = Dict( +ALL_TASK_OFFSETS[("linux-x86_64", v"1.6.1")] = Dict( :END => 312, :_isexception => 58, :_state => 56, diff --git a/src/memlayout/linux-x64-v1_8_0.jl b/src/memlayout/linux-x86_64-v1_8_0.jl similarity index 78% rename from src/memlayout/linux-x64-v1_8_0.jl rename to src/memlayout/linux-x86_64-v1_8_0.jl index 1f4dd8e8..6b2a97ce 100644 --- a/src/memlayout/linux-x64-v1_8_0.jl +++ b/src/memlayout/linux-x86_64-v1_8_0.jl @@ -1,8 +1,9 @@ -ALL_TASK_OFFSETS[("linux-x64", v"1.8.0")] = Dict( +ALL_TASK_OFFSETS[("linux-x86_64", v"1.8.0")] = Dict( :END => 368, :_isexception => 58, :_state => 56, :bufsz => 352, + :copy_stack => 360, :ctx => 144, :donenotify => 24, :eh => 136, @@ -18,10 +19,12 @@ ALL_TASK_OFFSETS[("linux-x64", v"1.8.0")] = Dict( :rngState1 => 72, :rngState2 => 80, :rngState3 => 88, + :sizeof_ctx => 200, :start => 48, :sticky => 57, :stkbuf => 344, :tid => 120, :tls => 16, + :tls_base_context => 6656, :world_age => 104, ) diff --git a/src/memlayout/main.jl b/src/memlayout/main.jl index fa56ffff..10f64df5 100644 --- a/src/memlayout/main.jl +++ b/src/memlayout/main.jl @@ -1,10 +1,74 @@ -const ALL_TASK_OFFSETS = Dict{Tuple{String, VersionNumber}, Dict{Symbol, Int}}() +const ALL_TASK_OFFSETS = + Dict{Tuple{String, VersionNumber}, Dict{Symbol, Int}}() -include("linux-x64-v1_3_1.jl") -include("linux-x64-v1_4_2.jl") -include("linux-x64-v1_5_3.jl") -include("linux-x64-v1_5_4.jl") -include("linux-x64-v1_6_1.jl") -include("linux-x64-v1_8_0.jl") -const TASK_OFFSETS = ALL_TASK_OFFSETS[("linux-x64", v"1.6.1")] +include("linux-x86_64-v1_3_1.jl") +include("linux-x86_64-v1_4_2.jl") +include("linux-x86_64-v1_5_3.jl") +include("linux-x86_64-v1_5_4.jl") +include("linux-x86_64-v1_6_1.jl") +include("linux-x86_64-v1_8_0.jl") + +const PLATFORM = @static if Sys.islinux() + "linux-" * string(Sys.ARCH) +elseif Sys.iswindows() + "windows-" * string(Sys.ARCH) +elseif Sys.isapple() + "darwin-" * string(Sys.ARCH) +end + +function find_offsets() + candi = [v for (p, v) in keys(ALL_TASK_OFFSETS) if p == PLATFORM] + sort!(candi) + candi = [v for v in candi if v <= VERSION] + isempty(candi) && error("No suitable offsets") + ALL_TASK_OFFSETS[(PLATFORM, candi[end])] +end + +const TASK_OFFSETS = find_offsets() + +## utilities + +# getter +function getfield_ptr(task, field) + ccall((:jl_getfield_ptr, libtask_julia), + Ptr{Cvoid}, (Any, Csize_t), + task, TASK_OFFSETS[field]) +end + +function getfield_int32(task, field) + ccall((:jl_getfield_int32_t, libtask_julia), + Int32, (Any, Csize_t), task, TASK_OFFSETS[field]) +end + +# setter +function setfield_nothing(task, field) + haskey(TASK_OFFSETS, field) && ccall( + (:jl_setfield_nothing, libtask_julia), + Any, (Any, Csize_t), task, TASK_OFFSETS[field]) +end + +function setfield_null(task, field) + haskey(TASK_OFFSETS, field) && ccall( + (:jl_setfield_null, libtask_julia), + Any, (Any, Csize_t), task, TASK_OFFSETS[field]) +end + +function memset_0(task, offset_field; end_field=:END) + haskey(TASK_OFFSETS, offset_field) && ccall( + (:jl_memset_0, libtask_julia), + Cvoid, (Any, Csize_t, Csize_t), + task, TASK_OFFSETS[offset_field], TASK_OFFSETS[end_field]) +end + +function setfield_size(task, field, val) + ccall((:jl_setfield_size_t, libtask_julia), + Any, (Any, Csize_t, Csize_t), + task, TASK_OFFSETS[field], val) +end + +function setfield_int32(task, field, val) + ccall((:jl_setfield_int32_t, libtask_julia), + Any, (Any, Csize_t, Int32), + task, TASK_OFFSETS[field], val) +end diff --git a/src/memlayout/memlayout.cpp b/src/memlayout/memlayout.cpp index 4951f2ec..f511916b 100644 --- a/src/memlayout/memlayout.cpp +++ b/src/memlayout/memlayout.cpp @@ -18,16 +18,16 @@ std::string jl_ver(std::string sep=".") { std::string platform() { #ifdef _WIN32 #ifdef _WIN64 - return "win-x64"; + return "windows-x86_64"; #endif - return "win-x86"; + return "windows-x86"; #endif #ifdef __APPLE__ - return "darwin-x64"; + return "darwin-x86_64"; #endif #ifdef __linux__ #ifdef __x86_64 - return "linux-x64"; + return "linux-x86_64"; #else return "linux-x86"; #endif From fe5fcccdbf57afce69fac25075620a3baba873cd Mon Sep 17 00:00:00 2001 From: KDr2 Date: Tue, 22 Jun 2021 15:36:23 +0000 Subject: [PATCH 03/17] upgrade Libtask_jll to v0.5.1 --- Project.toml | 2 +- src/ctask.jl | 32 +++++++++++++++++--------------- src/memlayout/main.jl | 27 ++++++++++++++------------- src/memlayout/memlayout.cpp | 2 ++ 4 files changed, 34 insertions(+), 29 deletions(-) diff --git a/Project.toml b/Project.toml index 6d6f1fc6..9ee5aa26 100644 --- a/Project.toml +++ b/Project.toml @@ -12,7 +12,7 @@ LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" [compat] -Libtask_jll = "0.5" +Libtask_jll = "0.5.1" julia = "1.3" [extras] diff --git a/src/ctask.jl b/src/ctask.jl index 5d22ba95..a3e6a754 100644 --- a/src/ctask.jl +++ b/src/ctask.jl @@ -51,12 +51,12 @@ function enable_stack_copying(t::Task) end # return ccall((:jl_enable_stack_copying, libtask_julia), # Any, (Any,), t)::Task - copy_stack = getfield_int32(t, :copy_stack) + copy_stack = internal_getfield(t, :copy_stack, Int32) if copy_stack == 0 - setfield_int32(t, :copy_stack, 1) - setfield_size(t, :bufsz, 0) + internal_setfield(t, :copy_stack, Int32(1)) + internal_setfield(t, :bufsz, Csize_t(0)) ccall((:jl_reset_task_ctx, libtask_julia), - Any, (Any, Csize_t, Csize_t, Csize_t), + Cvoid, (Any, Csize_t, Csize_t, Csize_t), t, TASK_OFFSETS[:ctx], TASK_OFFSETS[:sizeof_ctx], TASK_OFFSETS[:tls_base_context]) end @@ -116,23 +116,25 @@ function Base.copy(ctask::CTask) # newtask = ccall((:jl_clone_task, libtask_julia), Any, (Any,), task)::Task newtask = ccall((:jl_clone_task_opaque, libtask_julia), Any, (Any, Csize_t), task, TASK_OFFSETS[:END])::Task - setfield_nothing(newtask, :exception) - setfield_nothing(newtask, :backtrace) - setfield_null(newtask, :excstack) - setfield_nothing(newtask, :tls) - setfield_nothing(newtask, :result) - setfield_nothing(newtask, :donenotify) + internal_setfield(newtask, :exception, nothing) + internal_setfield(newtask, :backtrace, nothing) + internal_setfield(newtask, :tls, nothing) + internal_setfield(newtask, :result, nothing) + internal_setfield(newtask, :donenotify, nothing) + internal_setfield(newtask, :excstack, C_NULL) + internal_setfield(newtask, :ptls, C_NULL) + internal_setfield(newtask, :gcstack, C_NULL) if haskey(TASK_OFFSETS, :stkbuf) && haskey(TASK_OFFSETS, :bufsz) - old_stkbuf = getfield_ptr(task, :stkbuf) + old_stkbuf = internal_getfield(task, :stkbuf, Ptr) if old_stkbuf != C_NULL - setfield_size(task, :bufsz, 0) + internal_setfield(task, :bufsz, Csize_t(0)) else - setfield_null(newtask, :stkbuf) + internal_setfield(newtask, :stkbuf, C_NULL) end - setfield_size(newtask, :bufsz, 0) + internal_setfield(newtask, :bufsz, Csize_t(0)) end - memset_0(newtask, :locks; end_field=:END) + memset(newtask, 0, :locks) # memory copy done task.storage[:n_copies] = 1 + n_copies(task) diff --git a/src/memlayout/main.jl b/src/memlayout/main.jl index 10f64df5..bc504623 100644 --- a/src/memlayout/main.jl +++ b/src/memlayout/main.jl @@ -30,45 +30,46 @@ const TASK_OFFSETS = find_offsets() ## utilities # getter -function getfield_ptr(task, field) +function internal_getfield(task, field, ::Type{Ptr}) ccall((:jl_getfield_ptr, libtask_julia), Ptr{Cvoid}, (Any, Csize_t), task, TASK_OFFSETS[field]) end -function getfield_int32(task, field) +function internal_getfield(task, field, ::Type{Int32}) ccall((:jl_getfield_int32_t, libtask_julia), Int32, (Any, Csize_t), task, TASK_OFFSETS[field]) end # setter -function setfield_nothing(task, field) +function internal_setfield(task, field, ::Nothing) haskey(TASK_OFFSETS, field) && ccall( (:jl_setfield_nothing, libtask_julia), Any, (Any, Csize_t), task, TASK_OFFSETS[field]) end -function setfield_null(task, field) +function internal_setfield(task, field, p::Ptr{Nothing}) + p == C_NULL || error("this function is only for setting NULL value") haskey(TASK_OFFSETS, field) && ccall( (:jl_setfield_null, libtask_julia), Any, (Any, Csize_t), task, TASK_OFFSETS[field]) end -function memset_0(task, offset_field; end_field=:END) - haskey(TASK_OFFSETS, offset_field) && ccall( - (:jl_memset_0, libtask_julia), - Cvoid, (Any, Csize_t, Csize_t), - task, TASK_OFFSETS[offset_field], TASK_OFFSETS[end_field]) -end - -function setfield_size(task, field, val) +function internal_setfield(task, field, val::Csize_t) ccall((:jl_setfield_size_t, libtask_julia), Any, (Any, Csize_t, Csize_t), task, TASK_OFFSETS[field], val) end -function setfield_int32(task, field, val) +function internal_setfield(task, field, val::Int32) ccall((:jl_setfield_int32_t, libtask_julia), Any, (Any, Csize_t, Int32), task, TASK_OFFSETS[field], val) end + +function memset(task, val, offset_field; end_field=:END) + haskey(TASK_OFFSETS, offset_field) && ccall( + (:jl_memset, libtask_julia), + Cvoid, (Any, Csize_t, Csize_t, Int), + task, TASK_OFFSETS[offset_field], TASK_OFFSETS[end_field], val) +end diff --git a/src/memlayout/memlayout.cpp b/src/memlayout/memlayout.cpp index f511916b..93672d9a 100644 --- a/src/memlayout/memlayout.cpp +++ b/src/memlayout/memlayout.cpp @@ -103,7 +103,9 @@ std::map task_field_offsets() { #undef field_info data["copy_stack"] = offsetof(jl_task_t, bufsz) + sizeof(size_t); data["sizeof_ctx"] = sizeof(((jl_task_t*)0)->ctx); + // data["sizeof_stack_ctx"] = sizeof(((jl_task_t*)0)->copy_stack_ctx); data["tls_base_context"] = offsetof(struct _jl_tls_states_t, base_ctx); + // data["tls_copy_stack_ctx"] = offsetof(struct _jl_tls_states_t, copy_stack_ctx); return data; } From 5f22f7b09cb3b010f301fdf7289e8f5dd79da4e8 Mon Sep 17 00:00:00 2001 From: KDr2 Date: Tue, 22 Jun 2021 23:05:10 +0000 Subject: [PATCH 04/17] support linux-x86 --- src/memlayout/linux-x86-v1_3_1.jl | 28 ++++++++++++++++++++++++++++ src/memlayout/linux-x86-v1_4_2.jl | 28 ++++++++++++++++++++++++++++ src/memlayout/linux-x86-v1_5_3.jl | 28 ++++++++++++++++++++++++++++ src/memlayout/linux-x86-v1_5_4.jl | 27 +++++++++++++++++++++++++++ src/memlayout/linux-x86-v1_6_1.jl | 24 ++++++++++++++++++++++++ src/memlayout/linux-x86-v1_8_0.jl | 30 ++++++++++++++++++++++++++++++ src/memlayout/main.jl | 8 ++++++++ 7 files changed, 173 insertions(+) create mode 100644 src/memlayout/linux-x86-v1_3_1.jl create mode 100644 src/memlayout/linux-x86-v1_4_2.jl create mode 100644 src/memlayout/linux-x86-v1_5_3.jl create mode 100644 src/memlayout/linux-x86-v1_5_4.jl create mode 100644 src/memlayout/linux-x86-v1_6_1.jl create mode 100644 src/memlayout/linux-x86-v1_8_0.jl diff --git a/src/memlayout/linux-x86-v1_3_1.jl b/src/memlayout/linux-x86-v1_3_1.jl new file mode 100644 index 00000000..66461532 --- /dev/null +++ b/src/memlayout/linux-x86-v1_3_1.jl @@ -0,0 +1,28 @@ +ALL_TASK_OFFSETS[("linux-x86", v"1.3.1")] = Dict( + :END => 364, + :backtrace => 28, + :bufsz => 204, + :copy_stack => 208, + :ctx => 44, + :donenotify => 16, + :eh => 212, + :exception => 24, + :excstack => 220, + :gcstack => 216, + :locks => 232, + :logstate => 32, + :next => 0, + :prio => 230, + :queue => 4, + :result => 20, + :sizeof_ctx => 156, + :start => 36, + :state => 12, + :sticky => 40, + :stkbuf => 200, + :tid => 228, + :timing_stack => 360, + :tls => 8, + :tls_base_context => 3404, + :world_age => 224, +) diff --git a/src/memlayout/linux-x86-v1_4_2.jl b/src/memlayout/linux-x86-v1_4_2.jl new file mode 100644 index 00000000..fa408f34 --- /dev/null +++ b/src/memlayout/linux-x86-v1_4_2.jl @@ -0,0 +1,28 @@ +ALL_TASK_OFFSETS[("linux-x86", v"1.4.2")] = Dict( + :END => 364, + :backtrace => 28, + :bufsz => 204, + :copy_stack => 208, + :ctx => 44, + :donenotify => 16, + :eh => 212, + :exception => 24, + :excstack => 220, + :gcstack => 216, + :locks => 232, + :logstate => 32, + :next => 0, + :prio => 230, + :queue => 4, + :result => 20, + :sizeof_ctx => 156, + :start => 36, + :state => 12, + :sticky => 40, + :stkbuf => 200, + :tid => 228, + :timing_stack => 360, + :tls => 8, + :tls_base_context => 3404, + :world_age => 224, +) diff --git a/src/memlayout/linux-x86-v1_5_3.jl b/src/memlayout/linux-x86-v1_5_3.jl new file mode 100644 index 00000000..a6da71f9 --- /dev/null +++ b/src/memlayout/linux-x86-v1_5_3.jl @@ -0,0 +1,28 @@ +ALL_TASK_OFFSETS[("linux-x86", v"1.5.3")] = Dict( + :END => 364, + :backtrace => 28, + :bufsz => 204, + :copy_stack => 208, + :ctx => 44, + :donenotify => 16, + :eh => 212, + :exception => 24, + :excstack => 220, + :gcstack => 216, + :locks => 232, + :logstate => 32, + :next => 0, + :prio => 230, + :queue => 4, + :result => 20, + :sizeof_ctx => 156, + :start => 36, + :state => 12, + :sticky => 40, + :stkbuf => 200, + :tid => 228, + :timing_stack => 360, + :tls => 8, + :tls_base_context => 3408, + :world_age => 224, +) diff --git a/src/memlayout/linux-x86-v1_5_4.jl b/src/memlayout/linux-x86-v1_5_4.jl new file mode 100644 index 00000000..80d2bd9a --- /dev/null +++ b/src/memlayout/linux-x86-v1_5_4.jl @@ -0,0 +1,27 @@ +ALL_TASK_OFFSETS[("linux-x86", v"1.5.4")] = Dict( + :END => 360, + :backtrace => 28, + :bufsz => 204, + :copy_stack => 208, + :ctx => 44, + :donenotify => 16, + :eh => 212, + :exception => 24, + :excstack => 220, + :gcstack => 216, + :locks => 228, + :logstate => 32, + :next => 0, + :prio => 226, + :queue => 4, + :result => 20, + :sizeof_ctx => 156, + :start => 36, + :state => 12, + :sticky => 40, + :stkbuf => 200, + :tid => 224, + :timing_stack => 356, + :tls => 8, + :tls_base_context => 3408, +) diff --git a/src/memlayout/linux-x86-v1_6_1.jl b/src/memlayout/linux-x86-v1_6_1.jl new file mode 100644 index 00000000..8d04faee --- /dev/null +++ b/src/memlayout/linux-x86-v1_6_1.jl @@ -0,0 +1,24 @@ +ALL_TASK_OFFSETS[("linux-x86", v"1.6.1")] = Dict( + :END => 216, + :_isexception => 30, + :_state => 28, + :bufsz => 204, + :copy_stack => 208, + :ctx => 44, + :donenotify => 12, + :eh => 40, + :excstack => 36, + :gcstack => 212, + :logstate => 20, + :next => 0, + :prio => 34, + :queue => 4, + :result => 16, + :sizeof_ctx => 156, + :start => 24, + :sticky => 29, + :stkbuf => 200, + :tid => 32, + :tls => 8, + :tls_base_context => 3412, +) diff --git a/src/memlayout/linux-x86-v1_8_0.jl b/src/memlayout/linux-x86-v1_8_0.jl new file mode 100644 index 00000000..e681843b --- /dev/null +++ b/src/memlayout/linux-x86-v1_8_0.jl @@ -0,0 +1,30 @@ +ALL_TASK_OFFSETS[("linux-x86", v"1.8.0")] = Dict( + :END => 256, + :_isexception => 30, + :_state => 28, + :bufsz => 248, + :copy_stack => 252, + :ctx => 88, + :donenotify => 12, + :eh => 84, + :excstack => 80, + :gcstack => 64, + :logstate => 20, + :next => 0, + :prio => 78, + :ptls => 72, + :queue => 4, + :result => 16, + :rngState0 => 32, + :rngState1 => 40, + :rngState2 => 48, + :rngState3 => 56, + :sizeof_ctx => 156, + :start => 24, + :sticky => 29, + :stkbuf => 244, + :tid => 76, + :tls => 8, + :tls_base_context => 3416, + :world_age => 68, +) diff --git a/src/memlayout/main.jl b/src/memlayout/main.jl index bc504623..46337afc 100644 --- a/src/memlayout/main.jl +++ b/src/memlayout/main.jl @@ -2,6 +2,13 @@ const ALL_TASK_OFFSETS = Dict{Tuple{String, VersionNumber}, Dict{Symbol, Int}}() +include("linux-x86-v1_3_1.jl") +include("linux-x86-v1_4_2.jl") +include("linux-x86-v1_5_3.jl") +include("linux-x86-v1_5_4.jl") +include("linux-x86-v1_6_1.jl") +include("linux-x86-v1_8_0.jl") + include("linux-x86_64-v1_3_1.jl") include("linux-x86_64-v1_4_2.jl") include("linux-x86_64-v1_5_3.jl") @@ -9,6 +16,7 @@ include("linux-x86_64-v1_5_4.jl") include("linux-x86_64-v1_6_1.jl") include("linux-x86_64-v1_8_0.jl") + const PLATFORM = @static if Sys.islinux() "linux-" * string(Sys.ARCH) elseif Sys.iswindows() From 8e9dbab479fe9bc6c29ad06b4ae539721b767b27 Mon Sep 17 00:00:00 2001 From: KDr2 Date: Wed, 23 Jun 2021 02:07:57 +0000 Subject: [PATCH 05/17] correct ARCH name --- src/memlayout/main.jl | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/memlayout/main.jl b/src/memlayout/main.jl index 46337afc..53910a37 100644 --- a/src/memlayout/main.jl +++ b/src/memlayout/main.jl @@ -16,13 +16,18 @@ include("linux-x86_64-v1_5_4.jl") include("linux-x86_64-v1_6_1.jl") include("linux-x86_64-v1_8_0.jl") +const ARCH = @static if string(Sys.ARCH)[1] == 'i' + "x86" +else + string(Sys.ARCH) +end const PLATFORM = @static if Sys.islinux() - "linux-" * string(Sys.ARCH) + "linux-" * ARCH elseif Sys.iswindows() - "windows-" * string(Sys.ARCH) + "windows-" * ARCH elseif Sys.isapple() - "darwin-" * string(Sys.ARCH) + "darwin-" * ARCH end function find_offsets() From dc206e1f2d63093a9146b92e1549ed34b2654c30 Mon Sep 17 00:00:00 2001 From: KDr2 Date: Wed, 23 Jun 2021 03:17:58 +0000 Subject: [PATCH 06/17] layout info on macOS --- src/memlayout/darwin-x86_64-v1_3_1.jl | 28 +++++++++++++++++++++++++++ src/memlayout/darwin-x86_64-v1_4_2.jl | 28 +++++++++++++++++++++++++++ src/memlayout/darwin-x86_64-v1_5_4.jl | 27 ++++++++++++++++++++++++++ src/memlayout/darwin-x86_64-v1_6_1.jl | 24 +++++++++++++++++++++++ src/memlayout/main.jl | 5 +++++ 5 files changed, 112 insertions(+) create mode 100644 src/memlayout/darwin-x86_64-v1_3_1.jl create mode 100644 src/memlayout/darwin-x86_64-v1_4_2.jl create mode 100644 src/memlayout/darwin-x86_64-v1_5_4.jl create mode 100644 src/memlayout/darwin-x86_64-v1_6_1.jl diff --git a/src/memlayout/darwin-x86_64-v1_3_1.jl b/src/memlayout/darwin-x86_64-v1_3_1.jl new file mode 100644 index 00000000..f154b529 --- /dev/null +++ b/src/memlayout/darwin-x86_64-v1_3_1.jl @@ -0,0 +1,28 @@ +ALL_TASK_OFFSETS[("darwin-x86_64", v"1.3.1")] = Dict( + :END => 568, + :backtrace => 56, + :bufsz => 248, + :copy_stack => 256, + :ctx => 84, + :donenotify => 32, + :eh => 264, + :exception => 48, + :excstack => 280, + :gcstack => 272, + :locks => 304, + :logstate => 64, + :next => 0, + :prio => 298, + :queue => 8, + :result => 40, + :sizeof_ctx => 152, + :start => 72, + :state => 24, + :sticky => 80, + :stkbuf => 240, + :tid => 296, + :timing_stack => 560, + :tls => 16, + :tls_base_context => 6664, + :world_age => 288, +) diff --git a/src/memlayout/darwin-x86_64-v1_4_2.jl b/src/memlayout/darwin-x86_64-v1_4_2.jl new file mode 100644 index 00000000..82c858ed --- /dev/null +++ b/src/memlayout/darwin-x86_64-v1_4_2.jl @@ -0,0 +1,28 @@ +ALL_TASK_OFFSETS[("darwin-x86_64", v"1.4.2")] = Dict( + :END => 568, + :backtrace => 56, + :bufsz => 248, + :copy_stack => 256, + :ctx => 84, + :donenotify => 32, + :eh => 264, + :exception => 48, + :excstack => 280, + :gcstack => 272, + :locks => 304, + :logstate => 64, + :next => 0, + :prio => 298, + :queue => 8, + :result => 40, + :sizeof_ctx => 152, + :start => 72, + :state => 24, + :sticky => 80, + :stkbuf => 240, + :tid => 296, + :timing_stack => 560, + :tls => 16, + :tls_base_context => 6664, + :world_age => 288, +) diff --git a/src/memlayout/darwin-x86_64-v1_5_4.jl b/src/memlayout/darwin-x86_64-v1_5_4.jl new file mode 100644 index 00000000..ec6ddd4e --- /dev/null +++ b/src/memlayout/darwin-x86_64-v1_5_4.jl @@ -0,0 +1,27 @@ +ALL_TASK_OFFSETS[("darwin-x86_64", v"1.5.4")] = Dict( + :END => 560, + :backtrace => 56, + :bufsz => 248, + :copy_stack => 256, + :ctx => 84, + :donenotify => 32, + :eh => 264, + :exception => 48, + :excstack => 280, + :gcstack => 272, + :locks => 296, + :logstate => 64, + :next => 0, + :prio => 290, + :queue => 8, + :result => 40, + :sizeof_ctx => 152, + :start => 72, + :state => 24, + :sticky => 80, + :stkbuf => 240, + :tid => 288, + :timing_stack => 552, + :tls => 16, + :tls_base_context => 6672, +) diff --git a/src/memlayout/darwin-x86_64-v1_6_1.jl b/src/memlayout/darwin-x86_64-v1_6_1.jl new file mode 100644 index 00000000..cc4892eb --- /dev/null +++ b/src/memlayout/darwin-x86_64-v1_6_1.jl @@ -0,0 +1,24 @@ +ALL_TASK_OFFSETS[("darwin-x86_64", v"1.6.1")] = Dict( + :END => 264, + :_isexception => 58, + :_state => 56, + :bufsz => 240, + :copy_stack => 248, + :ctx => 80, + :donenotify => 24, + :eh => 72, + :excstack => 64, + :gcstack => 256, + :logstate => 40, + :next => 0, + :prio => 62, + :queue => 8, + :result => 32, + :sizeof_ctx => 152, + :start => 48, + :sticky => 57, + :stkbuf => 232, + :tid => 60, + :tls => 16, + :tls_base_context => 6680, +) diff --git a/src/memlayout/main.jl b/src/memlayout/main.jl index 53910a37..792e4c3e 100644 --- a/src/memlayout/main.jl +++ b/src/memlayout/main.jl @@ -16,6 +16,11 @@ include("linux-x86_64-v1_5_4.jl") include("linux-x86_64-v1_6_1.jl") include("linux-x86_64-v1_8_0.jl") +include("darwin-x86_64-v1_3_1.jl") +include("darwin-x86_64-v1_4_2.jl") +include("darwin-x86_64-v1_5_4.jl") +include("darwin-x86_64-v1_6_1.jl") + const ARCH = @static if string(Sys.ARCH)[1] == 'i' "x86" else From ef790174c3b6488704c4b125fe3e57e054d9b5cb Mon Sep 17 00:00:00 2001 From: KDr2 Date: Wed, 23 Jun 2021 03:38:20 +0000 Subject: [PATCH 07/17] run test on each platform regardless of the results on others --- .github/workflows/Testing.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/Testing.yaml b/.github/workflows/Testing.yaml index 8d6d66e7..fa17a364 100644 --- a/.github/workflows/Testing.yaml +++ b/.github/workflows/Testing.yaml @@ -7,7 +7,7 @@ on: jobs: test: runs-on: ${{ matrix.os }} - continue-on-error: ${{ matrix.version == 'nightly' }} + continue-on-error: true # ${{ matrix.version == 'nightly' }} strategy: matrix: version: From d286f7a4e8c9a0b5b35798b8e52c0cc2cead5b9e Mon Sep 17 00:00:00 2001 From: KDr2 Date: Wed, 23 Jun 2021 10:01:56 +0000 Subject: [PATCH 08/17] win64 support --- src/memlayout/main.jl | 5 +++++ src/memlayout/windows-x86_64-v1_3_1.jl | 28 ++++++++++++++++++++++++++ src/memlayout/windows-x86_64-v1_4_2.jl | 28 ++++++++++++++++++++++++++ src/memlayout/windows-x86_64-v1_5_4.jl | 27 +++++++++++++++++++++++++ src/memlayout/windows-x86_64-v1_6_1.jl | 24 ++++++++++++++++++++++ 5 files changed, 112 insertions(+) create mode 100644 src/memlayout/windows-x86_64-v1_3_1.jl create mode 100644 src/memlayout/windows-x86_64-v1_4_2.jl create mode 100644 src/memlayout/windows-x86_64-v1_5_4.jl create mode 100644 src/memlayout/windows-x86_64-v1_6_1.jl diff --git a/src/memlayout/main.jl b/src/memlayout/main.jl index 792e4c3e..959af804 100644 --- a/src/memlayout/main.jl +++ b/src/memlayout/main.jl @@ -21,6 +21,11 @@ include("darwin-x86_64-v1_4_2.jl") include("darwin-x86_64-v1_5_4.jl") include("darwin-x86_64-v1_6_1.jl") +include("windows-x86_64-v1_3_1.jl") +include("windows-x86_64-v1_4_2.jl") +include("windows-x86_64-v1_5_4.jl") +include("windows-x86_64-v1_6_1.jl") + const ARCH = @static if string(Sys.ARCH)[1] == 'i' "x86" else diff --git a/src/memlayout/windows-x86_64-v1_3_1.jl b/src/memlayout/windows-x86_64-v1_3_1.jl new file mode 100644 index 00000000..1669f3f8 --- /dev/null +++ b/src/memlayout/windows-x86_64-v1_3_1.jl @@ -0,0 +1,28 @@ +ALL_TASK_OFFSETS[("windows-x86_64", v"1.3.1")] = Dict( + :END => 704, + :backtrace => 56, + :bufsz => 376, + :copy_stack => 384, + :ctx => 96, + :donenotify => 32, + :eh => 392, + :exception => 48, + :excstack => 408, + :gcstack => 400, + :locks => 432, + :logstate => 64, + :next => 0, + :prio => 426, + :queue => 8, + :result => 40, + :sizeof_ctx => 272, + :start => 72, + :state => 24, + :sticky => 80, + :stkbuf => 368, + :tid => 424, + :timing_stack => 688, + :tls => 16, + :tls_base_context => 6608, + :world_age => 416, +) diff --git a/src/memlayout/windows-x86_64-v1_4_2.jl b/src/memlayout/windows-x86_64-v1_4_2.jl new file mode 100644 index 00000000..504caa71 --- /dev/null +++ b/src/memlayout/windows-x86_64-v1_4_2.jl @@ -0,0 +1,28 @@ +ALL_TASK_OFFSETS[("windows-x86_64", v"1.4.2")] = Dict( + :END => 704, + :backtrace => 56, + :bufsz => 376, + :copy_stack => 384, + :ctx => 96, + :donenotify => 32, + :eh => 392, + :exception => 48, + :excstack => 408, + :gcstack => 400, + :locks => 432, + :logstate => 64, + :next => 0, + :prio => 426, + :queue => 8, + :result => 40, + :sizeof_ctx => 272, + :start => 72, + :state => 24, + :sticky => 80, + :stkbuf => 368, + :tid => 424, + :timing_stack => 688, + :tls => 16, + :tls_base_context => 6608, + :world_age => 416, +) diff --git a/src/memlayout/windows-x86_64-v1_5_4.jl b/src/memlayout/windows-x86_64-v1_5_4.jl new file mode 100644 index 00000000..446c1396 --- /dev/null +++ b/src/memlayout/windows-x86_64-v1_5_4.jl @@ -0,0 +1,27 @@ +ALL_TASK_OFFSETS[("windows-x86_64", v"1.5.4")] = Dict( + :END => 688, + :backtrace => 56, + :bufsz => 376, + :copy_stack => 384, + :ctx => 96, + :donenotify => 32, + :eh => 392, + :exception => 48, + :excstack => 408, + :gcstack => 400, + :locks => 424, + :logstate => 64, + :next => 0, + :prio => 418, + :queue => 8, + :result => 40, + :sizeof_ctx => 272, + :start => 72, + :state => 24, + :sticky => 80, + :stkbuf => 368, + :tid => 416, + :timing_stack => 680, + :tls => 16, + :tls_base_context => 6608, +) diff --git a/src/memlayout/windows-x86_64-v1_6_1.jl b/src/memlayout/windows-x86_64-v1_6_1.jl new file mode 100644 index 00000000..6640becd --- /dev/null +++ b/src/memlayout/windows-x86_64-v1_6_1.jl @@ -0,0 +1,24 @@ +ALL_TASK_OFFSETS[("windows-x86_64", v"1.6.1")] = Dict( + :END => 384, + :_isexception => 58, + :_state => 56, + :bufsz => 360, + :copy_stack => 368, + :ctx => 80, + :donenotify => 24, + :eh => 72, + :excstack => 64, + :gcstack => 376, + :logstate => 40, + :next => 0, + :prio => 62, + :queue => 8, + :result => 32, + :sizeof_ctx => 272, + :start => 48, + :sticky => 57, + :stkbuf => 352, + :tid => 60, + :tls => 16, + :tls_base_context => 6624, +) From 82de1b032e816ea127089a4a79eb2a3976fe719a Mon Sep 17 00:00:00 2001 From: KDr2 Date: Wed, 23 Jun 2021 20:28:52 +0000 Subject: [PATCH 09/17] win32 support --- src/memlayout/main.jl | 5 +++++ src/memlayout/memlayout.cpp | 9 +++++++++ src/memlayout/windows-x86-v1_3_1.jl | 28 ++++++++++++++++++++++++++++ src/memlayout/windows-x86-v1_4_2.jl | 28 ++++++++++++++++++++++++++++ src/memlayout/windows-x86-v1_5_4.jl | 27 +++++++++++++++++++++++++++ src/memlayout/windows-x86-v1_6_1.jl | 24 ++++++++++++++++++++++++ 6 files changed, 121 insertions(+) create mode 100644 src/memlayout/windows-x86-v1_3_1.jl create mode 100644 src/memlayout/windows-x86-v1_4_2.jl create mode 100644 src/memlayout/windows-x86-v1_5_4.jl create mode 100644 src/memlayout/windows-x86-v1_6_1.jl diff --git a/src/memlayout/main.jl b/src/memlayout/main.jl index 959af804..4eff2f5c 100644 --- a/src/memlayout/main.jl +++ b/src/memlayout/main.jl @@ -21,6 +21,11 @@ include("darwin-x86_64-v1_4_2.jl") include("darwin-x86_64-v1_5_4.jl") include("darwin-x86_64-v1_6_1.jl") +include("windows-x86-v1_3_1.jl") +include("windows-x86-v1_4_2.jl") +include("windows-x86-v1_5_4.jl") +include("windows-x86-v1_6_1.jl") + include("windows-x86_64-v1_3_1.jl") include("windows-x86_64-v1_4_2.jl") include("windows-x86_64-v1_5_4.jl") diff --git a/src/memlayout/memlayout.cpp b/src/memlayout/memlayout.cpp index 93672d9a..6004eb9e 100644 --- a/src/memlayout/memlayout.cpp +++ b/src/memlayout/memlayout.cpp @@ -1,3 +1,12 @@ +/** + * linux64: g++ -I $JULIA_HOME/include/julia/ memlayout.cpp -o memlayout + * linux32: apt-get install g++-multilib + * g++ -march=pentium4 -m32 -I $JULIA_HOME/include/julia/ memlayout.cpp -o memlayout + * macOS: g++ -std=c++11 -I $JULIA_APP/Contents/Resources/julia/include/julia/ memlayout.cpp -o memlayout + * win64: g++ -I $JULIA_HOME/include/julia/ memlayout.cpp -o memlayout + * win32: g++ -I $JULIA_HOME/include/julia/ memlayout.cpp -o memlayout + **/ + #include #include #include diff --git a/src/memlayout/windows-x86-v1_3_1.jl b/src/memlayout/windows-x86-v1_3_1.jl new file mode 100644 index 00000000..6fe2d316 --- /dev/null +++ b/src/memlayout/windows-x86-v1_3_1.jl @@ -0,0 +1,28 @@ +ALL_TASK_OFFSETS[("windows-x86", v"1.3.1")] = Dict( + :END => 280, + :backtrace => 28, + :bufsz => 120, + :copy_stack => 124, + :ctx => 44, + :donenotify => 16, + :eh => 128, + :exception => 24, + :excstack => 136, + :gcstack => 132, + :locks => 148, + :logstate => 32, + :next => 0, + :prio => 146, + :queue => 4, + :result => 20, + :sizeof_ctx => 72, + :start => 36, + :state => 12, + :sticky => 40, + :stkbuf => 116, + :tid => 144, + :timing_stack => 276, + :tls => 8, + :tls_base_context => 3352, + :world_age => 140, +) diff --git a/src/memlayout/windows-x86-v1_4_2.jl b/src/memlayout/windows-x86-v1_4_2.jl new file mode 100644 index 00000000..1f502163 --- /dev/null +++ b/src/memlayout/windows-x86-v1_4_2.jl @@ -0,0 +1,28 @@ +ALL_TASK_OFFSETS[("windows-x86", v"1.4.2")] = Dict( + :END => 280, + :backtrace => 28, + :bufsz => 120, + :copy_stack => 124, + :ctx => 44, + :donenotify => 16, + :eh => 128, + :exception => 24, + :excstack => 136, + :gcstack => 132, + :locks => 148, + :logstate => 32, + :next => 0, + :prio => 146, + :queue => 4, + :result => 20, + :sizeof_ctx => 72, + :start => 36, + :state => 12, + :sticky => 40, + :stkbuf => 116, + :tid => 144, + :timing_stack => 276, + :tls => 8, + :tls_base_context => 3352, + :world_age => 140, +) diff --git a/src/memlayout/windows-x86-v1_5_4.jl b/src/memlayout/windows-x86-v1_5_4.jl new file mode 100644 index 00000000..53f9c6dc --- /dev/null +++ b/src/memlayout/windows-x86-v1_5_4.jl @@ -0,0 +1,27 @@ +ALL_TASK_OFFSETS[("windows-x86", v"1.5.4")] = Dict( + :END => 276, + :backtrace => 28, + :bufsz => 120, + :copy_stack => 124, + :ctx => 44, + :donenotify => 16, + :eh => 128, + :exception => 24, + :excstack => 136, + :gcstack => 132, + :locks => 144, + :logstate => 32, + :next => 0, + :prio => 142, + :queue => 4, + :result => 20, + :sizeof_ctx => 72, + :start => 36, + :state => 12, + :sticky => 40, + :stkbuf => 116, + :tid => 140, + :timing_stack => 272, + :tls => 8, + :tls_base_context => 3356, +) diff --git a/src/memlayout/windows-x86-v1_6_1.jl b/src/memlayout/windows-x86-v1_6_1.jl new file mode 100644 index 00000000..2b1f3750 --- /dev/null +++ b/src/memlayout/windows-x86-v1_6_1.jl @@ -0,0 +1,24 @@ +ALL_TASK_OFFSETS[("windows-x86", v"1.6.1")] = Dict( + :END => 132, + :_isexception => 30, + :_state => 28, + :bufsz => 120, + :copy_stack => 124, + :ctx => 44, + :donenotify => 12, + :eh => 40, + :excstack => 36, + :gcstack => 128, + :logstate => 20, + :next => 0, + :prio => 34, + :queue => 4, + :result => 16, + :sizeof_ctx => 72, + :start => 24, + :sticky => 29, + :stkbuf => 116, + :tid => 32, + :tls => 8, + :tls_base_context => 3360, +) From 5b7945f981473998c1953738aaeb8f7f2c611507 Mon Sep 17 00:00:00 2001 From: KDr2 Date: Thu, 24 Jun 2021 03:05:19 +0000 Subject: [PATCH 10/17] memlayout workflow --- .github/workflows/MemLayoutGen.yaml | 45 +++++++++++++++++++ .../workflows}/memlayout.cpp | 0 .github/workflows/memlayout.jl | 31 +++++++++++++ 3 files changed, 76 insertions(+) create mode 100644 .github/workflows/MemLayoutGen.yaml rename {src/memlayout => .github/workflows}/memlayout.cpp (100%) create mode 100644 .github/workflows/memlayout.jl diff --git a/.github/workflows/MemLayoutGen.yaml b/.github/workflows/MemLayoutGen.yaml new file mode 100644 index 00000000..c0d1ee2a --- /dev/null +++ b/.github/workflows/MemLayoutGen.yaml @@ -0,0 +1,45 @@ +name: MemLayout Info Generating +on: + push: + branches: + - master + pull_request: +jobs: + test: + runs-on: ${{ matrix.os }} + continue-on-error: true + strategy: + matrix: + version: + - '1.3.1' + - '1.4.2' + - '1.5.3' + - '1.5.4' + - '1.6.1' + os: + - ubuntu-latest + - windows-latest + - macOS-latest + arch: + - x64 + - x86 + exclude: + - os: macOS-latest + arch: x86 + steps: + - name: Set up MinGW + uses: egor-tensin/setup-mingw@v2 + with: + platform: i686 + cc: 1 + if: ${{ matrix.os == 'windows-latest' && matrix.arch == 'x86' }} + - uses: actions/checkout@v2 + - uses: julia-actions/setup-julia@v1 + with: + version: ${{ matrix.version }} + arch: ${{ matrix.arch }} + - run: julia .github/workflows/memlayout.jl + - uses: EndBug/add-and-commit@v7 + with: + add: 'src/memlayout' + author_name: GitHub Actions diff --git a/src/memlayout/memlayout.cpp b/.github/workflows/memlayout.cpp similarity index 100% rename from src/memlayout/memlayout.cpp rename to .github/workflows/memlayout.cpp diff --git a/.github/workflows/memlayout.jl b/.github/workflows/memlayout.jl new file mode 100644 index 00000000..a2009c5b --- /dev/null +++ b/.github/workflows/memlayout.jl @@ -0,0 +1,31 @@ +const ARCH = @static if string(Sys.ARCH)[1] == 'i' + "x86" +else + string(Sys.ARCH) +end + +const PLATFORM = @static if Sys.islinux() + "linux-" * ARCH +elseif Sys.iswindows() + "windows-" * ARCH +elseif Sys.isapple() + "darwin-" * ARCH +end + +OUTPUT = "$(PLATFORM)-v$(VERSION.major)_$(VERSION.minor)_$(VERSION.patch).jl" + +const PROJECT_DIR = (@__DIR__) |> dirname |> dirname +const INCLUDE = joinpath(dirname(Sys.BINDIR), "include/julia") +const OPTIONS = if string(Sys.ARCH)[1] == 'i' + Sys.islinux() && run(`sudo apt-get install g++-multilib -y`) + ["-std=c++11","-march=pentium4", "-m32", "-static-libgcc", "-static-libstdc++"] +else + ["-std=c++11"] +end + +run(`g++ $(OPTIONS) -I$(INCLUDE) $(PROJECT_DIR)/.github/workflows/memlayout.cpp -o memlayout`) +run(`./memlayout`) + +if isfile(OUTPUT) && !isfile(joinpath("src/memlayout", OUTPUT)) + Base.Filesystem.mv(OUTPUT, joinpath("src/memlayout", OUTPUT)) +end From 1917109580680dcc01e1020cb61c2c2bd7778abd Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Thu, 24 Jun 2021 04:45:26 +0000 Subject: [PATCH 11/17] Commit from GitHub Actions (MemLayout Info Generating) --- src/memlayout/windows-x86_64-v1_5_3.jl | 28 ++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/memlayout/windows-x86_64-v1_5_3.jl diff --git a/src/memlayout/windows-x86_64-v1_5_3.jl b/src/memlayout/windows-x86_64-v1_5_3.jl new file mode 100644 index 00000000..07d4ebae --- /dev/null +++ b/src/memlayout/windows-x86_64-v1_5_3.jl @@ -0,0 +1,28 @@ +ALL_TASK_OFFSETS[("windows-x86_64", v"1.5.3")] = Dict( + :END => 704, + :backtrace => 56, + :bufsz => 376, + :copy_stack => 384, + :ctx => 96, + :donenotify => 32, + :eh => 392, + :exception => 48, + :excstack => 408, + :gcstack => 400, + :locks => 432, + :logstate => 64, + :next => 0, + :prio => 426, + :queue => 8, + :result => 40, + :sizeof_ctx => 272, + :start => 72, + :state => 24, + :sticky => 80, + :stkbuf => 368, + :tid => 424, + :timing_stack => 688, + :tls => 16, + :tls_base_context => 6608, + :world_age => 416, +) From ca985d3c12e56e7fd0868ad2a047b7e9c00f7aef Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Thu, 24 Jun 2021 04:53:00 +0000 Subject: [PATCH 12/17] Commit from GitHub Actions (MemLayout Info Generating) --- src/memlayout/windows-x86-v1_5_3.jl | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/memlayout/windows-x86-v1_5_3.jl diff --git a/src/memlayout/windows-x86-v1_5_3.jl b/src/memlayout/windows-x86-v1_5_3.jl new file mode 100644 index 00000000..7c73b7a8 --- /dev/null +++ b/src/memlayout/windows-x86-v1_5_3.jl @@ -0,0 +1,28 @@ +ALL_TASK_OFFSETS[("windows-x86", v"1.5.3")] = Dict( + :END => 280, + :backtrace => 28, + :bufsz => 120, + :copy_stack => 124, + :ctx => 44, + :donenotify => 16, + :eh => 128, + :exception => 24, + :excstack => 136, + :gcstack => 132, + :locks => 148, + :logstate => 32, + :next => 0, + :prio => 146, + :queue => 4, + :result => 20, + :sizeof_ctx => 72, + :start => 36, + :state => 12, + :sticky => 40, + :stkbuf => 116, + :tid => 144, + :timing_stack => 276, + :tls => 8, + :tls_base_context => 3356, + :world_age => 140, +) From 336c9a228836db68ccdf4ac208747a80bb3e6853 Mon Sep 17 00:00:00 2001 From: KDr2 Date: Thu, 24 Jun 2021 05:16:28 +0000 Subject: [PATCH 13/17] only generate layout file on PR --- .github/workflows/MemLayoutGen.yaml | 3 --- .github/workflows/memlayout.jl | 7 ++++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/MemLayoutGen.yaml b/.github/workflows/MemLayoutGen.yaml index c0d1ee2a..c95f3e89 100644 --- a/.github/workflows/MemLayoutGen.yaml +++ b/.github/workflows/MemLayoutGen.yaml @@ -1,8 +1,5 @@ name: MemLayout Info Generating on: - push: - branches: - - master pull_request: jobs: test: diff --git a/.github/workflows/memlayout.jl b/.github/workflows/memlayout.jl index a2009c5b..7bae221a 100644 --- a/.github/workflows/memlayout.jl +++ b/.github/workflows/memlayout.jl @@ -13,6 +13,9 @@ elseif Sys.isapple() end OUTPUT = "$(PLATFORM)-v$(VERSION.major)_$(VERSION.minor)_$(VERSION.patch).jl" +OUTPUT_DEST = joinpath("src/memlayout", OUTPUT) + +isfile(OUTPUT_DEST) && exit(0) const PROJECT_DIR = (@__DIR__) |> dirname |> dirname const INCLUDE = joinpath(dirname(Sys.BINDIR), "include/julia") @@ -26,6 +29,4 @@ end run(`g++ $(OPTIONS) -I$(INCLUDE) $(PROJECT_DIR)/.github/workflows/memlayout.cpp -o memlayout`) run(`./memlayout`) -if isfile(OUTPUT) && !isfile(joinpath("src/memlayout", OUTPUT)) - Base.Filesystem.mv(OUTPUT, joinpath("src/memlayout", OUTPUT)) -end +isfile(OUTPUT) && Base.Filesystem.mv(OUTPUT, OUTPUT_DEST) From 3f4f8fd518ead05b32f53a0fbde9bc64dc751250 Mon Sep 17 00:00:00 2001 From: KDr2 Date: Thu, 24 Jun 2021 05:36:28 +0000 Subject: [PATCH 14/17] rename exe file --- .github/workflows/memlayout.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/memlayout.jl b/.github/workflows/memlayout.jl index 7bae221a..10296f49 100644 --- a/.github/workflows/memlayout.jl +++ b/.github/workflows/memlayout.jl @@ -26,7 +26,7 @@ else ["-std=c++11"] end -run(`g++ $(OPTIONS) -I$(INCLUDE) $(PROJECT_DIR)/.github/workflows/memlayout.cpp -o memlayout`) -run(`./memlayout`) +run(`g++ $(OPTIONS) -I$(INCLUDE) $(PROJECT_DIR)/.github/workflows/memlayout.cpp -o memlayout-gen.exe`) +run(`./memlayout-gen.exe`) isfile(OUTPUT) && Base.Filesystem.mv(OUTPUT, OUTPUT_DEST) From 7ab06db397a6931bbe7278401931acf00928ff15 Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Thu, 24 Jun 2021 05:39:28 +0000 Subject: [PATCH 15/17] Commit from GitHub Actions (MemLayout Info Generating) --- src/memlayout/darwin-x86_64-v1_5_3.jl | 28 +++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/memlayout/darwin-x86_64-v1_5_3.jl diff --git a/src/memlayout/darwin-x86_64-v1_5_3.jl b/src/memlayout/darwin-x86_64-v1_5_3.jl new file mode 100644 index 00000000..6d5bc272 --- /dev/null +++ b/src/memlayout/darwin-x86_64-v1_5_3.jl @@ -0,0 +1,28 @@ +ALL_TASK_OFFSETS[("darwin-x86_64", v"1.5.3")] = Dict( + :END => 568, + :backtrace => 56, + :bufsz => 248, + :copy_stack => 256, + :ctx => 84, + :donenotify => 32, + :eh => 264, + :exception => 48, + :excstack => 280, + :gcstack => 272, + :locks => 304, + :logstate => 64, + :next => 0, + :prio => 298, + :queue => 8, + :result => 40, + :sizeof_ctx => 152, + :start => 72, + :state => 24, + :sticky => 80, + :stkbuf => 240, + :tid => 296, + :timing_stack => 560, + :tls => 16, + :tls_base_context => 6672, + :world_age => 288, +) From 7ce48dbf6017617766cb65ae5dafca42dfce2cde Mon Sep 17 00:00:00 2001 From: KDr2 Date: Thu, 24 Jun 2021 05:47:24 +0000 Subject: [PATCH 16/17] include mem layout info of v1.5.3 --- src/memlayout/main.jl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/memlayout/main.jl b/src/memlayout/main.jl index 4eff2f5c..169cc93a 100644 --- a/src/memlayout/main.jl +++ b/src/memlayout/main.jl @@ -18,16 +18,19 @@ include("linux-x86_64-v1_8_0.jl") include("darwin-x86_64-v1_3_1.jl") include("darwin-x86_64-v1_4_2.jl") +include("darwin-x86_64-v1_5_3.jl") include("darwin-x86_64-v1_5_4.jl") include("darwin-x86_64-v1_6_1.jl") include("windows-x86-v1_3_1.jl") include("windows-x86-v1_4_2.jl") +include("windows-x86-v1_5_3.jl") include("windows-x86-v1_5_4.jl") include("windows-x86-v1_6_1.jl") include("windows-x86_64-v1_3_1.jl") include("windows-x86_64-v1_4_2.jl") +include("windows-x86_64-v1_5_3.jl") include("windows-x86_64-v1_5_4.jl") include("windows-x86_64-v1_6_1.jl") From b114dc0d71aac1b898348a5b4eecbf6e43bd8c7e Mon Sep 17 00:00:00 2001 From: KDr2 Date: Fri, 25 Jun 2021 02:34:31 +0000 Subject: [PATCH 17/17] move memlayout generator to a subfolder --- .github/workflows/MemLayoutGen.yaml | 2 +- .github/workflows/{ => tasklayout}/memlayout.cpp | 0 .github/workflows/{ => tasklayout}/memlayout.jl | 4 ++-- 3 files changed, 3 insertions(+), 3 deletions(-) rename .github/workflows/{ => tasklayout}/memlayout.cpp (100%) rename .github/workflows/{ => tasklayout}/memlayout.jl (88%) diff --git a/.github/workflows/MemLayoutGen.yaml b/.github/workflows/MemLayoutGen.yaml index c95f3e89..c233d8f5 100644 --- a/.github/workflows/MemLayoutGen.yaml +++ b/.github/workflows/MemLayoutGen.yaml @@ -35,7 +35,7 @@ jobs: with: version: ${{ matrix.version }} arch: ${{ matrix.arch }} - - run: julia .github/workflows/memlayout.jl + - run: julia .github/workflows/tasklayout/memlayout.jl - uses: EndBug/add-and-commit@v7 with: add: 'src/memlayout' diff --git a/.github/workflows/memlayout.cpp b/.github/workflows/tasklayout/memlayout.cpp similarity index 100% rename from .github/workflows/memlayout.cpp rename to .github/workflows/tasklayout/memlayout.cpp diff --git a/.github/workflows/memlayout.jl b/.github/workflows/tasklayout/memlayout.jl similarity index 88% rename from .github/workflows/memlayout.jl rename to .github/workflows/tasklayout/memlayout.jl index 10296f49..78ec9ae5 100644 --- a/.github/workflows/memlayout.jl +++ b/.github/workflows/tasklayout/memlayout.jl @@ -17,7 +17,7 @@ OUTPUT_DEST = joinpath("src/memlayout", OUTPUT) isfile(OUTPUT_DEST) && exit(0) -const PROJECT_DIR = (@__DIR__) |> dirname |> dirname +const PROJECT_DIR = (@__DIR__) |> dirname |> dirname |> dirname const INCLUDE = joinpath(dirname(Sys.BINDIR), "include/julia") const OPTIONS = if string(Sys.ARCH)[1] == 'i' Sys.islinux() && run(`sudo apt-get install g++-multilib -y`) @@ -26,7 +26,7 @@ else ["-std=c++11"] end -run(`g++ $(OPTIONS) -I$(INCLUDE) $(PROJECT_DIR)/.github/workflows/memlayout.cpp -o memlayout-gen.exe`) +run(`g++ $(OPTIONS) -I$(INCLUDE) $(PROJECT_DIR)/.github/workflows/tasklayout/memlayout.cpp -o memlayout-gen.exe`) run(`./memlayout-gen.exe`) isfile(OUTPUT) && Base.Filesystem.mv(OUTPUT, OUTPUT_DEST)