From a88d7c1cdcf83d24d1f0b7644d32505b088350be Mon Sep 17 00:00:00 2001 From: David Anderson Date: Thu, 10 Jul 2008 05:38:54 +0000 Subject: [PATCH] fixed a number of regressions, things are starting to load --HG-- branch : refac-jit extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/branches/refac-jit%402395 --- sourcepawn/jit/BaseRuntime.cpp | 10 ++++----- sourcepawn/jit/Makefile | 33 ++++++++++++++++++++++++---- sourcepawn/jit/engine2.cpp | 3 ++- sourcepawn/jit/sp_vm_basecontext.cpp | 2 +- sourcepawn/jit/sp_vm_function.cpp | 2 +- 5 files changed, 38 insertions(+), 12 deletions(-) diff --git a/sourcepawn/jit/BaseRuntime.cpp b/sourcepawn/jit/BaseRuntime.cpp index ace6223e..3c3227df 100644 --- a/sourcepawn/jit/BaseRuntime.cpp +++ b/sourcepawn/jit/BaseRuntime.cpp @@ -239,7 +239,7 @@ void BaseRuntime::RefreshFunctionCache() { continue; } - m_PubFuncs[i]->Set(pub->code_offs, this, pub->funcid, i); + m_PubFuncs[i]->Set(pub->code_offs, this, (i << 1) | 1, i); } } @@ -261,7 +261,7 @@ IPluginFunction *BaseRuntime::GetFunctionById(funcid_t func_id) { m_PubFuncs[func_id] = new CFunction(m_pPlugin->publics[func_id].code_offs, this, - m_pPlugin->publics[func_id].funcid, + (func_id << 1) | 1, func_id); pFunc = m_PubFuncs[func_id]; } @@ -269,7 +269,7 @@ IPluginFunction *BaseRuntime::GetFunctionById(funcid_t func_id) { pFunc->Set(m_pPlugin->publics[func_id].code_offs, this, - m_pPlugin->publics[func_id].funcid, + (func_id << 1) | 1, func_id); } } @@ -293,7 +293,7 @@ IPluginFunction *BaseRuntime::GetFunctionByName(const char *public_name) GetPublicByIndex(index, &pub); if (pub) { - m_PubFuncs[index] = new CFunction(pub->code_offs, this, pub->funcid, index); + m_PubFuncs[index] = new CFunction(pub->code_offs, this, (index << 1) | 1, index); } pFunc = m_PubFuncs[index]; } @@ -303,7 +303,7 @@ IPluginFunction *BaseRuntime::GetFunctionByName(const char *public_name) GetPublicByIndex(index, &pub); if (pub) { - pFunc->Set(pub->code_offs, this, pub->funcid, index); + pFunc->Set(pub->code_offs, this, (index << 1) | 1, index); } else { diff --git a/sourcepawn/jit/Makefile b/sourcepawn/jit/Makefile index d8966966..fdc1358b 100644 --- a/sourcepawn/jit/Makefile +++ b/sourcepawn/jit/Makefile @@ -1,7 +1,8 @@ # (C)2004-2008 SourceMod Development Team # Makefile written by David "BAILOPAN" Anderson -SMSDK = ../../.. +SMSDK = ../.. +SOURCEHOOK = ../../../sourcemm-1.6/sourcehook ##################################### ### EDIT BELOW FOR OTHER PROJECTS ### @@ -9,7 +10,26 @@ SMSDK = ../../.. PROJECT = sourcepawn.jit.x86 -OBJECTS = dll_exports.cpp jit_x86.cpp opcode_helpers.cpp +OBJECTS = dll_exports.cpp \ + x86/jit_x86.cpp \ + x86/opcode_helpers.cpp \ + sp_vm_basecontext.cpp \ + sp_vm_engine.cpp \ + sp_vm_function.cpp \ + engine2.cpp \ + BaseRuntime.cpp \ + zlib/adler32.c \ + zlib/compress.c \ + zlib/crc32.c \ + zlib/deflate.c \ + zlib/gzio.c \ + zlib/infback.c \ + zlib/inffast.c \ + zlib/inflate.c \ + zlib/inftrees.c \ + zlib/trees.c \ + zlib/uncompr.c \ + zlib/zutil.c ############################################## ### CONFIGURE ANY OTHER FLAGS/OPTIONS HERE ### @@ -24,7 +44,7 @@ CPP = gcc-4.1 LINK = -static-libgcc INCLUDE = -I. -I.. -I$(SMSDK)/public -I$(SMSDK)/public/jit -I$(SMSDK)/public/jit/x86 \ - -I$(SMSDK)/public/sourcepawn + -I$(SMSDK)/public/sourcepawn -I$(SOURCEHOOK) CFLAGS += -D_LINUX -Dstricmp=strcasecmp -D_stricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp \ -D_snprintf=snprintf -D_vsnprintf=vsnprintf -D_alloca=alloca -Dstrcmpi=strcasecmp -Wall -DHAVE_STDINT_H \ @@ -52,12 +72,17 @@ endif BINARY = $(PROJECT).so OBJ_LINUX := $(OBJECTS:%.cpp=$(BIN_DIR)/%.o) +OBJ_LINUX := $(OBJ_LINUX:%.c=$(BIN_DIR)/%.o) + +$(BIN_DIR)/%.o: %.c + $(CPP) $(INCLUDE) $(CFLAGS) -o $@ -c $< $(BIN_DIR)/%.o: %.cpp $(CPP) $(INCLUDE) $(CFLAGS) $(CPPFLAGS) -o $@ -c $< all: - mkdir -p $(BIN_DIR) + mkdir -p $(BIN_DIR)/x86 + mkdir -p $(BIN_DIR)/zlib $(MAKE) -f Makefile jit jit: $(OBJ_LINUX) diff --git a/sourcepawn/jit/engine2.cpp b/sourcepawn/jit/engine2.cpp index e9e0b941..aa69bbc1 100644 --- a/sourcepawn/jit/engine2.cpp +++ b/sourcepawn/jit/engine2.cpp @@ -125,6 +125,7 @@ IPluginRuntime *SourcePawnEngine2::LoadPlugin(ICompilation *co, const char *file uint8_t *base; int z_result; int error; + BaseRuntime *pRuntime; FILE *fp = fopen(file, "rb"); @@ -203,7 +204,7 @@ IPluginRuntime *SourcePawnEngine2::LoadPlugin(ICompilation *co, const char *file return NULL; } - BaseRuntime *pRuntime = new BaseRuntime(plugin); + pRuntime = new BaseRuntime(plugin); if (co == NULL) { diff --git a/sourcepawn/jit/sp_vm_basecontext.cpp b/sourcepawn/jit/sp_vm_basecontext.cpp index b2565da7..e6988046 100644 --- a/sourcepawn/jit/sp_vm_basecontext.cpp +++ b/sourcepawn/jit/sp_vm_basecontext.cpp @@ -262,7 +262,7 @@ int BaseContext::GetPubvarByIndex(uint32_t index, sp_pubvar_t **pubvar) int BaseContext::FindPubvarByName(const char *name, uint32_t *index) { - return m_pRuntime->FindPublicByName(name, index); + return m_pRuntime->FindPubvarByName(name, index); } int BaseContext::GetPubvarAddrs(uint32_t index, cell_t *local_addr, cell_t **phys_addr) diff --git a/sourcepawn/jit/sp_vm_function.cpp b/sourcepawn/jit/sp_vm_function.cpp index c94528a0..aea522e4 100644 --- a/sourcepawn/jit/sp_vm_function.cpp +++ b/sourcepawn/jit/sp_vm_function.cpp @@ -50,7 +50,7 @@ void CFunction::Set(uint32_t code_addr, BaseRuntime *runtime, funcid_t fnid, uin bool CFunction::IsRunnable() { - return m_pRuntime->IsPaused(); + return !m_pRuntime->IsPaused(); } int CFunction::CallFunction(const cell_t *params, unsigned int num_params, cell_t *result)