diff options
Diffstat (limited to 'doc')
-rw-r--r-- | doc/changes.html | 297 | ||||
-rw-r--r-- | doc/contact.html | 2 | ||||
-rw-r--r-- | doc/ext_c_api.html | 2 | ||||
-rw-r--r-- | doc/ext_ffi.html | 2 | ||||
-rw-r--r-- | doc/ext_ffi_api.html | 8 | ||||
-rw-r--r-- | doc/ext_ffi_semantics.html | 26 | ||||
-rw-r--r-- | doc/ext_ffi_tutorial.html | 2 | ||||
-rw-r--r-- | doc/ext_jit.html | 4 | ||||
-rw-r--r-- | doc/ext_profiler.html | 365 | ||||
-rw-r--r-- | doc/extensions.html | 75 | ||||
-rw-r--r-- | doc/faq.html | 2 | ||||
-rw-r--r-- | doc/install.html | 133 | ||||
-rw-r--r-- | doc/luajit.html | 8 | ||||
-rw-r--r-- | doc/running.html | 3 | ||||
-rw-r--r-- | doc/status.html | 2 |
15 files changed, 631 insertions, 300 deletions
diff --git a/doc/changes.html b/doc/changes.html index 96eef660..9684d7c0 100644 --- a/doc/changes.html +++ b/doc/changes.html | |||
@@ -44,6 +44,8 @@ div.major { max-width: 600px; padding: 1em; margin: 1em 0 1em 0; } | |||
44 | <a href="ext_jit.html">jit.* Library</a> | 44 | <a href="ext_jit.html">jit.* Library</a> |
45 | </li><li> | 45 | </li><li> |
46 | <a href="ext_c_api.html">Lua/C API</a> | 46 | <a href="ext_c_api.html">Lua/C API</a> |
47 | </li><li> | ||
48 | <a href="ext_profiler.html">Profiler</a> | ||
47 | </li></ul> | 49 | </li></ul> |
48 | </li><li> | 50 | </li><li> |
49 | <a href="status.html">Status</a> | 51 | <a href="status.html">Status</a> |
@@ -72,6 +74,72 @@ to see whether newer versions are available. | |||
72 | </p> | 74 | </p> |
73 | 75 | ||
74 | <div class="major" style="background: #d0d0ff;"> | 76 | <div class="major" style="background: #d0d0ff;"> |
77 | <h2 id="LuaJIT-2.1.0-beta2">LuaJIT 2.1.0-beta2 — 2016-03-03</h2> | ||
78 | <ul> | ||
79 | <li>Enable trace stitching.</li> | ||
80 | <li>Use internal implementation for converting FP numbers to strings.</li> | ||
81 | <li>Parse Unicode escape <tt>'\u{XX...}'</tt> in string literals.</li> | ||
82 | <li>Add MIPS soft-float support.</li> | ||
83 | <li>Switch MIPS port to dual-number mode.</li> | ||
84 | <li>x86/x64: Add support for AES-NI, AVX and AVX2 to DynASM.</li> | ||
85 | <li>FFI: Add <tt>ssize_t</tt> declaration.</li> | ||
86 | <li>FFI: Parse <tt>#line NN</tt> and <tt>#NN</tt>.</li> | ||
87 | <li>Various minor fixes.</li> | ||
88 | </ul> | ||
89 | |||
90 | <h2 id="LuaJIT-2.1.0-beta1">LuaJIT 2.1.0-beta1 — 2015-08-25</h2> | ||
91 | <p> | ||
92 | This is a brief summary of the major changes in LuaJIT 2.1 compared to 2.0. | ||
93 | Please take a look at the commit history for more details. | ||
94 | </p> | ||
95 | <ul> | ||
96 | <li>Changes to the VM core: | ||
97 | <ul> | ||
98 | <li>Add low-overhead profiler (<tt>-jp</tt>).</li> | ||
99 | <li>Add <tt>LJ_GC64</tt> mode: 64 bit GC object references (really: 47 bit). Interpreter-only for now.</li> | ||
100 | <li>Add <tt>LJ_FR2</tt> mode: Two-slot frame info. Required by <tt>LJ_GC64</tt> mode.</li> | ||
101 | <li>Add <tt>table.new()</tt> and <tt>table.clear()</tt>.</li> | ||
102 | <li>Parse binary number literals (<tt>0bxxx</tt>).</li> | ||
103 | </ul></li> | ||
104 | <li>Improvements to the JIT compiler: | ||
105 | <ul> | ||
106 | <li>Add trace stitching (disabled for now).</li> | ||
107 | <li>Compile various builtins: <tt>string.char()</tt>, <tt>string.reverse()</tt>, <tt>string.lower()</tt>, <tt>string.upper()</tt>, <tt>string.rep()</tt>, <tt>string.format()</tt>, <tt>table.concat()</tt>, <tt>bit.tohex()</tt>, <tt>getfenv(0)</tt>, <tt>debug.getmetatable()</tt>.</li> | ||
108 | <li>Compile <tt>string.find()</tt> for fixed string searches (no patterns).</li> | ||
109 | <li>Compile <tt>BC_TSETM</tt>, e.g. <tt>{1,2,3,f()}</tt>.</li> | ||
110 | <li>Compile string concatenations (<tt>BC_CAT</tt>).</li> | ||
111 | <li>Compile <tt>__concat</tt> metamethod.</li> | ||
112 | <li>Various minor optimizations.</li> | ||
113 | </ul></li> | ||
114 | <li>Internal Changes: | ||
115 | <ul> | ||
116 | <li>Add support for embedding LuaJIT bytecode for builtins.</li> | ||
117 | <li>Replace various builtins with embedded bytecode.</li> | ||
118 | <li>Refactor string buffers and string formatting.</li> | ||
119 | <li>Remove obsolete non-truncating number to integer conversions.</li> | ||
120 | </ul></li> | ||
121 | <li>Ports: | ||
122 | <ul> | ||
123 | <li>Add Xbox One port (<tt>LJ_GC64</tt> mode).</li> | ||
124 | <li>ARM64: Add port of the interpreter (<tt>LJ_GC64</tt> mode).</li> | ||
125 | <li>x64: Add separate port of the interpreter to <tt>LJ_GC64</tt> mode.</li> | ||
126 | <li>x86/x64: Drop internal x87 math functions. Use libm functions.</li> | ||
127 | <li>x86: Remove x87 support from interpreter. SSE2 is mandatory now.</li> | ||
128 | <li>PPC/e500: Drop support for this architecture.</li> | ||
129 | </ul></li> | ||
130 | <li>FFI library: | ||
131 | <ul> | ||
132 | <li>FFI: Add 64 bit bitwise operations.</li> | ||
133 | <li>FFI: Compile VLA/VLS and large cdata allocations with default initialization.</li> | ||
134 | <li>FFI: Compile conversions from functions to function pointers.</li> | ||
135 | <li>FFI: Compile lightuserdata to <tt>void *</tt> conversion.</li> | ||
136 | <li>FFI: Compile <tt>ffi.gc(cdata, nil)</tt>, too.</li> | ||
137 | <li>FFI: Add <tt>ffi.typeinfo()</tt>.</li> | ||
138 | </ul></li> | ||
139 | </ul> | ||
140 | </div> | ||
141 | |||
142 | <div class="major" style="background: #ffffd0;"> | ||
75 | <h2 id="LuaJIT-2.0.4">LuaJIT 2.0.4 — 2015-05-14</h2> | 143 | <h2 id="LuaJIT-2.0.4">LuaJIT 2.0.4 — 2015-05-14</h2> |
76 | <ul> | 144 | <ul> |
77 | <li>Fix stack check in narrowing optimization.</li> | 145 | <li>Fix stack check in narrowing optimization.</li> |
@@ -735,235 +803,6 @@ This matches the behavior of Lua 5.1, but not the specification.</li> | |||
735 | no point in listing differences over earlier versions.</li> | 803 | no point in listing differences over earlier versions.</li> |
736 | </ul> | 804 | </ul> |
737 | </div> | 805 | </div> |
738 | |||
739 | <div class="major" style="background: #ffff80;"> | ||
740 | <h2 id="LuaJIT-1.1.8">LuaJIT 1.1.8 — 2012-04-16</h2> | ||
741 | <ul> | ||
742 | <li>Merged with Lua 5.1.5. Also integrated fixes for all | ||
743 | <a href="http://www.lua.org/bugs.html#5.1.5"><span class="ext">»</span> <span class="ext">»</span> currently known bugs in Lua 5.1.5</a>.</li> | ||
744 | </ul> | ||
745 | |||
746 | <h2 id="LuaJIT-1.1.7">LuaJIT 1.1.7 — 2011-05-05</h2> | ||
747 | <ul> | ||
748 | <li>Added fixes for the | ||
749 | <a href="http://www.lua.org/bugs.html#5.1.4"><span class="ext">»</span> currently known bugs in Lua 5.1.4</a>.</li> | ||
750 | </ul> | ||
751 | |||
752 | <h2 id="LuaJIT-1.1.6">LuaJIT 1.1.6 — 2010-03-28</h2> | ||
753 | <ul> | ||
754 | <li>Added fixes for the | ||
755 | <a href="http://www.lua.org/bugs.html#5.1.4"><span class="ext">»</span> currently known bugs in Lua 5.1.4</a>.</li> | ||
756 | <li>Removed wrong GC check in <tt>jit_createstate()</tt>. | ||
757 | Thanks to Tim Mensch.</li> | ||
758 | <li>Fixed bad assertions while compiling <tt>table.insert()</tt> and | ||
759 | <tt>table.remove()</tt>.</li> | ||
760 | </ul> | ||
761 | |||
762 | <h2 id="LuaJIT-1.1.5">LuaJIT 1.1.5 — 2008-10-25</h2> | ||
763 | <ul> | ||
764 | <li>Merged with Lua 5.1.4. Fixes all | ||
765 | <a href="http://www.lua.org/bugs.html#5.1.3"><span class="ext">»</span> known bugs in Lua 5.1.3</a>.</li> | ||
766 | </ul> | ||
767 | |||
768 | <h2 id="LuaJIT-1.1.4">LuaJIT 1.1.4 — 2008-02-05</h2> | ||
769 | <ul> | ||
770 | <li>Merged with Lua 5.1.3. Fixes all | ||
771 | <a href="http://www.lua.org/bugs.html#5.1.2"><span class="ext">»</span> known bugs in Lua 5.1.2</a>.</li> | ||
772 | <li>Fixed possible (but unlikely) stack corruption while compiling | ||
773 | <tt>k^x</tt> expressions.</li> | ||
774 | <li>Fixed DynASM template for cmpss instruction.</li> | ||
775 | </ul> | ||
776 | |||
777 | <h2 id="LuaJIT-1.1.3">LuaJIT 1.1.3 — 2007-05-24</h2> | ||
778 | <ul> | ||
779 | <li>Merged with Lua 5.1.2. Fixes all | ||
780 | <a href="http://www.lua.org/bugs.html#5.1.1"><span class="ext">»</span> known bugs in Lua 5.1.1</a>.</li> | ||
781 | <li>Merged pending Lua 5.1.x fixes: "return -nil" bug, spurious count hook call.</li> | ||
782 | <li>Remove a (sometimes) wrong assertion in <tt>luaJIT_findpc()</tt>.</li> | ||
783 | <li>DynASM now allows labels for displacements and <tt>.aword</tt>.</li> | ||
784 | <li>Fix some compiler warnings for DynASM glue (internal API change).</li> | ||
785 | <li>Correct naming for SSSE3 (temporarily known as SSE4) in DynASM and x86 disassembler.</li> | ||
786 | <li>The loadable debug modules now handle redirection to stdout | ||
787 | (e.g. <tt>-j trace=-</tt>).</li> | ||
788 | </ul> | ||
789 | |||
790 | <h2 id="LuaJIT-1.1.2">LuaJIT 1.1.2 — 2006-06-24</h2> | ||
791 | <ul> | ||
792 | <li>Fix MSVC inline assembly: use only local variables with | ||
793 | <tt>lua_number2int()</tt>.</li> | ||
794 | <li>Fix "attempt to call a thread value" bug on Mac OS X: | ||
795 | make values of consts used as lightuserdata keys unique | ||
796 | to avoid joining by the compiler/linker.</li> | ||
797 | </ul> | ||
798 | |||
799 | <h2 id="LuaJIT-1.1.1">LuaJIT 1.1.1 — 2006-06-20</h2> | ||
800 | <ul> | ||
801 | <li>Merged with Lua 5.1.1. Fixes all | ||
802 | <a href="http://www.lua.org/bugs.html#5.1"><span class="ext">»</span> known bugs in Lua 5.1</a>.</li> | ||
803 | <li>Enforce (dynamic) linker error for EXE/DLL version mismatches.</li> | ||
804 | <li>Minor changes to DynASM: faster pre-processing, smaller encoding | ||
805 | for some immediates.</li> | ||
806 | </ul> | ||
807 | <p> | ||
808 | This release is in sync with Coco 1.1.1 (see the | ||
809 | <a href="http://coco.luajit.org/changes.html"><span class="ext">»</span> Coco Change History</a>). | ||
810 | </p> | ||
811 | |||
812 | <h2 id="LuaJIT-1.1.0">LuaJIT 1.1.0 — 2006-03-13</h2> | ||
813 | <ul> | ||
814 | <li>Merged with Lua 5.1 (final).</li> | ||
815 | |||
816 | <li>New JIT call frame setup: | ||
817 | <ul> | ||
818 | <li>The C stack is kept 16 byte aligned (faster). | ||
819 | Mandatory for Mac OS X on Intel, too.</li> | ||
820 | <li>Faster calling conventions for internal C helper functions.</li> | ||
821 | <li>Better instruction scheduling for function prologue, OP_CALL and | ||
822 | OP_RETURN.</li> | ||
823 | </ul></li> | ||
824 | |||
825 | <li>Miscellaneous optimizations: | ||
826 | <ul> | ||
827 | <li>Faster loads of FP constants. Remove narrow-to-wide store-to-load | ||
828 | forwarding stalls.</li> | ||
829 | <li>Use (scalar) SSE2 ops (if the CPU supports it) to speed up slot moves | ||
830 | and FP to integer conversions.</li> | ||
831 | <li>Optimized the two-argument form of <tt>OP_CONCAT</tt> (<tt>a..b</tt>).</li> | ||
832 | <li>Inlined <tt>OP_MOD</tt> (<tt>a%b</tt>). | ||
833 | With better accuracy than the C variant, too.</li> | ||
834 | <li>Inlined <tt>OP_POW</tt> (<tt>a^b</tt>). Unroll <tt>x^k</tt> or | ||
835 | use <tt>k^x = 2^(log2(k)*x)</tt> or call <tt>pow()</tt>.</li> | ||
836 | </ul></li> | ||
837 | |||
838 | <li>Changes in the optimizer: | ||
839 | <ul> | ||
840 | <li>Improved hinting for table keys derived from table values | ||
841 | (<tt>t1[t2[x]]</tt>).</li> | ||
842 | <li>Lookup hinting now works with arbitrary object types and | ||
843 | supports index chains, too.</li> | ||
844 | <li>Generate type hints for arithmetic and comparison operators, | ||
845 | OP_LEN, OP_CONCAT and OP_FORPREP.</li> | ||
846 | <li>Remove several hint definitions in favour of a generic COMBINE hint.</li> | ||
847 | <li>Complete rewrite of <tt>jit.opt_inline</tt> module | ||
848 | (ex <tt>jit.opt_lib</tt>).</li> | ||
849 | </ul></li> | ||
850 | |||
851 | <li>Use adaptive deoptimization: | ||
852 | <ul> | ||
853 | <li>If runtime verification of a contract fails, the affected | ||
854 | instruction is recompiled and patched on-the-fly. | ||
855 | Regular programs will trigger deoptimization only occasionally.</li> | ||
856 | <li>This avoids generating code for uncommon fallback cases | ||
857 | most of the time. Generated code is up to 30% smaller compared to | ||
858 | LuaJIT 1.0.3.</li> | ||
859 | <li>Deoptimization is used for many opcodes and contracts: | ||
860 | <ul> | ||
861 | <li>OP_CALL, OP_TAILCALL: type mismatch for callable.</li> | ||
862 | <li>Inlined calls: closure mismatch, parameter number and type mismatches.</li> | ||
863 | <li>OP_GETTABLE, OP_SETTABLE: table or key type and range mismatches.</li> | ||
864 | <li>All arithmetic and comparison operators, OP_LEN, OP_CONCAT, | ||
865 | OP_FORPREP: operand type and range mismatches.</li> | ||
866 | </ul></li> | ||
867 | <li>Complete redesign of the debug and traceback info | ||
868 | (bytecode ↔ mcode) to support deoptimization. | ||
869 | Much more flexible and needs only 50% of the space.</li> | ||
870 | <li>The modules <tt>jit.trace</tt>, <tt>jit.dumphints</tt> and | ||
871 | <tt>jit.dump</tt> handle deoptimization.</li> | ||
872 | </ul></li> | ||
873 | |||
874 | <li>Inlined many popular library functions | ||
875 | (for commonly used arguments only): | ||
876 | <ul> | ||
877 | <li>Most <tt>math.*</tt> functions (the 18 most used ones) | ||
878 | [2x-10x faster].</li> | ||
879 | <li><tt>string.len</tt>, <tt>string.sub</tt> and <tt>string.char</tt> | ||
880 | [2x-10x faster].</li> | ||
881 | <li><tt>table.insert</tt>, <tt>table.remove</tt> and <tt>table.getn</tt> | ||
882 | [3x-5x faster].</li> | ||
883 | <li><tt>coroutine.yield</tt> and <tt>coroutine.resume</tt> | ||
884 | [3x-5x faster].</li> | ||
885 | <li><tt>pairs</tt>, <tt>ipairs</tt> and the corresponding iterators | ||
886 | [8x-15x faster].</li> | ||
887 | </ul></li> | ||
888 | |||
889 | <li>Changes in the core and loadable modules and the stand-alone executable: | ||
890 | <ul> | ||
891 | <li>Added <tt>jit.version</tt>, <tt>jit.version_num</tt> | ||
892 | and <tt>jit.arch</tt>.</li> | ||
893 | <li>Reorganized some internal API functions (<tt>jit.util.*mcode*</tt>).</li> | ||
894 | <li>The <tt>-j dump</tt> output now shows JSUB names, too.</li> | ||
895 | <li>New x86 disassembler module written in pure Lua. No dependency | ||
896 | on ndisasm anymore. Flexible API, very compact (500 lines) | ||
897 | and complete (x87, MMX, SSE, SSE2, SSE3, SSSE3, privileged instructions).</li> | ||
898 | <li><tt>luajit -v</tt> prints the LuaJIT version and copyright | ||
899 | on a separate line.</li> | ||
900 | </ul></li> | ||
901 | |||
902 | <li>Added SSE, SSE2, SSE3 and SSSE3 support to DynASM.</li> | ||
903 | <li>Miscellaneous doc changes. Added a section about | ||
904 | <a href="install.html#embedding">embedding LuaJIT</a>.</li> | ||
905 | </ul> | ||
906 | <p> | ||
907 | This release is in sync with Coco 1.1.0 (see the | ||
908 | <a href="http://coco.luajit.org/changes.html"><span class="ext">»</span> Coco Change History</a>). | ||
909 | </p> | ||
910 | </div> | ||
911 | |||
912 | <div class="major" style="background: #ffffd0;"> | ||
913 | <h2 id="LuaJIT-1.0.3">LuaJIT 1.0.3 — 2005-09-08</h2> | ||
914 | <ul> | ||
915 | <li>Even more docs.</li> | ||
916 | <li>Unified closure checks in <tt>jit.*</tt>.</li> | ||
917 | <li>Fixed some range checks in <tt>jit.util.*</tt>.</li> | ||
918 | <li>Fixed __newindex call originating from <tt>jit_settable_str()</tt>.</li> | ||
919 | <li>Merged with Lua 5.1 alpha (including early bug fixes).</li> | ||
920 | </ul> | ||
921 | <p> | ||
922 | This is the first public release of LuaJIT. | ||
923 | </p> | ||
924 | |||
925 | <h2 id="LuaJIT-1.0.2">LuaJIT 1.0.2 — 2005-09-02</h2> | ||
926 | <ul> | ||
927 | <li>Add support for flushing the Valgrind translation cache <br> | ||
928 | (<tt>MYCFLAGS= -DUSE_VALGRIND</tt>).</li> | ||
929 | <li>Add support for freeing executable mcode memory to the <tt>mmap()</tt>-based | ||
930 | variant for POSIX systems.</li> | ||
931 | <li>Reorganized the C function signature handling in | ||
932 | <tt>jit.opt_lib</tt>.</li> | ||
933 | <li>Changed to index-based hints for inlining C functions. | ||
934 | Still no support in the backend for inlining.</li> | ||
935 | <li>Hardcode <tt>HEAP_CREATE_ENABLE_EXECUTE</tt> value if undefined.</li> | ||
936 | <li>Misc. changes to the <tt>jit.*</tt> modules.</li> | ||
937 | <li>Misc. changes to the Makefiles.</li> | ||
938 | <li>Lots of new docs.</li> | ||
939 | <li>Complete doc reorg.</li> | ||
940 | </ul> | ||
941 | <p> | ||
942 | Not released because Lua 5.1 alpha came out today. | ||
943 | </p> | ||
944 | |||
945 | <h2 id="LuaJIT-1.0.1">LuaJIT 1.0.1 — 2005-08-31</h2> | ||
946 | <ul> | ||
947 | <li>Missing GC step in <tt>OP_CONCAT</tt>.</li> | ||
948 | <li>Fix result handling for C –> JIT calls.</li> | ||
949 | <li>Detect CPU feature bits.</li> | ||
950 | <li>Encode conditional moves (<tt>fucomip</tt>) only when supported.</li> | ||
951 | <li>Add fallback instructions for FP compares.</li> | ||
952 | <li>Add support for <tt>LUA_COMPAT_VARARG</tt>. Still disabled by default.</li> | ||
953 | <li>MSVC needs a specific place for the <tt>CALLBACK</tt> attribute | ||
954 | (David Burgess).</li> | ||
955 | <li>Misc. doc updates.</li> | ||
956 | </ul> | ||
957 | <p> | ||
958 | Interim non-public release. | ||
959 | Special thanks to Adam D. Moss for reporting most of the bugs. | ||
960 | </p> | ||
961 | |||
962 | <h2 id="LuaJIT-1.0.0">LuaJIT 1.0.0 — 2005-08-29</h2> | ||
963 | <p> | ||
964 | This is the initial non-public release of LuaJIT. | ||
965 | </p> | ||
966 | </div> | ||
967 | <br class="flush"> | 806 | <br class="flush"> |
968 | </div> | 807 | </div> |
969 | <div id="foot"> | 808 | <div id="foot"> |
diff --git a/doc/contact.html b/doc/contact.html index 9f358805..52623764 100644 --- a/doc/contact.html +++ b/doc/contact.html | |||
@@ -41,6 +41,8 @@ | |||
41 | <a href="ext_jit.html">jit.* Library</a> | 41 | <a href="ext_jit.html">jit.* Library</a> |
42 | </li><li> | 42 | </li><li> |
43 | <a href="ext_c_api.html">Lua/C API</a> | 43 | <a href="ext_c_api.html">Lua/C API</a> |
44 | </li><li> | ||
45 | <a href="ext_profiler.html">Profiler</a> | ||
44 | </li></ul> | 46 | </li></ul> |
45 | </li><li> | 47 | </li><li> |
46 | <a href="status.html">Status</a> | 48 | <a href="status.html">Status</a> |
diff --git a/doc/ext_c_api.html b/doc/ext_c_api.html index 95985583..e1af3ed0 100644 --- a/doc/ext_c_api.html +++ b/doc/ext_c_api.html | |||
@@ -41,6 +41,8 @@ | |||
41 | <a href="ext_jit.html">jit.* Library</a> | 41 | <a href="ext_jit.html">jit.* Library</a> |
42 | </li><li> | 42 | </li><li> |
43 | <a class="current" href="ext_c_api.html">Lua/C API</a> | 43 | <a class="current" href="ext_c_api.html">Lua/C API</a> |
44 | </li><li> | ||
45 | <a href="ext_profiler.html">Profiler</a> | ||
44 | </li></ul> | 46 | </li></ul> |
45 | </li><li> | 47 | </li><li> |
46 | <a href="status.html">Status</a> | 48 | <a href="status.html">Status</a> |
diff --git a/doc/ext_ffi.html b/doc/ext_ffi.html index 1db5b6a7..d814f4d0 100644 --- a/doc/ext_ffi.html +++ b/doc/ext_ffi.html | |||
@@ -41,6 +41,8 @@ | |||
41 | <a href="ext_jit.html">jit.* Library</a> | 41 | <a href="ext_jit.html">jit.* Library</a> |
42 | </li><li> | 42 | </li><li> |
43 | <a href="ext_c_api.html">Lua/C API</a> | 43 | <a href="ext_c_api.html">Lua/C API</a> |
44 | </li><li> | ||
45 | <a href="ext_profiler.html">Profiler</a> | ||
44 | </li></ul> | 46 | </li></ul> |
45 | </li><li> | 47 | </li><li> |
46 | <a href="status.html">Status</a> | 48 | <a href="status.html">Status</a> |
diff --git a/doc/ext_ffi_api.html b/doc/ext_ffi_api.html index 90bd65d0..6d405960 100644 --- a/doc/ext_ffi_api.html +++ b/doc/ext_ffi_api.html | |||
@@ -46,6 +46,8 @@ td.abiparam { font-weight: bold; width: 6em; } | |||
46 | <a href="ext_jit.html">jit.* Library</a> | 46 | <a href="ext_jit.html">jit.* Library</a> |
47 | </li><li> | 47 | </li><li> |
48 | <a href="ext_c_api.html">Lua/C API</a> | 48 | <a href="ext_c_api.html">Lua/C API</a> |
49 | </li><li> | ||
50 | <a href="ext_profiler.html">Profiler</a> | ||
49 | </li></ul> | 51 | </li></ul> |
50 | </li><li> | 52 | </li><li> |
51 | <a href="status.html">Status</a> | 53 | <a href="status.html">Status</a> |
@@ -466,6 +468,8 @@ otherwise. The following parameters are currently defined: | |||
466 | <td class="abiparam">eabi</td><td class="abidesc">EABI variant of the standard ABI</td></tr> | 468 | <td class="abiparam">eabi</td><td class="abidesc">EABI variant of the standard ABI</td></tr> |
467 | <tr class="odd"> | 469 | <tr class="odd"> |
468 | <td class="abiparam">win</td><td class="abidesc">Windows variant of the standard ABI</td></tr> | 470 | <td class="abiparam">win</td><td class="abidesc">Windows variant of the standard ABI</td></tr> |
471 | <tr class="even"> | ||
472 | <td class="abiparam">gc64</td><td class="abidesc">64 bit GC references</td></tr> | ||
469 | </table> | 473 | </table> |
470 | 474 | ||
471 | <h3 id="ffi_os"><tt>ffi.os</tt></h3> | 475 | <h3 id="ffi_os"><tt>ffi.os</tt></h3> |
@@ -542,8 +546,8 @@ corresponding ctype. | |||
542 | The parser for Lua source code treats numeric literals with the | 546 | The parser for Lua source code treats numeric literals with the |
543 | suffixes <tt>LL</tt> or <tt>ULL</tt> as signed or unsigned 64 bit | 547 | suffixes <tt>LL</tt> or <tt>ULL</tt> as signed or unsigned 64 bit |
544 | integers. Case doesn't matter, but uppercase is recommended for | 548 | integers. Case doesn't matter, but uppercase is recommended for |
545 | readability. It handles both decimal (<tt>42LL</tt>) and hexadecimal | 549 | readability. It handles decimal (<tt>42LL</tt>), hexadecimal |
546 | (<tt>0x2aLL</tt>) literals. | 550 | (<tt>0x2aLL</tt>) and binary (<tt>0b101010LL</tt>) literals. |
547 | </p> | 551 | </p> |
548 | <p> | 552 | <p> |
549 | The imaginary part of complex numbers can be specified by suffixing | 553 | The imaginary part of complex numbers can be specified by suffixing |
diff --git a/doc/ext_ffi_semantics.html b/doc/ext_ffi_semantics.html index 0a754569..15843d7c 100644 --- a/doc/ext_ffi_semantics.html +++ b/doc/ext_ffi_semantics.html | |||
@@ -46,6 +46,8 @@ td.convop { font-style: italic; width: 40%; } | |||
46 | <a href="ext_jit.html">jit.* Library</a> | 46 | <a href="ext_jit.html">jit.* Library</a> |
47 | </li><li> | 47 | </li><li> |
48 | <a href="ext_c_api.html">Lua/C API</a> | 48 | <a href="ext_c_api.html">Lua/C API</a> |
49 | </li><li> | ||
50 | <a href="ext_profiler.html">Profiler</a> | ||
49 | </li></ul> | 51 | </li></ul> |
50 | </li><li> | 52 | </li><li> |
51 | <a href="status.html">Status</a> | 53 | <a href="status.html">Status</a> |
@@ -183,6 +185,8 @@ a <tt>typedef</tt>, except re-declarations will be ignored): | |||
183 | <tt>uint16_t</tt>, <tt>uint32_t</tt>, <tt>uint64_t</tt>, | 185 | <tt>uint16_t</tt>, <tt>uint32_t</tt>, <tt>uint64_t</tt>, |
184 | <tt>intptr_t</tt>, <tt>uintptr_t</tt>.</li> | 186 | <tt>intptr_t</tt>, <tt>uintptr_t</tt>.</li> |
185 | 187 | ||
188 | <li>From <tt><unistd.h></tt> (POSIX): <tt>ssize_t</tt>.</li> | ||
189 | |||
186 | </ul> | 190 | </ul> |
187 | <p> | 191 | <p> |
188 | You're encouraged to use these types in preference to | 192 | You're encouraged to use these types in preference to |
@@ -730,6 +734,22 @@ You'll have to explicitly convert a 64 bit integer to a Lua | |||
730 | number (e.g. for regular floating-point calculations) with | 734 | number (e.g. for regular floating-point calculations) with |
731 | <tt>tonumber()</tt>. But note this may incur a precision loss.</li> | 735 | <tt>tonumber()</tt>. But note this may incur a precision loss.</li> |
732 | 736 | ||
737 | <li><b>64 bit bitwise operations</b>: the rules for 64 bit | ||
738 | arithmetic operators apply analogously.<br> | ||
739 | |||
740 | Unlike the other <tt>bit.*</tt> operations, <tt>bit.tobit()</tt> | ||
741 | converts a cdata number via <tt>int64_t</tt> to <tt>int32_t</tt> and | ||
742 | returns a Lua number.<br> | ||
743 | |||
744 | For <tt>bit.band()</tt>, <tt>bit.bor()</tt> and <tt>bit.bxor()</tt>, the | ||
745 | conversion to <tt>int64_t</tt> or <tt>uint64_t</tt> applies to | ||
746 | <em>all</em> arguments, if <em>any</em> argument is a cdata number.<br> | ||
747 | |||
748 | For all other operations, only the first argument is used to determine | ||
749 | the output type. This implies that a cdata number as a shift count for | ||
750 | shifts and rotates is accepted, but that alone does <em>not</em> cause | ||
751 | a cdata number output. | ||
752 | |||
733 | </ul> | 753 | </ul> |
734 | 754 | ||
735 | <h3 id="cdata_comp">Comparisons of cdata objects</h3> | 755 | <h3 id="cdata_comp">Comparisons of cdata objects</h3> |
@@ -1205,9 +1225,8 @@ suboptimal performance, especially when used in inner loops: | |||
1205 | <li>Vector operations.</li> | 1225 | <li>Vector operations.</li> |
1206 | <li>Table initializers.</li> | 1226 | <li>Table initializers.</li> |
1207 | <li>Initialization of nested <tt>struct</tt>/<tt>union</tt> types.</li> | 1227 | <li>Initialization of nested <tt>struct</tt>/<tt>union</tt> types.</li> |
1208 | <li>Allocations of variable-length arrays or structs.</li> | 1228 | <li>Non-default initialization of VLA/VLS or large C types |
1209 | <li>Allocations of C types with a size > 128 bytes or an | 1229 | (> 128 bytes or > 16 array elements.</li> |
1210 | alignment > 8 bytes.</li> | ||
1211 | <li>Conversions from lightuserdata to <tt>void *</tt>.</li> | 1230 | <li>Conversions from lightuserdata to <tt>void *</tt>.</li> |
1212 | <li>Pointer differences for element sizes that are not a power of | 1231 | <li>Pointer differences for element sizes that are not a power of |
1213 | two.</li> | 1232 | two.</li> |
@@ -1224,7 +1243,6 @@ value.</li> | |||
1224 | Other missing features: | 1243 | Other missing features: |
1225 | </p> | 1244 | </p> |
1226 | <ul> | 1245 | <ul> |
1227 | <li>Bit operations for 64 bit types.</li> | ||
1228 | <li>Arithmetic for <tt>complex</tt> numbers.</li> | 1246 | <li>Arithmetic for <tt>complex</tt> numbers.</li> |
1229 | <li>Passing structs by value to vararg C functions.</li> | 1247 | <li>Passing structs by value to vararg C functions.</li> |
1230 | <li><a href="extensions.html#exceptions">C++ exception interoperability</a> | 1248 | <li><a href="extensions.html#exceptions">C++ exception interoperability</a> |
diff --git a/doc/ext_ffi_tutorial.html b/doc/ext_ffi_tutorial.html index d396714c..01200c45 100644 --- a/doc/ext_ffi_tutorial.html +++ b/doc/ext_ffi_tutorial.html | |||
@@ -48,6 +48,8 @@ td.idiomlua b { font-weight: normal; color: #2142bf; } | |||
48 | <a href="ext_jit.html">jit.* Library</a> | 48 | <a href="ext_jit.html">jit.* Library</a> |
49 | </li><li> | 49 | </li><li> |
50 | <a href="ext_c_api.html">Lua/C API</a> | 50 | <a href="ext_c_api.html">Lua/C API</a> |
51 | </li><li> | ||
52 | <a href="ext_profiler.html">Profiler</a> | ||
51 | </li></ul> | 53 | </li></ul> |
52 | </li><li> | 54 | </li><li> |
53 | <a href="status.html">Status</a> | 55 | <a href="status.html">Status</a> |
diff --git a/doc/ext_jit.html b/doc/ext_jit.html index 3bfc9052..86098019 100644 --- a/doc/ext_jit.html +++ b/doc/ext_jit.html | |||
@@ -41,6 +41,8 @@ | |||
41 | <a class="current" href="ext_jit.html">jit.* Library</a> | 41 | <a class="current" href="ext_jit.html">jit.* Library</a> |
42 | </li><li> | 42 | </li><li> |
43 | <a href="ext_c_api.html">Lua/C API</a> | 43 | <a href="ext_c_api.html">Lua/C API</a> |
44 | </li><li> | ||
45 | <a href="ext_profiler.html">Profiler</a> | ||
44 | </li></ul> | 46 | </li></ul> |
45 | </li><li> | 47 | </li><li> |
46 | <a href="status.html">Status</a> | 48 | <a href="status.html">Status</a> |
@@ -151,7 +153,7 @@ Contains the target OS name: | |||
151 | <h3 id="jit_arch"><tt>jit.arch</tt></h3> | 153 | <h3 id="jit_arch"><tt>jit.arch</tt></h3> |
152 | <p> | 154 | <p> |
153 | Contains the target architecture name: | 155 | Contains the target architecture name: |
154 | "x86", "x64", "arm", "ppc", "ppcspe", or "mips". | 156 | "x86", "x64", "arm", "arm64", "ppc", "mips" or "mips64". |
155 | </p> | 157 | </p> |
156 | 158 | ||
157 | <h2 id="jit_opt"><tt>jit.opt.*</tt> — JIT compiler optimization control</h2> | 159 | <h2 id="jit_opt"><tt>jit.opt.*</tt> — JIT compiler optimization control</h2> |
diff --git a/doc/ext_profiler.html b/doc/ext_profiler.html new file mode 100644 index 00000000..69ea25db --- /dev/null +++ b/doc/ext_profiler.html | |||
@@ -0,0 +1,365 @@ | |||
1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> | ||
2 | <html> | ||
3 | <head> | ||
4 | <title>Profiler</title> | ||
5 | <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> | ||
6 | <meta name="Author" content="Mike Pall"> | ||
7 | <meta name="Copyright" content="Copyright (C) 2005-2016, Mike Pall"> | ||
8 | <meta name="Language" content="en"> | ||
9 | <link rel="stylesheet" type="text/css" href="bluequad.css" media="screen"> | ||
10 | <link rel="stylesheet" type="text/css" href="bluequad-print.css" media="print"> | ||
11 | </head> | ||
12 | <body> | ||
13 | <div id="site"> | ||
14 | <a href="http://luajit.org"><span>Lua<span id="logo">JIT</span></span></a> | ||
15 | </div> | ||
16 | <div id="head"> | ||
17 | <h1>Profiler</h1> | ||
18 | </div> | ||
19 | <div id="nav"> | ||
20 | <ul><li> | ||
21 | <a href="luajit.html">LuaJIT</a> | ||
22 | <ul><li> | ||
23 | <a href="http://luajit.org/download.html">Download <span class="ext">»</span></a> | ||
24 | </li><li> | ||
25 | <a href="install.html">Installation</a> | ||
26 | </li><li> | ||
27 | <a href="running.html">Running</a> | ||
28 | </li></ul> | ||
29 | </li><li> | ||
30 | <a href="extensions.html">Extensions</a> | ||
31 | <ul><li> | ||
32 | <a href="ext_ffi.html">FFI Library</a> | ||
33 | <ul><li> | ||
34 | <a href="ext_ffi_tutorial.html">FFI Tutorial</a> | ||
35 | </li><li> | ||
36 | <a href="ext_ffi_api.html">ffi.* API</a> | ||
37 | </li><li> | ||
38 | <a href="ext_ffi_semantics.html">FFI Semantics</a> | ||
39 | </li></ul> | ||
40 | </li><li> | ||
41 | <a href="ext_jit.html">jit.* Library</a> | ||
42 | </li><li> | ||
43 | <a href="ext_c_api.html">Lua/C API</a> | ||
44 | </li><li> | ||
45 | <a class="current" href="ext_profiler.html">Profiler</a> | ||
46 | </li></ul> | ||
47 | </li><li> | ||
48 | <a href="status.html">Status</a> | ||
49 | <ul><li> | ||
50 | <a href="changes.html">Changes</a> | ||
51 | </li></ul> | ||
52 | </li><li> | ||
53 | <a href="faq.html">FAQ</a> | ||
54 | </li><li> | ||
55 | <a href="http://luajit.org/performance.html">Performance <span class="ext">»</span></a> | ||
56 | </li><li> | ||
57 | <a href="http://wiki.luajit.org/">Wiki <span class="ext">»</span></a> | ||
58 | </li><li> | ||
59 | <a href="http://luajit.org/list.html">Mailing List <span class="ext">»</span></a> | ||
60 | </li></ul> | ||
61 | </div> | ||
62 | <div id="main"> | ||
63 | <p> | ||
64 | LuaJIT has an integrated statistical profiler with very low overhead. It | ||
65 | allows sampling the currently executing stack and other parameters in | ||
66 | regular intervals. | ||
67 | </p> | ||
68 | <p> | ||
69 | The integrated profiler can be accessed from three levels: | ||
70 | </p> | ||
71 | <ul> | ||
72 | <li>The <a href="#hl_profiler">bundled high-level profiler</a>, invoked by the | ||
73 | <a href="#j_p"><tt>-jp</tt></a> command line option.</li> | ||
74 | <li>A <a href="#ll_lua_api">low-level Lua API</a> to control the profiler.</li> | ||
75 | <li>A <a href="#ll_c_api">low-level C API</a> to control the profiler.</li> | ||
76 | </ul> | ||
77 | |||
78 | <h2 id="hl_profiler">High-Level Profiler</h2> | ||
79 | <p> | ||
80 | The bundled high-level profiler offers basic profiling functionality. It | ||
81 | generates simple textual summaries or source code annotations. It can be | ||
82 | accessed with the <a href="#j_p"><tt>-jp</tt></a> command line option | ||
83 | or from Lua code by loading the underlying <tt>jit.p</tt> module. | ||
84 | </p> | ||
85 | <p> | ||
86 | To cut to the chase — run this to get a CPU usage profile by | ||
87 | function name: | ||
88 | </p> | ||
89 | <pre class="code"> | ||
90 | luajit -jp myapp.lua | ||
91 | </pre> | ||
92 | <p> | ||
93 | It's <em>not</em> a stated goal of the bundled profiler to add every | ||
94 | possible option or to cater for special profiling needs. The low-level | ||
95 | profiler APIs are documented below. They may be used by third-party | ||
96 | authors to implement advanced functionality, e.g. IDE integration or | ||
97 | graphical profilers. | ||
98 | </p> | ||
99 | <p> | ||
100 | Note: Sampling works for both interpreted and JIT-compiled code. The | ||
101 | results for JIT-compiled code may sometimes be surprising. LuaJIT | ||
102 | heavily optimizes and inlines Lua code — there's no simple | ||
103 | one-to-one correspondence between source code lines and the sampled | ||
104 | machine code. | ||
105 | </p> | ||
106 | |||
107 | <h3 id="j_p"><tt>-jp=[options[,output]]</tt></h3> | ||
108 | <p> | ||
109 | The <tt>-jp</tt> command line option starts the high-level profiler. | ||
110 | When the application run by the command line terminates, the profiler | ||
111 | stops and writes the results to <tt>stdout</tt> or to the specified | ||
112 | <tt>output</tt> file. | ||
113 | </p> | ||
114 | <p> | ||
115 | The <tt>options</tt> argument specifies how the profiling is to be | ||
116 | performed: | ||
117 | </p> | ||
118 | <ul> | ||
119 | <li><tt>f</tt> — Stack dump: function name, otherwise module:line. | ||
120 | This is the default mode.</li> | ||
121 | <li><tt>F</tt> — Stack dump: ditto, but dump module:name.</li> | ||
122 | <li><tt>l</tt> — Stack dump: module:line.</li> | ||
123 | <li><tt><number></tt> — stack dump depth (callee ← | ||
124 | caller). Default: 1.</li> | ||
125 | <li><tt>-<number></tt> — Inverse stack dump depth (caller | ||
126 | → callee).</li> | ||
127 | <li><tt>s</tt> — Split stack dump after first stack level. Implies | ||
128 | depth ≥ 2 or depth ≤ -2.</li> | ||
129 | <li><tt>p</tt> — Show full path for module names.</li> | ||
130 | <li><tt>v</tt> — Show VM states.</li> | ||
131 | <li><tt>z</tt> — Show <a href="#jit_zone">zones</a>.</li> | ||
132 | <li><tt>r</tt> — Show raw sample counts. Default: show percentages.</li> | ||
133 | <li><tt>a</tt> — Annotate excerpts from source code files.</li> | ||
134 | <li><tt>A</tt> — Annotate complete source code files.</li> | ||
135 | <li><tt>G</tt> — Produce raw output suitable for graphical tools.</li> | ||
136 | <li><tt>m<number></tt> — Minimum sample percentage to be shown. | ||
137 | Default: 3%.</li> | ||
138 | <li><tt>i<number></tt> — Sampling interval in milliseconds. | ||
139 | Default: 10ms.<br> | ||
140 | Note: The actual sampling precision is OS-dependent.</li> | ||
141 | </ul> | ||
142 | <p> | ||
143 | The default output for <tt>-jp</tt> is a list of the most CPU consuming | ||
144 | spots in the application. Increasing the stack dump depth with (say) | ||
145 | <tt>-jp=2</tt> may help to point out the main callers or callees of | ||
146 | hotspots. But sample aggregation is still flat per unique stack dump. | ||
147 | </p> | ||
148 | <p> | ||
149 | To get a two-level view (split view) of callers/callees, use | ||
150 | <tt>-jp=s</tt> or <tt>-jp=-s</tt>. The percentages shown for the second | ||
151 | level are relative to the first level. | ||
152 | </p> | ||
153 | <p> | ||
154 | To see how much time is spent in each line relative to a function, use | ||
155 | <tt>-jp=fl</tt>. | ||
156 | </p> | ||
157 | <p> | ||
158 | To see how much time is spent in different VM states or | ||
159 | <a href="#jit_zone">zones</a>, use <tt>-jp=v</tt> or <tt>-jp=z</tt>. | ||
160 | </p> | ||
161 | <p> | ||
162 | Combinations of <tt>v/z</tt> with <tt>f/F/l</tt> produce two-level | ||
163 | views, e.g. <tt>-jp=vf</tt> or <tt>-jp=fv</tt>. This shows the time | ||
164 | spent in a VM state or zone vs. hotspots. This can be used to answer | ||
165 | questions like "Which time consuming functions are only interpreted?" or | ||
166 | "What's the garbage collector overhead for a specific function?". | ||
167 | </p> | ||
168 | <p> | ||
169 | Multiple options can be combined — but not all combinations make | ||
170 | sense, see above. E.g. <tt>-jp=3si4m1</tt> samples three stack levels | ||
171 | deep in 4ms intervals and shows a split view of the CPU consuming | ||
172 | functions and their callers with a 1% threshold. | ||
173 | </p> | ||
174 | <p> | ||
175 | Source code annotations produced by <tt>-jp=a</tt> or <tt>-jp=A</tt> are | ||
176 | always flat and at the line level. Obviously, the source code files need | ||
177 | to be readable by the profiler script. | ||
178 | </p> | ||
179 | <p> | ||
180 | The high-level profiler can also be started and stopped from Lua code with: | ||
181 | </p> | ||
182 | <pre class="code"> | ||
183 | require("jit.p").start(options, output) | ||
184 | ... | ||
185 | require("jit.p").stop() | ||
186 | </pre> | ||
187 | |||
188 | <h3 id="jit_zone"><tt>jit.zone</tt> — Zones</h3> | ||
189 | <p> | ||
190 | Zones can be used to provide information about different parts of an | ||
191 | application to the high-level profiler. E.g. a game could make use of an | ||
192 | <tt>"AI"</tt> zone, a <tt>"PHYS"</tt> zone, etc. Zones are hierarchical, | ||
193 | organized as a stack. | ||
194 | </p> | ||
195 | <p> | ||
196 | The <tt>jit.zone</tt> module needs to be loaded explicitly: | ||
197 | </p> | ||
198 | <pre class="code"> | ||
199 | local zone = require("jit.zone") | ||
200 | </pre> | ||
201 | <ul> | ||
202 | <li><tt>zone("name")</tt> pushes a named zone to the zone stack.</li> | ||
203 | <li><tt>zone()</tt> pops the current zone from the zone stack and | ||
204 | returns its name.</li> | ||
205 | <li><tt>zone:get()</tt> returns the current zone name or <tt>nil</tt>.</li> | ||
206 | <li><tt>zone:flush()</tt> flushes the zone stack.</li> | ||
207 | </ul> | ||
208 | <p> | ||
209 | To show the time spent in each zone use <tt>-jp=z</tt>. To show the time | ||
210 | spent relative to hotspots use e.g. <tt>-jp=zf</tt> or <tt>-jp=fz</tt>. | ||
211 | </p> | ||
212 | |||
213 | <h2 id="ll_lua_api">Low-level Lua API</h2> | ||
214 | <p> | ||
215 | The <tt>jit.profile</tt> module gives access to the low-level API of the | ||
216 | profiler from Lua code. This module needs to be loaded explicitly: | ||
217 | <pre class="code"> | ||
218 | local profile = require("jit.profile") | ||
219 | </pre> | ||
220 | <p> | ||
221 | This module can be used to implement your own higher-level profiler. | ||
222 | A typical profiling run starts the profiler, captures stack dumps in | ||
223 | the profiler callback, adds them to a hash table to aggregate the number | ||
224 | of samples, stops the profiler and then analyzes all of the captured | ||
225 | stack dumps. Other parameters can be sampled in the profiler callback, | ||
226 | too. But it's important not to spend too much time in the callback, | ||
227 | since this may skew the statistics. | ||
228 | </p> | ||
229 | |||
230 | <h3 id="profile_start"><tt>profile.start(mode, cb)</tt> | ||
231 | — Start profiler</h3> | ||
232 | <p> | ||
233 | This function starts the profiler. The <tt>mode</tt> argument is a | ||
234 | string holding options: | ||
235 | </p> | ||
236 | <ul> | ||
237 | <li><tt>f</tt> — Profile with precision down to the function level.</li> | ||
238 | <li><tt>l</tt> — Profile with precision down to the line level.</li> | ||
239 | <li><tt>i<number></tt> — Sampling interval in milliseconds (default | ||
240 | 10ms).</br> | ||
241 | Note: The actual sampling precision is OS-dependent. | ||
242 | </li> | ||
243 | </ul> | ||
244 | <p> | ||
245 | The <tt>cb</tt> argument is a callback function which is called with | ||
246 | three arguments: <tt>(thread, samples, vmstate)</tt>. The callback is | ||
247 | called on a separate coroutine, the <tt>thread</tt> argument is the | ||
248 | state that holds the stack to sample for profiling. Note: do | ||
249 | <em>not</em> modify the stack of that state or call functions on it. | ||
250 | </p> | ||
251 | <p> | ||
252 | <tt>samples</tt> gives the number of accumulated samples since the last | ||
253 | callback (usually 1). | ||
254 | </p> | ||
255 | <p> | ||
256 | <tt>vmstate</tt> holds the VM state at the time the profiling timer | ||
257 | triggered. This may or may not correspond to the state of the VM when | ||
258 | the profiling callback is called. The state is either <tt>'N'</tt> | ||
259 | native (compiled) code, <tt>'I'</tt> interpreted code, <tt>'C'</tt> | ||
260 | C code, <tt>'G'</tt> the garbage collector, or <tt>'J'</tt> the JIT | ||
261 | compiler. | ||
262 | </p> | ||
263 | |||
264 | <h3 id="profile_stop"><tt>profile.stop()</tt> | ||
265 | — Stop profiler</h3> | ||
266 | <p> | ||
267 | This function stops the profiler. | ||
268 | </p> | ||
269 | |||
270 | <h3 id="profile_dump"><tt>dump = profile.dumpstack([thread,] fmt, depth)</tt> | ||
271 | — Dump stack </h3> | ||
272 | <p> | ||
273 | This function allows taking stack dumps in an efficient manner. It | ||
274 | returns a string with a stack dump for the <tt>thread</tt> (coroutine), | ||
275 | formatted according to the <tt>fmt</tt> argument: | ||
276 | </p> | ||
277 | <ul> | ||
278 | <li><tt>p</tt> — Preserve the full path for module names. Otherwise | ||
279 | only the file name is used.</li> | ||
280 | <li><tt>f</tt> — Dump the function name if it can be derived. Otherwise | ||
281 | use module:line.</li> | ||
282 | <li><tt>F</tt> — Ditto, but dump module:name.</li> | ||
283 | <li><tt>l</tt> — Dump module:line.</li> | ||
284 | <li><tt>Z</tt> — Zap the following characters for the last dumped | ||
285 | frame.</li> | ||
286 | <li>All other characters are added verbatim to the output string.</li> | ||
287 | </ul> | ||
288 | <p> | ||
289 | The <tt>depth</tt> argument gives the number of frames to dump, starting | ||
290 | at the topmost frame of the thread. A negative number dumps the frames in | ||
291 | inverse order. | ||
292 | </p> | ||
293 | <p> | ||
294 | The first example prints a list of the current module names and line | ||
295 | numbers of up to 10 frames in separate lines. The second example prints | ||
296 | semicolon-separated function names for all frames (up to 100) in inverse | ||
297 | order: | ||
298 | </p> | ||
299 | <pre class="code"> | ||
300 | print(profile.dumpstack(thread, "l\n", 10)) | ||
301 | print(profile.dumpstack(thread, "lZ;", -100)) | ||
302 | </pre> | ||
303 | |||
304 | <h2 id="ll_c_api">Low-level C API</h2> | ||
305 | <p> | ||
306 | The profiler can be controlled directly from C code, e.g. for | ||
307 | use by IDEs. The declarations are in <tt>"luajit.h"</tt> (see | ||
308 | <a href="ext_c_api.html">Lua/C API</a> extensions). | ||
309 | </p> | ||
310 | |||
311 | <h3 id="luaJIT_profile_start"><tt>luaJIT_profile_start(L, mode, cb, data)</tt> | ||
312 | — Start profiler</h3> | ||
313 | <p> | ||
314 | This function starts the profiler. <a href="#profile_start">See | ||
315 | above</a> for a description of the <tt>mode</tt> argument. | ||
316 | </p> | ||
317 | <p> | ||
318 | The <tt>cb</tt> argument is a callback function with the following | ||
319 | declaration: | ||
320 | </p> | ||
321 | <pre class="code"> | ||
322 | typedef void (*luaJIT_profile_callback)(void *data, lua_State *L, | ||
323 | int samples, int vmstate); | ||
324 | </pre> | ||
325 | <p> | ||
326 | <tt>data</tt> is available for use by the callback. <tt>L</tt> is the | ||
327 | state that holds the stack to sample for profiling. Note: do | ||
328 | <em>not</em> modify this stack or call functions on this stack — | ||
329 | use a separate coroutine for this purpose. <a href="#profile_start">See | ||
330 | above</a> for a description of <tt>samples</tt> and <tt>vmstate</tt>. | ||
331 | </p> | ||
332 | |||
333 | <h3 id="luaJIT_profile_stop"><tt>luaJIT_profile_stop(L)</tt> | ||
334 | — Stop profiler</h3> | ||
335 | <p> | ||
336 | This function stops the profiler. | ||
337 | </p> | ||
338 | |||
339 | <h3 id="luaJIT_profile_dumpstack"><tt>p = luaJIT_profile_dumpstack(L, fmt, depth, len)</tt> | ||
340 | — Dump stack </h3> | ||
341 | <p> | ||
342 | This function allows taking stack dumps in an efficient manner. | ||
343 | <a href="#profile_dump">See above</a> for a description of <tt>fmt</tt> | ||
344 | and <tt>depth</tt>. | ||
345 | </p> | ||
346 | <p> | ||
347 | This function returns a <tt>const char *</tt> pointing to a | ||
348 | private string buffer of the profiler. The <tt>int *len</tt> | ||
349 | argument returns the length of the output string. The buffer is | ||
350 | overwritten on the next call and deallocated when the profiler stops. | ||
351 | You either need to consume the content immediately or copy it for later | ||
352 | use. | ||
353 | </p> | ||
354 | <br class="flush"> | ||
355 | </div> | ||
356 | <div id="foot"> | ||
357 | <hr class="hide"> | ||
358 | Copyright © 2005-2016 Mike Pall | ||
359 | <span class="noprint"> | ||
360 | · | ||
361 | <a href="contact.html">Contact</a> | ||
362 | </span> | ||
363 | </div> | ||
364 | </body> | ||
365 | </html> | ||
diff --git a/doc/extensions.html b/doc/extensions.html index 1efaca9d..9d666293 100644 --- a/doc/extensions.html +++ b/doc/extensions.html | |||
@@ -58,6 +58,8 @@ td.excinterop { | |||
58 | <a href="ext_jit.html">jit.* Library</a> | 58 | <a href="ext_jit.html">jit.* Library</a> |
59 | </li><li> | 59 | </li><li> |
60 | <a href="ext_c_api.html">Lua/C API</a> | 60 | <a href="ext_c_api.html">Lua/C API</a> |
61 | </li><li> | ||
62 | <a href="ext_profiler.html">Profiler</a> | ||
61 | </li></ul> | 63 | </li></ul> |
62 | </li><li> | 64 | </li><li> |
63 | <a href="status.html">Status</a> | 65 | <a href="status.html">Status</a> |
@@ -113,6 +115,9 @@ bit.lshift bit.rshift bit.arshift bit.rol bit.ror bit.bswap | |||
113 | This module is a LuaJIT built-in — you don't need to download or | 115 | This module is a LuaJIT built-in — you don't need to download or |
114 | install Lua BitOp. The Lua BitOp site has full documentation for all | 116 | install Lua BitOp. The Lua BitOp site has full documentation for all |
115 | <a href="http://bitop.luajit.org/api.html"><span class="ext">»</span> Lua BitOp API functions</a>. | 117 | <a href="http://bitop.luajit.org/api.html"><span class="ext">»</span> Lua BitOp API functions</a>. |
118 | The FFI adds support for | ||
119 | <a href="ext_ffi_semantics.html#cdata_arith">64 bit bitwise operations</a>, | ||
120 | using the same API functions. | ||
116 | </p> | 121 | </p> |
117 | <p> | 122 | <p> |
118 | Please make sure to <tt>require</tt> the module before using any of | 123 | Please make sure to <tt>require</tt> the module before using any of |
@@ -146,6 +151,11 @@ LuaJIT adds some | |||
146 | <a href="ext_c_api.html">extra functions to the Lua/C API</a>. | 151 | <a href="ext_c_api.html">extra functions to the Lua/C API</a>. |
147 | </p> | 152 | </p> |
148 | 153 | ||
154 | <h3 id="profiler">Profiler</h3> | ||
155 | <p> | ||
156 | LuaJIT has an <a href="ext_profiler.html">integrated profiler</a>. | ||
157 | </p> | ||
158 | |||
149 | <h2 id="library">Enhanced Standard Library Functions</h2> | 159 | <h2 id="library">Enhanced Standard Library Functions</h2> |
150 | 160 | ||
151 | <h3 id="xpcall"><tt>xpcall(f, err [,args...])</tt> passes arguments</h3> | 161 | <h3 id="xpcall"><tt>xpcall(f, err [,args...])</tt> passes arguments</h3> |
@@ -173,7 +183,7 @@ in <tt>"-inf"</tt>. | |||
173 | <h3 id="tonumber"><tt>tonumber()</tt> etc. use builtin string to number conversion</h3> | 183 | <h3 id="tonumber"><tt>tonumber()</tt> etc. use builtin string to number conversion</h3> |
174 | <p> | 184 | <p> |
175 | All string-to-number conversions consistently convert integer and | 185 | All string-to-number conversions consistently convert integer and |
176 | floating-point inputs in decimal and hexadecimal on all platforms. | 186 | floating-point inputs in decimal, hexadecimal and binary on all platforms. |
177 | <tt>strtod()</tt> is <em>not</em> used anymore, which avoids numerous | 187 | <tt>strtod()</tt> is <em>not</em> used anymore, which avoids numerous |
178 | problems with poor C library implementations. The builtin conversion | 188 | problems with poor C library implementations. The builtin conversion |
179 | function provides full precision according to the IEEE-754 standard, it | 189 | function provides full precision according to the IEEE-754 standard, it |
@@ -197,6 +207,36 @@ for dot releases (x.y.0 → x.y.1), but may change with major or | |||
197 | minor releases (2.0 → 2.1) or between any beta release. Foreign | 207 | minor releases (2.0 → 2.1) or between any beta release. Foreign |
198 | bytecode (e.g. from Lua 5.1) is incompatible and cannot be loaded. | 208 | bytecode (e.g. from Lua 5.1) is incompatible and cannot be loaded. |
199 | </p> | 209 | </p> |
210 | <p> | ||
211 | Note: <tt>LJ_GC64</tt> mode requires a different frame layout, which implies | ||
212 | a different, incompatible bytecode format for ports that use this mode (e.g. | ||
213 | ARM64). This may be rectified in the future. | ||
214 | </p> | ||
215 | |||
216 | <h3 id="table_new"><tt>table.new(narray, nhash)</tt> allocates a pre-sized table</h3> | ||
217 | <p> | ||
218 | An extra library function <tt>table.new()</tt> can be made available via | ||
219 | <tt>require("table.new")</tt>. This creates a pre-sized table, just like | ||
220 | the C API equivalent <tt>lua_createtable()</tt>. This is useful for big | ||
221 | tables if the final table size is known and automatic table resizing is | ||
222 | too expensive. | ||
223 | </p> | ||
224 | |||
225 | <h3 id="table_clear"><tt>table.clear(tab)</tt> clears a table</h3> | ||
226 | <p> | ||
227 | An extra library function <tt>table.clear()</tt> can be made available | ||
228 | via <tt>require("table.clear")</tt>. This clears all keys and values | ||
229 | from a table, but preserves the allocated array/hash sizes. This is | ||
230 | useful when a table, which is linked from multiple places, needs to be | ||
231 | cleared and/or when recycling a table for use by the same context. This | ||
232 | avoids managing backlinks, saves an allocation and the overhead of | ||
233 | incremental array/hash part growth. | ||
234 | </p> | ||
235 | <p> | ||
236 | Please note this function is meant for very specific situations. In most | ||
237 | cases it's better to replace the (usually single) link with a new table | ||
238 | and let the GC do its work. | ||
239 | </p> | ||
200 | 240 | ||
201 | <h3 id="math_random">Enhanced PRNG for <tt>math.random()</tt></h3> | 241 | <h3 id="math_random">Enhanced PRNG for <tt>math.random()</tt></h3> |
202 | <p> | 242 | <p> |
@@ -304,6 +344,14 @@ Lua 5.1, which prevents implementing features that would otherwise | |||
304 | break the Lua/C API and ABI (e.g. <tt>_ENV</tt>). | 344 | break the Lua/C API and ABI (e.g. <tt>_ENV</tt>). |
305 | </p> | 345 | </p> |
306 | 346 | ||
347 | <h2 id="lua53">Extensions from Lua 5.3</h2> | ||
348 | <p> | ||
349 | LuaJIT supports some extensions from Lua 5.3: | ||
350 | <ul> | ||
351 | <li>Unicode escape <tt>'\u{XX...}'</tt> embeds the UTF-8 encoding in string literals.</li> | ||
352 | <li>The argument table <tt>arg</tt> can be read (and modified) by <tt>LUA_INIT</tt> and <tt>-e</tt> chunks.</li> | ||
353 | </ul> | ||
354 | |||
307 | <h2 id="exceptions">C++ Exception Interoperability</h2> | 355 | <h2 id="exceptions">C++ Exception Interoperability</h2> |
308 | <p> | 356 | <p> |
309 | LuaJIT has built-in support for interoperating with C++ exceptions. | 357 | LuaJIT has built-in support for interoperating with C++ exceptions. |
@@ -318,25 +366,30 @@ the toolchain used to compile LuaJIT: | |||
318 | </tr> | 366 | </tr> |
319 | <tr class="odd separate"> | 367 | <tr class="odd separate"> |
320 | <td class="excplatform">POSIX/x64, DWARF2 unwinding</td> | 368 | <td class="excplatform">POSIX/x64, DWARF2 unwinding</td> |
321 | <td class="exccompiler">GCC 4.3+</td> | 369 | <td class="exccompiler">GCC 4.3+, Clang</td> |
322 | <td class="excinterop"><b style="color: #00a000;">Full</b></td> | 370 | <td class="excinterop"><b style="color: #00a000;">Full</b></td> |
323 | </tr> | 371 | </tr> |
324 | <tr class="even"> | 372 | <tr class="even"> |
373 | <td class="excplatform">ARM <tt>-DLUAJIT_UNWIND_EXTERNAL</tt></td> | ||
374 | <td class="exccompiler">GCC, Clang</td> | ||
375 | <td class="excinterop"><b style="color: #00a000;">Full</b></td> | ||
376 | </tr> | ||
377 | <tr class="odd"> | ||
325 | <td class="excplatform">Other platforms, DWARF2 unwinding</td> | 378 | <td class="excplatform">Other platforms, DWARF2 unwinding</td> |
326 | <td class="exccompiler">GCC</td> | 379 | <td class="exccompiler">GCC, Clang</td> |
327 | <td class="excinterop"><b style="color: #c06000;">Limited</b></td> | 380 | <td class="excinterop"><b style="color: #c06000;">Limited</b></td> |
328 | </tr> | 381 | </tr> |
329 | <tr class="odd"> | 382 | <tr class="even"> |
330 | <td class="excplatform">Windows/x64</td> | 383 | <td class="excplatform">Windows/x64</td> |
331 | <td class="exccompiler">MSVC or WinSDK</td> | 384 | <td class="exccompiler">MSVC or WinSDK</td> |
332 | <td class="excinterop"><b style="color: #00a000;">Full</b></td> | 385 | <td class="excinterop"><b style="color: #00a000;">Full</b></td> |
333 | </tr> | 386 | </tr> |
334 | <tr class="even"> | 387 | <tr class="odd"> |
335 | <td class="excplatform">Windows/x86</td> | 388 | <td class="excplatform">Windows/x86</td> |
336 | <td class="exccompiler">Any</td> | 389 | <td class="exccompiler">Any</td> |
337 | <td class="excinterop"><b style="color: #a00000;">No</b></td> | 390 | <td class="excinterop"><b style="color: #00a000;">Full</b></td> |
338 | </tr> | 391 | </tr> |
339 | <tr class="odd"> | 392 | <tr class="even"> |
340 | <td class="excplatform">Other platforms</td> | 393 | <td class="excplatform">Other platforms</td> |
341 | <td class="exccompiler">Other compilers</td> | 394 | <td class="exccompiler">Other compilers</td> |
342 | <td class="excinterop"><b style="color: #a00000;">No</b></td> | 395 | <td class="excinterop"><b style="color: #a00000;">No</b></td> |
@@ -385,14 +438,6 @@ C++ destructors.</li> | |||
385 | <li>Lua errors <b>cannot</b> be caught on the C++ side.</li> | 438 | <li>Lua errors <b>cannot</b> be caught on the C++ side.</li> |
386 | <li>Throwing Lua errors across C++ frames will <b>not</b> call | 439 | <li>Throwing Lua errors across C++ frames will <b>not</b> call |
387 | C++ destructors.</li> | 440 | C++ destructors.</li> |
388 | <li>Additionally, on Windows/x86 with SEH-based C++ exceptions: | ||
389 | it's <b>not</b> safe to throw a Lua error across any frames containing | ||
390 | a C++ function with any try/catch construct or using variables with | ||
391 | (implicit) destructors. This also applies to any functions which may be | ||
392 | inlined in such a function. It doesn't matter whether <tt>lua_error()</tt> | ||
393 | is called inside or outside of a try/catch or whether any object actually | ||
394 | needs to be destroyed: the SEH chain is corrupted and this will eventually | ||
395 | lead to the termination of the process.</li> | ||
396 | </ul> | 441 | </ul> |
397 | <br class="flush"> | 442 | <br class="flush"> |
398 | </div> | 443 | </div> |
diff --git a/doc/faq.html b/doc/faq.html index 516078d7..605fdd0a 100644 --- a/doc/faq.html +++ b/doc/faq.html | |||
@@ -44,6 +44,8 @@ dd { margin-left: 1.5em; } | |||
44 | <a href="ext_jit.html">jit.* Library</a> | 44 | <a href="ext_jit.html">jit.* Library</a> |
45 | </li><li> | 45 | </li><li> |
46 | <a href="ext_c_api.html">Lua/C API</a> | 46 | <a href="ext_c_api.html">Lua/C API</a> |
47 | </li><li> | ||
48 | <a href="ext_profiler.html">Profiler</a> | ||
47 | </li></ul> | 49 | </li></ul> |
48 | </li><li> | 50 | </li><li> |
49 | <a href="status.html">Status</a> | 51 | <a href="status.html">Status</a> |
diff --git a/doc/install.html b/doc/install.html index e3139583..efeda33c 100644 --- a/doc/install.html +++ b/doc/install.html | |||
@@ -69,6 +69,8 @@ td.compatno { | |||
69 | <a href="ext_jit.html">jit.* Library</a> | 69 | <a href="ext_jit.html">jit.* Library</a> |
70 | </li><li> | 70 | </li><li> |
71 | <a href="ext_c_api.html">Lua/C API</a> | 71 | <a href="ext_c_api.html">Lua/C API</a> |
72 | </li><li> | ||
73 | <a href="ext_profiler.html">Profiler</a> | ||
72 | </li></ul> | 74 | </li></ul> |
73 | </li><li> | 75 | </li><li> |
74 | <a href="status.html">Status</a> | 76 | <a href="status.html">Status</a> |
@@ -112,17 +114,17 @@ operating systems, CPUs and compilers: | |||
112 | </tr> | 114 | </tr> |
113 | <tr class="odd separate"> | 115 | <tr class="odd separate"> |
114 | <td class="compatcpu">x86 (32 bit)</td> | 116 | <td class="compatcpu">x86 (32 bit)</td> |
115 | <td class="compatos">GCC 4.x+<br>GCC 3.4</td> | 117 | <td class="compatos">GCC 4.2+</td> |
116 | <td class="compatos">GCC 4.x+<br>GCC 3.4</td> | 118 | <td class="compatos">GCC 4.2+</td> |
117 | <td class="compatos">XCode 5.0+<br>Clang</td> | 119 | <td class="compatos">XCode 5.0+<br>Clang</td> |
118 | <td class="compatos">MSVC, MSVC/EE<br>WinSDK<br>MinGW, Cygwin</td> | 120 | <td class="compatos">MSVC, MSVC/EE<br>WinSDK<br>MinGW, Cygwin</td> |
119 | </tr> | 121 | </tr> |
120 | <tr class="even"> | 122 | <tr class="even"> |
121 | <td class="compatcpu">x64 (64 bit)</td> | 123 | <td class="compatcpu">x64 (64 bit)</td> |
122 | <td class="compatos">GCC 4.x+</td> | 124 | <td class="compatos">GCC 4.2+</td> |
123 | <td class="compatos">ORBIS (<a href="#ps4">PS4</a>)</td> | 125 | <td class="compatos">GCC 4.2+<br>ORBIS (<a href="#ps4">PS4</a>)</td> |
124 | <td class="compatos">XCode 5.0+<br>Clang</td> | 126 | <td class="compatos">XCode 5.0+<br>Clang</td> |
125 | <td class="compatos">MSVC + SDK v7.0<br>WinSDK v7.0</td> | 127 | <td class="compatos">MSVC + SDK v7.0<br>WinSDK v7.0<br>Durango (<a href="#xboxone">Xbox One</a>)</td> |
126 | </tr> | 128 | </tr> |
127 | <tr class="odd"> | 129 | <tr class="odd"> |
128 | <td class="compatcpu"><a href="#cross2">ARMv5+<br>ARM9E+</a></td> | 130 | <td class="compatcpu"><a href="#cross2">ARMv5+<br>ARM9E+</a></td> |
@@ -132,21 +134,21 @@ operating systems, CPUs and compilers: | |||
132 | <td class="compatos compatno"> </td> | 134 | <td class="compatos compatno"> </td> |
133 | </tr> | 135 | </tr> |
134 | <tr class="even"> | 136 | <tr class="even"> |
135 | <td class="compatcpu"><a href="#cross2">PPC</a></td> | 137 | <td class="compatcpu"><a href="#cross2">ARM64</a></td> |
136 | <td class="compatos">GCC 4.3+</td> | 138 | <td class="compatos">GCC 4.8+</td> |
137 | <td class="compatos">GCC 4.3+<br>GCC 4.1 (<a href="#ps3">PS3</a>)</td> | 139 | <td class="compatos compatno"> </td> |
140 | <td class="compatos">XCode 6.0+<br>Clang 3.5+</td> | ||
138 | <td class="compatos compatno"> </td> | 141 | <td class="compatos compatno"> </td> |
139 | <td class="compatos">XEDK (<a href="#xbox360">Xbox 360</a>)</td> | ||
140 | </tr> | 142 | </tr> |
141 | <tr class="odd"> | 143 | <tr class="odd"> |
142 | <td class="compatcpu"><a href="#cross2">PPC/e500v2</a></td> | 144 | <td class="compatcpu"><a href="#cross2">PPC</a></td> |
143 | <td class="compatos">GCC 4.3+</td> | ||
144 | <td class="compatos">GCC 4.3+</td> | 145 | <td class="compatos">GCC 4.3+</td> |
146 | <td class="compatos">GCC 4.3+<br>GCC 4.1 (<a href="#ps3">PS3</a>)</td> | ||
145 | <td class="compatos compatno"> </td> | 147 | <td class="compatos compatno"> </td> |
146 | <td class="compatos compatno"> </td> | 148 | <td class="compatos">XEDK (<a href="#xbox360">Xbox 360</a>)</td> |
147 | </tr> | 149 | </tr> |
148 | <tr class="even"> | 150 | <tr class="even"> |
149 | <td class="compatcpu"><a href="#cross2">MIPS</a></td> | 151 | <td class="compatcpu"><a href="#cross2">MIPS32<br>MIPS64</a></td> |
150 | <td class="compatos">GCC 4.3+</td> | 152 | <td class="compatos">GCC 4.3+</td> |
151 | <td class="compatos">GCC 4.3+</td> | 153 | <td class="compatos">GCC 4.3+</td> |
152 | <td class="compatos compatno"> </td> | 154 | <td class="compatos compatno"> </td> |
@@ -200,7 +202,7 @@ which is probably the default on your system, anyway. Simply run: | |||
200 | make | 202 | make |
201 | </pre> | 203 | </pre> |
202 | <p> | 204 | <p> |
203 | This always builds a native x86, x64 or PPC binary, depending on the host OS | 205 | This always builds a native binary, depending on the host OS |
204 | you're running this command on. Check the section on | 206 | you're running this command on. Check the section on |
205 | <a href="#cross">cross-compilation</a> for more options. | 207 | <a href="#cross">cross-compilation</a> for more options. |
206 | </p> | 208 | </p> |
@@ -331,25 +333,36 @@ directory where <tt>luajit.exe</tt> is installed | |||
331 | 333 | ||
332 | <h2 id="cross">Cross-compiling LuaJIT</h2> | 334 | <h2 id="cross">Cross-compiling LuaJIT</h2> |
333 | <p> | 335 | <p> |
336 | First, let's clear up some terminology: | ||
337 | </p> | ||
338 | <ul> | ||
339 | <li>Host: This is your development system, usually based on a x64 or x86 CPU.</li> | ||
340 | <li>Target: This is the target system you want LuaJIT to run on, e.g. Android/ARM.</li> | ||
341 | <li>Toolchain: This comprises a C compiler, linker, assembler and a matching C library.</li> | ||
342 | <li>Host (or system) toolchain: This is the toolchain used to build native binaries for your host system.</li> | ||
343 | <li>Cross-compile toolchain: This is the toolchain used to build binaries for the target system. They can only be run on the target system.</li> | ||
344 | </ul> | ||
345 | <p> | ||
334 | The GNU Makefile-based build system allows cross-compiling on any host | 346 | The GNU Makefile-based build system allows cross-compiling on any host |
335 | for any supported target, as long as both architectures have the same | 347 | for any supported target: |
336 | pointer size. If you want to cross-compile to any 32 bit target on an | ||
337 | x64 OS, you need to install the multilib development package (e.g. | ||
338 | <tt>libc6-dev-i386</tt> on Debian/Ubuntu) and build a 32 bit host part | ||
339 | (<tt>HOST_CC="gcc -m32"</tt>). | ||
340 | </p> | 348 | </p> |
349 | <ul> | ||
350 | <li>Yes, you need a toolchain for both your host <em>and</em> your target!</li> | ||
351 | <li>Both host and target architectures must have the same pointer size.</li> | ||
352 | <li>E.g. if you want to cross-compile to a 32 bit target on a 64 bit host, you need to install the multilib development package (e.g. <tt>libc6-dev-i386</tt> on Debian/Ubuntu) and build a 32 bit host part (<tt>HOST_CC="gcc -m32"</tt>).</li> | ||
353 | <li>64 bit targets always require compilation on a 64 bit host.</li> | ||
354 | </ul> | ||
341 | <p> | 355 | <p> |
342 | You need to specify <tt>TARGET_SYS</tt> whenever the host OS and the | 356 | You need to specify <tt>TARGET_SYS</tt> whenever the host OS and the |
343 | target OS differ, or you'll get assembler or linker errors. E.g. if | 357 | target OS differ, or you'll get assembler or linker errors: |
344 | you're compiling on a Windows or OSX host for embedded Linux or Android, | ||
345 | you need to add <tt>TARGET_SYS=Linux</tt> to the examples below. For a | ||
346 | minimal target OS, you may need to disable the built-in allocator in | ||
347 | <tt>src/Makefile</tt> and use <tt>TARGET_SYS=Other</tt>. Don't forget to | ||
348 | specify the same <tt>TARGET_SYS</tt> for the install step, too. | ||
349 | </p> | 358 | </p> |
359 | <ul> | ||
360 | <li>E.g. if you're compiling on a Windows or OSX host for embedded Linux or Android, you need to add <tt>TARGET_SYS=Linux</tt> to the examples below.</li> | ||
361 | <li>For a minimal target OS, you may need to disable the built-in allocator in <tt>src/Makefile</tt> and use <tt>TARGET_SYS=Other</tt>.</li> | ||
362 | <li>Don't forget to specify the same <tt>TARGET_SYS</tt> for the install step, too.</li> | ||
363 | </ul> | ||
350 | <p> | 364 | <p> |
351 | The examples below only show some popular targets — please check | 365 | Here are some examples where host and target have the same CPU: |
352 | the comments in <tt>src/Makefile</tt> for more details. | ||
353 | </p> | 366 | </p> |
354 | <pre class="code"> | 367 | <pre class="code"> |
355 | # Cross-compile to a 32 bit binary on a multilib x64 OS | 368 | # Cross-compile to a 32 bit binary on a multilib x64 OS |
@@ -367,37 +380,47 @@ use the canonical toolchain triplets for Linux. | |||
367 | </p> | 380 | </p> |
368 | <p> | 381 | <p> |
369 | Since there's often no easy way to detect CPU features at runtime, it's | 382 | Since there's often no easy way to detect CPU features at runtime, it's |
370 | important to compile with the proper CPU or architecture settings. You | 383 | important to compile with the proper CPU or architecture settings: |
371 | can specify these when building the toolchain yourself. Or add | 384 | </o> |
372 | <tt>-mcpu=...</tt> or <tt>-march=...</tt> to <tt>TARGET_CFLAGS</tt>. For | 385 | <ul> |
373 | ARM it's important to have the correct <tt>-mfloat-abi=...</tt> setting, | 386 | <li>The best way to get consistent results is to specify the correct settings when building the toolchain yourself.</li> |
374 | too. Otherwise LuaJIT may not run at the full performance of your target | 387 | <li>For a pre-built, generic toolchain add <tt>-mcpu=...</tt> or <tt>-march=...</tt> and other necessary flags to <tt>TARGET_CFLAGS</tt>.</li> |
375 | CPU. | 388 | <li>For ARM it's important to have the correct <tt>-mfloat-abi=...</tt> setting, too. Otherwise LuaJIT may not run at the full performance of your target CPU.</li> |
389 | <li>For MIPS it's important to select a supported ABI (o32 on MIPS32, n64 on MIPS64) and consistently compile your project either with hard-float or soft-float compiler settings.</li> | ||
390 | </ul> | ||
391 | <p> | ||
392 | Here are some examples for targets with a different CPU than the host: | ||
376 | </p> | 393 | </p> |
377 | <pre class="code"> | 394 | <pre class="code"> |
378 | # ARM soft-float | 395 | # ARM soft-float |
379 | make HOST_CC="gcc -m32" CROSS=arm-linux-gnueabi- \ | 396 | make HOST_CC="gcc -m32" CROSS=arm-linux-gnueabi- \ |
380 | TARGET_CFLAGS="-mfloat-abi=soft" | 397 | TARGET_CFLAGS="-mfloat-abi=soft" |
381 | 398 | ||
382 | # ARM soft-float ABI with VFP (example for Cortex-A8) | 399 | # ARM soft-float ABI with VFP (example for Cortex-A9) |
383 | make HOST_CC="gcc -m32" CROSS=arm-linux-gnueabi- \ | 400 | make HOST_CC="gcc -m32" CROSS=arm-linux-gnueabi- \ |
384 | TARGET_CFLAGS="-mcpu=cortex-a8 -mfloat-abi=softfp" | 401 | TARGET_CFLAGS="-mcpu=cortex-a9 -mfloat-abi=softfp" |
385 | 402 | ||
386 | # ARM hard-float ABI with VFP (armhf, requires recent toolchain) | 403 | # ARM hard-float ABI with VFP (armhf, most modern toolchains) |
387 | make HOST_CC="gcc -m32" CROSS=arm-linux-gnueabihf- | 404 | make HOST_CC="gcc -m32" CROSS=arm-linux-gnueabihf- |
388 | 405 | ||
406 | # ARM64 | ||
407 | make CROSS=aarch64-linux- | ||
408 | |||
389 | # PPC | 409 | # PPC |
390 | make HOST_CC="gcc -m32" CROSS=powerpc-linux-gnu- | 410 | make HOST_CC="gcc -m32" CROSS=powerpc-linux-gnu- |
391 | # PPC/e500v2 (fast interpreter only) | ||
392 | make HOST_CC="gcc -m32" CROSS=powerpc-e500v2-linux-gnuspe- | ||
393 | 411 | ||
394 | # MIPS big-endian | 412 | # MIPS32 big-endian |
395 | make HOST_CC="gcc -m32" CROSS=mips-linux- | 413 | make HOST_CC="gcc -m32" CROSS=mips-linux- |
396 | # MIPS little-endian | 414 | # MIPS32 little-endian |
397 | make HOST_CC="gcc -m32" CROSS=mipsel-linux- | 415 | make HOST_CC="gcc -m32" CROSS=mipsel-linux- |
416 | |||
417 | # MIPS64 big-endian | ||
418 | make CROSS=mips-linux- TARGET_CFLAGS="-mips64r2 -mabi=64" | ||
419 | # MIPS64 little-endian | ||
420 | make CROSS=mipsel-linux- TARGET_CFLAGS="-mips64r2 -mabi=64" | ||
398 | </pre> | 421 | </pre> |
399 | <p> | 422 | <p> |
400 | You can cross-compile for <b id="android">Android</b> using the <a href="http://developer.android.com/sdk/ndk/index.html"><span class="ext">»</span> Android NDK</a>. | 423 | You can cross-compile for <b id="android">Android</b> using the <a href="https://developer.android.com/ndk/index.html">Android NDK</a>. |
401 | The environment variables need to match the install locations and the | 424 | The environment variables need to match the install locations and the |
402 | desired target platform. E.g. Android 4.0 corresponds to ABI level 14. | 425 | desired target platform. E.g. Android 4.0 corresponds to ABI level 14. |
403 | For details check the folder <tt>docs</tt> in the NDK directory. | 426 | For details check the folder <tt>docs</tt> in the NDK directory. |
@@ -411,7 +434,7 @@ to build/deploy or which lowest common denominator you want to pick: | |||
411 | # Android/ARM, armeabi (ARMv5TE soft-float), Android 2.2+ (Froyo) | 434 | # Android/ARM, armeabi (ARMv5TE soft-float), Android 2.2+ (Froyo) |
412 | NDK=/opt/android/ndk | 435 | NDK=/opt/android/ndk |
413 | NDKABI=8 | 436 | NDKABI=8 |
414 | NDKVER=$NDK/toolchains/arm-linux-androideabi-4.6 | 437 | NDKVER=$NDK/toolchains/arm-linux-androideabi-4.9 |
415 | NDKP=$NDKVER/prebuilt/linux-x86/bin/arm-linux-androideabi- | 438 | NDKP=$NDKVER/prebuilt/linux-x86/bin/arm-linux-androideabi- |
416 | NDKF="--sysroot $NDK/platforms/android-$NDKABI/arch-arm" | 439 | NDKF="--sysroot $NDK/platforms/android-$NDKABI/arch-arm" |
417 | make HOST_CC="gcc -m32" CROSS=$NDKP TARGET_FLAGS="$NDKF" | 440 | make HOST_CC="gcc -m32" CROSS=$NDKP TARGET_FLAGS="$NDKF" |
@@ -419,16 +442,16 @@ make HOST_CC="gcc -m32" CROSS=$NDKP TARGET_FLAGS="$NDKF" | |||
419 | # Android/ARM, armeabi-v7a (ARMv7 VFP), Android 4.0+ (ICS) | 442 | # Android/ARM, armeabi-v7a (ARMv7 VFP), Android 4.0+ (ICS) |
420 | NDK=/opt/android/ndk | 443 | NDK=/opt/android/ndk |
421 | NDKABI=14 | 444 | NDKABI=14 |
422 | NDKVER=$NDK/toolchains/arm-linux-androideabi-4.6 | 445 | NDKVER=$NDK/toolchains/arm-linux-androideabi-4.9 |
423 | NDKP=$NDKVER/prebuilt/linux-x86/bin/arm-linux-androideabi- | 446 | NDKP=$NDKVER/prebuilt/linux-x86/bin/arm-linux-androideabi- |
424 | NDKF="--sysroot $NDK/platforms/android-$NDKABI/arch-arm" | 447 | NDKF="--sysroot $NDK/platforms/android-$NDKABI/arch-arm" |
425 | NDKARCH="-march=armv7-a -mfloat-abi=softfp -Wl,--fix-cortex-a8" | 448 | NDKARCH="-march=armv7-a -mfloat-abi=softfp -Wl,--fix-cortex-a8" |
426 | make HOST_CC="gcc -m32" CROSS=$NDKP TARGET_FLAGS="$NDKF $NDKARCH" | 449 | make HOST_CC="gcc -m32" CROSS=$NDKP TARGET_FLAGS="$NDKF $NDKARCH" |
427 | 450 | ||
428 | # Android/MIPS, mips (MIPS32R1 hard-float), Android 4.0+ (ICS) | 451 | # Android/MIPS, mipsel (MIPS32R1 hard-float), Android 4.0+ (ICS) |
429 | NDK=/opt/android/ndk | 452 | NDK=/opt/android/ndk |
430 | NDKABI=14 | 453 | NDKABI=14 |
431 | NDKVER=$NDK/toolchains/mipsel-linux-android-4.6 | 454 | NDKVER=$NDK/toolchains/mipsel-linux-android-4.9 |
432 | NDKP=$NDKVER/prebuilt/linux-x86/bin/mipsel-linux-android- | 455 | NDKP=$NDKVER/prebuilt/linux-x86/bin/mipsel-linux-android- |
433 | NDKF="--sysroot $NDK/platforms/android-$NDKABI/arch-mips" | 456 | NDKF="--sysroot $NDK/platforms/android-$NDKABI/arch-mips" |
434 | make HOST_CC="gcc -m32" CROSS=$NDKP TARGET_FLAGS="$NDKF" | 457 | make HOST_CC="gcc -m32" CROSS=$NDKP TARGET_FLAGS="$NDKF" |
@@ -436,7 +459,7 @@ make HOST_CC="gcc -m32" CROSS=$NDKP TARGET_FLAGS="$NDKF" | |||
436 | # Android/x86, x86 (i686 SSE3), Android 4.0+ (ICS) | 459 | # Android/x86, x86 (i686 SSE3), Android 4.0+ (ICS) |
437 | NDK=/opt/android/ndk | 460 | NDK=/opt/android/ndk |
438 | NDKABI=14 | 461 | NDKABI=14 |
439 | NDKVER=$NDK/toolchains/x86-4.6 | 462 | NDKVER=$NDK/toolchains/x86-4.9 |
440 | NDKP=$NDKVER/prebuilt/linux-x86/bin/i686-linux-android- | 463 | NDKP=$NDKVER/prebuilt/linux-x86/bin/i686-linux-android- |
441 | NDKF="--sysroot $NDK/platforms/android-$NDKABI/arch-x86" | 464 | NDKF="--sysroot $NDK/platforms/android-$NDKABI/arch-x86" |
442 | make HOST_CC="gcc -m32" CROSS=$NDKP TARGET_FLAGS="$NDKF" | 465 | make HOST_CC="gcc -m32" CROSS=$NDKP TARGET_FLAGS="$NDKF" |
@@ -452,11 +475,19 @@ much slower than the JIT compiler. Please complain to Apple, not me. | |||
452 | Or use Android. :-p | 475 | Or use Android. :-p |
453 | </p> | 476 | </p> |
454 | <pre class="code"> | 477 | <pre class="code"> |
478 | # iOS/ARM (32 bit) | ||
455 | ISDKP=$(xcrun --sdk iphoneos --show-sdk-path) | 479 | ISDKP=$(xcrun --sdk iphoneos --show-sdk-path) |
456 | ICC=$(xcrun --sdk iphoneos --find clang) | 480 | ICC=$(xcrun --sdk iphoneos --find clang) |
457 | ISDKF="-arch armv7 -isysroot $ISDKP" | 481 | ISDKF="-arch armv7 -isysroot $ISDKP" |
458 | make DEFAULT_CC=clang HOST_CC="clang -m32 -arch i386" \ | 482 | make DEFAULT_CC=clang HOST_CC="clang -m32 -arch i386" \ |
459 | CROSS="$(dirname $ICC)/" TARGET_FLAGS="$ISDKF" TARGET_SYS=iOS | 483 | CROSS="$(dirname $ICC)/" TARGET_FLAGS="$ISDKF" TARGET_SYS=iOS |
484 | |||
485 | # iOS/ARM64 | ||
486 | ISDKP=$(xcrun --sdk iphoneos --show-sdk-path) | ||
487 | ICC=$(xcrun --sdk iphoneos --find clang) | ||
488 | ISDKF="-arch arm64 -isysroot $ISDKP" | ||
489 | make DEFAULT_CC=clang CROSS="$(dirname $ICC)/" \ | ||
490 | TARGET_FLAGS="$ISDKF" TARGET_SYS=iOS | ||
460 | </pre> | 491 | </pre> |
461 | 492 | ||
462 | <h3 id="consoles">Cross-compiling for consoles</h3> | 493 | <h3 id="consoles">Cross-compiling for consoles</h3> |
@@ -513,6 +544,16 @@ the following commands: | |||
513 | cd src | 544 | cd src |
514 | xedkbuild | 545 | xedkbuild |
515 | </pre> | 546 | </pre> |
547 | <p> | ||
548 | To cross-compile for <b id="xboxone">Xbox One</b> from a Windows host, | ||
549 | open a "Visual Studio .NET Command Prompt" (64 bit host compiler), | ||
550 | <tt>cd</tt> to the directory where you've unpacked the sources and run | ||
551 | the following commands: | ||
552 | </p> | ||
553 | <pre class="code"> | ||
554 | cd src | ||
555 | xb1build | ||
556 | </pre> | ||
516 | 557 | ||
517 | <h2 id="embed">Embedding LuaJIT</h2> | 558 | <h2 id="embed">Embedding LuaJIT</h2> |
518 | <p> | 559 | <p> |
diff --git a/doc/luajit.html b/doc/luajit.html index 0fc491f1..44a7b8a1 100644 --- a/doc/luajit.html +++ b/doc/luajit.html | |||
@@ -126,6 +126,8 @@ table.feature small { | |||
126 | <a href="ext_jit.html">jit.* Library</a> | 126 | <a href="ext_jit.html">jit.* Library</a> |
127 | </li><li> | 127 | </li><li> |
128 | <a href="ext_c_api.html">Lua/C API</a> | 128 | <a href="ext_c_api.html">Lua/C API</a> |
129 | </li><li> | ||
130 | <a href="ext_profiler.html">Profiler</a> | ||
129 | </li></ul> | 131 | </li></ul> |
130 | </li><li> | 132 | </li><li> |
131 | <a href="status.html">Status</a> | 133 | <a href="status.html">Status</a> |
@@ -164,13 +166,13 @@ LuaJIT is Copyright © 2005-2016 Mike Pall, released under the | |||
164 | <tr><td><span style="font-size:90%;">Embedded</span></td><td>Android</td><td>iOS</td></tr> | 166 | <tr><td><span style="font-size:90%;">Embedded</span></td><td>Android</td><td>iOS</td></tr> |
165 | </table> | 167 | </table> |
166 | <table class="feature os os3"> | 168 | <table class="feature os os3"> |
167 | <tr><td>PS3</td><td>PS4</td><td>PS Vita</td><td>Xbox 360</td></tr> | 169 | <tr><td>PS3</td><td>PS4</td><td>PS Vita</td><td>Xbox 360</td><td>Xbox One</td></tr> |
168 | </table> | 170 | </table> |
169 | <table class="feature compiler"> | 171 | <table class="feature compiler"> |
170 | <tr><td>GCC</td><td>CLANG<br>LLVM</td><td>MSVC</td></tr> | 172 | <tr><td>GCC</td><td>Clang<br>LLVM</td><td>MSVC</td></tr> |
171 | </table> | 173 | </table> |
172 | <table class="feature cpu"> | 174 | <table class="feature cpu"> |
173 | <tr><td>x86</td><td>x64</td><td>ARM</td><td>PPC</td><td>e500</td><td>MIPS</td></tr> | 175 | <tr><td>x86<br>x64</td><td>ARM<br>ARM64</td><td>PPC</td><td>MIPS32<br>MIPS64</td></tr> |
174 | </table> | 176 | </table> |
175 | <table class="feature fcompat"> | 177 | <table class="feature fcompat"> |
176 | <tr><td>Lua 5.1<br>API+ABI</td><td>+ JIT</td><td>+ BitOp</td><td>+ FFI</td><td>Drop-in<br>DLL/.so</td></tr> | 178 | <tr><td>Lua 5.1<br>API+ABI</td><td>+ JIT</td><td>+ BitOp</td><td>+ FFI</td><td>Drop-in<br>DLL/.so</td></tr> |
diff --git a/doc/running.html b/doc/running.html index 49e2d177..28a73264 100644 --- a/doc/running.html +++ b/doc/running.html | |||
@@ -63,6 +63,8 @@ td.param_default { | |||
63 | <a href="ext_jit.html">jit.* Library</a> | 63 | <a href="ext_jit.html">jit.* Library</a> |
64 | </li><li> | 64 | </li><li> |
65 | <a href="ext_c_api.html">Lua/C API</a> | 65 | <a href="ext_c_api.html">Lua/C API</a> |
66 | </li><li> | ||
67 | <a href="ext_profiler.html">Profiler</a> | ||
66 | </li></ul> | 68 | </li></ul> |
67 | </li><li> | 69 | </li><li> |
68 | <a href="status.html">Status</a> | 70 | <a href="status.html">Status</a> |
@@ -178,6 +180,7 @@ Here are the available LuaJIT control commands: | |||
178 | <li id="j_flush"><tt>-jflush</tt> — Flushes the whole cache of compiled code.</li> | 180 | <li id="j_flush"><tt>-jflush</tt> — Flushes the whole cache of compiled code.</li> |
179 | <li id="j_v"><tt>-jv</tt> — Shows verbose information about the progress of the JIT compiler.</li> | 181 | <li id="j_v"><tt>-jv</tt> — Shows verbose information about the progress of the JIT compiler.</li> |
180 | <li id="j_dump"><tt>-jdump</tt> — Dumps the code and structures used in various compiler stages.</li> | 182 | <li id="j_dump"><tt>-jdump</tt> — Dumps the code and structures used in various compiler stages.</li> |
183 | <li id="j_p"><tt>-jp</tt> — Start the <a href="ext_profiler.html">integrated profiler</a>.</li> | ||
181 | </ul> | 184 | </ul> |
182 | <p> | 185 | <p> |
183 | The <tt>-jv</tt> and <tt>-jdump</tt> commands are extension modules | 186 | The <tt>-jv</tt> and <tt>-jdump</tt> commands are extension modules |
diff --git a/doc/status.html b/doc/status.html index b3524397..d10033b0 100644 --- a/doc/status.html +++ b/doc/status.html | |||
@@ -44,6 +44,8 @@ ul li { padding-bottom: 0.3em; } | |||
44 | <a href="ext_jit.html">jit.* Library</a> | 44 | <a href="ext_jit.html">jit.* Library</a> |
45 | </li><li> | 45 | </li><li> |
46 | <a href="ext_c_api.html">Lua/C API</a> | 46 | <a href="ext_c_api.html">Lua/C API</a> |
47 | </li><li> | ||
48 | <a href="ext_profiler.html">Profiler</a> | ||
47 | </li></ul> | 49 | </li></ul> |
48 | </li><li> | 50 | </li><li> |
49 | <a class="current" href="status.html">Status</a> | 51 | <a class="current" href="status.html">Status</a> |