Skip to content

Commit 5980ef9

Browse files
committed
Merge branch LuaJIT/v2.1 into v2.1-agentzh
This merge makes jit.prngstate unusable since the prng usage has changed in LuaJIT/LuaJIT. TODO: - Make jit.prngstate usable with the new prng functionality - Reinstate the string hashing optimisations
2 parents 3d9a548 + dd0f09f commit 5980ef9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

109 files changed

+2893
-2030
lines changed

doc/ext_ffi_semantics.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1219,7 +1219,7 @@ <h2 id="status">Current Status</h2>
12191219
<li>Table initializers.</li>
12201220
<li>Initialization of nested <tt>struct</tt>/<tt>union</tt> types.</li>
12211221
<li>Non-default initialization of VLA/VLS or large C&nbsp;types
1222-
(&gt; 128&nbsp;bytes or &gt; 16 array elements.</li>
1222+
(&gt; 128&nbsp;bytes or &gt; 16 array elements).</li>
12231223
<li>Bitfield initializations.</li>
12241224
<li>Pointer differences for element sizes that are not a power of
12251225
two.</li>

doc/extensions.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ <h2 id="exceptions">C++ Exception Interoperability</h2>
408408
</tr>
409409
<tr class="even">
410410
<td class="excplatform">Windows/x64</td>
411-
<td class="exccompiler">MSVC or WinSDK</td>
411+
<td class="exccompiler">MSVC</td>
412412
<td class="excinterop"><b style="color: #00a000;">Full</b></td>
413413
</tr>
414414
<tr class="odd">

doc/faq.html

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ <h1>Frequently Asked Questions (FAQ)</h1>
5757
</li></ul>
5858
</div>
5959
<div id="main">
60-
<dl>
60+
<dl id="info">
6161
<dt>Q: Where can I learn more about LuaJIT and Lua?</dt>
6262
<dd>
6363
<ul style="padding: 0;">
@@ -77,7 +77,7 @@ <h1>Frequently Asked Questions (FAQ)</h1>
7777
</ul>
7878
</dl>
7979

80-
<dl>
80+
<dl id="tech">
8181
<dt>Q: Where can I learn more about the compiler technology used by LuaJIT?</dt>
8282
<dd>
8383
I'm planning to write more documentation about the internals of LuaJIT.
@@ -93,7 +93,7 @@ <h1>Frequently Asked Questions (FAQ)</h1>
9393
</dd>
9494
</dl>
9595

96-
<dl>
96+
<dl id="arg">
9797
<dt>Q: Why do I get this error: "attempt to index global 'arg' (a nil value)"?<br>
9898
Q: My vararg functions fail after switching to LuaJIT!</dt>
9999
<dd>LuaJIT is compatible to the Lua 5.1 language standard. It doesn't
@@ -103,7 +103,7 @@ <h1>Frequently Asked Questions (FAQ)</h1>
103103
vararg syntax</a>.</dd>
104104
</dl>
105105

106-
<dl>
106+
<dl id="x87">
107107
<dt>Q: Why do I get this error: "bad FPU precision"?<br>
108108
<dt>Q: I get weird behavior after initializing Direct3D.<br>
109109
<dt>Q: Some FPU operations crash after I load a Delphi DLL.<br>
@@ -125,7 +125,7 @@ <h1>Frequently Asked Questions (FAQ)</h1>
125125

126126
</dl>
127127

128-
<dl>
128+
<dl id="ctrlc">
129129
<dt>Q: Sometimes Ctrl-C fails to stop my Lua program. Why?</dt>
130130
<dd>The interrupt signal handler sets a Lua debug hook. But this is
131131
currently ignored by compiled code (this will eventually be fixed). If
@@ -136,7 +136,31 @@ <h1>Frequently Asked Questions (FAQ)</h1>
136136
running inside a C function under the Lua interpreter.</dd>
137137
</dl>
138138

139-
<dl>
139+
<dl id="sandbox">
140+
<dt>Q: Can Lua code be safely sandboxed?</dt>
141+
<dd>
142+
Maybe for an extremly restricted subset of Lua and if you relentlessly
143+
scrutinize every single interface function you offer to the untrusted code.<br>
144+
145+
Although Lua provides some sandboxing functionality (<tt>setfenv()</tt>, hooks),
146+
it's very hard to get this right even for the Lua core libraries. Of course,
147+
you'll need to inspect any extension library, too. And there are libraries
148+
that are inherently unsafe, e.g. the <a href="ext_ffi.html">FFI library</a>.<br>
149+
150+
Relatedly, <b>loading untrusted bytecode is not safe!</b> It's trivial
151+
to crash the Lua or LuaJIT VM with maliciously crafted bytecode. This is
152+
well known and there's no bytecode verification on purpose, so please
153+
don't report a bug about it. Check the <tt>mode</tt> parameter for the
154+
<tt>load*()</tt> functions to disable loading of bytecode.<br>
155+
156+
In general, the only promising approach is to sandbox Lua code at the
157+
process level and not the VM level.<br>
158+
159+
More reading material at the <a href="http://lua-users.org/wiki/SandBoxes"><span class="ext">&raquo;</span>&nbsp;Lua Wiki</a> and <a href="https://en.wikipedia.org/wiki/Sandbox_(computer_security)">Wikipedia</a>.
160+
</dd>
161+
</dl>
162+
163+
<dl id="patches">
140164
<dt>Q: Why doesn't my favorite power-patch for Lua apply against LuaJIT?</dt>
141165
<dd>Because it's a completely redesigned VM and has very little code
142166
in common with Lua anymore. Also, if the patch introduces changes to
@@ -147,7 +171,7 @@ <h1>Frequently Asked Questions (FAQ)</h1>
147171
The compiler will happily optimize away such indirections.</dd>
148172
</dl>
149173

150-
<dl>
174+
<dl id="arch">
151175
<dt>Q: Lua runs everywhere. Why doesn't LuaJIT support my CPU?</dt>
152176
<dd>Because it's a compiler &mdash; it needs to generate native
153177
machine code. This means the code generator must be ported to each
@@ -158,7 +182,7 @@ <h1>Frequently Asked Questions (FAQ)</h1>
158182
demand and/or sponsoring.</dd>
159183
</dl>
160184

161-
<dl>
185+
<dl id="when">
162186
<dt>Q: When will feature X be added? When will the next version be released?</dt>
163187
<dd>When it's ready.<br>
164188
C'mon, it's open source &mdash; I'm doing it on my own time and you're

dynasm/dasm_x86.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -305,11 +305,13 @@ int dasm_link(Dst_DECL, size_t *szp)
305305

306306
while (pos != lastpos) {
307307
dasm_ActList p = D->actionlist + b[pos++];
308+
int op = 0;
308309
while (1) {
309-
int op, action = *p++;
310+
int action = *p++;
310311
switch (action) {
311-
case DASM_REL_LG: p++; op = p[-3]; goto rel_pc;
312-
case DASM_REL_PC: op = p[-2]; rel_pc: {
312+
case DASM_REL_LG: p++;
313+
/* fallthrough */
314+
case DASM_REL_PC: {
313315
int shrink = op == 0xe9 ? 3 : ((op&0xf0) == 0x80 ? 4 : 0);
314316
if (shrink) { /* Shrinkable branch opcode? */
315317
int lofs, lpos = b[pos];
@@ -341,9 +343,10 @@ int dasm_link(Dst_DECL, size_t *szp)
341343
case DASM_LABEL_PC: b[pos++] += ofs; break; /* Fix label offset. */
342344
case DASM_ALIGN: ofs -= (b[pos++]+ofs)&*p++; break; /* Adjust ofs. */
343345
case DASM_EXTERN: p += 2; break;
344-
case DASM_ESC: p++; break;
346+
case DASM_ESC: op = *p++; break;
345347
case DASM_MARK: break;
346348
case DASM_SECTION: case DASM_STOP: goto stop;
349+
default: op = action; break;
347350
}
348351
}
349352
stop: (void)0;

src/Makefile

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@ XCFLAGS=
132132
#
133133
# This define is required to run LuaJIT under Valgrind. The Valgrind
134134
# header files must be installed. You should enable debug information, too.
135-
# Use --suppressions=lj.supp to avoid some false positives.
136135
#XCFLAGS+= -DLUAJIT_USE_VALGRIND
137136
#
138137
# This is the client for the GDB JIT API. GDB 7.0 or higher is required
@@ -212,7 +211,7 @@ TARGET_CC= $(STATIC_CC)
212211
TARGET_STCC= $(STATIC_CC)
213212
TARGET_DYNCC= $(DYNAMIC_CC)
214213
TARGET_LD= $(CROSS)$(CC)
215-
TARGET_AR= $(CROSS)ar rcus
214+
TARGET_AR= $(CROSS)ar rcus 2>/dev/null
216215
TARGET_STRIP= $(CROSS)strip
217216

218217
TARGET_LIBPATH= $(or $(PREFIX),/usr/local)/$(or $(MULTILIB),lib)
@@ -316,7 +315,6 @@ ifeq (Windows,$(TARGET_SYS))
316315
TARGET_XSHLDFLAGS= -shared -Wl,--out-implib,$(TARGET_DLLDOTANAME)
317316
TARGET_DYNXLDOPTS=
318317
else
319-
TARGET_AR+= 2>/dev/null
320318
ifeq (,$(shell $(TARGET_CC) -o /dev/null -c -x c /dev/null -fno-stack-protector 2>/dev/null || echo 1))
321319
TARGET_XCFLAGS+= -fno-stack-protector
322320
endif
@@ -368,7 +366,7 @@ ifneq ($(HOST_SYS),$(TARGET_SYS))
368366
HOST_XCFLAGS+= -DLUAJIT_OS=LUAJIT_OS_OSX
369367
else
370368
ifeq (iOS,$(TARGET_SYS))
371-
HOST_XCFLAGS+= -DLUAJIT_OS=LUAJIT_OS_OSX
369+
HOST_XCFLAGS+= -DLUAJIT_OS=LUAJIT_OS_OSX -DTARGET_OS_IPHONE=1
372370
else
373371
HOST_XCFLAGS+= -DLUAJIT_OS=LUAJIT_OS_OTHER
374372
endif
@@ -497,10 +495,10 @@ LJLIB_O= lib_base.o lib_math.o lib_bit.o lib_string.o lib_table.o \
497495
lib_io.o lib_os.o lib_package.o lib_debug.o lib_jit.o lib_ffi.o
498496
LJLIB_C= $(LJLIB_O:.o=.c)
499497

500-
LJCORE_O= lj_gc.o lj_err.o lj_char.o lj_bc.o lj_obj.o lj_buf.o \
498+
LJCORE_O= lj_assert.o lj_gc.o lj_err.o lj_char.o lj_bc.o lj_obj.o lj_buf.o \
501499
lj_str.o lj_tab.o lj_func.o lj_udata.o lj_meta.o lj_debug.o \
502-
lj_state.o lj_dispatch.o lj_vmevent.o lj_vmmath.o lj_strscan.o \
503-
lj_strfmt.o lj_strfmt_num.o lj_api.o lj_profile.o \
500+
lj_prng.o lj_state.o lj_dispatch.o lj_vmevent.o lj_vmmath.o \
501+
lj_strscan.o lj_strfmt.o lj_strfmt_num.o lj_api.o lj_profile.o \
504502
lj_lex.o lj_parse.o lj_bcread.o lj_bcwrite.o lj_load.o \
505503
lj_ir.o lj_opt_mem.o lj_opt_fold.o lj_opt_narrow.o \
506504
lj_opt_dce.o lj_opt_loop.o lj_opt_split.o lj_opt_sink.o \
@@ -616,7 +614,6 @@ E= @echo
616614
default all: $(TARGET_T)
617615

618616
amalg:
619-
@grep "^[+|]" ljamalg.c
620617
$(MAKE) all "LJCORE_O=ljamalg.o"
621618

622619
clean:
@@ -650,7 +647,7 @@ $(MINILUA_T): $(MINILUA_O)
650647
$(E) "HOSTLINK $@"
651648
$(Q)$(HOST_CC) $(HOST_ALDFLAGS) -o $@ $(MINILUA_O) $(MINILUA_LIBS) $(HOST_ALIBS)
652649

653-
host/buildvm_arch.h: $(DASM_DASC) $(DASM_DEP) $(DASM_DIR)/*.lua
650+
host/buildvm_arch.h: $(DASM_DASC) $(DASM_DEP) $(DASM_DIR)/*.lua lj_arch.h lua.h luaconf.h
654651
$(E) "DYNASM $@"
655652
$(Q)$(DASM) $(DASM_FLAGS) -o $@ $(DASM_DASC)
656653

src/Makefile.dep

Lines changed: 36 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
lib_aux.o: lib_aux.c lua.h luaconf.h lauxlib.h lj_obj.h lj_def.h \
22
lj_arch.h lj_err.h lj_errmsg.h lj_state.h lj_trace.h lj_jit.h lj_ir.h \
3-
lj_dispatch.h lj_bc.h lj_traceerr.h lj_lib.h lj_alloc.h
3+
lj_dispatch.h lj_bc.h lj_traceerr.h lj_lib.h
44
lib_base.o: lib_base.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h \
55
lj_def.h lj_arch.h lj_gc.h lj_err.h lj_errmsg.h lj_debug.h lj_str.h \
66
lj_tab.h lj_meta.h lj_state.h lj_frame.h lj_bc.h lj_ctype.h lj_cconv.h \
@@ -28,7 +28,7 @@ lib_jit.o: lib_jit.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h lj_def.h \
2828
lj_target.h lj_target_*.h lj_trace.h lj_dispatch.h lj_traceerr.h \
2929
lj_vm.h lj_vmevent.h lj_lib.h luajit.h lj_libdef.h
3030
lib_math.o: lib_math.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h \
31-
lj_def.h lj_arch.h lj_lib.h lj_vm.h lj_libdef.h
31+
lj_def.h lj_arch.h lj_lib.h lj_vm.h lj_prng.h lj_libdef.h
3232
lib_os.o: lib_os.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h lj_def.h \
3333
lj_arch.h lj_gc.h lj_err.h lj_errmsg.h lj_buf.h lj_str.h lj_lib.h \
3434
lj_libdef.h
@@ -41,7 +41,8 @@ lib_string.o: lib_string.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h \
4141
lib_table.o: lib_table.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h \
4242
lj_def.h lj_arch.h lj_gc.h lj_err.h lj_errmsg.h lj_buf.h lj_str.h \
4343
lj_tab.h lj_ff.h lj_ffdef.h lj_lib.h lj_libdef.h
44-
lj_alloc.o: lj_alloc.c lj_def.h lua.h luaconf.h lj_arch.h lj_alloc.h
44+
lj_alloc.o: lj_alloc.c lj_def.h lua.h luaconf.h lj_arch.h lj_alloc.h \
45+
lj_prng.h
4546
lj_api.o: lj_api.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \
4647
lj_err.h lj_errmsg.h lj_debug.h lj_str.h lj_tab.h lj_func.h lj_udata.h \
4748
lj_meta.h lj_state.h lj_bc.h lj_frame.h lj_trace.h lj_jit.h lj_ir.h \
@@ -51,6 +52,7 @@ lj_asm.o: lj_asm.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \
5152
lj_ircall.h lj_iropt.h lj_mcode.h lj_trace.h lj_dispatch.h lj_traceerr.h \
5253
lj_snap.h lj_asm.h lj_vm.h lj_target.h lj_target_*.h lj_emit_*.h \
5354
lj_asm_*.h
55+
lj_assert.o: lj_assert.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h
5456
lj_bc.o: lj_bc.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_bc.h \
5557
lj_bcdef.h
5658
lj_bcread.o: lj_bcread.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \
@@ -125,7 +127,7 @@ lj_gdbjit.o: lj_gdbjit.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \
125127
lj_ir.o: lj_ir.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \
126128
lj_buf.h lj_str.h lj_tab.h lj_ir.h lj_jit.h lj_ircall.h lj_iropt.h \
127129
lj_trace.h lj_dispatch.h lj_bc.h lj_traceerr.h lj_ctype.h lj_cdata.h \
128-
lj_carith.h lj_vm.h lj_strscan.h lj_strfmt.h lj_lib.h
130+
lj_carith.h lj_vm.h lj_strscan.h lj_strfmt.h lj_prng.h
129131
lj_lex.o: lj_lex.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \
130132
lj_err.h lj_errmsg.h lj_buf.h lj_str.h lj_tab.h lj_ctype.h lj_cdata.h \
131133
lualib.h lj_state.h lj_lex.h lj_parse.h lj_char.h lj_strscan.h \
@@ -139,7 +141,7 @@ lj_load.o: lj_load.c lua.h luaconf.h lauxlib.h lj_obj.h lj_def.h \
139141
lj_frame.h lj_bc.h lj_vm.h lj_lex.h lj_bcdump.h lj_parse.h
140142
lj_mcode.o: lj_mcode.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \
141143
lj_gc.h lj_err.h lj_errmsg.h lj_jit.h lj_ir.h lj_mcode.h lj_trace.h \
142-
lj_dispatch.h lj_bc.h lj_traceerr.h lj_vm.h
144+
lj_dispatch.h lj_bc.h lj_traceerr.h lj_prng.h lj_vm.h
143145
lj_meta.o: lj_meta.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \
144146
lj_err.h lj_errmsg.h lj_buf.h lj_str.h lj_tab.h lj_meta.h lj_frame.h \
145147
lj_bc.h lj_vm.h lj_strscan.h lj_strfmt.h lj_lib.h
@@ -155,7 +157,7 @@ lj_opt_loop.o: lj_opt_loop.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \
155157
lj_iropt.h lj_trace.h lj_dispatch.h lj_bc.h lj_traceerr.h lj_snap.h \
156158
lj_vm.h
157159
lj_opt_mem.o: lj_opt_mem.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \
158-
lj_tab.h lj_ir.h lj_jit.h lj_iropt.h lj_ircall.h
160+
lj_tab.h lj_ir.h lj_jit.h lj_iropt.h lj_ircall.h lj_dispatch.h lj_bc.h
159161
lj_opt_narrow.o: lj_opt_narrow.c lj_obj.h lua.h luaconf.h lj_def.h \
160162
lj_arch.h lj_bc.h lj_ir.h lj_jit.h lj_iropt.h lj_trace.h lj_dispatch.h \
161163
lj_traceerr.h lj_vm.h lj_strscan.h
@@ -171,19 +173,21 @@ lj_parse.o: lj_parse.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \
171173
lj_profile.o: lj_profile.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \
172174
lj_buf.h lj_gc.h lj_str.h lj_frame.h lj_bc.h lj_debug.h lj_dispatch.h \
173175
lj_jit.h lj_ir.h lj_trace.h lj_traceerr.h lj_profile.h luajit.h
176+
lj_prng.o: lj_prng.c lj_def.h lua.h luaconf.h lj_arch.h lj_prng.h
174177
lj_record.o: lj_record.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \
175178
lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_meta.h lj_frame.h lj_bc.h \
176179
lj_ctype.h lj_gc.h lj_ff.h lj_ffdef.h lj_debug.h lj_ir.h lj_jit.h \
177180
lj_ircall.h lj_iropt.h lj_trace.h lj_dispatch.h lj_traceerr.h \
178-
lj_record.h lj_ffrecord.h lj_snap.h lj_vm.h
181+
lj_record.h lj_ffrecord.h lj_snap.h lj_vm.h lj_prng.h
179182
lj_snap.o: lj_snap.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \
180183
lj_tab.h lj_state.h lj_frame.h lj_bc.h lj_ir.h lj_jit.h lj_iropt.h \
181184
lj_trace.h lj_dispatch.h lj_traceerr.h lj_snap.h lj_target.h \
182185
lj_target_*.h lj_ctype.h lj_cdata.h
183186
lj_state.o: lj_state.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \
184187
lj_gc.h lj_err.h lj_errmsg.h lj_buf.h lj_str.h lj_tab.h lj_func.h \
185188
lj_meta.h lj_state.h lj_frame.h lj_bc.h lj_ctype.h lj_trace.h lj_jit.h \
186-
lj_ir.h lj_dispatch.h lj_traceerr.h lj_vm.h lj_lex.h lj_alloc.h luajit.h
189+
lj_ir.h lj_dispatch.h lj_traceerr.h lj_vm.h lj_prng.h lj_lex.h \
190+
lj_alloc.h luajit.h
187191
lj_str.o: lj_str.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \
188192
lj_err.h lj_errmsg.h lj_str.h lj_char.h
189193
lj_strfmt.o: lj_strfmt.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \
@@ -198,36 +202,37 @@ lj_trace.o: lj_trace.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \
198202
lj_gc.h lj_err.h lj_errmsg.h lj_debug.h lj_str.h lj_frame.h lj_bc.h \
199203
lj_state.h lj_ir.h lj_jit.h lj_iropt.h lj_mcode.h lj_trace.h \
200204
lj_dispatch.h lj_traceerr.h lj_snap.h lj_gdbjit.h lj_record.h lj_asm.h \
201-
lj_vm.h lj_vmevent.h lj_target.h lj_target_*.h
205+
lj_vm.h lj_vmevent.h lj_target.h lj_target_*.h lj_prng.h
202206
lj_udata.o: lj_udata.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \
203207
lj_gc.h lj_udata.h
204208
lj_vmevent.o: lj_vmevent.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \
205209
lj_str.h lj_tab.h lj_state.h lj_dispatch.h lj_bc.h lj_jit.h lj_ir.h \
206210
lj_vm.h lj_vmevent.h
207211
lj_vmmath.o: lj_vmmath.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \
208212
lj_ir.h lj_vm.h
209-
ljamalg.o: ljamalg.c lua.h luaconf.h lauxlib.h lj_gc.c lj_obj.h lj_def.h \
210-
lj_arch.h lj_gc.h lj_err.h lj_errmsg.h lj_buf.h lj_str.h lj_tab.h \
211-
lj_func.h lj_udata.h lj_meta.h lj_state.h lj_frame.h lj_bc.h lj_ctype.h \
212-
lj_cdata.h lj_trace.h lj_jit.h lj_ir.h lj_dispatch.h lj_traceerr.h \
213-
lj_vm.h lj_err.c lj_debug.h lj_ff.h lj_ffdef.h lj_strfmt.h lj_char.c \
214-
lj_char.h lj_bc.c lj_bcdef.h lj_obj.c lj_buf.c lj_str.c lj_tab.c \
215-
lj_func.c lj_udata.c lj_meta.c lj_strscan.h lj_lib.h lj_debug.c \
216-
lj_state.c lj_lex.h lj_alloc.h luajit.h lj_dispatch.c lj_ccallback.h \
217-
lj_profile.h lj_vmevent.c lj_vmevent.h lj_vmmath.c lj_strscan.c \
218-
lj_strfmt.c lj_strfmt_num.c lj_api.c lj_profile.c lj_lex.c lualib.h \
219-
lj_parse.h lj_parse.c lj_bcread.c lj_bcdump.h lj_bcwrite.c lj_load.c \
220-
lj_ctype.c lj_cdata.c lj_cconv.h lj_cconv.c lj_ccall.c lj_ccall.h \
221-
lj_ccallback.c lj_target.h lj_target_*.h lj_mcode.h lj_carith.c \
222-
lj_carith.h lj_clib.c lj_clib.h lj_cparse.c lj_cparse.h lj_lib.c lj_ir.c \
223-
lj_ircall.h lj_iropt.h lj_opt_mem.c lj_opt_fold.c lj_folddef.h \
224-
lj_opt_narrow.c lj_opt_dce.c lj_opt_loop.c lj_snap.h lj_opt_split.c \
225-
lj_opt_sink.c lj_mcode.c lj_snap.c lj_record.c lj_record.h lj_ffrecord.h \
226-
lj_crecord.c lj_crecord.h lj_ffrecord.c lj_recdef.h lj_asm.c lj_asm.h \
227-
lj_emit_*.h lj_asm_*.h lj_trace.c lj_gdbjit.h lj_gdbjit.c lj_alloc.c \
228-
lib_aux.c lib_base.c lj_libdef.h lib_math.c lib_string.c lib_table.c \
229-
lib_io.c lib_os.c lib_package.c lib_debug.c lib_bit.c lib_jit.c \
230-
lib_ffi.c lib_init.c
213+
ljamalg.o: ljamalg.c lua.h luaconf.h lauxlib.h lj_assert.c lj_obj.h \
214+
lj_def.h lj_arch.h lj_gc.c lj_gc.h lj_err.h lj_errmsg.h lj_buf.h \
215+
lj_str.h lj_tab.h lj_func.h lj_udata.h lj_meta.h lj_state.h lj_frame.h \
216+
lj_bc.h lj_ctype.h lj_cdata.h lj_trace.h lj_jit.h lj_ir.h lj_dispatch.h \
217+
lj_traceerr.h lj_vm.h lj_err.c lj_debug.h lj_ff.h lj_ffdef.h lj_strfmt.h \
218+
lj_char.c lj_char.h lj_bc.c lj_bcdef.h lj_obj.c lj_buf.c lj_str.c \
219+
lj_tab.c lj_func.c lj_udata.c lj_meta.c lj_strscan.h lj_lib.h lj_debug.c \
220+
lj_prng.c lj_prng.h lj_state.c lj_lex.h lj_alloc.h luajit.h \
221+
lj_dispatch.c lj_ccallback.h lj_profile.h lj_vmevent.c lj_vmevent.h \
222+
lj_vmmath.c lj_strscan.c lj_strfmt.c lj_strfmt_num.c lj_api.c \
223+
lj_profile.c lj_lex.c lualib.h lj_parse.h lj_parse.c lj_bcread.c \
224+
lj_bcdump.h lj_bcwrite.c lj_load.c lj_ctype.c lj_cdata.c lj_cconv.h \
225+
lj_cconv.c lj_ccall.c lj_ccall.h lj_ccallback.c lj_target.h \
226+
lj_target_*.h lj_mcode.h lj_carith.c lj_carith.h lj_clib.c lj_clib.h \
227+
lj_cparse.c lj_cparse.h lj_lib.c lj_ir.c lj_ircall.h lj_iropt.h \
228+
lj_opt_mem.c lj_opt_fold.c lj_folddef.h lj_opt_narrow.c lj_opt_dce.c \
229+
lj_opt_loop.c lj_snap.h lj_opt_split.c lj_opt_sink.c lj_mcode.c \
230+
lj_snap.c lj_record.c lj_record.h lj_ffrecord.h lj_crecord.c \
231+
lj_crecord.h lj_ffrecord.c lj_recdef.h lj_asm.c lj_asm.h lj_emit_*.h \
232+
lj_asm_*.h lj_trace.c lj_gdbjit.h lj_gdbjit.c lj_alloc.c lib_aux.c \
233+
lib_base.c lj_libdef.h lib_math.c lib_string.c lib_table.c lib_io.c \
234+
lib_os.c lib_package.c lib_debug.c lib_bit.c lib_jit.c lib_ffi.c \
235+
lib_init.c
231236
luajit.o: luajit.c lua.h luaconf.h lauxlib.h lualib.h luajit.h lj_arch.h
232237
host/buildvm.o: host/buildvm.c host/buildvm.h lj_def.h lua.h luaconf.h \
233238
lj_arch.h lj_obj.h lj_def.h lj_arch.h lj_gc.h lj_obj.h lj_bc.h lj_ir.h \

src/lib_aux.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -345,17 +345,13 @@ LUALIB_API lua_State *luaL_newstate(void)
345345

346346
#else
347347

348-
#include "lj_alloc.h"
349-
350348
LUALIB_API lua_State *luaL_newstate(void)
351349
{
352350
lua_State *L;
353-
void *ud = lj_alloc_create();
354-
if (ud == NULL) return NULL;
355351
#if LJ_64 && !LJ_GC64
356-
L = lj_state_newstate(lj_alloc_f, ud);
352+
L = lj_state_newstate(LJ_ALLOCF_INTERNAL, NULL);
357353
#else
358-
L = lua_newstate(lj_alloc_f, ud);
354+
L = lua_newstate(LJ_ALLOCF_INTERNAL, NULL);
359355
#endif
360356
if (L) G(L)->panic = panic;
361357
return L;

src/lib_base.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ LJLIB_ASM(tonumber) LJLIB_REC(.)
302302
while (lj_char_isspace((unsigned char)(*ep))) ep++;
303303
if (*ep == '\0') {
304304
if (LJ_DUALNUM && LJ_LIKELY(ul < 0x80000000u+neg)) {
305-
if (neg) ul = -ul;
305+
if (neg) ul = (unsigned long)-(long)ul;
306306
setintV(L->base-1-LJ_FR2, (int32_t)ul);
307307
} else {
308308
lua_Number n = (lua_Number)ul;

src/lib_debug.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,8 @@ LJLIB_CF(debug_debug)
369369
return 0;
370370
if (luaL_loadbuffer(L, buffer, strlen(buffer), "=(debug command)") ||
371371
lua_pcall(L, 0, 0, 0)) {
372-
fputs(lua_tostring(L, -1), stderr);
372+
const char *s = lua_tostring(L, -1);
373+
fputs(s ? s : "(error object is not a string)", stderr);
373374
fputs("\n", stderr);
374375
}
375376
lua_settop(L, 0); /* remove eventual returns */

0 commit comments

Comments
 (0)