Landed sourcepawn-1.2. The big changes:

1) JIT compilation/optimization now occurs per-function, and only when functions are first used.  We're now officially a whole-method JIT rather than an AOT compiler (albiet, still a simple JIT).  This has two implications: Functions are now much better abstracted internally, and loading a plugin is now much less expensive.  If a function contains calls to other functions, THOSE functions are only compiled when they're invoked as well.

2) I've removed debug mode.  We always show full backtraces now, as there was a very cheap way to implement this which really cleaned up everything.  This is great for a number of reasons -- there's less code, the JIT is better designed, we don't need to relocate debug tables, and best of all we no longer have to tell users to enable debug mode at their own expense.

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%402459
This commit is contained in:
David Anderson
2008-08-15 05:22:26 +00:00
parent 95aca7b61b
commit 7875fe1acd
49 changed files with 3475 additions and 1724 deletions
+1 -1
View File
@@ -296,7 +296,7 @@ namespace SourceMod
* @brief Attempts to load a plugin.
*
* @param path Path and filename of plugin, relative to plugins folder.
* @param debug Whether or not to default the plugin into debug mode.
* @param debug Deprecated, must be false.
* @param type Lifetime of the plugin.
* @param error Buffer to hold any error message.
* @param maxlength Maximum length of error message buffer.
+4
View File
@@ -65,6 +65,10 @@ public:
inptr++;
return val;
}
inline cell_t peek_cell()
{
return *inptr;
}
inline cell_t *read_cellptr()
{
cell_t *val = *(cell_t **)(inptr);
+52 -5
View File
@@ -998,6 +998,38 @@ inline void IA32_Mov_Rm_Imm32_Disp32(JitWriter *jit,
jit->write_int32(val);
}
inline void IA32_Mov_Rm_Imm32_SIB(JitWriter *jit,
jit_uint8_t dest,
jit_int32_t val,
jit_int32_t disp,
jit_uint8_t index,
jit_uint8_t scale)
{
jit->write_ubyte(IA32_MOV_RM_IMM32);
if (disp >= SCHAR_MIN && disp <= SCHAR_MAX)
{
jit->write_ubyte(ia32_modrm(MOD_DISP8, 0, REG_SIB));
}
else
{
jit->write_ubyte(ia32_modrm(MOD_DISP32, 0, REG_SIB));
}
jit->write_ubyte(ia32_sib(scale, index, dest));
if (disp >= SCHAR_MIN && disp <= SCHAR_MAX)
{
jit->write_byte((jit_int8_t)disp);
}
else
{
jit->write_int32(disp);
}
jit->write_int32(val);
}
inline void IA32_Mov_RmEBP_Imm32_Disp_Reg(JitWriter *jit,
jit_uint8_t dest_base,
jit_uint8_t dest_index,
@@ -1347,24 +1379,39 @@ inline void IA32_Write_Jump32_Abs(JitWriter *jit, jitoffs_t jmp, void *target)
jit->outptr = oldptr;
}
/* For writing and auto-calculating an absolute target */
inline void IA32_Jump_Imm32_Abs(JitWriter *jit, jitoffs_t target)
/* For writing and auto-calculating a relative target */
inline void IA32_Jump_Imm32_Rel(JitWriter *jit, jitoffs_t target)
{
/* :TODO: this should work, but does it? */
jit->write_ubyte(IA32_JMP_IMM32);
IA32_Write_Jump32(jit, jit->get_outputpos(), target);
jit->outptr += 4;
}
inline void IA32_Jump_Cond_Imm32_Abs(JitWriter *jit, jit_uint8_t cond, jitoffs_t target)
/* For writing and auto-calculating an absolute target */
inline void IA32_Jump_Imm32_Abs(JitWriter *jit, void *target)
{
jitoffs_t jmp;
jmp = IA32_Jump_Imm32(jit, 0);
IA32_Write_Jump32_Abs(jit, jmp, target);
}
inline void IA32_Jump_Cond_Imm32_Rel(JitWriter *jit, jit_uint8_t cond, jitoffs_t target)
{
/* :TODO: this should work, but does it? */
jit->write_ubyte(IA32_JCC_IMM32_1);
jit->write_ubyte(IA32_JCC_IMM32_2+cond);
IA32_Write_Jump32(jit, jit->get_outputpos(), target);
jit->outptr += 4;
}
inline void IA32_Jump_Cond_Imm32_Abs(JitWriter *jit, jit_uint8_t cond, void *target)
{
jit->write_ubyte(IA32_JCC_IMM32_1);
jit->write_ubyte(IA32_JCC_IMM32_2+cond);
IA32_Write_Jump32_Abs(jit, jit->get_outputpos(), target);
jit->outptr += 4;
}
inline void IA32_Send_Jump8_Here(JitWriter *jit, jitoffs_t jmp)
{
jitoffs_t curptr = jit->get_outputpos();
+3
View File
@@ -98,6 +98,9 @@ typedef struct sp_file_hdr_s
#define SP_FLAG_DEBUG (1<<0) /**< Debug information is present in the file */
#define SP_CODEVERS_JIT1 9 /**< Code version for JIT1 */
#define SP_CODEVERS_JIT2 10 /**< Code version for JIT2 */
/**
* @brief File-encoded format of the ".code" section.
*/
+28 -1
View File
@@ -42,7 +42,7 @@
/** SourcePawn Engine API Version */
#define SOURCEPAWN_ENGINE_API_VERSION 4
#define SOURCEPAWN_ENGINE2_API_VERSION 1
#define SOURCEPAWN_ENGINE2_API_VERSION 2
#if !defined SOURCEMOD_BUILD
#define SOURCEMOD_BUILD
@@ -955,7 +955,21 @@ namespace SourcePawn
class IDebugListener
{
public:
/**
* @brief Invoked on a context execution error.
*
* @param ctx Context.
* @param error Object holding error information and a backtrace.
*/
virtual void OnContextExecuteError(IPluginContext *ctx, IContextTrace *error) =0;
/**
* @brief Called on debug spew.
*
* @param msg Message text.
* @param fmt Message formatting arguments (printf-style).
*/
virtual void OnDebugSpew(const char *msg, ...) =0;
};
/**
@@ -1225,6 +1239,19 @@ namespace SourcePawn
* @return Error string, or NULL if not found.
*/
virtual const char *GetErrorString(int err) =0;
/**
* @brief Initializes the SourcePawn engine.
*
* @return True on success, false if failed.
*/
virtual bool Initialize() =0;
/**
* @brief Shuts down the SourcePawn engine. Only needs to be called if
* Initialize() succeeded.
*/
virtual void Shutdown() =0;
};
};
+2 -3
View File
@@ -83,6 +83,8 @@ typedef uint32_t funcid_t; /**< Function index code */
#define SP_ERROR_NATIVE 23 /**< Error originates from a native */
#define SP_ERROR_NOT_RUNNABLE 24 /**< Function or plugin is not runnable */
#define SP_ERROR_ABORTED 25 /**< Function call was aborted */
#define SP_ERROR_CODE_TOO_OLD 26 /**< Code is too old for this VM */
#define SP_ERROR_CODE_TOO_NEW 27 /**< Code is too new for this VM */
//Hey you! Update the string table if you add to the end of me! */
/**********************************************
@@ -201,7 +203,4 @@ typedef struct sp_debug_symbol_s
sp_fdbg_symbol_t *sym; /**< Pointer to original symbol */
} sp_debug_symbol_t;
//#define SPFLAG_PLUGIN_DEBUG (1<<0) /**< plugin is in debug mode */
//#define SPFLAG_PLUGIN_PAUSED (1<<1) /**< plugin is "paused" (blocked from executing) */
#endif //_INCLUDE_SOURCEPAWN_VM_TYPES_H