Skip to content

Commit

Permalink
Deploying to deploy from @ f0513fa 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
doyougnu committed May 7, 2024
1 parent c41ea5d commit 7af41c1
Show file tree
Hide file tree
Showing 16 changed files with 94 additions and 91 deletions.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ which is a constant that describes the kind of closure, for example, a
which the garbage collector requires to collect :term:`CAF`'s. Lastly, the info
table will hold the :term:`entry code` pointer for the heap object if one exists
[#]_ . For more see :ghcSource:`InfoTables.h
<rts/include/rts/storage/InfoTables.h>` for exact details and other variants.
<rts/include/rts/storage/InfoTables.h>` and :ghcSource:`Closures.h
<rts/include/rts/storage/Storage.h>` for exact details and variants.

Here is a depiction of the heap object layout without |TNTC| enabled. Code is
represented in orange and data in blue. Boxes which have a dashed outline change
Expand Down Expand Up @@ -83,14 +84,15 @@ depending on the type of heap object and build:
\draw[->, thick] (ip.south) |- (ecp.north west) node[midway] {};
\draw[->, thick] (ecp.east) |- (ec.west) node[midway] {};

Tables-next-to-code does two things: first it removes the entry code pointer
from the info table and second, it moves the entry code itself to the address
immediately after the info table and sets the info table pointer itself to the
address of the entry code. This setup allows the runtime system to save a
pointer indirection because the info table pointer now points to the entry code.
Thus, when jumping to the entry code, which is a common operation, the runtime
system saves a single indirection, but can still reference the fields of the
info table through a negative memory offset from the info table pointer.
Tables-next-to-code does two things: first it removes the entry code pointer and
places the type specific fields before the ``Closure Type``, and second, it
moves the entry code itself to the address immediately after the info table and
sets the info table pointer to the address of the entry code. This setup allows
the runtime system to save a pointer indirection because the info table pointer
now points to the entry code. Thus, when jumping to the entry code, which is a
common operation, the runtime system saves a single indirection, but can still
reference the fields of the info table through a negative memory offset from
the info table pointer.

Here is a depiction with |TNTC| enabled:

Expand All @@ -111,19 +113,19 @@ Here is a depiction with |TNTC| enabled:
(6,2.25)--node[rotate=0, yshift=7mm](header){Object Header} (14,2.25);

\node[below of=ip, draw,rectangle, thick, fill=blue!10,
minimum width=4cm, minimum height=2cm, xshift=5cm, yshift=-3cm] (layout) {Layout};
minimum width=4cm, minimum height=2cm, xshift=5cm, yshift=-5cm] (layout) {Layout};

\node[above of=layout, draw,rectangle, thick, dashed, fill=blue!10,
minimum width=4cm, minimum height=2cm, yshift=1cm] (other) {Type Specific
Fields};

\node[below of=layout, draw,rectangle, thick, fill=blue!10,
minimum width=4cm, minimum height=2cm, yshift=-1cm] (ct) {Closure Type};

\node[below of=ct, draw,rectangle, thick, fill=blue!10,
minimum width=4cm, minimum height=2cm, yshift=-1cm] (srt) {SRT Bitmap};

\node[below of=srt, draw,rectangle, thick, dashed, fill=blue!10,
minimum width=4cm, minimum height=2cm, yshift=-1cm] (other) {Type Specific
Fields};

