/[pcre]/code/trunk/sljit/sljitLir.h
ViewVC logotype

Diff of /code/trunk/sljit/sljitLir.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 879 by zherczeg, Sat Jan 14 17:05:53 2012 UTC revision 880 by zherczeg, Sun Jan 15 17:23:37 2012 UTC
# Line 44  Line 44 
44        - The compiler is thread-safe        - The compiler is thread-safe
45      Disadvantages:      Disadvantages:
46        - Limited number of registers (only 6+4 integer registers, max 3+2        - Limited number of registers (only 6+4 integer registers, max 3+2
47          temporary and max 3+2 general, and 4 floating point registers)          temporary, max 3+2 saved and 4 floating point registers)
48      In practice:      In practice:
49        - This approach is very effective for interpreters        - This approach is very effective for interpreters
50          - One of the general registers typically points to a stack interface          - One of the saved registers typically points to a stack interface
51          - It can jump to any exception handler anytime (even for another          - It can jump to any exception handler anytime (even for another
52            function. It is safe for SLJIT.)            function. It is safe for SLJIT.)
53          - Fast paths can be modified during runtime reflecting the changes          - Fast paths can be modified during runtime reflecting the changes
# Line 104  of sljitConfigInternal.h */ Line 104  of sljitConfigInternal.h */
104  #define SLJIT_TEMPORARY_EREG1   4  #define SLJIT_TEMPORARY_EREG1   4
105  #define SLJIT_TEMPORARY_EREG2   5  #define SLJIT_TEMPORARY_EREG2   5
106    
107  /* General (saved) registers preserve their values across function calls. */  /* Saved registers whose preserve their values across function calls. */
108  #define SLJIT_GENERAL_REG1      6  #define SLJIT_SAVED_REG1        6
109  #define SLJIT_GENERAL_REG2      7  #define SLJIT_SAVED_REG2        7
110  #define SLJIT_GENERAL_REG3      8  #define SLJIT_SAVED_REG3        8
111  /* Note: Extra Registers cannot be used for memory addressing. */  /* Note: Extra Registers cannot be used for memory addressing. */
112  /* Note: on x86-32, these registers are emulated (using stack loads & stores). */  /* Note: on x86-32, these registers are emulated (using stack loads & stores). */
113  #define SLJIT_GENERAL_EREG1     9  #define SLJIT_SAVED_EREG1       9
114  #define SLJIT_GENERAL_EREG2     10  #define SLJIT_SAVED_EREG2       10
115    
116  /* Read-only register (cannot be the destination of an operation). */  /* Read-only register (cannot be the destination of an operation). */
117  /* Note: SLJIT_MEM2( ... , SLJIT_LOCALS_REG) is not supported (x86 limitation). */  /* Note: SLJIT_MEM2( ... , SLJIT_LOCALS_REG) is not supported (x86 limitation). */
# Line 196  struct sljit_compiler { Line 196  struct sljit_compiler {
196    
197          /* Used local registers. */          /* Used local registers. */
198          int temporaries;          int temporaries;
199          /* Used general registers. */          /* Used saved registers. */
200          int generals;          int saveds;
201          /* Local stack size. */          /* Local stack size. */
202          int local_size;          int local_size;
203          /* Code size. */          /* Code size. */
# Line 208  struct sljit_compiler { Line 208  struct sljit_compiler {
208  #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)  #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
209          int args;          int args;
210          int temporaries_start;          int temporaries_start;
211          int generals_start;          int saveds_start;
212  #endif  #endif
213    
214  #if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)  #if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
# Line 228  struct sljit_compiler { Line 228  struct sljit_compiler {
228          sljit_ub *cpool_unique;          sljit_ub *cpool_unique;
229          sljit_uw cpool_diff;          sljit_uw cpool_diff;
230          sljit_uw cpool_fill;          sljit_uw cpool_fill;
231          /* General fields. */          /* Other members. */
232          /* Contains pointer, "ldr pc, [...]" pairs. */          /* Contains pointer, "ldr pc, [...]" pairs. */
233          sljit_uw patches;          sljit_uw patches;
234  #endif  #endif
# Line 317  static SLJIT_INLINE sljit_uw sljit_get_g Line 317  static SLJIT_INLINE sljit_uw sljit_get_g
317     Binary Interface) of the platform, which specify the purpose of machine     Binary Interface) of the platform, which specify the purpose of machine
318     registers and stack handling among other things. The sljit_emit_enter     registers and stack handling among other things. The sljit_emit_enter
319     function emits the necessary instructions for setting up a new context     function emits the necessary instructions for setting up a new context
320     for the executable code and moves function arguments to the general     for the executable code and moves function arguments to the saved
321     registers. The number of arguments are specified in the "args"     registers. The number of arguments are specified in the "args"
322     parameter and the first argument goes to SLJIT_GENERAL_REG1, the second     parameter and the first argument goes to SLJIT_SAVED_REG1, the second
323     goes to SLJIT_GENERAL_REG2 and so on. The number of temporary and     goes to SLJIT_SAVED_REG2 and so on. The number of temporary and
324     general registers are passed in "temporaries" and "generals" arguments     saved registers are passed in "temporaries" and "saveds" arguments
325     respectively. Since the general registers contains the arguments,     respectively. Since the saved registers contains the arguments,
326     "args" must be less or equal than "generals". The sljit_emit_enter     "args" must be less or equal than "saveds". The sljit_emit_enter
327     is also capable of allocating a stack space for local variables. The     is also capable of allocating a stack space for local variables. The
328     "local_size" argument contains the size in bytes of this local area     "local_size" argument contains the size in bytes of this local area
329     and its staring address is stored in SLJIT_LOCALS_REG. However     and its staring address is stored in SLJIT_LOCALS_REG. However
# Line 338  static SLJIT_INLINE sljit_uw sljit_get_g Line 338  static SLJIT_INLINE sljit_uw sljit_get_g
338  #define SLJIT_MAX_LOCAL_SIZE    65536  #define SLJIT_MAX_LOCAL_SIZE    65536
339    
340  SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_enter(struct sljit_compiler *compiler,  SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_enter(struct sljit_compiler *compiler,
341          int args, int temporaries, int generals, int local_size);          int args, int temporaries, int saveds, int local_size);
342    
343  /* The machine code has a context (which contains the local stack space size,  /* The machine code has a context (which contains the local stack space size,
344     number of used registers, etc.) which initialized by sljit_emit_enter. Several     number of used registers, etc.) which initialized by sljit_emit_enter. Several
# Line 353  SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_ Line 353  SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_
353  /* Note: multiple calls of this function overwrites the previous call. */  /* Note: multiple calls of this function overwrites the previous call. */
354    
355  SLJIT_API_FUNC_ATTRIBUTE void sljit_set_context(struct sljit_compiler *compiler,  SLJIT_API_FUNC_ATTRIBUTE void sljit_set_context(struct sljit_compiler *compiler,
356          int args, int temporaries, int generals, int local_size);          int args, int temporaries, int saveds, int local_size);
357    
358  /* Return from machine code.  The op argument can be SLJIT_UNUSED which means the  /* Return from machine code.  The op argument can be SLJIT_UNUSED which means the
359     function does not return with anything or any opcode between SLJIT_MOV and     function does not return with anything or any opcode between SLJIT_MOV and
# Line 369  SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_ Line 369  SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_
369     use this as a return value later. */     use this as a return value later. */
370    
371  /* Note: only for sljit specific, non ABI compilant calls. Fast, since only a few machine instructions  /* Note: only for sljit specific, non ABI compilant calls. Fast, since only a few machine instructions
372     are needed. Excellent for small uility functions, where saving general registers and setting up     are needed. Excellent for small uility functions, where saving registers and setting up
373     a new stack frame would cost too much performance. However, it is still possible to return     a new stack frame would cost too much performance. However, it is still possible to return
374     to the address of the caller (or anywhere else). */     to the address of the caller (or anywhere else). */
375    
# Line 378  SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_ Line 378  SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_
378  /* Note: although sljit_emit_fast_return could be replaced by an ijump, it is not suggested,  /* Note: although sljit_emit_fast_return could be replaced by an ijump, it is not suggested,
379     since many architectures do clever branch prediction on call / return instruction pairs. */     since many architectures do clever branch prediction on call / return instruction pairs. */
380    
381  SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_fast_enter(struct sljit_compiler *compiler, int dst, sljit_w dstw, int args, int temporaries, int generals, int local_size);  SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_fast_enter(struct sljit_compiler *compiler, int dst, sljit_w dstw, int args, int temporaries, int saveds, int local_size);
382  SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_fast_return(struct sljit_compiler *compiler, int src, sljit_w srcw);  SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_fast_return(struct sljit_compiler *compiler, int src, sljit_w srcw);
383    
384  /*  /*
# Line 586  SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_ Line 586  SLJIT_API_FUNC_ATTRIBUTE int sljit_emit_
586    
587  /* The following function is a helper function for sljit_emit_op_custom.  /* The following function is a helper function for sljit_emit_op_custom.
588     It returns with the real machine register index of any SLJIT_TEMPORARY     It returns with the real machine register index of any SLJIT_TEMPORARY
589     SLJIT_GENERAL or SLJIT_LOCALS register.     SLJIT_SAVED or SLJIT_LOCALS register.
590     Note: it returns with -1 for virtual registers (all EREGs on x86-32).     Note: it returns with -1 for virtual registers (all EREGs on x86-32).
591     Note: register returned by SLJIT_LOCALS_REG is not necessary the real     Note: register returned by SLJIT_LOCALS_REG is not necessary the real
592           stack pointer register of the target architecture. */           stack pointer register of the target architecture. */

Legend:
Removed from v.879  
changed lines
  Added in v.880

  ViewVC Help
Powered by ViewVC 1.1.5