/[pcre]/code/trunk/sljit/sljitNativeX86_32.c
ViewVC logotype

Diff of /code/trunk/sljit/sljitNativeX86_32.c

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

revision 1505 by zherczeg, Mon Aug 11 06:42:28 2014 UTC revision 1506 by zherczeg, Sat Sep 27 06:25:26 2014 UTC
# Line 71  SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_ Line 71  SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_
71          sljit_ub *inst;          sljit_ub *inst;
72    
73          CHECK_ERROR();          CHECK_ERROR();
74          check_sljit_emit_enter(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size);          CHECK(check_sljit_emit_enter(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size));
75            set_emit_enter(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size);
76    
         compiler->options = options;  
         compiler->scratches = scratches;  
         compiler->saveds = saveds;  
         compiler->fscratches = fscratches;  
         compiler->fsaveds = fsaveds;  
77          compiler->args = args;          compiler->args = args;
78          compiler->flags_saved = 0;          compiler->flags_saved = 0;
 #if (defined SLJIT_DEBUG && SLJIT_DEBUG)  
         compiler->logical_local_size = local_size;  
 #endif  
79    
80          size = 1 + (scratches > 7 ? (scratches - 7) : 0) + (saveds <= 3 ? saveds : 3);          size = 1 + (scratches > 7 ? (scratches - 7) : 0) + (saveds <= 3 ? saveds : 3);
81  #if (defined SLJIT_X86_32_FASTCALL && SLJIT_X86_32_FASTCALL)  #if (defined SLJIT_X86_32_FASTCALL && SLJIT_X86_32_FASTCALL)
# Line 141  SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_ Line 134  SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_
134          }          }
135  #endif  #endif
136    
137          SLJIT_COMPILE_ASSERT(FIXED_LOCALS_OFFSET >= (2 + 4) * sizeof(sljit_uw), require_at_least_two_words);          SLJIT_COMPILE_ASSERT(SLJIT_LOCALS_OFFSET >= (2 + 4) * sizeof(sljit_uw), require_at_least_two_words);
138  #if defined(__APPLE__)  #if defined(__APPLE__)
139          /* Ignore pushed registers and FIXED_LOCALS_OFFSET when          /* Ignore pushed registers and SLJIT_LOCALS_OFFSET when computing the aligned local size. */
         computing the aligned local size. */  
