diff options
author | Mike Pall <mike> | 2011-06-29 01:51:39 +0200 |
---|---|---|
committer | Mike Pall <mike> | 2011-06-29 01:52:23 +0200 |
commit | 82eca898db87bde10fbbb14a0f35ef75b6c3dcc6 (patch) | |
tree | 9b5aa8a81267664430a94fc40a131fe33c1832d7 /src | |
parent | deeb8196c4d4085f3cc5a3389b568de7da739190 (diff) | |
download | luajit-82eca898db87bde10fbbb14a0f35ef75b6c3dcc6.tar.gz luajit-82eca898db87bde10fbbb14a0f35ef75b6c3dcc6.tar.bz2 luajit-82eca898db87bde10fbbb14a0f35ef75b6c3dcc6.zip |
Prefer recording loops over calls.
Hotcounts are decremented by 2 for loops and by 1 for calls.
Diffstat (limited to 'src')
-rw-r--r-- | src/buildvm_arm.dasc | 12 | ||||
-rw-r--r-- | src/buildvm_arm.h | 128 | ||||
-rw-r--r-- | src/buildvm_x64.h | 60 | ||||
-rw-r--r-- | src/buildvm_x64win.h | 40 | ||||
-rw-r--r-- | src/buildvm_x86.dasc | 8 | ||||
-rw-r--r-- | src/buildvm_x86.h | 30 | ||||
-rw-r--r-- | src/lj_dispatch.c | 3 | ||||
-rw-r--r-- | src/lj_dispatch.h | 4 | ||||
-rw-r--r-- | src/lj_jit.h | 2 | ||||
-rw-r--r-- | src/lj_trace.c | 5 |
10 files changed, 151 insertions, 141 deletions
diff --git a/src/buildvm_arm.dasc b/src/buildvm_arm.dasc index fd7c7b81..9b6b5aed 100644 --- a/src/buildvm_arm.dasc +++ b/src/buildvm_arm.dasc | |||
@@ -185,23 +185,23 @@ | |||
185 | | | 185 | | |
186 | #define PC2PROTO(field) ((int)offsetof(GCproto, field)-(int)sizeof(GCproto)) | 186 | #define PC2PROTO(field) ((int)offsetof(GCproto, field)-(int)sizeof(GCproto)) |
187 | | | 187 | | |
188 | |.macro hotcheck | 188 | |.macro hotcheck, delta |
189 | | lsr CARG1, PC, #1 | 189 | | lsr CARG1, PC, #1 |
190 | | and CARG1, CARG1, #126 | 190 | | and CARG1, CARG1, #126 |
191 | | sub CARG1, CARG1, #-GG_DISP2HOT | 191 | | sub CARG1, CARG1, #-GG_DISP2HOT |
192 | | ldrh CARG2, [DISPATCH, CARG1] | 192 | | ldrh CARG2, [DISPATCH, CARG1] |
193 | | subs CARG2, CARG2, #1 | 193 | | subs CARG2, CARG2, #delta |
194 | | strh CARG2, [DISPATCH, CARG1] | 194 | | strh CARG2, [DISPATCH, CARG1] |
195 | |.endmacro | 195 | |.endmacro |
196 | | | 196 | | |
197 | |.macro hotloop | 197 | |.macro hotloop |
198 | | hotcheck | 198 | | hotcheck HOTCOUNT_LOOP |
199 | | beq ->vm_hotloop | 199 | | blo ->vm_hotloop |
200 | |.endmacro | 200 | |.endmacro |
201 | | | 201 | | |
202 | |.macro hotcall | 202 | |.macro hotcall |
203 | | hotcheck | 203 | | hotcheck HOTCOUNT_CALL |
204 | | beq ->vm_hotcall | 204 | | blo ->vm_hotcall |
205 | |.endmacro | 205 | |.endmacro |
206 | | | 206 | | |
207 | |// Set current VM state. | 207 | |// Set current VM state. |
diff --git a/src/buildvm_arm.h b/src/buildvm_arm.h index 505048bd..b450f5df 100644 --- a/src/buildvm_arm.h +++ b/src/buildvm_arm.h | |||
@@ -12,7 +12,7 @@ | |||
12 | #define DASM_SECTION_CODE_OP 0 | 12 | #define DASM_SECTION_CODE_OP 0 |
13 | #define DASM_SECTION_CODE_SUB 1 | 13 | #define DASM_SECTION_CODE_SUB 1 |
14 | #define DASM_MAXSECTION 2 | 14 | #define DASM_MAXSECTION 2 |
15 | static const unsigned int build_actionlist[5702] = { | 15 | static const unsigned int build_actionlist[5706] = { |
16 | 0x00010001, | 16 | 0x00010001, |
17 | 0x00060014, | 17 | 0x00060014, |
18 | 0xe3160000, | 18 | 0xe3160000, |
@@ -5381,9 +5381,10 @@ static const unsigned int build_actionlist[5702] = { | |||
5381 | 0xe2400000, | 5381 | 0xe2400000, |
5382 | 0x000a0000, | 5382 | 0x000a0000, |
5383 | 0xe19710b0, | 5383 | 0xe19710b0, |
5384 | 0xe2511001, | 5384 | 0xe2511000, |
5385 | 0x000a0000, | ||
5385 | 0xe18710b0, | 5386 | 0xe18710b0, |
5386 | 0x0a000000, | 5387 | 0x3a000000, |
5387 | 0x00050091, | 5388 | 0x00050091, |
5388 | 0x00000000, | 5389 | 0x00000000, |
5389 | 0xe1aa00d9, | 5390 | 0xe1aa00d9, |
@@ -5519,9 +5520,10 @@ static const unsigned int build_actionlist[5702] = { | |||
5519 | 0xe2400000, | 5520 | 0xe2400000, |
5520 | 0x000a0000, | 5521 | 0x000a0000, |
5521 | 0xe19710b0, | 5522 | 0xe19710b0, |
5522 | 0xe2511001, | 5523 | 0xe2511000, |
5524 | 0x000a0000, | ||
5523 | 0xe18710b0, | 5525 | 0xe18710b0, |
5524 | 0x0a000000, | 5526 | 0x3a000000, |
5525 | 0x00050091, | 5527 | 0x00050091, |
5526 | 0x00000000, | 5528 | 0x00000000, |
5527 | 0xe1aa00d9, | 5529 | 0xe1aa00d9, |
@@ -5550,9 +5552,10 @@ static const unsigned int build_actionlist[5702] = { | |||
5550 | 0xe2400000, | 5552 | 0xe2400000, |
5551 | 0x000a0000, | 5553 | 0x000a0000, |
5552 | 0xe19710b0, | 5554 | 0xe19710b0, |
5553 | 0xe2511001, | 5555 | 0xe2511000, |
5556 | 0x000a0000, | ||
5554 | 0xe18710b0, | 5557 | 0xe18710b0, |
5555 | 0x0a000000, | 5558 | 0x3a000000, |
5556 | 0x00050091, | 5559 | 0x00050091, |
5557 | 0x00000000, | 5560 | 0x00000000, |
5558 | 0xe5d6c000, | 5561 | 0xe5d6c000, |
@@ -5590,9 +5593,10 @@ static const unsigned int build_actionlist[5702] = { | |||
5590 | 0xe2400000, | 5593 | 0xe2400000, |
5591 | 0x000a0000, | 5594 | 0x000a0000, |
5592 | 0xe19710b0, | 5595 | 0xe19710b0, |
5593 | 0xe2511001, | 5596 | 0xe2511000, |
5597 | 0x000a0000, | ||
5594 | 0xe18710b0, | 5598 | 0xe18710b0, |
5595 | 0x0a000000, | 5599 | 0x3a000000, |
5596 | 0x00050093, | 5600 | 0x00050093, |
5597 | 0x00000000, | 5601 | 0x00000000, |
5598 | 0xe5180000, | 5602 | 0xe5180000, |
@@ -7138,7 +7142,7 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop) | |||
7138 | 7142 | ||
7139 | case BC_FORL: | 7143 | case BC_FORL: |
7140 | #if LJ_HASJIT | 7144 | #if LJ_HASJIT |
7141 | dasm_put(Dst, 5363, -GG_DISP2HOT); | 7145 | dasm_put(Dst, 5363, -GG_DISP2HOT, HOTCOUNT_LOOP); |
7142 | #endif | 7146 | #endif |
7143 | break; | 7147 | break; |
7144 | 7148 | ||
@@ -7150,68 +7154,68 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop) | |||
7150 | case BC_FORI: | 7154 | case BC_FORI: |
7151 | case BC_IFORL: | 7155 | case BC_IFORL: |
7152 | vk = (op == BC_IFORL || op == BC_JFORL); | 7156 | vk = (op == BC_IFORL || op == BC_JFORL); |
7153 | dasm_put(Dst, 5373); | 7157 | dasm_put(Dst, 5374); |
7154 | if (op != BC_JFORL) { | 7158 | if (op != BC_JFORL) { |
7155 | dasm_put(Dst, 5375); | 7159 | dasm_put(Dst, 5376); |
7156 | } | 7160 | } |
7157 | if (!vk) { | 7161 | if (!vk) { |
7158 | dasm_put(Dst, 5377, -LJ_TISNUM, -LJ_TISNUM, -LJ_TISNUM); | 7162 | dasm_put(Dst, 5378, -LJ_TISNUM, -LJ_TISNUM, -LJ_TISNUM); |
7159 | } else { | 7163 | } else { |
7160 | dasm_put(Dst, 5395, -LJ_TISNUM); | 7164 | dasm_put(Dst, 5396, -LJ_TISNUM); |
7161 | if (op == BC_IFORL) { | 7165 | if (op == BC_IFORL) { |
7162 | dasm_put(Dst, 5403); | 7166 | dasm_put(Dst, 5404); |
7163 | } else { | 7167 | } else { |
7164 | dasm_put(Dst, 5405); | 7168 | dasm_put(Dst, 5406); |
7165 | } | 7169 | } |
7166 | dasm_put(Dst, 5408); | 7170 | dasm_put(Dst, 5409); |
7167 | } | 7171 | } |
7168 | dasm_put(Dst, 5413); | 7172 | dasm_put(Dst, 5414); |
7169 | if (op == BC_FORI) { | 7173 | if (op == BC_FORI) { |
7170 | dasm_put(Dst, 5415); | 7174 | dasm_put(Dst, 5416); |
7171 | } else if (op == BC_JFORI) { | 7175 | } else if (op == BC_JFORI) { |
7172 | dasm_put(Dst, 5417); | 7176 | dasm_put(Dst, 5418); |
7173 | } else if (op == BC_IFORL) { | 7177 | } else if (op == BC_IFORL) { |
7174 | dasm_put(Dst, 5420); | 7178 | dasm_put(Dst, 5421); |
7175 | } | 7179 | } |
7176 | if (vk) { | 7180 | if (vk) { |
7177 | dasm_put(Dst, 5422); | 7181 | dasm_put(Dst, 5423); |
7178 | } | 7182 | } |
7179 | dasm_put(Dst, 5424); | 7183 | dasm_put(Dst, 5425); |
7180 | if (op == BC_JFORI || op == BC_JFORL) { | 7184 | if (op == BC_JFORI || op == BC_JFORL) { |
7181 | dasm_put(Dst, 5429, BC_JLOOP); | 7185 | dasm_put(Dst, 5430, BC_JLOOP); |
7182 | } | 7186 | } |
7183 | dasm_put(Dst, 5432); | 7187 | dasm_put(Dst, 5433); |
7184 | if (!vk) { | 7188 | if (!vk) { |
7185 | dasm_put(Dst, 5439); | 7189 | dasm_put(Dst, 5440); |
7186 | } else { | 7190 | } else { |
7187 | dasm_put(Dst, 5441); | 7191 | dasm_put(Dst, 5442); |
7188 | } | 7192 | } |
7189 | dasm_put(Dst, 5443); | 7193 | dasm_put(Dst, 5444); |
7190 | if (!vk) { | 7194 | if (!vk) { |
7191 | dasm_put(Dst, 5447, -LJ_TISNUM, -LJ_TISNUM); | 7195 | dasm_put(Dst, 5448, -LJ_TISNUM, -LJ_TISNUM); |
7192 | } else { | 7196 | } else { |
7193 | dasm_put(Dst, 5459); | 7197 | dasm_put(Dst, 5460); |
7194 | } | 7198 | } |
7195 | dasm_put(Dst, 5468); | 7199 | dasm_put(Dst, 5469); |
7196 | if (op == BC_FORI) { | 7200 | if (op == BC_FORI) { |
7197 | dasm_put(Dst, 5472); | 7201 | dasm_put(Dst, 5473); |
7198 | } else if (op == BC_JFORI) { | 7202 | } else if (op == BC_JFORI) { |
7199 | dasm_put(Dst, 5474, BC_JLOOP); | 7203 | dasm_put(Dst, 5475, BC_JLOOP); |
7200 | } else if (op == BC_IFORL) { | 7204 | } else if (op == BC_IFORL) { |
7201 | dasm_put(Dst, 5479); | 7205 | dasm_put(Dst, 5480); |
7202 | } else { | 7206 | } else { |
7203 | dasm_put(Dst, 5481, BC_JLOOP); | 7207 | dasm_put(Dst, 5482, BC_JLOOP); |
7204 | } | 7208 | } |
7205 | dasm_put(Dst, 5484); | 7209 | dasm_put(Dst, 5485); |
7206 | if (vk) { | 7210 | if (vk) { |
7207 | dasm_put(Dst, 5490); | 7211 | dasm_put(Dst, 5491); |
7208 | } | 7212 | } |
7209 | dasm_put(Dst, 5495); | 7213 | dasm_put(Dst, 5496); |
7210 | break; | 7214 | break; |
7211 | 7215 | ||
7212 | case BC_ITERL: | 7216 | case BC_ITERL: |
7213 | #if LJ_HASJIT | 7217 | #if LJ_HASJIT |
7214 | dasm_put(Dst, 5501, -GG_DISP2HOT); | 7218 | dasm_put(Dst, 5502, -GG_DISP2HOT, HOTCOUNT_LOOP); |
7215 | #endif | 7219 | #endif |
7216 | break; | 7220 | break; |
7217 | 7221 | ||
@@ -7220,40 +7224,40 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop) | |||
7220 | break; | 7224 | break; |
7221 | #endif | 7225 | #endif |
7222 | case BC_IITERL: | 7226 | case BC_IITERL: |
7223 | dasm_put(Dst, 5511); | 7227 | dasm_put(Dst, 5513); |
7224 | if (op == BC_JITERL) { | 7228 | if (op == BC_JITERL) { |
7225 | dasm_put(Dst, 5513, -LJ_TNIL, BC_JLOOP); | 7229 | dasm_put(Dst, 5515, -LJ_TNIL, BC_JLOOP); |
7226 | } else { | 7230 | } else { |
7227 | dasm_put(Dst, 5519, -LJ_TNIL); | 7231 | dasm_put(Dst, 5521, -LJ_TNIL); |
7228 | } | 7232 | } |
7229 | dasm_put(Dst, 5525); | 7233 | dasm_put(Dst, 5527); |
7230 | break; | 7234 | break; |
7231 | 7235 | ||
7232 | case BC_LOOP: | 7236 | case BC_LOOP: |
7233 | #if LJ_HASJIT | 7237 | #if LJ_HASJIT |
7234 | dasm_put(Dst, 5532, -GG_DISP2HOT); | 7238 | dasm_put(Dst, 5534, -GG_DISP2HOT, HOTCOUNT_LOOP); |
7235 | #endif | 7239 | #endif |
7236 | break; | 7240 | break; |
7237 | 7241 | ||
7238 | case BC_ILOOP: | 7242 | case BC_ILOOP: |
7239 | dasm_put(Dst, 5542); | 7243 | dasm_put(Dst, 5545); |
7240 | break; | 7244 | break; |
7241 | 7245 | ||
7242 | case BC_JLOOP: | 7246 | case BC_JLOOP: |
7243 | #if LJ_HASJIT | 7247 | #if LJ_HASJIT |
7244 | dasm_put(Dst, 5549, DISPATCH_J(trace), DISPATCH_GL(vmstate), DtD(->mcode), DISPATCH_GL(jit_base), DISPATCH_GL(jit_L)); | 7248 | dasm_put(Dst, 5552, DISPATCH_J(trace), DISPATCH_GL(vmstate), DtD(->mcode), DISPATCH_GL(jit_base), DISPATCH_GL(jit_L)); |
7245 | #endif | 7249 | #endif |
7246 | break; | 7250 | break; |
7247 | 7251 | ||
7248 | case BC_JMP: | 7252 | case BC_JMP: |
7249 | dasm_put(Dst, 5563); | 7253 | dasm_put(Dst, 5566); |
7250 | break; | 7254 | break; |
7251 | 7255 | ||
7252 | /* -- Function headers -------------------------------------------------- */ | 7256 | /* -- Function headers -------------------------------------------------- */ |
7253 | 7257 | ||
7254 | case BC_FUNCF: | 7258 | case BC_FUNCF: |
7255 | #if LJ_HASJIT | 7259 | #if LJ_HASJIT |
7256 | dasm_put(Dst, 5572, -GG_DISP2HOT); | 7260 | dasm_put(Dst, 5575, -GG_DISP2HOT, HOTCOUNT_CALL); |
7257 | #endif | 7261 | #endif |
7258 | case BC_FUNCV: /* NYI: compiled vararg functions. */ | 7262 | case BC_FUNCV: /* NYI: compiled vararg functions. */ |
7259 | break; | 7263 | break; |
@@ -7263,42 +7267,42 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop) | |||
7263 | break; | 7267 | break; |
7264 | #endif | 7268 | #endif |
7265 | case BC_IFUNCF: | 7269 | case BC_IFUNCF: |
7266 | dasm_put(Dst, 5582, Dt1(->maxstack), -4+PC2PROTO(numparams), -4+PC2PROTO(k)); | 7270 | dasm_put(Dst, 5586, Dt1(->maxstack), -4+PC2PROTO(numparams), -4+PC2PROTO(k)); |
7267 | if (op != BC_JFUNCF) { | 7271 | if (op != BC_JFUNCF) { |
7268 | dasm_put(Dst, 5592); | 7272 | dasm_put(Dst, 5596); |
7269 | } | 7273 | } |
7270 | dasm_put(Dst, 5595, ~LJ_TNIL); | 7274 | dasm_put(Dst, 5599, ~LJ_TNIL); |
7271 | if (op == BC_JFUNCF) { | 7275 | if (op == BC_JFUNCF) { |
7272 | dasm_put(Dst, 5602, BC_JLOOP); | 7276 | dasm_put(Dst, 5606, BC_JLOOP); |
7273 | } else { | 7277 | } else { |
7274 | dasm_put(Dst, 5606); | 7278 | dasm_put(Dst, 5610); |
7275 | } | 7279 | } |
7276 | dasm_put(Dst, 5611); | 7280 | dasm_put(Dst, 5615); |
7277 | break; | 7281 | break; |
7278 | 7282 | ||
7279 | case BC_JFUNCV: | 7283 | case BC_JFUNCV: |
7280 | #if !LJ_HASJIT | 7284 | #if !LJ_HASJIT |
7281 | break; | 7285 | break; |
7282 | #endif | 7286 | #endif |
7283 | dasm_put(Dst, 5617); | 7287 | dasm_put(Dst, 5621); |
7284 | break; /* NYI: compiled vararg functions. */ | 7288 | break; /* NYI: compiled vararg functions. */ |
7285 | 7289 | ||
7286 | case BC_IFUNCV: | 7290 | case BC_IFUNCV: |
7287 | dasm_put(Dst, 5619, Dt1(->maxstack), 8+FRAME_VARG, -4+PC2PROTO(k), -4+PC2PROTO(numparams), ~LJ_TNIL); | 7291 | dasm_put(Dst, 5623, Dt1(->maxstack), 8+FRAME_VARG, -4+PC2PROTO(k), -4+PC2PROTO(numparams), ~LJ_TNIL); |
7288 | break; | 7292 | break; |
7289 | 7293 | ||
7290 | case BC_FUNCC: | 7294 | case BC_FUNCC: |
7291 | case BC_FUNCCW: | 7295 | case BC_FUNCCW: |
7292 | if (op == BC_FUNCC) { | 7296 | if (op == BC_FUNCC) { |
7293 | dasm_put(Dst, 5660, Dt8(->f)); | 7297 | dasm_put(Dst, 5664, Dt8(->f)); |
7294 | } else { | 7298 | } else { |
7295 | dasm_put(Dst, 5663, DISPATCH_GL(wrapf)); | 7299 | dasm_put(Dst, 5667, DISPATCH_GL(wrapf)); |
7296 | } | 7300 | } |
7297 | dasm_put(Dst, 5666, Dt1(->maxstack), Dt1(->base), Dt1(->top)); | 7301 | dasm_put(Dst, 5670, Dt1(->maxstack), Dt1(->base), Dt1(->top)); |
7298 | if (op == BC_FUNCCW) { | 7302 | if (op == BC_FUNCCW) { |
7299 | dasm_put(Dst, 5676, Dt8(->f)); | 7303 | dasm_put(Dst, 5680, Dt8(->f)); |
7300 | } | 7304 | } |
7301 | dasm_put(Dst, 5679, LJ_VMST_C, DISPATCH_GL(vmstate), Dt1(->base), LJ_VMST_INTERP, Dt1(->top), DISPATCH_GL(vmstate)); | 7305 | dasm_put(Dst, 5683, LJ_VMST_C, DISPATCH_GL(vmstate), Dt1(->base), LJ_VMST_INTERP, Dt1(->top), DISPATCH_GL(vmstate)); |
7302 | break; | 7306 | break; |
7303 | 7307 | ||
7304 | /* ---------------------------------------------------------------------- */ | 7308 | /* ---------------------------------------------------------------------- */ |
@@ -7318,7 +7322,7 @@ static int build_backend(BuildCtx *ctx) | |||
7318 | 7322 | ||
7319 | build_subroutines(ctx); | 7323 | build_subroutines(ctx); |
7320 | 7324 | ||
7321 | dasm_put(Dst, 5701); | 7325 | dasm_put(Dst, 5705); |
7322 | for (op = 0; op < BC__MAX; op++) | 7326 | for (op = 0; op < BC__MAX; op++) |
7323 | build_ins(ctx, (BCOp)op, op); | 7327 | build_ins(ctx, (BCOp)op, op); |
7324 | 7328 | ||
diff --git a/src/buildvm_x64.h b/src/buildvm_x64.h index f6ed666c..4e4eca54 100644 --- a/src/buildvm_x64.h +++ b/src/buildvm_x64.h | |||
@@ -751,16 +751,16 @@ static const unsigned char build_actionlist[16156] = { | |||
751 | 182,232,131,195,4,193,232,16,65,252,255,36,252,238,248,6,255,65,199,71,252, | 751 | 182,232,131,195,4,193,232,16,65,252,255,36,252,238,248,6,255,65,199,71,252, |
752 | 252,237,65,131,199,8,255,199,68,194,252,244,237,255,131,192,1,252,233,244, | 752 | 252,237,65,131,199,8,255,199,68,194,252,244,237,255,131,192,1,252,233,244, |
753 | 5,248,7,141,171,233,252,247,197,237,15,133,244,14,41,252,234,255,1,252,233, | 753 | 5,248,7,141,171,233,252,247,197,237,15,133,244,14,41,252,234,255,1,252,233, |
754 | 255,137,221,209,252,237,129,229,239,102,65,131,172,253,46,233,1,15,132,244, | 754 | 255,137,221,209,252,237,129,229,239,102,65,129,172,253,46,233,238,15,130, |
755 | 148,255,141,12,202,255,129,121,253,4,239,15,133,244,255,255,129,121,253,12, | 755 | 244,148,255,141,12,202,255,129,121,253,4,239,15,133,244,255,255,129,121,253, |
756 | 239,15,133,244,60,129,121,253,20,239,15,133,244,60,139,41,131,121,16,0,15, | 756 | 12,239,15,133,244,60,129,121,253,20,239,15,133,244,60,139,41,131,121,16,0, |
757 | 140,244,251,255,129,121,253,12,239,15,133,244,165,129,121,253,20,239,15,133, | 757 | 15,140,244,251,255,129,121,253,12,239,15,133,244,165,129,121,253,20,239,15, |
758 | 244,165,255,139,105,16,133,252,237,15,136,244,251,3,41,15,128,244,247,137, | 758 | 133,244,165,255,139,105,16,133,252,237,15,136,244,251,3,41,15,128,244,247, |
759 | 41,255,59,105,8,199,65,28,237,137,105,24,255,15,142,244,253,248,1,248,6,141, | 759 | 137,41,255,59,105,8,199,65,28,237,137,105,24,255,15,142,244,253,248,1,248, |
760 | 156,253,131,233,255,141,156,253,131,233,15,183,67,252,254,15,142,245,248, | 760 | 6,141,156,253,131,233,255,141,156,253,131,233,15,183,67,252,254,15,142,245, |
761 | 1,248,6,255,15,143,244,253,248,6,141,156,253,131,233,248,1,255,248,7,139, | 761 | 248,1,248,6,255,15,143,244,253,248,6,141,156,253,131,233,248,1,255,248,7, |
762 | 3,15,182,204,15,182,232,131,195,4,193,232,16,65,252,255,36,252,238,248,5, | 762 | 139,3,15,182,204,15,182,232,131,195,4,193,232,16,65,252,255,36,252,238,248, |
763 | 255,3,41,15,128,244,1,137,41,255,15,141,244,7,255,141,156,253,131,233,15, | 763 | 5,255,3,41,15,128,244,1,137,41,255,15,141,244,7,255,141,156,253,131,233,15, |
764 | 183,67,252,254,15,141,245,255,15,140,244,7,255,252,233,244,6,248,9,255,129, | 764 | 183,67,252,254,15,141,245,255,15,140,244,7,255,252,233,244,6,248,9,255,129, |
765 | 121,253,4,239,255,15,131,244,60,129,121,253,12,239,15,131,244,60,255,129, | 765 | 121,253,4,239,255,15,131,244,60,129,121,253,12,239,15,131,244,60,255,129, |
766 | 121,253,12,239,15,131,244,165,129,121,253,20,239,15,131,244,165,255,139,105, | 766 | 121,253,12,239,15,131,244,165,129,121,253,20,239,15,131,244,165,255,139,105, |
@@ -777,22 +777,22 @@ static const unsigned char build_actionlist[16156] = { | |||
777 | 139,4,129,72,139,128,233,139,108,36,24,65,137,150,233,65,137,174,233,76,137, | 777 | 139,4,129,72,139,128,233,139,108,36,24,65,137,150,233,65,137,174,233,76,137, |
778 | 36,36,76,137,108,36,8,72,131,252,236,16,252,255,224,255,141,156,253,131,233, | 778 | 36,36,76,137,108,36,8,72,131,252,236,16,252,255,224,255,141,156,253,131,233, |
779 | 139,3,15,182,204,15,182,232,131,195,4,193,232,16,65,252,255,36,252,238,255, | 779 | 139,3,15,182,204,15,182,232,131,195,4,193,232,16,65,252,255,36,252,238,255, |
780 | 137,221,209,252,237,129,229,239,102,65,131,172,253,46,233,1,15,132,244,150, | 780 | 137,221,209,252,237,129,229,239,102,65,129,172,253,46,233,238,15,130,244, |
781 | 255,68,139,187,233,139,108,36,24,141,12,202,59,141,233,15,135,244,24,15,182, | 781 | 150,255,68,139,187,233,139,108,36,24,141,12,202,59,141,233,15,135,244,24, |
782 | 139,233,57,200,15,134,244,249,248,2,255,15,183,67,252,254,252,233,245,255, | 782 | 15,182,139,233,57,200,15,134,244,249,248,2,255,15,183,67,252,254,252,233, |
783 | 248,3,199,68,194,252,252,237,131,192,1,57,200,15,134,244,3,252,233,244,2, | 783 | 245,255,248,3,199,68,194,252,252,237,131,192,1,57,200,15,134,244,3,252,233, |
784 | 255,141,44,197,237,141,4,194,68,139,122,252,248,137,104,252,252,68,137,120, | 784 | 244,2,255,141,44,197,237,141,4,194,68,139,122,252,248,137,104,252,252,68, |
785 | 252,248,139,108,36,24,141,12,200,59,141,233,15,135,244,23,137,209,137,194, | 785 | 137,120,252,248,139,108,36,24,141,12,200,59,141,233,15,135,244,23,137,209, |
786 | 15,182,171,233,133,252,237,15,132,244,248,248,1,131,193,8,57,209,15,131,244, | 786 | 137,194,15,182,171,233,133,252,237,15,132,244,248,248,1,131,193,8,57,209, |
787 | 249,68,139,121,252,248,68,137,56,68,139,121,252,252,68,137,120,4,131,192, | 787 | 15,131,244,249,68,139,121,252,248,68,137,56,68,139,121,252,252,68,137,120, |
788 | 8,199,65,252,252,237,131,252,237,1,15,133,244,1,248,2,255,68,139,187,233, | 788 | 4,131,192,8,199,65,252,252,237,131,252,237,1,15,133,244,1,248,2,255,68,139, |
789 | 139,3,15,182,204,15,182,232,131,195,4,193,232,16,65,252,255,36,252,238,255, | 789 | 187,233,139,3,15,182,204,15,182,232,131,195,4,193,232,16,65,252,255,36,252, |
790 | 248,3,199,64,4,237,131,192,8,131,252,237,1,15,133,244,3,252,233,244,2,255, | 790 | 238,255,248,3,199,64,4,237,131,192,8,131,252,237,1,15,133,244,3,252,233,244, |
791 | 139,106,252,248,76,139,189,233,139,108,36,24,141,68,194,252,248,137,149,233, | 791 | 2,255,139,106,252,248,76,139,189,233,139,108,36,24,141,68,194,252,248,137, |
792 | 141,136,233,59,141,233,137,133,233,255,76,137,252,254,137,252,239,255,15, | 792 | 149,233,141,136,233,59,141,233,137,133,233,255,76,137,252,254,137,252,239, |
793 | 135,244,22,65,199,134,233,237,255,65,252,255,215,255,65,252,255,150,233,255, | 793 | 255,15,135,244,22,65,199,134,233,237,255,65,252,255,215,255,65,252,255,150, |
794 | 65,199,134,233,237,139,149,233,141,12,194,252,247,217,3,141,233,139,90,252, | 794 | 233,255,65,199,134,233,237,139,149,233,141,12,194,252,247,217,3,141,233,139, |
795 | 252,252,233,244,12,255,254,0 | 795 | 90,252,252,252,233,244,12,255,254,0 |
796 | }; | 796 | }; |
797 | 797 | ||
798 | enum { | 798 | enum { |
@@ -2777,7 +2777,7 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse) | |||
2777 | 2777 | ||
2778 | case BC_FORL: | 2778 | case BC_FORL: |
2779 | #if LJ_HASJIT | 2779 | #if LJ_HASJIT |
2780 | dasm_put(Dst, 15309, HOTCOUNT_PCMASK, GG_DISP2HOT); | 2780 | dasm_put(Dst, 15309, HOTCOUNT_PCMASK, GG_DISP2HOT, HOTCOUNT_LOOP); |
2781 | #endif | 2781 | #endif |
2782 | break; | 2782 | break; |
2783 | 2783 | ||
@@ -2893,7 +2893,7 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse) | |||
2893 | 2893 | ||
2894 | case BC_ITERL: | 2894 | case BC_ITERL: |
2895 | #if LJ_HASJIT | 2895 | #if LJ_HASJIT |
2896 | dasm_put(Dst, 15309, HOTCOUNT_PCMASK, GG_DISP2HOT); | 2896 | dasm_put(Dst, 15309, HOTCOUNT_PCMASK, GG_DISP2HOT, HOTCOUNT_LOOP); |
2897 | #endif | 2897 | #endif |
2898 | break; | 2898 | break; |
2899 | 2899 | ||
@@ -2913,7 +2913,7 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse) | |||
2913 | 2913 | ||
2914 | case BC_LOOP: | 2914 | case BC_LOOP: |
2915 | #if LJ_HASJIT | 2915 | #if LJ_HASJIT |
2916 | dasm_put(Dst, 15309, HOTCOUNT_PCMASK, GG_DISP2HOT); | 2916 | dasm_put(Dst, 15309, HOTCOUNT_PCMASK, GG_DISP2HOT, HOTCOUNT_LOOP); |
2917 | #endif | 2917 | #endif |
2918 | break; | 2918 | break; |
2919 | 2919 | ||
@@ -2942,7 +2942,7 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse) | |||
2942 | 2942 | ||
2943 | case BC_FUNCF: | 2943 | case BC_FUNCF: |
2944 | #if LJ_HASJIT | 2944 | #if LJ_HASJIT |
2945 | dasm_put(Dst, 15842, HOTCOUNT_PCMASK, GG_DISP2HOT); | 2945 | dasm_put(Dst, 15842, HOTCOUNT_PCMASK, GG_DISP2HOT, HOTCOUNT_CALL); |
2946 | #endif | 2946 | #endif |
2947 | case BC_FUNCV: /* NYI: compiled vararg functions. */ | 2947 | case BC_FUNCV: /* NYI: compiled vararg functions. */ |
2948 | break; | 2948 | break; |
diff --git a/src/buildvm_x64win.h b/src/buildvm_x64win.h index bb813284..0e1b5b46 100644 --- a/src/buildvm_x64win.h +++ b/src/buildvm_x64win.h | |||
@@ -746,7 +746,7 @@ static const unsigned char build_actionlist[16011] = { | |||
746 | 36,252,235,248,6,255,199,71,252,252,237,131,199,8,255,199,68,194,252,244, | 746 | 36,252,235,248,6,255,199,71,252,252,237,131,199,8,255,199,68,194,252,244, |
747 | 237,255,131,192,1,252,233,244,5,248,7,141,174,233,252,247,197,237,15,133, | 747 | 237,255,131,192,1,252,233,244,5,248,7,141,174,233,252,247,197,237,15,133, |
748 | 244,14,41,252,234,255,1,252,233,255,137,252,245,209,252,237,129,229,239,102, | 748 | 244,14,41,252,234,255,1,252,233,255,137,252,245,209,252,237,129,229,239,102, |
749 | 131,172,253,43,233,1,15,132,244,148,255,141,12,202,255,129,121,253,4,239, | 749 | 129,172,253,43,233,238,15,130,244,148,255,141,12,202,255,129,121,253,4,239, |
750 | 15,133,244,255,255,129,121,253,12,239,15,133,244,60,129,121,253,20,239,15, | 750 | 15,133,244,255,255,129,121,253,12,239,15,133,244,60,129,121,253,20,239,15, |
751 | 133,244,60,139,41,131,121,16,0,15,140,244,251,255,129,121,253,12,239,15,133, | 751 | 133,244,60,139,41,131,121,16,0,15,140,244,251,255,129,121,253,12,239,15,133, |
752 | 244,165,129,121,253,20,239,15,133,244,165,255,139,105,16,133,252,237,15,136, | 752 | 244,165,129,121,253,20,239,15,133,244,165,255,139,105,16,133,252,237,15,136, |
@@ -775,21 +775,21 @@ static const unsigned char build_actionlist[16011] = { | |||
775 | 15,127,153,233,102,68,15,127,161,233,102,68,15,127,169,233,102,68,15,127, | 775 | 15,127,153,233,102,68,15,127,161,233,102,68,15,127,169,233,102,68,15,127, |
776 | 177,233,102,68,15,127,185,233,252,255,224,255,141,180,253,134,233,139,6,15, | 776 | 177,233,102,68,15,127,185,233,252,255,224,255,141,180,253,134,233,139,6,15, |
777 | 182,204,15,182,232,131,198,4,193,232,16,252,255,36,252,235,255,137,252,245, | 777 | 182,204,15,182,232,131,198,4,193,232,16,252,255,36,252,235,255,137,252,245, |
778 | 209,252,237,129,229,239,102,131,172,253,43,233,1,15,132,244,150,255,139,190, | 778 | 209,252,237,129,229,239,102,129,172,253,43,233,238,15,130,244,150,255,139, |
779 | 233,139,108,36,96,141,12,202,59,141,233,15,135,244,24,15,182,142,233,57,200, | 779 | 190,233,139,108,36,96,141,12,202,59,141,233,15,135,244,24,15,182,142,233, |
780 | 15,134,244,249,248,2,255,15,183,70,252,254,252,233,245,255,248,3,199,68,194, | 780 | 57,200,15,134,244,249,248,2,255,15,183,70,252,254,252,233,245,255,248,3,199, |
781 | 252,252,237,131,192,1,57,200,15,134,244,3,252,233,244,2,255,141,44,197,237, | 781 | 68,194,252,252,237,131,192,1,57,200,15,134,244,3,252,233,244,2,255,141,44, |
782 | 141,4,194,139,122,252,248,137,104,252,252,137,120,252,248,139,108,36,96,141, | 782 | 197,237,141,4,194,139,122,252,248,137,104,252,252,137,120,252,248,139,108, |
783 | 12,200,59,141,233,15,135,244,23,137,209,137,194,15,182,174,233,133,252,237, | 783 | 36,96,141,12,200,59,141,233,15,135,244,23,137,209,137,194,15,182,174,233, |
784 | 15,132,244,248,248,1,131,193,8,57,209,15,131,244,249,139,121,252,248,137, | 784 | 133,252,237,15,132,244,248,248,1,131,193,8,57,209,15,131,244,249,139,121, |
785 | 56,139,121,252,252,137,120,4,131,192,8,199,65,252,252,237,131,252,237,1,15, | 785 | 252,248,137,56,139,121,252,252,137,120,4,131,192,8,199,65,252,252,237,131, |
786 | 133,244,1,248,2,255,139,190,233,139,6,15,182,204,15,182,232,131,198,4,193, | 786 | 252,237,1,15,133,244,1,248,2,255,139,190,233,139,6,15,182,204,15,182,232, |
787 | 232,16,252,255,36,252,235,255,248,3,199,64,4,237,131,192,8,131,252,237,1, | 787 | 131,198,4,193,232,16,252,255,36,252,235,255,248,3,199,64,4,237,131,192,8, |
788 | 15,133,244,3,252,233,244,2,255,139,106,252,248,72,139,189,233,139,108,36, | 788 | 131,252,237,1,15,133,244,3,252,233,244,2,255,139,106,252,248,72,139,189,233, |
789 | 96,141,68,194,252,248,137,149,233,141,136,233,59,141,233,137,133,233,255, | 789 | 139,108,36,96,141,68,194,252,248,137,149,233,141,136,233,59,141,233,137,133, |
790 | 72,137,252,250,137,252,233,255,15,135,244,22,199,131,233,237,255,252,255, | 790 | 233,255,72,137,252,250,137,252,233,255,15,135,244,22,199,131,233,237,255, |
791 | 215,255,252,255,147,233,255,199,131,233,237,139,149,233,141,12,194,252,247, | 791 | 252,255,215,255,252,255,147,233,255,199,131,233,237,139,149,233,141,12,194, |
792 | 217,3,141,233,139,114,252,252,252,233,244,12,255,254,0 | 792 | 252,247,217,3,141,233,139,114,252,252,252,233,244,12,255,254,0 |
793 | }; | 793 | }; |
794 | 794 | ||
795 | enum { | 795 | enum { |
@@ -2775,7 +2775,7 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse) | |||
2775 | 2775 | ||
2776 | case BC_FORL: | 2776 | case BC_FORL: |
2777 | #if LJ_HASJIT | 2777 | #if LJ_HASJIT |
2778 | dasm_put(Dst, 15111, HOTCOUNT_PCMASK, GG_DISP2HOT); | 2778 | dasm_put(Dst, 15111, HOTCOUNT_PCMASK, GG_DISP2HOT, HOTCOUNT_LOOP); |
2779 | #endif | 2779 | #endif |
2780 | break; | 2780 | break; |
2781 | 2781 | ||
@@ -2891,7 +2891,7 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse) | |||
2891 | 2891 | ||
2892 | case BC_ITERL: | 2892 | case BC_ITERL: |
2893 | #if LJ_HASJIT | 2893 | #if LJ_HASJIT |
2894 | dasm_put(Dst, 15111, HOTCOUNT_PCMASK, GG_DISP2HOT); | 2894 | dasm_put(Dst, 15111, HOTCOUNT_PCMASK, GG_DISP2HOT, HOTCOUNT_LOOP); |
2895 | #endif | 2895 | #endif |
2896 | break; | 2896 | break; |
2897 | 2897 | ||
@@ -2911,7 +2911,7 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse) | |||
2911 | 2911 | ||
2912 | case BC_LOOP: | 2912 | case BC_LOOP: |
2913 | #if LJ_HASJIT | 2913 | #if LJ_HASJIT |
2914 | dasm_put(Dst, 15111, HOTCOUNT_PCMASK, GG_DISP2HOT); | 2914 | dasm_put(Dst, 15111, HOTCOUNT_PCMASK, GG_DISP2HOT, HOTCOUNT_LOOP); |
2915 | #endif | 2915 | #endif |
2916 | break; | 2916 | break; |
2917 | 2917 | ||
@@ -2940,7 +2940,7 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse) | |||
2940 | 2940 | ||
2941 | case BC_FUNCF: | 2941 | case BC_FUNCF: |
2942 | #if LJ_HASJIT | 2942 | #if LJ_HASJIT |
2943 | dasm_put(Dst, 15710, HOTCOUNT_PCMASK, GG_DISP2HOT); | 2943 | dasm_put(Dst, 15710, HOTCOUNT_PCMASK, GG_DISP2HOT, HOTCOUNT_CALL); |
2944 | #endif | 2944 | #endif |
2945 | case BC_FUNCV: /* NYI: compiled vararg functions. */ | 2945 | case BC_FUNCV: /* NYI: compiled vararg functions. */ |
2946 | break; | 2946 | break; |
diff --git a/src/buildvm_x86.dasc b/src/buildvm_x86.dasc index effd0737..21e18ea8 100644 --- a/src/buildvm_x86.dasc +++ b/src/buildvm_x86.dasc | |||
@@ -333,16 +333,16 @@ | |||
333 | | mov reg, PC | 333 | | mov reg, PC |
334 | | shr reg, 1 | 334 | | shr reg, 1 |
335 | | and reg, HOTCOUNT_PCMASK | 335 | | and reg, HOTCOUNT_PCMASK |
336 | | sub word [DISPATCH+reg+GG_DISP2HOT], 1 | 336 | | sub word [DISPATCH+reg+GG_DISP2HOT], HOTCOUNT_LOOP |
337 | | jz ->vm_hotloop | 337 | | jb ->vm_hotloop |
338 | |.endmacro | 338 | |.endmacro |
339 | | | 339 | | |
340 | |.macro hotcall, reg | 340 | |.macro hotcall, reg |
341 | | mov reg, PC | 341 | | mov reg, PC |
342 | | shr reg, 1 | 342 | | shr reg, 1 |
343 | | and reg, HOTCOUNT_PCMASK | 343 | | and reg, HOTCOUNT_PCMASK |
344 | | sub word [DISPATCH+reg+GG_DISP2HOT], 1 | 344 | | sub word [DISPATCH+reg+GG_DISP2HOT], HOTCOUNT_CALL |
345 | | jz ->vm_hotcall | 345 | | jb ->vm_hotcall |
346 | |.endmacro | 346 | |.endmacro |
347 | | | 347 | | |
348 | |// Set current VM state. | 348 | |// Set current VM state. |
diff --git a/src/buildvm_x86.h b/src/buildvm_x86.h index 7adb2637..a9b74642 100644 --- a/src/buildvm_x86.h +++ b/src/buildvm_x86.h | |||
@@ -798,12 +798,12 @@ static const unsigned char build_actionlist[17111] = { | |||
798 | 204,15,182,232,131,198,4,193,232,16,252,255,36,171,248,6,255,199,71,252,252, | 798 | 204,15,182,232,131,198,4,193,232,16,252,255,36,171,248,6,255,199,71,252,252, |
799 | 237,131,199,8,255,199,68,194,252,244,237,255,131,192,1,252,233,244,5,248, | 799 | 237,131,199,8,255,199,68,194,252,244,237,255,131,192,1,252,233,244,5,248, |
800 | 7,141,174,233,252,247,197,237,15,133,244,14,41,252,234,255,1,252,233,255, | 800 | 7,141,174,233,252,247,197,237,15,133,244,14,41,252,234,255,1,252,233,255, |
801 | 137,252,245,209,252,237,129,229,239,102,131,172,253,43,233,1,15,132,244,148, | 801 | 137,252,245,209,252,237,129,229,239,102,129,172,253,43,233,238,15,130,244, |
802 | 255,141,12,202,255,129,121,253,4,239,15,133,244,255,255,129,121,253,12,239, | 802 | 148,255,141,12,202,255,129,121,253,4,239,15,133,244,255,255,129,121,253,12, |
803 | 15,133,244,60,129,121,253,20,239,15,133,244,60,139,41,131,121,16,0,15,140, | 803 | 239,15,133,244,60,129,121,253,20,239,15,133,244,60,139,41,131,121,16,0,15, |
804 | 244,251,255,129,121,253,12,239,15,133,244,165,129,121,253,20,239,15,133,244, | 804 | 140,244,251,255,129,121,253,12,239,15,133,244,165,129,121,253,20,239,15,133, |
805 | 165,255,139,105,16,133,252,237,15,136,244,251,3,41,15,128,244,247,137,41, | 805 | 244,165,255,139,105,16,133,252,237,15,136,244,251,3,41,15,128,244,247,137, |
806 | 255,59,105,8,199,65,28,237,137,105,24,255,15,142,244,253,248,1,248,6,141, | 806 | 41,255,59,105,8,199,65,28,237,137,105,24,255,15,142,244,253,248,1,248,6,141, |
807 | 180,253,134,233,255,141,180,253,134,233,15,183,70,252,254,15,142,245,248, | 807 | 180,253,134,233,255,141,180,253,134,233,15,183,70,252,254,15,142,245,248, |
808 | 1,248,6,255,15,143,244,253,248,6,141,180,253,134,233,248,1,255,248,7,139, | 808 | 1,248,6,255,15,143,244,253,248,6,141,180,253,134,233,248,1,255,248,7,139, |
809 | 6,15,182,204,15,182,232,131,198,4,193,232,16,252,255,36,171,248,5,255,3,41, | 809 | 6,15,182,204,15,182,232,131,198,4,193,232,16,252,255,36,171,248,5,255,3,41, |
@@ -823,11 +823,11 @@ static const unsigned char build_actionlist[17111] = { | |||
823 | 134,233,139,1,137,105,252,252,137,65,252,248,255,139,139,233,139,4,129,139, | 823 | 134,233,139,1,137,105,252,252,137,65,252,248,255,139,139,233,139,4,129,139, |
824 | 128,233,139,108,36,48,137,147,233,137,171,233,252,255,224,255,141,180,253, | 824 | 128,233,139,108,36,48,137,147,233,137,171,233,252,255,224,255,141,180,253, |
825 | 134,233,139,6,15,182,204,15,182,232,131,198,4,193,232,16,252,255,36,171,255, | 825 | 134,233,139,6,15,182,204,15,182,232,131,198,4,193,232,16,252,255,36,171,255, |
826 | 137,252,245,209,252,237,129,229,239,102,131,172,253,43,233,1,15,132,244,150, | 826 | 137,252,245,209,252,237,129,229,239,102,129,172,253,43,233,238,15,130,244, |
827 | 255,139,190,233,139,108,36,48,141,12,202,59,141,233,15,135,244,24,15,182, | 827 | 150,255,139,190,233,139,108,36,48,141,12,202,59,141,233,15,135,244,24,15, |
828 | 142,233,57,200,15,134,244,249,248,2,255,15,183,70,252,254,252,233,245,255, | 828 | 182,142,233,57,200,15,134,244,249,248,2,255,15,183,70,252,254,252,233,245, |
829 | 248,3,199,68,194,252,252,237,131,192,1,57,200,15,134,244,3,252,233,244,2, | 829 | 255,248,3,199,68,194,252,252,237,131,192,1,57,200,15,134,244,3,252,233,244, |
830 | 255,141,44,197,237,141,4,194,139,122,252,248,137,104,252,252,137,120,252, | 830 | 2,255,141,44,197,237,141,4,194,139,122,252,248,137,104,252,252,137,120,252, |
831 | 248,139,108,36,48,141,12,200,59,141,233,15,135,244,23,137,209,137,194,15, | 831 | 248,139,108,36,48,141,12,200,59,141,233,15,135,244,23,137,209,137,194,15, |
832 | 182,174,233,133,252,237,15,132,244,248,248,1,131,193,8,57,209,15,131,244, | 832 | 182,174,233,133,252,237,15,132,244,248,248,1,131,193,8,57,209,15,131,244, |
833 | 249,139,121,252,248,137,56,139,121,252,252,137,120,4,131,192,8,199,65,252, | 833 | 249,139,121,252,248,137,56,139,121,252,252,137,120,4,131,192,8,199,65,252, |
@@ -2933,7 +2933,7 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse) | |||
2933 | 2933 | ||
2934 | case BC_FORL: | 2934 | case BC_FORL: |
2935 | #if LJ_HASJIT | 2935 | #if LJ_HASJIT |
2936 | dasm_put(Dst, 16297, HOTCOUNT_PCMASK, GG_DISP2HOT); | 2936 | dasm_put(Dst, 16297, HOTCOUNT_PCMASK, GG_DISP2HOT, HOTCOUNT_LOOP); |
2937 | #endif | 2937 | #endif |
2938 | break; | 2938 | break; |
2939 | 2939 | ||
@@ -3049,7 +3049,7 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse) | |||
3049 | 3049 | ||
3050 | case BC_ITERL: | 3050 | case BC_ITERL: |
3051 | #if LJ_HASJIT | 3051 | #if LJ_HASJIT |
3052 | dasm_put(Dst, 16297, HOTCOUNT_PCMASK, GG_DISP2HOT); | 3052 | dasm_put(Dst, 16297, HOTCOUNT_PCMASK, GG_DISP2HOT, HOTCOUNT_LOOP); |
3053 | #endif | 3053 | #endif |
3054 | break; | 3054 | break; |
3055 | 3055 | ||
@@ -3069,7 +3069,7 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse) | |||
3069 | 3069 | ||
3070 | case BC_LOOP: | 3070 | case BC_LOOP: |
3071 | #if LJ_HASJIT | 3071 | #if LJ_HASJIT |
3072 | dasm_put(Dst, 16297, HOTCOUNT_PCMASK, GG_DISP2HOT); | 3072 | dasm_put(Dst, 16297, HOTCOUNT_PCMASK, GG_DISP2HOT, HOTCOUNT_LOOP); |
3073 | #endif | 3073 | #endif |
3074 | break; | 3074 | break; |
3075 | 3075 | ||
@@ -3098,7 +3098,7 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop, int cmov, int sse) | |||
3098 | 3098 | ||
3099 | case BC_FUNCF: | 3099 | case BC_FUNCF: |
3100 | #if LJ_HASJIT | 3100 | #if LJ_HASJIT |
3101 | dasm_put(Dst, 16808, HOTCOUNT_PCMASK, GG_DISP2HOT); | 3101 | dasm_put(Dst, 16808, HOTCOUNT_PCMASK, GG_DISP2HOT, HOTCOUNT_CALL); |
3102 | #endif | 3102 | #endif |
3103 | case BC_FUNCV: /* NYI: compiled vararg functions. */ | 3103 | case BC_FUNCV: /* NYI: compiled vararg functions. */ |
3104 | break; | 3104 | break; |
diff --git a/src/lj_dispatch.c b/src/lj_dispatch.c index c29cad46..b1d17add 100644 --- a/src/lj_dispatch.c +++ b/src/lj_dispatch.c | |||
@@ -50,7 +50,8 @@ void lj_dispatch_init(GG_State *GG) | |||
50 | /* Initialize hotcount table. */ | 50 | /* Initialize hotcount table. */ |
51 | void lj_dispatch_init_hotcount(global_State *g) | 51 | void lj_dispatch_init_hotcount(global_State *g) |
52 | { | 52 | { |
53 | HotCount start = (HotCount)G2J(g)->param[JIT_P_hotloop]; | 53 | int32_t hotloop = G2J(g)->param[JIT_P_hotloop]; |
54 | HotCount start = (HotCount)(hotloop*HOTCOUNT_LOOP - 1); | ||
54 | HotCount *hotcount = G2GG(g)->hotcount; | 55 | HotCount *hotcount = G2GG(g)->hotcount; |
55 | uint32_t i; | 56 | uint32_t i; |
56 | for (i = 0; i < HOTCOUNT_SIZE; i++) | 57 | for (i = 0; i < HOTCOUNT_SIZE; i++) |
diff --git a/src/lj_dispatch.h b/src/lj_dispatch.h index dd4f68fe..c50d33ac 100644 --- a/src/lj_dispatch.h +++ b/src/lj_dispatch.h | |||
@@ -20,6 +20,10 @@ typedef uint16_t HotCount; | |||
20 | #define HOTCOUNT_SIZE 64 | 20 | #define HOTCOUNT_SIZE 64 |
21 | #define HOTCOUNT_PCMASK ((HOTCOUNT_SIZE-1)*sizeof(HotCount)) | 21 | #define HOTCOUNT_PCMASK ((HOTCOUNT_SIZE-1)*sizeof(HotCount)) |
22 | 22 | ||
23 | /* Hotcount decrements. */ | ||
24 | #define HOTCOUNT_LOOP 2 | ||
25 | #define HOTCOUNT_CALL 1 | ||
26 | |||
23 | /* This solves a circular dependency problem -- bump as needed. Sigh. */ | 27 | /* This solves a circular dependency problem -- bump as needed. Sigh. */ |
24 | #define GG_NUM_ASMFF 62 | 28 | #define GG_NUM_ASMFF 62 |
25 | 29 | ||
diff --git a/src/lj_jit.h b/src/lj_jit.h index 7e26aadc..1f7ddc21 100644 --- a/src/lj_jit.h +++ b/src/lj_jit.h | |||
@@ -232,7 +232,7 @@ typedef struct HotPenalty { | |||
232 | } HotPenalty; | 232 | } HotPenalty; |
233 | 233 | ||
234 | #define PENALTY_SLOTS 64 /* Penalty cache slot. Must be a power of 2. */ | 234 | #define PENALTY_SLOTS 64 /* Penalty cache slot. Must be a power of 2. */ |
235 | #define PENALTY_MIN 36 /* Minimum penalty value. */ | 235 | #define PENALTY_MIN (36*2) /* Minimum penalty value. */ |
236 | #define PENALTY_MAX 60000 /* Maximum penalty value. */ | 236 | #define PENALTY_MAX 60000 /* Maximum penalty value. */ |
237 | #define PENALTY_RNDBITS 4 /* # of random bits to add to penalty value. */ | 237 | #define PENALTY_RNDBITS 4 /* # of random bits to add to penalty value. */ |
238 | 238 | ||
diff --git a/src/lj_trace.c b/src/lj_trace.c index c65ca9cd..33cc98f7 100644 --- a/src/lj_trace.c +++ b/src/lj_trace.c | |||
@@ -643,9 +643,10 @@ void lj_trace_ins(jit_State *J, const BCIns *pc) | |||
643 | /* A hotcount triggered. Start recording a root trace. */ | 643 | /* A hotcount triggered. Start recording a root trace. */ |
644 | void LJ_FASTCALL lj_trace_hot(jit_State *J, const BCIns *pc) | 644 | void LJ_FASTCALL lj_trace_hot(jit_State *J, const BCIns *pc) |
645 | { | 645 | { |
646 | ERRNO_SAVE | ||
647 | /* Note: pc is the interpreter bytecode PC here. It's offset by 1. */ | 646 | /* Note: pc is the interpreter bytecode PC here. It's offset by 1. */ |
648 | hotcount_set(J2GG(J), pc, J->param[JIT_P_hotloop]+1); /* Reset hotcount. */ | 647 | ERRNO_SAVE |
648 | /* Reset hotcount. */ | ||
649 | hotcount_set(J2GG(J), pc, J->param[JIT_P_hotloop]*HOTCOUNT_LOOP); | ||
649 | /* Only start a new trace if not recording or inside __gc call or vmevent. */ | 650 | /* Only start a new trace if not recording or inside __gc call or vmevent. */ |
650 | if (J->state == LJ_TRACE_IDLE && | 651 | if (J->state == LJ_TRACE_IDLE && |
651 | !(J2G(J)->hookmask & (HOOK_GC|HOOK_VMEVENT))) { | 652 | !(J2G(J)->hookmask & (HOOK_GC|HOOK_VMEVENT))) { |