diff options
Diffstat (limited to 'libraries/LuaJIT-1.1.7/jitdoc/coco_portability.html')
-rw-r--r-- | libraries/LuaJIT-1.1.7/jitdoc/coco_portability.html | 235 |
1 files changed, 235 insertions, 0 deletions
diff --git a/libraries/LuaJIT-1.1.7/jitdoc/coco_portability.html b/libraries/LuaJIT-1.1.7/jitdoc/coco_portability.html new file mode 100644 index 0000000..e120ae9 --- /dev/null +++ b/libraries/LuaJIT-1.1.7/jitdoc/coco_portability.html | |||
@@ -0,0 +1,235 @@ | |||
1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> | ||
2 | <html> | ||
3 | <head> | ||
4 | <title>Portability Requirements for Coco</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-2011, 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 | <style type="text/css"> | ||
12 | table.support { | ||
13 | line-height: 1.2; | ||
14 | width: 25em; | ||
15 | } | ||
16 | tr.supporthead td { | ||
17 | font-weight: bold; | ||
18 | } | ||
19 | td.supportcpu { | ||
20 | width: 6em; | ||
21 | } | ||
22 | td.supportsys { | ||
23 | width: 8em; | ||
24 | } | ||
25 | </style> | ||
26 | </head> | ||
27 | <body> | ||
28 | <div id="site"> | ||
29 | <a href="http://luajit.org/"><span>Lua<span id="logo">JIT</span></span></a> | ||
30 | </div> | ||
31 | <div id="head"> | ||
32 | <h1>Portability Requirements for Coco</h1> | ||
33 | </div> | ||
34 | <div id="nav"> | ||
35 | <ul><li> | ||
36 | <a href="index.html">Index</a> | ||
37 | </li><li> | ||
38 | <a href="luajit.html">LuaJIT</a> | ||
39 | <ul><li> | ||
40 | <a href="luajit_features.html">Features</a> | ||
41 | </li><li> | ||
42 | <a href="luajit_install.html">Installation</a> | ||
43 | </li><li> | ||
44 | <a href="luajit_run.html">Running</a> | ||
45 | </li><li> | ||
46 | <a href="luajit_api.html">API Extensions</a> | ||
47 | </li><li> | ||
48 | <a href="luajit_intro.html">Introduction</a> | ||
49 | </li><li> | ||
50 | <a href="luajit_performance.html">Performance</a> | ||
51 | </li><li> | ||
52 | <a href="luajit_debug.html">Debugging</a> | ||
53 | </li><li> | ||
54 | <a href="luajit_changes.html">Changes</a> | ||
55 | </li></ul> | ||
56 | </li><li> | ||
57 | <a href="coco.html">Coco</a> | ||
58 | <ul><li> | ||
59 | <a class="current" href="coco_portability.html">Portability</a> | ||
60 | </li><li> | ||
61 | <a href="coco_api.html">API Extensions</a> | ||
62 | </li><li> | ||
63 | <a href="coco_changes.html">Changes</a> | ||
64 | </li></ul> | ||
65 | </li><li> | ||
66 | <a href="dynasm.html">DynASM</a> | ||
67 | <ul><li> | ||
68 | <a href="dynasm_features.html">Features</a> | ||
69 | </li><li> | ||
70 | <a href="dynasm_examples.html">Examples</a> | ||
71 | </li></ul> | ||
72 | </li><li> | ||
73 | <a href="http://luajit.org/download.html">Download <span class="ext">»</span></a> | ||
74 | </li></ul> | ||
75 | </div> | ||
76 | <div id="main"> | ||
77 | <p> | ||
78 | Coco needs some machine-specific features which are | ||
79 | inherently non-portable. Although the coverage is pretty good, | ||
80 | this means that Coco will probably never be a standard part | ||
81 | of the Lua core (which is pure ANSI C). | ||
82 | </p> | ||
83 | |||
84 | <h2>Context Switching Methods</h2> | ||
85 | <p> | ||
86 | Coco relies on four different machine-specific methods | ||
87 | for allocating a C stack and switching context. | ||
88 | The appropriate method is automatically selected at compile time. | ||
89 | </p> | ||
90 | |||
91 | <h3>GCC Inline Assembler</h3> | ||
92 | <p> | ||
93 | This method is only available when GCC 3.x/4.x is used | ||
94 | to compile the source. | ||
95 | This is the fastest method for context switching, but only available | ||
96 | for a few CPUs (see below). | ||
97 | </p> | ||
98 | |||
99 | <h3>Modified setjmp Buffer</h3> | ||
100 | <p> | ||
101 | This method changes a few fields in the setjmp buffer to | ||
102 | redirect the next longjmp to a new function with a new stack | ||
103 | frame. It needs a bit of guesswork and lots of #ifdef's to | ||
104 | handle the supported CPU/OS combinations, but this is quite | ||
105 | manageable. | ||
106 | </p> | ||
107 | <p> | ||
108 | This is the fallback method if inline assembler is not available. | ||
109 | It's pretty fast because it doesn't have to save or restore signals | ||
110 | (which is slow and generally undesirable for Lua coroutines). | ||
111 | </p> | ||
112 | |||
113 | <h3>POSIX ucontext</h3> | ||
114 | <p> | ||
115 | The POSIX calls getcontext, makecontext and switchcontext | ||
116 | are used to set up and switch between different C stacks. | ||
117 | Although highly portable and even available for some | ||
118 | esoteric platforms, it's slower than the setjmp method | ||
119 | because it saves and restores signals, too (using at least one | ||
120 | syscall for each context switch). | ||
121 | </p> | ||
122 | <p> | ||
123 | You can force the use of ucontext (instead of setjmp) by enabling | ||
124 | <tt>-DCOCO_USE_UCONTEXT</tt> in <tt>src/Makefile</tt>. | ||
125 | </p> | ||
126 | |||
127 | <h3>Windows Fibers</h3> | ||
128 | <p> | ||
129 | This is the standard method to set up and switch between | ||
130 | different C stacks on Windows. It's available on Windows 98 | ||
131 | and later. | ||
132 | </p> | ||
133 | <p> | ||
134 | None of the other methods work for Windows because OS specific code | ||
135 | is required to switch exception handling contexts. | ||
136 | </p> | ||
137 | |||
138 | <h2 class="pagebreak">Supported Platforms</h2> | ||
139 | <p> | ||
140 | Coco has support for the following platforms: | ||
141 | </p> | ||
142 | <table class="support"> | ||
143 | <tr class="supporthead"> | ||
144 | <td class="supportcpu">CPU</td> | ||
145 | <td class="supportsys">System</td> | ||
146 | <td>Method</td> | ||
147 | </tr> | ||
148 | <tr class="odd separate"> | ||
149 | <td class="supportcpu">x86</td><td class="supportsys">(any OS)</td><td>gccasm</td></tr> | ||
150 | <tr class="even"> | ||
151 | <td class="supportcpu">x86</td><td class="supportsys">Linux</td><td>setjmp</td></tr> | ||
152 | <tr class="odd"> | ||
153 | <td class="supportcpu">x86</td><td class="supportsys">FreeBSD</td><td>setjmp</td></tr> | ||
154 | <tr class="even"> | ||
155 | <td class="supportcpu">x86</td><td class="supportsys">NetBSD</td><td>setjmp</td></tr> | ||
156 | <tr class="odd"> | ||
157 | <td class="supportcpu">x86</td><td class="supportsys">OpenBSD</td><td>setjmp</td></tr> | ||
158 | <tr class="even"> | ||
159 | <td class="supportcpu">x86</td><td class="supportsys">Solaris</td><td>setjmp</td></tr> | ||
160 | <tr class="odd"> | ||
161 | <td class="supportcpu">x86</td><td class="supportsys">Mac OS X</td><td>setjmp</td></tr> | ||
162 | <tr class="even separate"> | ||
163 | <td class="supportcpu">x64</td><td class="supportsys">(any OS)</td><td>gccasm</td></tr> | ||
164 | <tr class="odd"> | ||
165 | <td class="supportcpu">x64</td><td class="supportsys">Solaris</td><td>setjmp</td></tr> | ||
166 | <tr class="even separate"> | ||
167 | <td class="supportcpu">MIPS32</td><td class="supportsys">(any OS)</td><td>gccasm</td></tr> | ||
168 | <tr class="odd"> | ||
169 | <td class="supportcpu">MIPS32</td><td class="supportsys">Linux</td><td>setjmp</td></tr> | ||
170 | <tr class="even separate"> | ||
171 | <td class="supportcpu">ARM</td><td class="supportsys">Linux</td><td>setjmp</td></tr> | ||
172 | <tr class="odd separate"> | ||
173 | <td class="supportcpu">PPC32</td><td class="supportsys">Mac OS X</td><td>setjmp</td></tr> | ||
174 | <tr class="even separate"> | ||
175 | <td class="supportcpu">(any CPU)</td><td class="supportsys">POSIX</td><td>ucontext</td></tr> | ||
176 | <tr class="odd separate"> | ||
177 | <td class="supportcpu">(any CPU)</td><td class="supportsys">Windows</td><td>fibers</td></tr> | ||
178 | </table> | ||
179 | <pre> | ||
180 | </pre> | ||
181 | <p> | ||
182 | It should work pretty much anywhere where a <em>correct</em> | ||
183 | POSIX ucontext implementation is available. It has been tested | ||
184 | on every systems I could get hold of (e.g. Sparc, PPC32/PPC64, | ||
185 | IA64, Alpha, HPPA with various operating systems). | ||
186 | </p> | ||
187 | |||
188 | <h2>Caveats</h2> | ||
189 | <ul> | ||
190 | <li> | ||
191 | Some older operating systems may have defective ucontext | ||
192 | implementations because this feature is not widely used. E.g. some | ||
193 | implementations don't mix well with other C library functions | ||
194 | like <tt>malloc()</tt> or with native threads. | ||
195 | This is really not the fault of Coco — please upgrade your OS. | ||
196 | </li> | ||
197 | <li> | ||
198 | Note for Windows: Please read the explanation for the default | ||
199 | <a href="http://msdn.microsoft.com/library/en-us/dllproc/base/thread_stack_size.asp"><span class="ext">»</span> Thread Stack Size</a> | ||
200 | in case you want to create large numbers of Fiber-based coroutines. | ||
201 | </li> | ||
202 | <li> | ||
203 | Note for MinGW/Cygwin: Older releases of GCC (before 4.0) generate | ||
204 | wrong unwind information when <tt>-fomit-frame-pointer</tt> is used | ||
205 | with stdcalls. This may lead to crashes when exceptions are thrown. | ||
206 | The workaround is to always use two flags:<br> | ||
207 | <tt>-fomit-frame-pointer -maccumulate-outgoing-args</tt>. | ||
208 | </li> | ||
209 | <li> | ||
210 | Note for MIPS CPUs without FPU: It's recommended to compile | ||
211 | <em>all</em> sources with <tt>-msoft-float</tt>, even if you don't use | ||
212 | any floating point ops anywhere. Otherwise context switching must | ||
213 | save and restore FPU registers (which needs to go through | ||
214 | the slow kernel emulation). | ||
215 | </li> | ||
216 | <li> | ||
217 | To run Coco with <a href="http://valgrind.org/"><span class="ext">»</span> Valgrind</a> | ||
218 | (a memory debugger) you <em>must</em> add <tt>-DUSE_VALGRIND</tt> | ||
219 | to <tt>MYCFLAGS</tt> and recompile. You will get random errors | ||
220 | if you don't! Valgrind 3.x or later is required. Earlier versions | ||
221 | do not work well with newly allocated C stacks. | ||
222 | </li> | ||
223 | </ul> | ||
224 | <br class="flush"> | ||
225 | </div> | ||
226 | <div id="foot"> | ||
227 | <hr class="hide"> | ||
228 | Copyright © 2005-2011 Mike Pall | ||
229 | <span class="noprint"> | ||
230 | · | ||
231 | <a href="contact.html">Contact</a> | ||
232 | </span> | ||
233 | </div> | ||
234 | </body> | ||
235 | </html> | ||