140          saveds = (2 + (scratches > 7 ? (scratches - 7) : 0) + (saveds <= 3 ? saveds : 3)) * sizeof(sljit_uw);          saveds = (2 + (scratches > 7 ? (scratches - 7) : 0) + (saveds <= 3 ? saveds : 3)) * sizeof(sljit_uw);
141          local_size = ((FIXED_LOCALS_OFFSET + saveds + local_size + 15) & ~15) - saveds;          local_size = ((SLJIT_LOCALS_OFFSET + saveds + local_size + 15) & ~15) - saveds;
142  #else  #else
143          local_size = FIXED_LOCALS_OFFSET + ((local_size + sizeof(sljit_uw) - 1) & ~(sizeof(sljit_uw) - 1));          if (options & SLJIT_DOUBLE_ALIGNMENT) {
144                    local_size = SLJIT_LOCALS_OFFSET + ((local_size + 7) & ~7);
145    
146                    inst = (sljit_ub*)ensure_buf(compiler, 1 + 17);
147                    FAIL_IF(!inst);
148    
149                    INC_SIZE(17);
150                    inst[0] = MOV_r_rm;
151                    inst[1] = MOD_REG | (reg_map[TMP_REG1] << 3) | reg_map[SLJIT_SP];
152                    inst[2] = GROUP_F7;
153                    inst[3] = MOD_REG | (0 << 3) | reg_map[SLJIT_SP];
154                    *(sljit_sw*)(inst + 4) = 0x4;
155                    inst[8] = JNE_i8;
156                    inst[9] = 6;
157                    inst[10] = GROUP_BINARY_81;
158                    inst[11] = MOD_REG | (5 << 3) | reg_map[SLJIT_SP];
159                    *(sljit_sw*)(inst + 12) = 0x4;
160                    inst[16] = PUSH_r + reg_map[TMP_REG1];
161            }
162            else
163                    local_size = SLJIT_LOCALS_OFFSET + ((local_size + 3) & ~3);
164  #endif  #endif
165    
166          compiler->local_size = local_size;          compiler->local_size = local_size;
# Line 157  SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_ Line 169  SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_
169  #if (defined SLJIT_X86_32_FASTCALL && SLJIT_X86_32_FASTCALL)  #if (defined SLJIT_X86_32_FASTCALL && SLJIT_X86_32_FASTCALL)
170                  FAIL_IF(emit_do_imm(compiler, MOV_r_i32 + reg_map[SLJIT_R0], local_size));                  FAIL_IF(emit_do_imm(compiler, MOV_r_i32 + reg_map[SLJIT_R0], local_size));
171  #else  #else
172                  local_size -= FIXED_LOCALS_OFFSET;                  local_size -= SLJIT_LOCALS_OFFSET;
173                  FAIL_IF(emit_do_imm(compiler, MOV_r_i32 + reg_map[SLJIT_R0], local_size));                  FAIL_IF(emit_do_imm(compiler, MOV_r_i32 + reg_map[SLJIT_R0], local_size));
174                  FAIL_IF(emit_non_cum_binary(compiler, SUB_r_rm, SUB_rm_r, SUB, SUB_EAX_i32,                  FAIL_IF(emit_non_cum_binary(compiler, SUB_r_rm, SUB_rm_r, SUB, SUB_EAX_i32,
175                          SLJIT_SP, 0, SLJIT_SP, 0, SLJIT_IMM, FIXED_LOCALS_OFFSET));                          SLJIT_SP, 0, SLJIT_SP, 0, SLJIT_IMM, SLJIT_LOCALS_OFFSET));
176  #endif  #endif
177                  FAIL_IF(sljit_emit_ijump(compiler, SLJIT_CALL1, SLJIT_IMM, SLJIT_FUNC_OFFSET(sljit_grow_stack)));                  FAIL_IF(sljit_emit_ijump(compiler, SLJIT_CALL1, SLJIT_IMM, SLJIT_FUNC_OFFSET(sljit_grow_stack)));
178          }          }
# Line 171  SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_ Line 183  SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_
183                  SLJIT_SP, 0, SLJIT_SP, 0, SLJIT_IMM, local_size);                  SLJIT_SP, 0, SLJIT_SP, 0, SLJIT_IMM, local_size);
184  }  }
185    
186  SLJIT_API_FUNC_ATTRIBUTE void sljit_set_context(struct sljit_compiler *compiler,  SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_set_context(struct sljit_compiler *compiler,
187          sljit_si options, sljit_si args, sljit_si scratches, sljit_si saveds,          sljit_si options, sljit_si args, sljit_si scratches, sljit_si saveds,
188          sljit_si fscratches, sljit_si fsaveds, sljit_si local_size)          sljit_si fscratches, sljit_si fsaveds, sljit_si local_size)
189  {  {
190          CHECK_ERROR_VOID();          CHECK_ERROR();
191          check_sljit_set_context(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size);          CHECK(check_sljit_set_context(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size));
192            set_set_context(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size);
193    
         compiler->options = options;  
         compiler->scratches = scratches;  
         compiler->saveds = saveds;  
         compiler->fscratches = fscratches;  
         compiler->fsaveds = fsaveds;  
194          compiler->args = args;          compiler->args = args;
 #if (defined SLJIT_DEBUG && SLJIT_DEBUG)  
         compiler->logical_local_size = local_size;  
 #endif  
195    
196  #if defined(__APPLE__)  #if defined(__APPLE__)
197          saveds = (2 + (scratches > 7 ? (scratches - 7) : 0) + (saveds <= 3 ? saveds : 3)) * sizeof(sljit_uw);          saveds = (2 + (scratches > 7 ? (scratches - 7) : 0) + (saveds <= 3 ? saveds : 3)) * sizeof(sljit_uw);
198          compiler->local_size = ((FIXED_LOCALS_OFFSET + saveds + local_size + 15) & ~15) - saveds;          compiler->local_size = ((SLJIT_LOCALS_OFFSET + saveds + local_size + 15) & ~15) - saveds;
199  #else  #else
200          compiler->local_size = FIXED_LOCALS_OFFSET + ((local_size + sizeof(sljit_uw) - 1) & ~(sizeof(sljit_uw) - 1));          if (options & SLJIT_DOUBLE_ALIGNMENT)
201                    compiler->local_size = SLJIT_LOCALS_OFFSET + ((local_size + 7) & ~7);
202            else
203                    compiler->local_size = SLJIT_LOCALS_OFFSET + ((local_size + 3) & ~3);
204  #endif  #endif
205            return SLJIT_SUCCESS;
206  }  }
207    
208  SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_return(struct sljit_compiler *compiler, sljit_si op, sljit_si src, sljit_sw srcw)  SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_return(struct sljit_compiler *compiler, sljit_si op, sljit_si src, sljit_sw srcw)
# Line 202  SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_ Line 211  SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_
211          sljit_ub *inst;          sljit_ub *inst;
212    
213          CHECK_ERROR();          CHECK_ERROR();
214          check_sljit_emit_return(compiler, op, src, srcw);          CHECK(check_sljit_emit_return(compiler, op, src, srcw));
215          SLJIT_ASSERT(compiler->args >= 0);          SLJIT_ASSERT(compiler->args >= 0);
216    
217          compiler->flags_saved = 0;          compiler->flags_saved = 0;
# Line 212  SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_ Line 221  SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_
221          FAIL_IF(emit_cum_binary(compiler, ADD_r_rm, ADD_rm_r, ADD, ADD_EAX_i32,          FAIL_IF(emit_cum_binary(compiler, ADD_r_rm, ADD_rm_r, ADD, ADD_EAX_i32,
222                  SLJIT_SP, 0, SLJIT_SP, 0, SLJIT_IMM, compiler->local_size));                  SLJIT_SP, 0, SLJIT_SP, 0, SLJIT_IMM, compiler->local_size));
223    
224    #if !defined(__APPLE__)
225            if (compiler->options & SLJIT_DOUBLE_ALIGNMENT) {
226                    inst = (sljit_ub*)ensure_buf(compiler, 1 + 3);
227                    FAIL_IF(!inst);
228    
229                    INC_SIZE(3);
230                    inst[0] = MOV_r_rm;
231                    inst[1] = (reg_map[SLJIT_SP] << 3) | 0x4 /* SIB */;
232                    inst[2] = (4 << 3) | reg_map[SLJIT_SP];
233            }
234    #endif
235    
236          size = 2 + (compiler->scratches > 7 ? (compiler->scratches - 7) : 0) +          size = 2 + (compiler->scratches > 7 ? (compiler->scratches - 7) : 0) +
237                  (compiler->saveds <= 3 ? compiler->saveds : 3);                  (compiler->saveds <= 3 ? compiler->saveds : 3);
238  #if (defined SLJIT_X86_32_FASTCALL && SLJIT_X86_32_FASTCALL)  #if (defined SLJIT_X86_32_FASTCALL && SLJIT_X86_32_FASTCALL)
# Line 460  SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_ Line 481  SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_
481          sljit_ub *inst;          sljit_ub *inst;
482    
483          CHECK_ERROR();          CHECK_ERROR();
484          check_sljit_emit_fast_enter(compiler, dst, dstw);          CHECK(check_sljit_emit_fast_enter(compiler, dst, dstw));
485          ADJUST_LOCAL_OFFSET(dst, dstw);          ADJUST_LOCAL_OFFSET(dst, dstw);
486    
487          CHECK_EXTRA_REGS(dst, dstw, (void)0);          CHECK_EXTRA_REGS(dst, dstw, (void)0);
# Line 491  SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_ Line 512  SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_
512          sljit_ub *inst;          sljit_ub *inst;
513    
514          CHECK_ERROR();          CHECK_ERROR();
515          check_sljit_emit_fast_return(compiler, src, srcw);          CHECK(check_sljit_emit_fast_return(compiler, src, srcw));
516          ADJUST_LOCAL_OFFSET(src, srcw);          ADJUST_LOCAL_OFFSET(src, srcw);
517    
518          CHECK_EXTRA_REGS(src, srcw, (void)0);          CHECK_EXTRA_REGS(src, srcw, (void)0);

Legend:
Removed from v.1505  
changed lines
  Added in v.1506

  ViewVC Help
Powered by ViewVC 1.1.5