\node[below of=other, draw,rectangle, thick, fill=orange!20,
\node[below of=srt, draw,rectangle, thick, fill=orange!20,
minimum width=4cm, minimum height=2cm, yshift=-1cm] (ec) {Entry Code};

\draw[->, thick] (ip.south) |- (ec.north west) node[midway] {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ getBinDir, getLibDir, getDynLibDir, getDataDir, getLibexecDir, getSysconfDir ::


bindir, libdir, dynlibdir, datadir, libexecdir, sysconfdir :: FilePath
bindir = "/tmp/nix-build-hoh-0.0.1.drv-0/tmp.3duGRNwrrO/bin"
libdir = "/tmp/nix-build-hoh-0.0.1.drv-0/tmp.3duGRNwrrO/lib/x86_64-linux-ghc-9.4.8/lethargy-0.1.0.0-inplace-lethargy-asm"
dynlibdir = "/tmp/nix-build-hoh-0.0.1.drv-0/tmp.3duGRNwrrO/lib/x86_64-linux-ghc-9.4.8"
datadir = "/tmp/nix-build-hoh-0.0.1.drv-0/tmp.3duGRNwrrO/share/x86_64-linux-ghc-9.4.8/lethargy-0.1.0.0"
libexecdir = "/tmp/nix-build-hoh-0.0.1.drv-0/tmp.3duGRNwrrO/libexec/x86_64-linux-ghc-9.4.8/lethargy-0.1.0.0"
sysconfdir = "/tmp/nix-build-hoh-0.0.1.drv-0/tmp.3duGRNwrrO/etc"
bindir = "/tmp/nix-build-hoh-0.0.1.drv-0/tmp.YByz0f0glF/bin"
libdir = "/tmp/nix-build-hoh-0.0.1.drv-0/tmp.YByz0f0glF/lib/x86_64-linux-ghc-9.4.8/lethargy-0.1.0.0-inplace-lethargy-asm"
dynlibdir = "/tmp/nix-build-hoh-0.0.1.drv-0/tmp.YByz0f0glF/lib/x86_64-linux-ghc-9.4.8"
datadir = "/tmp/nix-build-hoh-0.0.1.drv-0/tmp.YByz0f0glF/share/x86_64-linux-ghc-9.4.8/lethargy-0.1.0.0"
libexecdir = "/tmp/nix-build-hoh-0.0.1.drv-0/tmp.YByz0f0glF/libexec/x86_64-linux-ghc-9.4.8/lethargy-0.1.0.0"
sysconfdir = "/tmp/nix-build-hoh-0.0.1.drv-0/tmp.YByz0f0glF/etc"

getBinDir = catchIO (getEnv "lethargy_bindir") (\_ -> return bindir)
getLibDir = catchIO (getEnv "lethargy_libdir") (\_ -> return libdir)
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified _static/dist-newstyle/cache/config
Binary file not shown.
Binary file modified _static/dist-newstyle/cache/elaborated-plan
Binary file not shown.
Binary file modified _static/dist-newstyle/cache/improved-plan
Binary file not shown.
2 changes: 1 addition & 1 deletion _static/dist-newstyle/cache/plan.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"cabal-version":"3.10.2.1","cabal-lib-version":"3.10.2.1","compiler-id":"ghc-9.4.8","os":"linux","arch":"x86_64","install-plan":[{"type":"pre-existing","id":"base-4.17.2.1","pkg-name":"base","pkg-version":"4.17.2.1","depends":["ghc-bignum-1.3","ghc-prim-0.9.1","rts"]},{"type":"pre-existing","id":"ghc-bignum-1.3","pkg-name":"ghc-bignum","pkg-version":"1.3","depends":["ghc-prim-0.9.1"]},{"type":"pre-existing","id":"ghc-prim-0.9.1","pkg-name":"ghc-prim","pkg-version":"0.9.1","depends":["rts"]},{"type":"configured","id":"lethargy-0.1.0.0-inplace-lethargy","pkg-name":"lethargy","pkg-version":"0.1.0.0","flags":{},"style":"local","pkg-src":{"type":"local","path":"/tmp/nix-build-hoh-0.0.1.drv-0/a8f263mmzd7jvpwad2b1wx39gjzscys8-source/code/lethargy"},"dist-dir":"/tmp/nix-build-hoh-0.0.1.drv-0/a8f263mmzd7jvpwad2b1wx39gjzscys8-source/code/dist-newstyle/build/x86_64-linux/ghc-9.4.8/lethargy-0.1.0.0/x/lethargy","build-info":"/tmp/nix-build-hoh-0.0.1.drv-0/a8f263mmzd7jvpwad2b1wx39gjzscys8-source/code/dist-newstyle/build/x86_64-linux/ghc-9.4.8/lethargy-0.1.0.0/x/lethargy/build-info.json","depends":["base-4.17.2.1"],"exe-depends":[],"component-name":"exe:lethargy","bin-file":"/tmp/nix-build-hoh-0.0.1.drv-0/a8f263mmzd7jvpwad2b1wx39gjzscys8-source/code/dist-newstyle/build/x86_64-linux/ghc-9.4.8/lethargy-0.1.0.0/x/lethargy/build/lethargy/lethargy"},{"type":"configured","id":"lethargy-0.1.0.0-inplace-lethargy-asm","pkg-name":"lethargy","pkg-version":"0.1.0.0","flags":{},"style":"local","pkg-src":{"type":"local","path":"/tmp/nix-build-hoh-0.0.1.drv-0/a8f263mmzd7jvpwad2b1wx39gjzscys8-source/code/lethargy"},"dist-dir":"/tmp/nix-build-hoh-0.0.1.drv-0/a8f263mmzd7jvpwad2b1wx39gjzscys8-source/code/dist-newstyle/build/x86_64-linux/ghc-9.4.8/lethargy-0.1.0.0/x/lethargy-asm","build-info":"/tmp/nix-build-hoh-0.0.1.drv-0/a8f263mmzd7jvpwad2b1wx39gjzscys8-source/code/dist-newstyle/build/x86_64-linux/ghc-9.4.8/lethargy-0.1.0.0/x/lethargy-asm/build-info.json","depends":["base-4.17.2.1"],"exe-depends":[],"component-name":"exe:lethargy-asm","bin-file":"/tmp/nix-build-hoh-0.0.1.drv-0/a8f263mmzd7jvpwad2b1wx39gjzscys8-source/code/dist-newstyle/build/x86_64-linux/ghc-9.4.8/lethargy-0.1.0.0/x/lethargy-asm/build/lethargy-asm/lethargy-asm"},{"type":"pre-existing","id":"rts","pkg-name":"rts","pkg-version":"1.0.2","depends":[]}]}
{"cabal-version":"3.10.2.1","cabal-lib-version":"3.10.2.1","compiler-id":"ghc-9.4.8","os":"linux","arch":"x86_64","install-plan":[{"type":"pre-existing","id":"base-4.17.2.1","pkg-name":"base","pkg-version":"4.17.2.1","depends":["ghc-bignum-1.3","ghc-prim-0.9.1","rts"]},{"type":"pre-existing","id":"ghc-bignum-1.3","pkg-name":"ghc-bignum","pkg-version":"1.3","depends":["ghc-prim-0.9.1"]},{"type":"pre-existing","id":"ghc-prim-0.9.1","pkg-name":"ghc-prim","pkg-version":"0.9.1","depends":["rts"]},{"type":"configured","id":"lethargy-0.1.0.0-inplace-lethargy","pkg-name":"lethargy","pkg-version":"0.1.0.0","flags":{},"style":"local","pkg-src":{"type":"local","path":"/tmp/nix-build-hoh-0.0.1.drv-0/y624b4klqil4z23gw7c0md8b3c5m0j68-source/code/lethargy"},"dist-dir":"/tmp/nix-build-hoh-0.0.1.drv-0/y624b4klqil4z23gw7c0md8b3c5m0j68-source/code/dist-newstyle/build/x86_64-linux/ghc-9.4.8/lethargy-0.1.0.0/x/lethargy","build-info":"/tmp/nix-build-hoh-0.0.1.drv-0/y624b4klqil4z23gw7c0md8b3c5m0j68-source/code/dist-newstyle/build/x86_64-linux/ghc-9.4.8/lethargy-0.1.0.0/x/lethargy/build-info.json","depends":["base-4.17.2.1"],"exe-depends":[],"component-name":"exe:lethargy","bin-file":"/tmp/nix-build-hoh-0.0.1.drv-0/y624b4klqil4z23gw7c0md8b3c5m0j68-source/code/dist-newstyle/build/x86_64-linux/ghc-9.4.8/lethargy-0.1.0.0/x/lethargy/build/lethargy/lethargy"},{"type":"configured","id":"lethargy-0.1.0.0-inplace-lethargy-asm","pkg-name":"lethargy","pkg-version":"0.1.0.0","flags":{},"style":"local","pkg-src":{"type":"local","path":"/tmp/nix-build-hoh-0.0.1.drv-0/y624b4klqil4z23gw7c0md8b3c5m0j68-source/code/lethargy"},"dist-dir":"/tmp/nix-build-hoh-0.0.1.drv-0/y624b4klqil4z23gw7c0md8b3c5m0j68-source/code/dist-newstyle/build/x86_64-linux/ghc-9.4.8/lethargy-0.1.0.0/x/lethargy-asm","build-info":"/tmp/nix-build-hoh-0.0.1.drv-0/y624b4klqil4z23gw7c0md8b3c5m0j68-source/code/dist-newstyle/build/x86_64-linux/ghc-9.4.8/lethargy-0.1.0.0/x/lethargy-asm/build-info.json","depends":["base-4.17.2.1"],"exe-depends":[],"component-name":"exe:lethargy-asm","bin-file":"/tmp/nix-build-hoh-0.0.1.drv-0/y624b4klqil4z23gw7c0md8b3c5m0j68-source/code/dist-newstyle/build/x86_64-linux/ghc-9.4.8/lethargy-0.1.0.0/x/lethargy-asm/build/lethargy-asm/lethargy-asm"},{"type":"pre-existing","id":"rts","pkg-name":"rts","pkg-version":"1.0.2","depends":[]}]}
Binary file modified _static/dist-newstyle/cache/solver-plan
Binary file not shown.
Binary file modified _static/dist-newstyle/cache/source-hashes
Binary file not shown.
2 changes: 1 addition & 1 deletion searchindex.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/Measurement_Observation/Binary_Profiling/asm.html
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@
Configuring executable &#39;lethargy-asm&#39; for lethargy-0.1.0.0..
Preprocessing executable &#39;lethargy-asm&#39; for lethargy-0.1.0.0..
Building executable &#39;lethargy-asm&#39; for lethargy-0.1.0.0..
[1 of 1] Compiling Main ( app/Main.hs, /tmp/nix-build-hoh-0.0.1.drv-0/a8f263mmzd7jvpwad2b1wx39gjzscys8-source/code/dist-newstyle/build/x86_64-linux/ghc-9.4.8/lethargy-0.1.0.0/x/lethargy-asm/build/lethargy-asm/lethargy-asm-tmp/Main.p_o )
[1 of 1] Compiling Main ( app/Main.hs, /tmp/nix-build-hoh-0.0.1.drv-0/y624b4klqil4z23gw7c0md8b3c5m0j68-source/code/dist-newstyle/build/x86_64-linux/ghc-9.4.8/lethargy-0.1.0.0/x/lethargy-asm/build/lethargy-asm/lethargy-asm-tmp/Main.p_o )

==================== Asm code ====================
.section .rodata.str,&quot;aMS&quot;,@progbits,1
Expand Down
21 changes: 11 additions & 10 deletions src/Measurement_Observation/Binary_Profiling/linux_perf.html
Original file line number Diff line number Diff line change
Expand Up @@ -234,21 +234,22 @@ <h2><span class="section-number">2.1.3.1. </span>What is Tables-Next-to-Code<a c
<a class="reference internal" href="../../glossary.html#term-Thunk"><span class="xref std std-term">Thunk</span></a>, Data Constructor, <a class="reference internal" href="../../glossary.html#term-PAP"><span class="xref std std-term">PAP</span></a> etc.; the <a class="reference internal" href="../../glossary.html#term-SRT"><span class="xref std std-term">SRT</span></a> <code class="docutils literal notranslate"><span class="pre">bitmap</span></code>,
which the garbage collector requires to collect <a class="reference internal" href="../../glossary.html#term-CAF"><span class="xref std std-term">CAF</span></a>’s. Lastly, the info
table will hold the <a class="reference internal" href="../../glossary.html#term-Entry-Code"><span class="xref std std-term">entry code</span></a> pointer for the heap object if one exists
<a class="footnote-reference brackets" href="#id11" id="id2" role="doc-noteref"><span class="fn-bracket">[</span>2<span class="fn-bracket">]</span></a> . For more see <a class="reference external" href="https://gitlab.haskell.org/ghc/ghc/-/blob/master/rts/include/rts/storage/InfoTables.h">InfoTables.h</a> for exact details and other variants.</p>
<a class="footnote-reference brackets" href="#id11" id="id2" role="doc-noteref"><span class="fn-bracket">[</span>2<span class="fn-bracket">]</span></a> . For more see <a class="reference external" href="https://gitlab.haskell.org/ghc/ghc/-/blob/master/rts/include/rts/storage/InfoTables.h">InfoTables.h</a> and <a class="reference external" href="https://gitlab.haskell.org/ghc/ghc/-/blob/master/rts/include/rts/storage/Storage.h">Closures.h</a> for exact details and variants.</p>
<p>Here is a depiction of the heap object layout without tables-next-to-code enabled. Code is
represented in orange and data in blue. Boxes which have a dashed outline change
depending on the type of heap object and build:</p>
<div class="figure" style="text-align: left"><p><img src="../../../_images/tikz-2ce56ab7d0223ce8614bc79f82a16c805c8cc6c3.svg" alt="Figure made with TikZ" /></p>
</div><p>Tables-next-to-code does two things: first it removes the entry code pointer
from the info table and second, it moves the entry code itself to the address
immediately after the info table and sets the info table pointer itself to the
address of the entry code. This setup allows the runtime system to save a
pointer indirection because the info table pointer now points to the entry code.
Thus, when jumping to the entry code, which is a common operation, the runtime
system saves a single indirection, but can still reference the fields of the
info table through a negative memory offset from the info table pointer.</p>
</div><p>Tables-next-to-code does two things: first it removes the entry code pointer and
places the type specific fields before the <code class="docutils literal notranslate"><span class="pre">Closure</span> <span class="pre">Type</span></code>, and second, it
moves the entry code itself to the address immediately after the info table and
sets the info table pointer to the address of the entry code. This setup allows
the runtime system to save a pointer indirection because the info table pointer
now points to the entry code. Thus, when jumping to the entry code, which is a
common operation, the runtime system saves a single indirection, but can still
reference the fields of the info table through a negative memory offset from
the info table pointer.</p>
<p>Here is a depiction with tables-next-to-code enabled:</p>
<div class="figure" style="text-align: left"><p><img src="../../../_images/tikz-9ac7c1a806690ce988332187ffaa95ac4c180c87.svg" alt="Figure made with TikZ" /></p>
<div class="figure" style="text-align: left"><p><img src="../../../_images/tikz-37e031dca7a0f5fe10a05bea1924af509e4478bf.svg" alt="Figure made with TikZ" /></p>
</div><p>The key change is that the info table pointer points to the entry code, while
the rest of the info table can still be referenced via negative offsets from the
entry code address.</p>
Expand Down

0 comments on commit 7af41c1

Please sign in to comment.