LuaJIT 2.0.4

This commit is contained in:
darealshinji 2015-09-12 12:38:01 +02:00
parent 1f7a59afcb
commit 541a9ad590
163 changed files with 559 additions and 424 deletions

View file

@ -1,7 +1,7 @@
===============================================================================
LuaJIT -- a Just-In-Time Compiler for Lua. http://luajit.org/
Copyright (C) 2005-2014 Mike Pall. All rights reserved.
Copyright (C) 2005-2015 Mike Pall. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View file

@ -1,11 +1,11 @@
README for LuaJIT 2.0.3
README for LuaJIT 2.0.4
-----------------------
LuaJIT is a Just-In-Time (JIT) compiler for the Lua programming language.
Project Homepage: http://luajit.org/
LuaJIT is Copyright (C) 2005-2014 Mike Pall.
LuaJIT is Copyright (C) 2005-2015 Mike Pall.
LuaJIT is free software, released under the MIT license.
See full Copyright Notice in the COPYRIGHT file or in luajit.h.

View file

@ -1,6 +1,6 @@
/*
** DynASM ARM encoding engine.
** Copyright (C) 2005-2014 Mike Pall. All rights reserved.
** Copyright (C) 2005-2015 Mike Pall. All rights reserved.
** Released under the MIT license. See dynasm.lua for full copyright notice.
*/

View file

@ -1,7 +1,7 @@
------------------------------------------------------------------------------
-- DynASM ARM module.
--
-- Copyright (C) 2005-2014 Mike Pall. All rights reserved.
-- Copyright (C) 2005-2015 Mike Pall. All rights reserved.
-- See dynasm.lua for full copyright notice.
------------------------------------------------------------------------------
@ -923,19 +923,22 @@ local function parse_template(params, template, nparams, pos)
end
map_op[".template__"] = function(params, template, nparams)
if not params then return sub(template, 9) end
if not params then return template:gsub("%x%x%x%x%x%x%x%x", "") end
-- Limit number of section buffer positions used by a single dasm_put().
-- A single opcode needs a maximum of 3 positions.
if secpos+3 > maxsecpos then wflush() end
local pos = wpos()
local apos, spos = #actargs, secpos
local lpos, apos, spos = #actlist, #actargs, secpos
local ok, err
for t in gmatch(template, "[^|]+") do
ok, err = pcall(parse_template, params, t, nparams, pos)
if ok then return end
secpos = spos
actlist[lpos+1] = nil
actlist[lpos+2] = nil
actlist[lpos+3] = nil
actargs[apos+1] = nil
actargs[apos+2] = nil
actargs[apos+3] = nil

View file

@ -1,6 +1,6 @@
/*
** DynASM MIPS encoding engine.
** Copyright (C) 2005-2014 Mike Pall. All rights reserved.
** Copyright (C) 2005-2015 Mike Pall. All rights reserved.
** Released under the MIT license. See dynasm.lua for full copyright notice.
*/

View file

@ -1,7 +1,7 @@
------------------------------------------------------------------------------
-- DynASM MIPS module.
--
-- Copyright (C) 2005-2014 Mike Pall. All rights reserved.
-- Copyright (C) 2005-2015 Mike Pall. All rights reserved.
-- See dynasm.lua for full copyright notice.
------------------------------------------------------------------------------

View file

@ -1,6 +1,6 @@
/*
** DynASM PPC encoding engine.
** Copyright (C) 2005-2014 Mike Pall. All rights reserved.
** Copyright (C) 2005-2015 Mike Pall. All rights reserved.
** Released under the MIT license. See dynasm.lua for full copyright notice.
*/

View file

@ -1,7 +1,7 @@
------------------------------------------------------------------------------
-- DynASM PPC module.
--
-- Copyright (C) 2005-2014 Mike Pall. All rights reserved.
-- Copyright (C) 2005-2015 Mike Pall. All rights reserved.
-- See dynasm.lua for full copyright notice.
------------------------------------------------------------------------------

View file

@ -1,6 +1,6 @@
/*
** DynASM encoding engine prototypes.
** Copyright (C) 2005-2014 Mike Pall. All rights reserved.
** Copyright (C) 2005-2015 Mike Pall. All rights reserved.
** Released under the MIT license. See dynasm.lua for full copyright notice.
*/

View file

@ -1,7 +1,7 @@
------------------------------------------------------------------------------
-- DynASM x64 module.
--
-- Copyright (C) 2005-2014 Mike Pall. All rights reserved.
-- Copyright (C) 2005-2015 Mike Pall. All rights reserved.
-- See dynasm.lua for full copyright notice.
------------------------------------------------------------------------------
-- This module just sets 64 bit mode for the combined x86/x64 module.

View file

@ -1,6 +1,6 @@
/*
** DynASM x86 encoding engine.
** Copyright (C) 2005-2014 Mike Pall. All rights reserved.
** Copyright (C) 2005-2015 Mike Pall. All rights reserved.
** Released under the MIT license. See dynasm.lua for full copyright notice.
*/

View file

@ -1,7 +1,7 @@
------------------------------------------------------------------------------
-- DynASM x86/x64 module.
--
-- Copyright (C) 2005-2014 Mike Pall. All rights reserved.
-- Copyright (C) 2005-2015 Mike Pall. All rights reserved.
-- See dynasm.lua for full copyright notice.
------------------------------------------------------------------------------
@ -1081,6 +1081,9 @@ local map_op = {
btr_2 = "mrqdw:0FB3Rm|miqdw:0FBA6mU",
bts_2 = "mrqdw:0FABRm|miqdw:0FBA5mU",
shld_3 = "mriqdw:0FA4RmU|mrCqdw:0FA5Rm",
shrd_3 = "mriqdw:0FACRmU|mrCqdw:0FADRm",
rdtsc_0 = "0F31", -- P1+
cpuid_0 = "0FA2", -- P1+
@ -1114,6 +1117,9 @@ local map_op = {
fucompp_0 = "DAE9",
fcompp_0 = "DED9",
fldenv_1 = "x.:D94m",
fnstenv_1 = "x.:D96m",
fstenv_1 = "x.:9BD96m",
fldcw_1 = "xw:nD95m",
fstcw_1 = "xw:n9BD97m",
fnstcw_1 = "xw:nD97m",
@ -1189,6 +1195,8 @@ local map_op = {
cvttps2dq_2 = "rmo:F30F5BrM",
cvttsd2si_2 = "rr/do:F20F2CrM|rr/qo:|rx/dq:|rxq:",
cvttss2si_2 = "rr/do:F30F2CrM|rr/qo:|rxd:|rx/qd:",
fxsave_1 = "x.:0FAE0m",
fxrstor_1 = "x.:0FAE1m",
ldmxcsr_1 = "xd:0FAE2m",
lfence_0 = "0FAEE8",
maskmovdqu_2 = "rro:660FF7rM",

View file

@ -2,7 +2,7 @@
-- DynASM. A dynamic assembler for code generation engines.
-- Originally designed and implemented for LuaJIT.
--
-- Copyright (C) 2005-2014 Mike Pall. All rights reserved.
-- Copyright (C) 2005-2015 Mike Pall. All rights reserved.
-- See below for full copyright notice.
------------------------------------------------------------------------------
@ -17,7 +17,7 @@ local _info = {
url = "http://luajit.org/dynasm.html",
license = "MIT",
copyright = [[
Copyright (C) 2005-2014 Mike Pall. All rights reserved.
Copyright (C) 2005-2015 Mike Pall. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the

View file

@ -1,6 +1,6 @@
/*
** Configuration header.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/
#ifndef luaconf_h
@ -37,7 +37,7 @@
#endif
#define LUA_LROOT "/usr/local"
#define LUA_LUADIR "/lua/5.1/"
#define LUA_LJDIR "/luajit-2.0.3/"
#define LUA_LJDIR "/luajit-2.0.4/"
#ifdef LUA_ROOT
#define LUA_JROOT LUA_ROOT

View file

@ -1,7 +1,7 @@
/*
** LuaJIT -- a Just-In-Time Compiler for Lua. http://luajit.org/
**
** Copyright (C) 2005-2014 Mike Pall. All rights reserved.
** Copyright (C) 2005-2015 Mike Pall. All rights reserved.
**
** Permission is hereby granted, free of charge, to any person obtaining
** a copy of this software and associated documentation files (the
@ -30,10 +30,10 @@
#include "lua.h"
#define LUAJIT_VERSION "LuaJIT 2.0.3"
#define LUAJIT_VERSION_NUM 20003 /* Version 2.0.3 = 02.00.03. */
#define LUAJIT_VERSION_SYM luaJIT_version_2_0_3
#define LUAJIT_COPYRIGHT "Copyright (C) 2005-2014 Mike Pall"
#define LUAJIT_VERSION "LuaJIT 2.0.4"
#define LUAJIT_VERSION_NUM 20004 /* Version 2.0.4 = 02.00.04. */
#define LUAJIT_VERSION_SYM luaJIT_version_2_0_4
#define LUAJIT_COPYRIGHT "Copyright (C) 2005-2015 Mike Pall"
#define LUAJIT_URL "http://luajit.org/"
/* Modes for luaJIT_setmode. */

View file

@ -1,6 +1,6 @@
/*
** Standard library header.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/
#ifndef _LUALIB_H

View file

@ -7,12 +7,12 @@
# Also works with MinGW and Cygwin on Windows.
# Please check msvcbuild.bat for building with MSVC on Windows.
#
# Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h
# Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
##############################################################################
MAJVER= 2
MINVER= 0
RELVER= 3
RELVER= 4
ABIVER= 5.1
NODOTABIVER= 51
@ -55,11 +55,11 @@ CCOPT_ppc=
CCOPT_ppcspe=
CCOPT_mips=
#
CCDEBUG=-g
CCDEBUG=
# Uncomment the next line to generate debug information:
#CCDEBUG= -g
#
CCWARN= -Wall -Wno-unused-function
CCWARN= -Wall
# Uncomment the next line to enable more warnings:
#CCWARN+= -Wextra -Wdeclaration-after-statement -Wredundant-decls -Wshadow -Wpointer-arith
#
@ -72,10 +72,10 @@ CCWARN= -Wall -Wno-unused-function
# as dynamic mode.
#
# Mixed mode creates a static + dynamic library and a statically linked luajit.
# BUILDMODE= mixed
BUILDMODE= mixed
#
# Static mode creates a static library and a statically linked luajit.
BUILDMODE= static
#BUILDMODE= static
#
# Dynamic mode creates a dynamic library and a dynamically linked luajit.
# Note: this executable will only run when the library is installed!
@ -88,7 +88,7 @@ BUILDMODE= static
##############################################################################
# Enable/disable these features as needed, but make sure you force a full
# recompile with "make clean", followed by "make".
XCFLAGS=-Igen
XCFLAGS=
#
# Permanently disable the FFI extension to reduce the size of the LuaJIT
# executable. But please consider that the FFI library is compiled-in,
@ -100,7 +100,7 @@ XCFLAGS=-Igen
# enabled by default. Some other features that *might* break some existing
# code (e.g. __pairs or os.execute() return values) can be enabled here.
# Note: this does not provide full compatibility with Lua 5.2 at this time.
XCFLAGS+= -DLUAJIT_ENABLE_LUA52COMPAT
#XCFLAGS+= -DLUAJIT_ENABLE_LUA52COMPAT
#
# Disable the JIT compiler, i.e. turn LuaJIT into a pure interpreter.
#XCFLAGS+= -DLUAJIT_DISABLE_JIT
@ -122,8 +122,10 @@ XCFLAGS+= -DLUAJIT_ENABLE_LUA52COMPAT
#
# Use the system provided memory allocator (realloc) instead of the
# bundled memory allocator. This is slower, but sometimes helpful for
# debugging. It's helpful for Valgrind's memcheck tool, too. This option
# cannot be enabled on x64, since the built-in allocator is mandatory.
# debugging. This option cannot be enabled on x64, since realloc usually
# doesn't return addresses in the right address range.
# OTOH this option is mandatory for Valgrind's memcheck tool on x64 and
# the only way to get useful results from it for all other architectures.
#XCFLAGS+= -DLUAJIT_USE_SYSMALLOC
#
# This define is required to run LuaJIT under Valgrind. The Valgrind
@ -188,9 +190,9 @@ TARGET_LD= $(CROSS)$(CC)
TARGET_AR= $(CROSS)ar rcus
TARGET_STRIP= $(CROSS)strip
TARGET_LIBPATH= ${CURDIR}
TARGET_LIBPATH= $(or $(PREFIX),/usr/local)/$(or $(MULTILIB),lib)
TARGET_SONAME= libluajit-$(ABIVER).so.$(MAJVER)
TARGET_DYLIBNAME= libluajit-aegisub.so
TARGET_DYLIBNAME= libluajit-$(ABIVER).$(MAJVER).dylib
TARGET_DYLIBPATH= $(TARGET_LIBPATH)/$(TARGET_DYLIBNAME)
TARGET_DLLNAME= lua$(NODOTABIVER).dll
TARGET_XSHLDFLAGS= -shared -fPIC -Wl,-soname,$(TARGET_SONAME)
@ -288,15 +290,15 @@ ifeq (Windows,$(TARGET_SYS))
TARGET_XSHLDFLAGS= -shared
TARGET_DYNXLDOPTS=
else
ifeq (,$(shell $(TARGET_CC) -o /dev/null -c -x c /dev/null -fno-stack-protector 2>/dev/null || echo 1))
TARGET_XCFLAGS+= -fno-stack-protector
endif
ifeq (Darwin,$(TARGET_SYS))
ifeq (,$(MACOSX_DEPLOYMENT_TARGET))
export MACOSX_DEPLOYMENT_TARGET=10.4
endif
TARGET_STRIP+= -x
TARGET_AR+= 2>/dev/null
ifeq (,$(shell $(TARGET_CC) -o /dev/null -c -x c /dev/null -fno-stack-protector 2>/dev/null || echo 1))
TARGET_XCFLAGS+= -fno-stack-protector
endif
TARGET_XSHLDFLAGS= -dynamiclib -single_module -undefined dynamic_lookup -fPIC
TARGET_DYNXLDOPTS=
TARGET_XSHLDFLAGS+= -install_name $(TARGET_DYLIBPATH) -compatibility_version $(MAJVER).$(MINVER) -current_version $(MAJVER).$(MINVER).$(RELVER)
@ -308,14 +310,10 @@ else
ifeq (iOS,$(TARGET_SYS))
TARGET_STRIP+= -x
TARGET_AR+= 2>/dev/null
TARGET_XCFLAGS+= -fno-stack-protector
TARGET_XSHLDFLAGS= -dynamiclib -single_module -undefined dynamic_lookup -fPIC
TARGET_DYNXLDOPTS=
TARGET_XSHLDFLAGS+= -install_name $(TARGET_DYLIBPATH) -compatibility_version $(MAJVER).$(MINVER) -current_version $(MAJVER).$(MINVER).$(RELVER)
else
ifneq (,$(findstring stack-protector,$(shell $(TARGET_CC) -dumpspecs)))
TARGET_XCFLAGS+= -fno-stack-protector
endif
ifneq (SunOS,$(TARGET_SYS))
ifneq (PS3,$(TARGET_SYS))
TARGET_XLDFLAGS+= -Wl,-E
@ -475,12 +473,12 @@ LIB_VMDEFP= $(LIB_VMDEF)
LUAJIT_O= luajit.o
LUAJIT_A= libluajit.a
LUAJIT_SO= libluajit-aegisub.so
LUAJIT_SO= libluajit.so
LUAJIT_T= luajit
ALL_T= $(LUAJIT_T) $(LUAJIT_A) $(LUAJIT_SO) $(HOST_T)
ALL_HDRGEN= gen/lj_bcdef.h gen/lj_ffdef.h gen/lj_libdef.h gen/lj_recdef.h gen/lj_folddef.h \
gen/buildvm_arch.h
ALL_HDRGEN= lj_bcdef.h lj_ffdef.h lj_libdef.h lj_recdef.h lj_folddef.h \
host/buildvm_arch.h
ALL_GEN= $(LJVM_S) $(ALL_HDRGEN) $(LIB_VMDEFP)
WIN_RM= *.obj *.lib *.exp *.dll *.exe *.manifest *.pdb *.ilk
ALL_RM= $(ALL_T) $(ALL_GEN) *.o host/*.o $(WIN_RM)
@ -494,11 +492,25 @@ TARGET_O= $(LUAJIT_A)
TARGET_T= $(LUAJIT_T) $(LUAJIT_SO)
TARGET_DEP= $(LIB_VMDEF) $(LUAJIT_SO)
ifeq (Windows,$(TARGET_SYS))
TARGET_DYNCC= $(STATIC_CC)
LJVM_MODE= peobj
LJVM_BOUT= $(LJVM_O)
LUAJIT_T= luajit.exe
ifeq (cygwin,$(HOST_MSYS))
LUAJIT_SO= cyg$(TARGET_DLLNAME)
else
LUAJIT_SO= $(TARGET_DLLNAME)
endif
# Mixed mode is not supported on Windows. And static mode doesn't work well.
# C modules cannot be loaded, because they bind to lua51.dll.
ifneq (static,$(BUILDMODE))
BUILDMODE= dynamic
TARGET_XCFLAGS+= -DLUA_BUILD_AS_DLL
endif
endif
ifeq (Darwin,$(TARGET_SYS))
LJVM_MODE= machasm
# -dead_strip breaks LuaJIT, but we really want it for everything else, so we
# have to dynamically link it
BUILDMODE= dynamic
endif
ifeq (iOS,$(TARGET_SYS))
LJVM_MODE= machasm
@ -557,6 +569,7 @@ E= @echo
default all: $(TARGET_T)
amalg:
@grep "^[+|]" ljamalg.c
$(MAKE) all "LJCORE_O=ljamalg.o"
clean:
@ -586,10 +599,7 @@ $(MINILUA_T): $(MINILUA_O)
$(E) "HOSTLINK $@"
$(Q)$(HOST_CC) $(HOST_ALDFLAGS) -o $@ $(MINILUA_O) $(MINILUA_LIBS) $(HOST_ALIBS)
gen:
mkdir -p gen
gen/buildvm_arch.h: $(DASM_DASC) $(DASM_DEP) gen
host/buildvm_arch.h: $(DASM_DASC) $(DASM_DEP)
$(E) "DYNASM $@"
$(Q)$(DASM) $(DASM_FLAGS) -o $@ $(DASM_DASC)
@ -603,19 +613,19 @@ $(LJVM_BOUT): $(BUILDVM_T)
$(E) "BUILDVM $@"
$(Q)$(BUILDVM_X) -m $(LJVM_MODE) -o $@
gen/lj_bcdef.h: $(BUILDVM_T) $(LJLIB_C)
lj_bcdef.h: $(BUILDVM_T) $(LJLIB_C)
$(E) "BUILDVM $@"
$(Q)$(BUILDVM_X) -m bcdef -o $@ $(LJLIB_C)
gen/lj_ffdef.h: $(BUILDVM_T) $(LJLIB_C)
lj_ffdef.h: $(BUILDVM_T) $(LJLIB_C)
$(E) "BUILDVM $@"
$(Q)$(BUILDVM_X) -m ffdef -o $@ $(LJLIB_C)
gen/lj_libdef.h: $(BUILDVM_T) $(LJLIB_C)
lj_libdef.h: $(BUILDVM_T) $(LJLIB_C)
$(E) "BUILDVM $@"
$(Q)$(BUILDVM_X) -m libdef -o $@ $(LJLIB_C)
gen/lj_recdef.h: $(BUILDVM_T) $(LJLIB_C)
lj_recdef.h: $(BUILDVM_T) $(LJLIB_C)
$(E) "BUILDVM $@"
$(Q)$(BUILDVM_X) -m recdef -o $@ $(LJLIB_C)
@ -623,7 +633,7 @@ $(LIB_VMDEF): $(BUILDVM_T) $(LJLIB_C)
$(E) "BUILDVM $@"
$(Q)$(BUILDVM_X) -m vmdef -o $(LIB_VMDEFP) $(LJLIB_C)
gen/lj_folddef.h: $(BUILDVM_T) lj_opt_fold.c
lj_folddef.h: $(BUILDVM_T) lj_opt_fold.c
$(E) "BUILDVM $@"
$(Q)$(BUILDVM_X) -m folddef -o $@ lj_opt_fold.c

View file

@ -4,39 +4,39 @@ lib_aux.o: lib_aux.c lua.h luaconf.h lauxlib.h lj_obj.h lj_def.h \
lib_base.o: lib_base.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h \
lj_def.h lj_arch.h lj_gc.h lj_err.h lj_errmsg.h lj_debug.h lj_str.h \
lj_tab.h lj_meta.h lj_state.h lj_ctype.h lj_cconv.h lj_bc.h lj_ff.h \
gen/lj_ffdef.h lj_dispatch.h lj_jit.h lj_ir.h lj_char.h lj_strscan.h \
lj_lib.h gen/lj_libdef.h
lj_ffdef.h lj_dispatch.h lj_jit.h lj_ir.h lj_char.h lj_strscan.h \
lj_lib.h lj_libdef.h
lib_bit.o: lib_bit.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h lj_def.h \
lj_arch.h lj_err.h lj_errmsg.h lj_str.h lj_lib.h gen/lj_libdef.h
lj_arch.h lj_err.h lj_errmsg.h lj_str.h lj_lib.h lj_libdef.h
lib_debug.o: lib_debug.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h \
lj_def.h lj_arch.h lj_gc.h lj_err.h lj_errmsg.h lj_debug.h lj_lib.h \
gen/lj_libdef.h
lj_libdef.h
lib_ffi.o: lib_ffi.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h lj_def.h \
lj_arch.h lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_meta.h \
lj_ctype.h lj_cparse.h lj_cdata.h lj_cconv.h lj_carith.h lj_ccall.h \
lj_ccallback.h lj_clib.h lj_ff.h gen/lj_ffdef.h lj_lib.h gen/lj_libdef.h
lj_ccallback.h lj_clib.h lj_ff.h lj_ffdef.h lj_lib.h lj_libdef.h
lib_init.o: lib_init.c lua.h luaconf.h lauxlib.h lualib.h lj_arch.h
lib_io.o: lib_io.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h lj_def.h \
lj_arch.h lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_state.h lj_ff.h \
gen/lj_ffdef.h lj_lib.h gen/lj_libdef.h
lj_ffdef.h lj_lib.h lj_libdef.h
lib_jit.o: lib_jit.c lua.h luaconf.h lauxlib.h lualib.h lj_arch.h \
lj_obj.h lj_def.h lj_err.h lj_errmsg.h lj_debug.h lj_str.h lj_tab.h \
lj_bc.h lj_ir.h lj_jit.h lj_ircall.h lj_iropt.h lj_target.h \
lj_target_*.h lj_dispatch.h lj_vm.h lj_vmevent.h lj_lib.h luajit.h \
gen/lj_libdef.h
lj_libdef.h
lib_math.o: lib_math.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h \
lj_def.h lj_arch.h lj_lib.h lj_vm.h gen/lj_libdef.h
lj_def.h lj_arch.h lj_lib.h lj_vm.h lj_libdef.h
lib_os.o: lib_os.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h lj_def.h \
lj_arch.h lj_err.h lj_errmsg.h lj_lib.h gen/lj_libdef.h
lj_arch.h lj_err.h lj_errmsg.h lj_lib.h lj_libdef.h
lib_package.o: lib_package.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h \
lj_def.h lj_arch.h lj_err.h lj_errmsg.h lj_lib.h
lib_string.o: lib_string.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h \
lj_def.h lj_arch.h lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_tab.h \
lj_meta.h lj_state.h lj_ff.h gen/lj_ffdef.h lj_bcdump.h lj_lex.h lj_char.h \
lj_lib.h gen/lj_libdef.h
lj_meta.h lj_state.h lj_ff.h lj_ffdef.h lj_bcdump.h lj_lex.h lj_char.h \
lj_lib.h lj_libdef.h
lib_table.o: lib_table.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h \
lj_def.h lj_arch.h lj_gc.h lj_err.h lj_errmsg.h lj_tab.h lj_lib.h \
gen/lj_libdef.h
lj_libdef.h
lj_alloc.o: lj_alloc.c lj_def.h lua.h luaconf.h lj_arch.h lj_alloc.h
lj_api.o: lj_api.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \
lj_err.h lj_errmsg.h lj_debug.h lj_str.h lj_tab.h lj_func.h lj_udata.h \
@ -48,7 +48,7 @@ lj_asm.o: lj_asm.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \
lj_snap.h lj_asm.h lj_vm.h lj_target.h lj_target_*.h lj_emit_*.h \
lj_asm_*.h
lj_bc.o: lj_bc.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_bc.h \
gen/lj_bcdef.h
lj_bcdef.h
lj_bcread.o: lj_bcread.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \
lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_bc.h lj_ctype.h \
lj_cdata.h lualib.h lj_lex.h lj_bcdump.h lj_state.h
@ -83,28 +83,28 @@ lj_cparse.o: lj_cparse.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \
lj_crecord.o: lj_crecord.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \
lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_frame.h lj_bc.h lj_ctype.h \
lj_gc.h lj_cdata.h lj_cparse.h lj_cconv.h lj_clib.h lj_ccall.h lj_ff.h \
gen/lj_ffdef.h lj_ir.h lj_jit.h lj_ircall.h lj_iropt.h lj_trace.h \
lj_ffdef.h lj_ir.h lj_jit.h lj_ircall.h lj_iropt.h lj_trace.h \
lj_dispatch.h lj_traceerr.h lj_record.h lj_ffrecord.h lj_snap.h \
lj_crecord.h
lj_ctype.o: lj_ctype.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \
lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_ctype.h lj_ccallback.h
lj_debug.o: lj_debug.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \
lj_err.h lj_errmsg.h lj_debug.h lj_str.h lj_tab.h lj_state.h lj_frame.h \
lj_bc.h lj_jit.h lj_ir.h
lj_bc.h lj_vm.h lj_jit.h lj_ir.h
lj_dispatch.o: lj_dispatch.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \
lj_err.h lj_errmsg.h lj_func.h lj_str.h lj_tab.h lj_meta.h lj_debug.h \
lj_state.h lj_frame.h lj_bc.h lj_ff.h gen/lj_ffdef.h lj_jit.h lj_ir.h \
lj_state.h lj_frame.h lj_bc.h lj_ff.h lj_ffdef.h lj_jit.h lj_ir.h \
lj_ccallback.h lj_ctype.h lj_gc.h lj_trace.h lj_dispatch.h lj_traceerr.h \
lj_vm.h luajit.h
lj_err.o: lj_err.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_err.h \
lj_errmsg.h lj_debug.h lj_str.h lj_func.h lj_state.h lj_frame.h lj_bc.h \
lj_ff.h gen/lj_ffdef.h lj_trace.h lj_jit.h lj_ir.h lj_dispatch.h \
lj_ff.h lj_ffdef.h lj_trace.h lj_jit.h lj_ir.h lj_dispatch.h \
lj_traceerr.h lj_vm.h
lj_ffrecord.o: lj_ffrecord.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \
lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_frame.h lj_bc.h lj_ff.h \
gen/lj_ffdef.h lj_ir.h lj_jit.h lj_ircall.h lj_iropt.h lj_trace.h \
lj_ffdef.h lj_ir.h lj_jit.h lj_ircall.h lj_iropt.h lj_trace.h \
lj_dispatch.h lj_traceerr.h lj_record.h lj_ffrecord.h lj_crecord.h \
lj_vm.h lj_strscan.h gen/lj_recdef.h
lj_vm.h lj_strscan.h lj_recdef.h
lj_func.o: lj_func.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \
lj_func.h lj_trace.h lj_jit.h lj_ir.h lj_dispatch.h lj_bc.h \
lj_traceerr.h lj_vm.h
@ -140,7 +140,7 @@ lj_opt_dce.o: lj_opt_dce.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \
lj_opt_fold.o: lj_opt_fold.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \
lj_str.h lj_tab.h lj_ir.h lj_jit.h lj_iropt.h lj_trace.h lj_dispatch.h \
lj_bc.h lj_traceerr.h lj_ctype.h lj_gc.h lj_carith.h lj_vm.h \
lj_strscan.h gen/lj_folddef.h
lj_strscan.h lj_folddef.h
lj_opt_loop.o: lj_opt_loop.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \
lj_err.h lj_errmsg.h lj_str.h lj_ir.h lj_jit.h lj_iropt.h lj_trace.h \
lj_dispatch.h lj_bc.h lj_traceerr.h lj_snap.h lj_vm.h
@ -159,7 +159,7 @@ lj_parse.o: lj_parse.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \
lj_state.h lj_bc.h lj_ctype.h lj_lex.h lj_parse.h lj_vm.h lj_vmevent.h
lj_record.o: lj_record.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h \
lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_meta.h lj_frame.h lj_bc.h \
lj_ctype.h lj_gc.h lj_ff.h gen/lj_ffdef.h lj_ir.h lj_jit.h lj_ircall.h \
lj_ctype.h lj_gc.h lj_ff.h lj_ffdef.h lj_ir.h lj_jit.h lj_ircall.h \
lj_iropt.h lj_trace.h lj_dispatch.h lj_traceerr.h lj_record.h \
lj_ffrecord.h lj_snap.h lj_vm.h
lj_snap.o: lj_snap.c lj_obj.h lua.h luaconf.h lj_def.h lj_arch.h lj_gc.h \
@ -192,7 +192,7 @@ ljamalg.o: ljamalg.c lua.h luaconf.h lauxlib.h lj_gc.c lj_obj.h lj_def.h \
lj_arch.h lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_tab.h lj_func.h \
lj_udata.h lj_meta.h lj_state.h lj_frame.h lj_bc.h lj_ctype.h lj_cdata.h \
lj_trace.h lj_jit.h lj_ir.h lj_dispatch.h lj_traceerr.h lj_vm.h lj_err.c \
lj_debug.h lj_ff.h gen/lj_ffdef.h lj_char.c lj_char.h lj_bc.c gen/lj_bcdef.h \
lj_debug.h lj_ff.h lj_ffdef.h lj_char.c lj_char.h lj_bc.c lj_bcdef.h \
lj_obj.c lj_str.c lj_tab.c lj_func.c lj_udata.c lj_meta.c lj_strscan.h \
lj_debug.c lj_state.c lj_lex.h lj_alloc.h lj_dispatch.c lj_ccallback.h \
luajit.h lj_vmevent.c lj_vmevent.h lj_vmmath.c lj_strscan.c lj_api.c \
@ -201,12 +201,12 @@ ljamalg.o: ljamalg.c lua.h luaconf.h lauxlib.h lj_gc.c lj_obj.h lj_def.h \
lj_ccall.c lj_ccall.h lj_ccallback.c lj_target.h lj_target_*.h \
lj_mcode.h lj_carith.c lj_carith.h lj_clib.c lj_clib.h lj_cparse.c \
lj_cparse.h lj_lib.c lj_lib.h lj_ir.c lj_ircall.h lj_iropt.h \
lj_opt_mem.c lj_opt_fold.c gen/lj_folddef.h lj_opt_narrow.c lj_opt_dce.c \
lj_opt_mem.c lj_opt_fold.c lj_folddef.h lj_opt_narrow.c lj_opt_dce.c \
lj_opt_loop.c lj_snap.h lj_opt_split.c lj_opt_sink.c lj_mcode.c \
lj_snap.c lj_record.c lj_record.h lj_ffrecord.h lj_crecord.c \
lj_crecord.h lj_ffrecord.c gen/lj_recdef.h lj_asm.c lj_asm.h lj_emit_*.h \
lj_crecord.h lj_ffrecord.c lj_recdef.h lj_asm.c lj_asm.h lj_emit_*.h \
lj_asm_*.h lj_trace.c lj_gdbjit.h lj_gdbjit.c lj_alloc.c lib_aux.c \
lib_base.c gen/lj_libdef.h lib_math.c lib_string.c lib_table.c lib_io.c \
lib_base.c lj_libdef.h lib_math.c lib_string.c lib_table.c lib_io.c \
lib_os.c lib_package.c lib_debug.c lib_bit.c lib_jit.c lib_ffi.c \
lib_init.c
luajit.o: luajit.c lua.h luaconf.h lauxlib.h lualib.h luajit.h lj_arch.h
@ -214,7 +214,7 @@ host/buildvm.o: host/buildvm.c host/buildvm.h lj_def.h lua.h luaconf.h \
lj_arch.h lj_obj.h lj_def.h lj_arch.h lj_gc.h lj_obj.h lj_bc.h lj_ir.h \
lj_ircall.h lj_ir.h lj_jit.h lj_frame.h lj_bc.h lj_dispatch.h lj_ctype.h \
lj_gc.h lj_ccall.h lj_ctype.h luajit.h \
gen/buildvm_arch.h lj_traceerr.h
host/buildvm_arch.h lj_traceerr.h
host/buildvm_asm.o: host/buildvm_asm.c host/buildvm.h lj_def.h lua.h luaconf.h \
lj_arch.h lj_bc.h lj_def.h lj_arch.h
host/buildvm_fold.o: host/buildvm_fold.c host/buildvm.h lj_def.h lua.h \

View file

@ -1,6 +1,6 @@
/*
** LuaJIT VM builder.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
**
** This is a tool to build the hand-tuned assembler code required for
** LuaJIT's bytecode interpreter. It supports a variety of output formats

View file

@ -1,6 +1,6 @@
/*
** LuaJIT VM builder.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/
#ifndef _BUILDVM_H

View file

@ -1,6 +1,6 @@
/*
** LuaJIT VM builder: Assembler source code emitter.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/
#include "buildvm.h"
@ -286,7 +286,7 @@ void emit_asm(BuildCtx *ctx)
fprintf(ctx->fp, "\n");
switch (ctx->mode) {
case BUILD_elfasm:
#if !LJ_TARGET_PS3
#if !(LJ_TARGET_PS3 || LJ_TARGET_PSVITA)
fprintf(ctx->fp, "\t.section .note.GNU-stack,\"\"," ELFASM_PX "progbits\n");
#endif
#if LJ_TARGET_PPCSPE

View file

@ -1,6 +1,6 @@
/*
** LuaJIT VM builder: IR folding hash table generator.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/
#include "buildvm.h"

View file

@ -1,6 +1,6 @@
/*
** LuaJIT VM builder: library definition compiler.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/
#include "buildvm.h"

View file

@ -1,6 +1,6 @@
/*
** LuaJIT VM builder: PE object emitter.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
**
** Only used for building on Windows, since we cannot assume the presence
** of a suitable assembler. The host and target byte order must match.

View file

@ -2,7 +2,7 @@
-- Lua script to generate a customized, minified version of Lua.
-- The resulting 'minilua' is used for the build process of LuaJIT.
----------------------------------------------------------------------------
-- Copyright (C) 2005-2014 Mike Pall. All rights reserved.
-- Copyright (C) 2005-2015 Mike Pall. All rights reserved.
-- Released under the MIT license. See Copyright Notice in luajit.h
----------------------------------------------------------------------------

View file

@ -1,7 +1,7 @@
----------------------------------------------------------------------------
-- LuaJIT bytecode listing module.
--
-- Copyright (C) 2005-2014 Mike Pall. All rights reserved.
-- Copyright (C) 2005-2015 Mike Pall. All rights reserved.
-- Released under the MIT license. See Copyright Notice in luajit.h
----------------------------------------------------------------------------
--
@ -41,7 +41,7 @@
-- Cache some library functions and objects.
local jit = require("jit")
assert(jit.version_num == 20003, "LuaJIT core/library version mismatch")
assert(jit.version_num == 20004, "LuaJIT core/library version mismatch")
local jutil = require("jit.util")
local vmdef = require("jit.vmdef")
local bit = require("bit")

View file

@ -1,7 +1,7 @@
----------------------------------------------------------------------------
-- LuaJIT module to save/list bytecode.
--
-- Copyright (C) 2005-2014 Mike Pall. All rights reserved.
-- Copyright (C) 2005-2015 Mike Pall. All rights reserved.
-- Released under the MIT license. See Copyright Notice in luajit.h
----------------------------------------------------------------------------
--
@ -11,7 +11,7 @@
------------------------------------------------------------------------------
local jit = require("jit")
assert(jit.version_num == 20003, "LuaJIT core/library version mismatch")
assert(jit.version_num == 20004, "LuaJIT core/library version mismatch")
local bit = require("bit")
-- Symbol name prefix for LuaJIT bytecode.
@ -69,7 +69,7 @@ local map_arch = {
local map_os = {
linux = true, windows = true, osx = true, freebsd = true, netbsd = true,
openbsd = true, solaris = true,
openbsd = true, dragonfly = true, solaris = true,
}
local function checkarg(str, map, err)

View file

@ -1,7 +1,7 @@
----------------------------------------------------------------------------
-- LuaJIT ARM disassembler module.
--
-- Copyright (C) 2005-2014 Mike Pall. All rights reserved.
-- Copyright (C) 2005-2015 Mike Pall. All rights reserved.
-- Released under the MIT license. See Copyright Notice in luajit.h
----------------------------------------------------------------------------
-- This is a helper module used by the LuaJIT machine code dumper module.

View file

@ -1,7 +1,7 @@
----------------------------------------------------------------------------
-- LuaJIT MIPS disassembler module.
--
-- Copyright (C) 2005-2014 Mike Pall. All rights reserved.
-- Copyright (C) 2005-2015 Mike Pall. All rights reserved.
-- Released under the MIT/X license. See Copyright Notice in luajit.h
----------------------------------------------------------------------------
-- This is a helper module used by the LuaJIT machine code dumper module.

View file

@ -1,7 +1,7 @@
----------------------------------------------------------------------------
-- LuaJIT MIPSEL disassembler wrapper module.
--
-- Copyright (C) 2005-2014 Mike Pall. All rights reserved.
-- Copyright (C) 2005-2015 Mike Pall. All rights reserved.
-- Released under the MIT license. See Copyright Notice in luajit.h
----------------------------------------------------------------------------
-- This module just exports the little-endian functions from the

View file

@ -1,7 +1,7 @@
----------------------------------------------------------------------------
-- LuaJIT PPC disassembler module.
--
-- Copyright (C) 2005-2014 Mike Pall. All rights reserved.
-- Copyright (C) 2005-2015 Mike Pall. All rights reserved.
-- Released under the MIT/X license. See Copyright Notice in luajit.h
----------------------------------------------------------------------------
-- This is a helper module used by the LuaJIT machine code dumper module.

View file

@ -1,7 +1,7 @@
----------------------------------------------------------------------------
-- LuaJIT x64 disassembler wrapper module.
--
-- Copyright (C) 2005-2014 Mike Pall. All rights reserved.
-- Copyright (C) 2005-2015 Mike Pall. All rights reserved.
-- Released under the MIT license. See Copyright Notice in luajit.h
----------------------------------------------------------------------------
-- This module just exports the 64 bit functions from the combined

View file

@ -1,7 +1,7 @@
----------------------------------------------------------------------------
-- LuaJIT x86/x64 disassembler module.
--
-- Copyright (C) 2005-2014 Mike Pall. All rights reserved.
-- Copyright (C) 2005-2015 Mike Pall. All rights reserved.
-- Released under the MIT license. See Copyright Notice in luajit.h
----------------------------------------------------------------------------
-- This is a helper module used by the LuaJIT machine code dumper module.

View file

@ -1,7 +1,7 @@
----------------------------------------------------------------------------
-- LuaJIT compiler dump module.
--
-- Copyright (C) 2005-2014 Mike Pall. All rights reserved.
-- Copyright (C) 2005-2015 Mike Pall. All rights reserved.
-- Released under the MIT license. See Copyright Notice in luajit.h
----------------------------------------------------------------------------
--
@ -55,7 +55,7 @@
-- Cache some library functions and objects.
local jit = require("jit")
assert(jit.version_num == 20003, "LuaJIT core/library version mismatch")
assert(jit.version_num == 20004, "LuaJIT core/library version mismatch")
local jutil = require("jit.util")
local vmdef = require("jit.vmdef")
local funcinfo, funcbc = jutil.funcinfo, jutil.funcbc

View file

@ -1,7 +1,7 @@
----------------------------------------------------------------------------
-- Verbose mode of the LuaJIT compiler.
--
-- Copyright (C) 2005-2014 Mike Pall. All rights reserved.
-- Copyright (C) 2005-2015 Mike Pall. All rights reserved.
-- Released under the MIT license. See Copyright Notice in luajit.h
----------------------------------------------------------------------------
--
@ -59,7 +59,7 @@
-- Cache some library functions and objects.
local jit = require("jit")
assert(jit.version_num == 20003, "LuaJIT core/library version mismatch")
assert(jit.version_num == 20004, "LuaJIT core/library version mismatch")
local jutil = require("jit.util")
local vmdef = require("jit.vmdef")
local funcinfo, traceinfo = jutil.funcinfo, jutil.traceinfo

View file

@ -1,6 +1,6 @@
/*
** Auxiliary library for the Lua/C API.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
**
** Major parts taken verbatim or adapted from the Lua interpreter.
** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h
@ -302,7 +302,7 @@ static int panic(lua_State *L)
#ifdef LUAJIT_USE_SYSMALLOC
#if LJ_64
#if LJ_64 && !defined(LUAJIT_USE_VALGRIND)
#error "Must use builtin allocator for 64 bit target"
#endif

View file

@ -1,6 +1,6 @@
/*
** Base and coroutine library.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
**
** Major portions taken verbatim or adapted from the Lua interpreter.
** Copyright (C) 1994-2011 Lua.org, PUC-Rio. See Copyright Notice in lua.h

View file

@ -1,6 +1,6 @@
/*
** Bit manipulation library.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/
#define lib_bit_c

View file

@ -1,6 +1,6 @@
/*
** Debug library.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
**
** Major portions taken verbatim or adapted from the Lua interpreter.
** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h

View file

@ -1,6 +1,6 @@
/*
** FFI library.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/
#define lib_ffi_c
@ -136,6 +136,7 @@ static int ffi_index_meta(lua_State *L, CTState *cts, CType *ct, MMS mm)
return 0;
}
}
copyTV(L, base, L->top);
tv = L->top-1;
}
return lj_meta_tailcall(L, tv);

View file

@ -1,6 +1,6 @@
/*
** Library initialization.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
**
** Major parts taken verbatim from the Lua interpreter.
** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h

View file

@ -1,6 +1,6 @@
/*
** I/O library.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
**
** Major portions taken verbatim or adapted from the Lua interpreter.
** Copyright (C) 1994-2011 Lua.org, PUC-Rio. See Copyright Notice in lua.h
@ -24,16 +24,6 @@
#include "lj_ff.h"
#include "lj_lib.h"
#if LJ_TARGET_WINDOWS
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
static int widen(const char *in, wchar_t *out)
{
return MultiByteToWideChar(CP_UTF8, 0, in, -1, out, MAX_PATH);
}
#endif
/* Userdata payload for I/O file. */
typedef struct IOFileUD {
FILE *fp; /* File handle. */
@ -92,15 +82,7 @@ static IOFileUD *io_file_open(lua_State *L, const char *mode)
{
const char *fname = strdata(lj_lib_checkstr(L, 1));
IOFileUD *iof = io_file_new(L);
#if LJ_TARGET_WINDOWS
wchar_t wfname[MAX_PATH];
wchar_t wmode[MAX_PATH];
if (!widen(fname, wfname) || !widen(mode, wmode))
luaL_argerror(L, 1, lj_str_pushf(L, "%s: failed to convert path to utf-16", fname));
iof->fp = _wfopen(wfname, wmode);
#else
iof->fp = fopen(fname, mode);
#endif
if (iof->fp == NULL)
luaL_argerror(L, 1, lj_str_pushf(L, "%s: %s", fname, strerror(errno)));
return iof;
@ -417,14 +399,7 @@ LJLIB_CF(io_open)
GCstr *s = lj_lib_optstr(L, 2);
const char *mode = s ? strdata(s) : "r";
IOFileUD *iof = io_file_new(L);
#if LJ_TARGET_WINDOWS
wchar_t wfname[MAX_PATH];
wchar_t wmode[MAX_PATH];
if (widen(fname, wfname) && widen(mode, wmode))
iof->fp = _wfopen(wfname, wmode);
#else
iof->fp = fopen(fname, mode);
#endif
return iof->fp != NULL ? 1 : luaL_fileresult(L, 0, fname);
}
@ -440,10 +415,7 @@ LJLIB_CF(io_popen)
fflush(NULL);
iof->fp = popen(fname, mode);
#else
wchar_t wfname[MAX_PATH];
wchar_t wmode[MAX_PATH];
if (widen(fname, wfname) && widen(mode, wmode))
iof->fp = _wpopen(wfname, wmode);
iof->fp = _popen(fname, mode);
#endif
return iof->fp != NULL ? 1 : luaL_fileresult(L, 0, fname);
#else
@ -454,7 +426,7 @@ LJLIB_CF(io_popen)
LJLIB_CF(io_tmpfile)
{
IOFileUD *iof = io_file_new(L);
#if LJ_TARGET_PS3 || LJ_TARGET_PS4
#if LJ_TARGET_PS3 || LJ_TARGET_PS4 || LJ_TARGET_PSVITA
iof->fp = NULL; errno = ENOSYS;
#else
iof->fp = tmpfile();

View file

@ -1,6 +1,6 @@
/*
** JIT library.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/
#define lib_jit_c

View file

@ -1,6 +1,6 @@
/*
** Math library.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/
#include <math.h>

View file

@ -1,13 +1,12 @@
/*
** OS library.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
**
** Major portions taken verbatim or adapted from the Lua interpreter.
** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h
*/
#include <errno.h>
#include <locale.h>
#include <time.h>
#define lib_os_c
@ -27,21 +26,8 @@
#include <stdio.h>
#endif
/* ------------------------------------------------------------------------ */
#if LJ_TARGET_WINDOWS
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
static wchar_t *widen_static(const char *narrow, int idx)
{
__declspec(thread) static wchar_t buffer[2][MAX_PATH];
return MultiByteToWideChar(CP_UTF8, 0, narrow, -1, buffer[idx], MAX_PATH) ? buffer[idx] : L"";
}
#define remove(x) _wremove(widen_static(x, 0))
#define system(x) _wsystem(widen_static(x, 0))
#define rename(x, y) _wrename(widen_static(x, 0), widen_static(y, 1))
#if !LJ_TARGET_PSVITA
#include <locale.h>
#endif
/* ------------------------------------------------------------------------ */
@ -87,7 +73,7 @@ LJLIB_CF(os_rename)
LJLIB_CF(os_tmpname)
{
#if LJ_TARGET_PS3 || LJ_TARGET_PS4
#if LJ_TARGET_PS3 || LJ_TARGET_PS4 || LJ_TARGET_PSVITA
lj_err_caller(L, LJ_ERR_OSUNIQF);
return 0;
#else
@ -271,6 +257,9 @@ LJLIB_CF(os_difftime)
LJLIB_CF(os_setlocale)
{
#if LJ_TARGET_PSVITA
lua_pushliteral(L, "C");
#else
GCstr *s = lj_lib_optstr(L, 1);
const char *str = s ? strdata(s) : NULL;
int opt = lj_lib_checkopt(L, 2, 6,
@ -282,6 +271,7 @@ LJLIB_CF(os_setlocale)
else if (opt == 4) opt = LC_MONETARY;
else if (opt == 6) opt = LC_ALL;
lua_pushstring(L, setlocale(opt, str));
#endif
return 1;
}

View file

@ -1,6 +1,6 @@
/*
** Package library.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
**
** Major portions taken verbatim or adapted from the Lua interpreter.
** Copyright (C) 1994-2012 Lua.org, PUC-Rio. See Copyright Notice in lua.h

View file

@ -1,6 +1,6 @@
/*
** String library.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
**
** Major portions taken verbatim or adapted from the Lua interpreter.
** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h

View file

@ -1,6 +1,6 @@
/*
** Table library.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
**
** Major portions taken verbatim or adapted from the Lua interpreter.
** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h

View file

@ -179,23 +179,29 @@ static LJ_AINLINE int CALL_MUNMAP(void *ptr, size_t size)
#if defined(MAP_32BIT)
#if defined(__sun__)
#define MMAP_REGION_START ((uintptr_t)0x1000)
#else
/* Actually this only gives us max. 1GB in current Linux kernels. */
#define MMAP_REGION_START ((uintptr_t)0)
#endif
static LJ_AINLINE void *CALL_MMAP(size_t size)
{
int olderr = errno;
void *ptr = mmap(NULL, size, MMAP_PROT, MAP_32BIT|MMAP_FLAGS, -1, 0);
void *ptr = mmap((void *)MMAP_REGION_START, size, MMAP_PROT, MAP_32BIT|MMAP_FLAGS, -1, 0);
errno = olderr;
return ptr;
}
#elif LJ_TARGET_OSX || LJ_TARGET_PS4 || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__sun__)
#elif LJ_TARGET_OSX || LJ_TARGET_PS4 || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) || defined(__sun__)
/* OSX and FreeBSD mmap() use a naive first-fit linear search.
** That's perfect for us. Except that -pagezero_size must be set for OSX,
** otherwise the lower 4GB are blocked. And the 32GB RLIMIT_DATA needs
** to be reduced to 250MB on FreeBSD.
*/
#if LJ_TARGET_OSX
#if LJ_TARGET_OSX || defined(__DragonFly__)
#define MMAP_REGION_START ((uintptr_t)0x10000)
#elif LJ_TARGET_PS4
#define MMAP_REGION_START ((uintptr_t)0x4000)
@ -232,7 +238,7 @@ static LJ_AINLINE void *CALL_MMAP(size_t size)
return p;
}
if (p != CMFAIL) munmap(p, size);
#ifdef __sun__
#if defined(__sun__) || defined(__DragonFly__)
alloc_hint += 0x1000000; /* Need near-exhaustive linear scan. */
if (alloc_hint + size < MMAP_REGION_END) continue;
#endif

View file

@ -1,6 +1,6 @@
/*
** Public Lua/C API.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
**
** Major portions taken verbatim or adapted from the Lua interpreter.
** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h

View file

@ -1,6 +1,6 @@
/*
** Target architecture selection.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/
#ifndef _LJ_ARCH_H
@ -67,7 +67,8 @@
#elif defined(__MACH__) && defined(__APPLE__)
#define LUAJIT_OS LUAJIT_OS_OSX
#elif (defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || \
defined(__NetBSD__) || defined(__OpenBSD__)) && !defined(__ORBIS__)
defined(__NetBSD__) || defined(__OpenBSD__) || \
defined(__DragonFly__)) && !defined(__ORBIS__)
#define LUAJIT_OS LUAJIT_OS_BSD
#elif (defined(__sun__) && defined(__svr4__)) || defined(__CYGWIN__)
#define LUAJIT_OS LUAJIT_OS_POSIX
@ -111,6 +112,11 @@
#define NULL ((void*)0)
#endif
#ifdef __psp2__
#define LJ_TARGET_PSVITA 1
#define LJ_TARGET_CONSOLE 1
#endif
#if _XBOX_VER >= 200
#define LJ_TARGET_XBOX360 1
#define LJ_TARGET_CONSOLE 1
@ -175,7 +181,9 @@
#define LJ_TARGET_UNIFYROT 2 /* Want only IR_BROR. */
#define LJ_ARCH_NUMMODE LJ_NUMMODE_DUAL
#if __ARM_ARCH_7__ || __ARM_ARCH_7A__ || __ARM_ARCH_7R__ || __ARM_ARCH_7S__
#if __ARM_ARCH____ARM_ARCH_8__ || __ARM_ARCH_8A__
#define LJ_ARCH_VERSION 80
#elif __ARM_ARCH_7__ || __ARM_ARCH_7A__ || __ARM_ARCH_7R__ || __ARM_ARCH_7S__ || __ARM_ARCH_7VE__
#define LJ_ARCH_VERSION 70
#elif __ARM_ARCH_6T2__
#define LJ_ARCH_VERSION 61
@ -334,6 +342,9 @@
#if defined(__mips_soft_float)
#error "No support for MIPS CPUs without FPU"
#endif
#if defined(_LP64)
#error "No support for MIPS64"
#endif
#endif
#endif

View file

@ -1,6 +1,6 @@
/*
** IR assembler (SSA IR -> machine code).
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/
#define lj_asm_c
@ -353,6 +353,7 @@ static Reg ra_rematk(ASMState *as, IRRef ref)
static int32_t ra_spill(ASMState *as, IRIns *ir)
{
int32_t slot = ir->s;
lua_assert(ir >= as->ir + REF_TRUE);
if (!ra_hasspill(slot)) {
if (irt_is64(ir->t)) {
slot = as->evenspill;
@ -1372,6 +1373,11 @@ static void asm_head_side(ASMState *as)
int pass3 = 0;
IRRef i;
if (as->snapno && as->topslot > as->parent->topslot) {
/* Force snap #0 alloc to prevent register overwrite in stack check. */
as->snapno = 0;
asm_snap_alloc(as);
}
allow = asm_head_side_base(as, irp, allow);
/* Scan all parent SLOADs and collect register dependencies. */

View file

@ -1,6 +1,6 @@
/*
** IR assembler (SSA IR -> machine code).
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/
#ifndef _LJ_ASM_H

View file

@ -1,6 +1,6 @@
/*
** ARM IR assembler (SSA IR -> machine code).
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/
/* -- Register allocator extensions --------------------------------------- */

View file

@ -1,6 +1,6 @@
/*
** MIPS IR assembler (SSA IR -> machine code).
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/
/* -- Register allocator extensions --------------------------------------- */

View file

@ -1,6 +1,6 @@
/*
** PPC IR assembler (SSA IR -> machine code).
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/
/* -- Register allocator extensions --------------------------------------- */
@ -49,6 +49,8 @@ static void asm_exitstub_setup(ASMState *as, ExitNo nexits)
{
ExitNo i;
MCode *mxp = as->mctop;
if (mxp - (nexits + 3 + MCLIM_REDZONE) < as->mclim)
asm_mclimit(as);
/* 1: mflr r0; bl ->vm_exit_handler; li r0, traceno; bl <1; bl <1; ... */
for (i = nexits-1; (int32_t)i >= 0; i--)
*--mxp = PPCI_BL|(((-3-i)&0x00ffffffu)<<2);

View file

@ -1,6 +1,6 @@
/*
** x86/x64 IR assembler (SSA IR -> machine code).
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/
/* -- Guard handling ------------------------------------------------------ */
@ -325,6 +325,14 @@ static Reg asm_fuseload(ASMState *as, IRRef ref, RegSet allow)
as->mrm.base = as->mrm.idx = RID_NONE;
return RID_MRM;
}
} else if (ir->o == IR_KINT64) {
RegSet avail = as->freeset & ~as->modset & RSET_GPR;
lua_assert(allow != RSET_EMPTY);
if (!(avail & (avail-1))) { /* Fuse if less than two regs available. */
as->mrm.ofs = ptr2addr(ir_kint64(ir));
as->mrm.base = as->mrm.idx = RID_NONE;
return RID_MRM;
}
} else if (mayfuse(as, ref)) {
RegSet xallow = (allow & RSET_GPR) ? allow : RSET_GPR;
if (ir->o == IR_SLOAD) {
@ -361,7 +369,7 @@ static Reg asm_fuseload(ASMState *as, IRRef ref, RegSet allow)
return RID_MRM;
}
}
if (!(as->freeset & allow) &&
if (!(as->freeset & allow) && !irref_isk(ref) &&
(allow == RSET_EMPTY || ra_hasspill(ir->s) || iscrossref(as, ref)))
goto fusespill;
return ra_allocref(as, ref, allow);
@ -571,7 +579,7 @@ static void asm_setupresult(ASMState *as, IRIns *ir, const CCallInfo *ci)
lua_assert(!irt_ispri(ir->t));
ra_destreg(as, ir, RID_RET);
}
} else if (LJ_32 && irt_isfp(ir->t)) {
} else if (LJ_32 && irt_isfp(ir->t) && !(ci->flags & CCI_CASTU64)) {
emit_x87op(as, XI_FPOP); /* Pop unused result from x87 st0. */
}
}
@ -1828,8 +1836,12 @@ static void asm_intarith(ASMState *as, IRIns *ir, x86Arith xa)
Reg dest, right;
int32_t k = 0;
if (as->flagmcp == as->mcp) { /* Drop test r,r instruction. */
as->flagmcp = NULL;
as->mcp += (LJ_64 && *as->mcp < XI_TESTb) ? 3 : 2;
MCode *p = as->mcp + ((LJ_64 && *as->mcp < XI_TESTb) ? 3 : 2);
if ((p[1] & 15) < 14) {
if ((p[1] & 15) >= 12) p[1] -= 4; /* L <->S, NL <-> NS */
as->flagmcp = NULL;
as->mcp = p;
} /* else: cannot transform LE/NLE to cc without use of OF. */
}
right = IR(rref)->r;
if (ra_hasreg(right)) {

View file

@ -1,6 +1,6 @@
/*
** Bytecode instruction modes.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/
#define lj_bc_c

View file

@ -1,6 +1,6 @@
/*
** Bytecode instruction format.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/
#ifndef _LJ_BC_H

View file

@ -1,6 +1,6 @@
/*
** Bytecode dump definitions.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/
#ifndef _LJ_BCDUMP_H

View file

@ -1,6 +1,6 @@
/*
** Bytecode reader.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/
#define lj_bcread_c

View file

@ -1,6 +1,6 @@
/*
** Bytecode writer.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/
#define lj_bcwrite_c

View file

@ -1,6 +1,6 @@
/*
** C data arithmetic.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/
#include "lj_obj.h"
@ -62,7 +62,7 @@ static int carith_checkarg(lua_State *L, CTState *cts, CDArith *ca)
TValue *o2 = i == 0 ? o+1 : o-1;
CType *ct = ctype_raw(cts, cdataV(o2)->ctypeid);
ca->ct[i] = NULL;
ca->p[i] = NULL;
ca->p[i] = (uint8_t *)strVdata(o);
ok = 0;
if (ctype_isenum(ct->info)) {
CTSize ofs;
@ -79,7 +79,7 @@ static int carith_checkarg(lua_State *L, CTState *cts, CDArith *ca)
}
} else {
ca->ct[i] = NULL;
ca->p[i] = NULL;
ca->p[i] = (void *)(intptr_t)1; /* To make it unequal. */
ok = 0;
}
}
@ -234,7 +234,9 @@ static int lj_carith_meta(lua_State *L, CTState *cts, CDArith *ca, MMS mm)
const char *repr[2];
int i, isenum = -1, isstr = -1;
if (mm == MM_eq) { /* Equality checks never raise an error. */
setboolV(L->top-1, 0);
int eq = ca->p[0] == ca->p[1];
setboolV(L->top-1, eq);
setboolV(&G(L)->tmptv2, eq); /* Remember for trace recorder. */
return 1;
}
for (i = 0; i < 2; i++) {

View file

@ -1,6 +1,6 @@
/*
** C data arithmetic.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/
#ifndef _LJ_CARITH_H

View file

@ -1,6 +1,6 @@
/*
** FFI C call handling.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/
#include "lj_obj.h"

View file

@ -1,6 +1,6 @@
/*
** FFI C call handling.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/
#ifndef _LJ_CCALL_H

View file

@ -1,6 +1,6 @@
/*
** FFI C callback handling.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/
#include "lj_obj.h"

View file

@ -1,6 +1,6 @@
/*
** FFI C callback handling.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/
#ifndef _LJ_CCALLBACK_H

View file

@ -1,6 +1,6 @@
/*
** C type conversions.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/
#include "lj_obj.h"
@ -702,6 +702,7 @@ static void cconv_substruct_init(CTState *cts, CType *d, uint8_t *dp,
} else if (ctype_isxattrib(df->info, CTA_SUBTYPE)) {
cconv_substruct_init(cts, ctype_rawchild(cts, df),
dp+df->size, o, len, ip);
if ((d->info & CTF_UNION)) break;
} /* Ignore all other entries in the chain. */
}
}

View file

@ -1,6 +1,6 @@
/*
** C type conversions.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/
#ifndef _LJ_CCONV_H

View file

@ -1,6 +1,6 @@
/*
** C data management.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/
#include "lj_obj.h"
@ -127,16 +127,16 @@ collect_attrib:
integer_key:
if (ctype_ispointer(ct->info)) {
CTSize sz = lj_ctype_size(cts, ctype_cid(ct->info)); /* Element size. */
if (sz != CTSIZE_INVALID) {
if (ctype_isptr(ct->info)) {
p = (uint8_t *)cdata_getptr(p, ct->size);
} else if ((ct->info & (CTF_VECTOR|CTF_COMPLEX))) {
if ((ct->info & CTF_COMPLEX)) idx &= 1;
*qual |= CTF_CONST; /* Valarray elements are constant. */
}
*pp = p + idx*(int32_t)sz;
return ct;
if (sz == CTSIZE_INVALID)
lj_err_caller(cts->L, LJ_ERR_FFI_INVSIZE);
if (ctype_isptr(ct->info)) {
p = (uint8_t *)cdata_getptr(p, ct->size);
} else if ((ct->info & (CTF_VECTOR|CTF_COMPLEX))) {
if ((ct->info & CTF_COMPLEX)) idx &= 1;
*qual |= CTF_CONST; /* Valarray elements are constant. */
}
*pp = p + idx*(int32_t)sz;
return ct;
}
} else if (tviscdata(key)) { /* Integer cdata key. */
GCcdata *cdk = cdataV(key);

View file

@ -1,6 +1,6 @@
/*
** C data management.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/
#ifndef _LJ_CDATA_H

View file

@ -1,6 +1,6 @@
/*
** FFI C library loader.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/
#include "lj_obj.h"

View file

@ -1,6 +1,6 @@
/*
** FFI C library loader.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/
#ifndef _LJ_CLIB_H

View file

@ -1,6 +1,6 @@
/*
** C declaration parser.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/
#include "lj_obj.h"

View file

@ -1,6 +1,6 @@
/*
** C declaration parser.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/
#ifndef _LJ_CPARSE_H

View file

@ -1,6 +1,6 @@
/*
** Trace recorder for C data operations.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/
#define lj_ffrecord_c
@ -794,7 +794,7 @@ again:
}
} else if (tref_isstr(idx)) {
GCstr *name = strV(&rd->argv[1]);
if (cd->ctypeid == CTID_CTYPEID)
if (cd && cd->ctypeid == CTID_CTYPEID)
ct = ctype_raw(cts, crec_constructor(J, cd, ptr));
if (ctype_isstruct(ct->info)) {
CTSize fofs;
@ -835,6 +835,7 @@ again:
CType *cct = ctype_rawchild(cts, ct);
if (ctype_isstruct(cct->info)) {
ct = cct;
cd = NULL;
if (tref_isstr(idx)) goto again;
}
}
@ -847,8 +848,11 @@ again:
/* Resolve reference for field. */
ct = ctype_get(cts, sid);
if (ctype_isref(ct->info))
if (ctype_isref(ct->info)) {
ptr = emitir(IRT(IR_XLOAD, IRT_PTR), ptr, 0);
sid = ctype_cid(ct->info);
ct = ctype_get(cts, sid);
}
while (ctype_isattrib(ct->info))
ct = ctype_child(cts, ct); /* Skip attributes. */
@ -1317,7 +1321,8 @@ static TRef crec_arith_ptr(jit_State *J, TRef *sp, CType **s, MMS mm)
}
/* Record ctype arithmetic metamethods. */
static void crec_arith_meta(jit_State *J, CTState *cts, RecordFFData *rd)
static TRef crec_arith_meta(jit_State *J, TRef *sp, CType **s, CTState *cts,
RecordFFData *rd)
{
cTValue *tv = NULL;
if (J->base[0]) {
@ -1338,13 +1343,20 @@ static void crec_arith_meta(jit_State *J, CTState *cts, RecordFFData *rd)
if (tvisfunc(tv)) {
J->base[-1] = lj_ir_kfunc(J, funcV(tv)) | TREF_FRAME;
rd->nres = -1; /* Pending tailcall. */
return;
return 0;
} /* NYI: non-function metamethods. */
} else if ((MMS)rd->data == MM_eq) {
J->base[0] = TREF_FALSE;
return;
} else if ((MMS)rd->data == MM_eq) { /* Fallback cdata pointer comparison. */
if (sp[0] && sp[1] && ctype_isnum(s[0]->info) == ctype_isnum(s[1]->info)) {
/* Assume true comparison. Fixup and emit pending guard later. */
lj_ir_set(J, IRTG(IR_EQ, IRT_PTR), sp[0], sp[1]);
J->postproc = LJ_POST_FIXGUARD;
return TREF_TRUE;
} else {
return TREF_FALSE;
}
}
lj_trace_err(J, LJ_TRERR_BADTYPE);
return 0;
}
void LJ_FASTCALL recff_cdata_arith(jit_State *J, RecordFFData *rd)
@ -1357,7 +1369,7 @@ void LJ_FASTCALL recff_cdata_arith(jit_State *J, RecordFFData *rd)
TRef tr = J->base[i];
CType *ct = ctype_get(cts, CTID_DOUBLE);
if (!tr) {
goto trymeta;
lj_trace_err(J, LJ_TRERR_BADTYPE);
} else if (tref_iscdata(tr)) {
CTypeID id = argv2cdata(J, tr, &rd->argv[i])->ctypeid;
IRType t;
@ -1387,11 +1399,12 @@ void LJ_FASTCALL recff_cdata_arith(jit_State *J, RecordFFData *rd)
}
if (ctype_isenum(ct->info)) ct = ctype_child(cts, ct);
if (ctype_isnum(ct->info)) {
if (t == IRT_CDATA) goto trymeta;
if (t == IRT_I64 || t == IRT_U64) lj_needsplit(J);
tr = emitir(IRT(IR_XLOAD, t), tr, 0);
} else if (!(ctype_isptr(ct->info) || ctype_isrefarray(ct->info))) {
goto trymeta;
if (t == IRT_CDATA) {
tr = 0;
} else {
if (t == IRT_I64 || t == IRT_U64) lj_needsplit(J);
tr = emitir(IRT(IR_XLOAD, t), tr, 0);
}
}
} else if (tref_isnil(tr)) {
tr = lj_ir_kptr(J, NULL);
@ -1411,10 +1424,17 @@ void LJ_FASTCALL recff_cdata_arith(jit_State *J, RecordFFData *rd)
emitir(IRTG(IR_EQ, IRT_STR), tr, lj_ir_kstr(J, str));
ct = ctype_child(cts, cct);
tr = lj_ir_kint(J, (int32_t)ofs);
} /* else: interpreter will throw. */
} /* else: interpreter will throw. */
} else { /* Interpreter will throw or return false. */
ct = ctype_get(cts, CTID_P_VOID);
}
} else if (ctype_isptr(ct->info)) {
tr = emitir(IRT(IR_ADD, IRT_PTR), tr, lj_ir_kintp(J, sizeof(GCstr)));
} else {
ct = ctype_get(cts, CTID_P_VOID);
}
} else if (!tref_isnum(tr)) {
goto trymeta;
tr = 0;
ct = ctype_get(cts, CTID_P_VOID);
}
ok:
s[i] = ct;
@ -1422,22 +1442,20 @@ void LJ_FASTCALL recff_cdata_arith(jit_State *J, RecordFFData *rd)
}
{
TRef tr;
if ((tr = crec_arith_int64(J, sp, s, (MMS)rd->data)) ||
(tr = crec_arith_ptr(J, sp, s, (MMS)rd->data))) {
J->base[0] = tr;
/* Fixup cdata comparisons, too. Avoids some cdata escapes. */
if (J->postproc == LJ_POST_FIXGUARD && frame_iscont(J->L->base-1) &&
!irt_isguard(J->guardemit)) {
const BCIns *pc = frame_contpc(J->L->base-1) - 1;
if (bc_op(*pc) <= BC_ISNEP) {
setframe_pc(&J2G(J)->tmptv, pc);
J2G(J)->tmptv.u32.lo = ((tref_istrue(tr) ^ bc_op(*pc)) & 1);
J->postproc = LJ_POST_FIXCOMP;
}
if (!(tr = crec_arith_int64(J, sp, s, (MMS)rd->data)) &&
!(tr = crec_arith_ptr(J, sp, s, (MMS)rd->data)) &&
!(tr = crec_arith_meta(J, sp, s, cts, rd)))
return;
J->base[0] = tr;
/* Fixup cdata comparisons, too. Avoids some cdata escapes. */
if (J->postproc == LJ_POST_FIXGUARD && frame_iscont(J->L->base-1) &&
!irt_isguard(J->guardemit)) {
const BCIns *pc = frame_contpc(J->L->base-1) - 1;
if (bc_op(*pc) <= BC_ISNEP) {
setframe_pc(&J2G(J)->tmptv, pc);
J2G(J)->tmptv.u32.lo = ((tref_istrue(tr) ^ bc_op(*pc)) & 1);
J->postproc = LJ_POST_FIXCOMP;
}
} else {
trymeta:
crec_arith_meta(J, cts, rd);
}
}
}

View file

@ -1,6 +1,6 @@
/*
** Trace recorder for C data operations.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/
#ifndef _LJ_CRECORD_H

View file

@ -1,6 +1,6 @@
/*
** C type management.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/
#include "lj_obj.h"

View file

@ -1,6 +1,6 @@
/*
** C type management.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/
#ifndef _LJ_CTYPE_H

View file

@ -1,6 +1,6 @@
/*
** Debugging and introspection.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/
#define lj_debug_c
@ -14,6 +14,7 @@
#include "lj_state.h"
#include "lj_frame.h"
#include "lj_bc.h"
#include "lj_vm.h"
#if LJ_HASJIT
#include "lj_jit.h"
#endif
@ -86,7 +87,8 @@ static BCPos debug_framepc(lua_State *L, GCfunc *fn, cTValue *nextframe)
if (frame_islua(f)) {
f = frame_prevl(f);
} else {
if (frame_isc(f))
if (frame_isc(f) || (LJ_HASFFI && frame_iscont(f) &&
(f-1)->u32.lo == LJ_CONT_FFI_CALLBACK))
cf = cframe_raw(cframe_prev(cf));
f = frame_prevd(f);
}
@ -463,7 +465,7 @@ int lj_debug_getinfo(lua_State *L, const char *what, lj_Debug *ar, int ext)
lj_debug_shortname(ar->short_src, name);
ar->linedefined = (int)firstline;
ar->lastlinedefined = (int)(firstline + pt->numline);
ar->what = firstline ? "Lua" : "main";
ar->what = (firstline || !pt->numline) ? "Lua" : "main";
} else {
ar->source = "=[C]";
ar->short_src[0] = '[';

View file

@ -1,6 +1,6 @@
/*
** Debugging and introspection.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/
#ifndef _LJ_DEBUG_H

View file

@ -1,6 +1,6 @@
/*
** LuaJIT common internal definitions.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/
#ifndef _LJ_DEF_H
@ -111,7 +111,7 @@ typedef uintptr_t BloomFilter;
#define bloomset(b, x) ((b) |= bloombit((x)))
#define bloomtest(b, x) ((b) & bloombit((x)))
#if defined(__GNUC__)
#if defined(__GNUC__) || defined(__psp2__)
#define LJ_NORET __attribute__((noreturn))
#define LJ_ALIGN(n) __attribute__((aligned(n)))
@ -119,7 +119,7 @@ typedef uintptr_t BloomFilter;
#define LJ_AINLINE inline __attribute__((always_inline))
#define LJ_NOINLINE __attribute__((noinline))
#if defined(__ELF__) || defined(__MACH__)
#if defined(__ELF__) || defined(__MACH__) || defined(__psp2__)
#if !((defined(__sun__) && defined(__svr4__)) || defined(__CELLOS_LV2__))
#define LJ_NOAPI extern __attribute__((visibility("hidden")))
#endif
@ -150,6 +150,9 @@ static LJ_AINLINE uint32_t lj_fls(uint32_t x)
#if defined(__arm__)
static LJ_AINLINE uint32_t lj_bswap(uint32_t x)
{
#if defined(__psp2__)
return __builtin_rev(x);
#else
uint32_t r;
#if __ARM_ARCH_6__ || __ARM_ARCH_6J__ || __ARM_ARCH_6T2__ || __ARM_ARCH_6Z__ ||\
__ARM_ARCH_6ZK__ || __ARM_ARCH_7__ || __ARM_ARCH_7A__ || __ARM_ARCH_7R__
@ -163,6 +166,7 @@ static LJ_AINLINE uint32_t lj_bswap(uint32_t x)
#endif
return ((r & 0xff00ffffu) >> 8) ^ lj_ror(x, 8);
#endif
#endif
}
static LJ_AINLINE uint64_t lj_bswap64(uint64_t x)

View file

@ -1,6 +1,6 @@
/*
** Instruction dispatch handling.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/
#define lj_dispatch_c

View file

@ -1,6 +1,6 @@
/*
** Instruction dispatch handling.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/
#ifndef _LJ_DISPATCH_H

View file

@ -1,6 +1,6 @@
/*
** ARM instruction emitter.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/
/* -- Constant encoding --------------------------------------------------- */

View file

@ -1,6 +1,6 @@
/*
** MIPS instruction emitter.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/
/* -- Emit basic instructions --------------------------------------------- */

View file

@ -1,6 +1,6 @@
/*
** PPC instruction emitter.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/
/* -- Emit basic instructions --------------------------------------------- */

View file

@ -1,6 +1,6 @@
/*
** x86/x64 instruction emitter.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/
/* -- Emit basic instructions --------------------------------------------- */

View file

@ -1,6 +1,6 @@
/*
** Error handling.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/
#define lj_err_c
@ -378,7 +378,7 @@ typedef struct UndocumentedDispatcherContext {
ULONG64 EstablisherFrame;
ULONG64 TargetIp;
PCONTEXT ContextRecord;
PEXCEPTION_ROUTINE LanguageHandler;
void (*LanguageHandler)(void);
PVOID HandlerData;
PUNWIND_HISTORY_TABLE HistoryTable;
ULONG ScopeIndex;
@ -499,8 +499,7 @@ static ptrdiff_t finderrfunc(lua_State *L)
{
cTValue *frame = L->base-1, *bot = tvref(L->stack);
void *cf = L->cframe;
while (frame > bot) {
lua_assert(cf != NULL);
while (frame > bot && cf) {
while (cframe_nres(cframe_raw(cf)) < 0) { /* cframe without frame? */
if (frame >= restorestack(L, -cframe_nres(cf)))
break;
@ -518,12 +517,14 @@ static ptrdiff_t finderrfunc(lua_State *L)
case FRAME_C:
cf = cframe_prev(cf);
/* fallthrough */
case FRAME_VARG:
frame = frame_prevd(frame);
break;
case FRAME_CONT:
#if LJ_HASFFI
if ((frame-1)->u32.lo == LJ_CONT_FFI_CALLBACK)
cf = cframe_prev(cf);
#endif
case FRAME_VARG:
frame = frame_prevd(frame);
break;
case FRAME_CP:
@ -725,9 +726,23 @@ LJ_NOINLINE void lj_err_arg(lua_State *L, int narg, ErrMsg em)
/* Typecheck error for arguments. */
LJ_NOINLINE void lj_err_argtype(lua_State *L, int narg, const char *xname)
{
TValue *o = narg < 0 ? L->top + narg : L->base + narg-1;
const char *tname = o < L->top ? lj_typename(o) : lj_obj_typename[0];
const char *msg = lj_str_pushf(L, err2msg(LJ_ERR_BADTYPE), xname, tname);
const char *tname, *msg;
if (narg <= LUA_REGISTRYINDEX) {
if (narg >= LUA_GLOBALSINDEX) {
tname = lj_obj_itypename[~LJ_TTAB];
} else {
GCfunc *fn = curr_func(L);
int idx = LUA_GLOBALSINDEX - narg;
if (idx <= fn->c.nupvalues)
tname = lj_typename(&fn->c.upvalue[idx-1]);
else
tname = lj_obj_typename[0];
}
} else {
TValue *o = narg < 0 ? L->top + narg : L->base + narg-1;
tname = o < L->top ? lj_typename(o) : lj_obj_typename[0];
}
msg = lj_str_pushf(L, err2msg(LJ_ERR_BADTYPE), xname, tname);
err_argmsg(L, narg, msg);
}

View file

@ -1,6 +1,6 @@
/*
** Error handling.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/
#ifndef _LJ_ERR_H

View file

@ -1,6 +1,6 @@
/*
** VM error messages.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/
/* This file may be included multiple times with different ERRDEF macros. */

View file

@ -1,6 +1,6 @@
/*
** Fast function IDs.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/
#ifndef _LJ_FF_H

View file

@ -1,6 +1,6 @@
/*
** Fast function call recorder.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/
#define lj_ffrecord_c

View file

@ -1,6 +1,6 @@
/*
** Fast function call recorder.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/
#ifndef _LJ_FFRECORD_H

View file

@ -1,6 +1,6 @@
/*
** Stack frames.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/
#ifndef _LJ_FRAME_H

View file

@ -1,6 +1,6 @@
/*
** Function handling (prototypes, functions and upvalues).
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
**
** Portions taken verbatim or adapted from the Lua interpreter.
** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h

View file

@ -1,6 +1,6 @@
/*
** Function handling (prototypes, functions and upvalues).
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/
#ifndef _LJ_FUNC_H

View file

@ -1,6 +1,6 @@
/*
** Garbage collector.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
**
** Major portions taken verbatim or adapted from the Lua interpreter.
** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h
@ -631,6 +631,8 @@ static size_t gc_onestep(lua_State *L)
case GCSsweep: {
MSize old = g->gc.total;
setmref(g->gc.sweep, gc_sweep(g, mref(g->gc.sweep, GCRef), GCSWEEPMAX));
lua_assert(old >= g->gc.total);
g->gc.estimate -= old - g->gc.total;
if (gcref(*mref(g->gc.sweep, GCRef)) == NULL) {
gc_shrink(g, L);
if (gcref(g->gc.mmudata)) { /* Need any finalizations? */
@ -643,8 +645,6 @@ static size_t gc_onestep(lua_State *L)
g->gc.debt = 0;
}
}
lua_assert(old >= g->gc.total);
g->gc.estimate -= old - g->gc.total;
return GCSWEEPMAX*GCSWEEPCOST;
}
case GCSfinalize:

View file

@ -1,6 +1,6 @@
/*
** Garbage collector.
** Copyright (C) 2005-2014 Mike Pall. See Copyright Notice in luajit.h
** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
*/
#ifndef _LJ_GC_H

Some files were not shown because too many files have changed in this diff Show more