Skip to content

Commit c3f78cc

Browse files
committed
Merge branch 'master' into libretro
2 parents 26be283 + 6994d24 commit c3f78cc

File tree

6 files changed

+34
-32
lines changed

6 files changed

+34
-32
lines changed

Makefile.libretro

+1-1
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ else ifeq ($(platform), vita)
332332
CFLAGS += -fsingle-precision-constant -mword-relocations -fno-unwind-tables
333333
CFLAGS += -fno-asynchronous-unwind-tables -ftree-vectorize
334334
#CFLAGS += -funroll-loops # ~280K bloat
335-
#CFLAGS += -fno-optimize-sibling-calls # debug?
335+
CFLAGS += -fno-optimize-sibling-calls # broken arm->thumb tailcalls?
336336
CFLAGS += -I$(VITASDK)/include -Ifrontend/vita
337337
CFLAGS += -DNO_DYLIB
338338
CFLAGS_LAST += -O3

libpcsxcore/new_dynarec/emu_if.c

+16-16
Original file line numberDiff line numberDiff line change
@@ -342,11 +342,10 @@ static void clear_local_cache(void)
342342
static noinline void ari64_execute_threaded_slow(struct psxRegisters *regs,
343343
enum blockExecCaller block_caller)
344344
{
345-
if (!ndrc_g.thread.busy) {
345+
if (ndrc_g.thread.busy_addr == ~0u) {
346346
memcpy(ndrc_smrv_regs, regs->GPR.r, sizeof(ndrc_smrv_regs));
347347
slock_lock(ndrc_g.thread.lock);
348-
ndrc_g.thread.addr = regs->pc;
349-
ndrc_g.thread.busy = 1;
348+
ndrc_g.thread.busy_addr = regs->pc;
350349
slock_unlock(ndrc_g.thread.lock);
351350
scond_signal(ndrc_g.thread.cond);
352351
}
@@ -357,7 +356,7 @@ static noinline void ari64_execute_threaded_slow(struct psxRegisters *regs,
357356
{
358357
psxInt.ExecuteBlock(regs, block_caller);
359358
}
360-
while (!regs->stop && ndrc_g.thread.busy && block_caller == EXEC_CALLER_OTHER);
359+
while (!regs->stop && ndrc_g.thread.busy_addr != ~0u && block_caller == EXEC_CALLER_OTHER);
361360

362361
psxInt.Notify(R3000ACPU_NOTIFY_BEFORE_SAVE, NULL);
363362
//ari64_notify(R3000ACPU_NOTIFY_AFTER_LOAD, NULL);
@@ -372,8 +371,7 @@ static void ari64_execute_threaded_once(struct psxRegisters *regs,
372371
*(void **)((char *)drc_local + LO_hash_table_ptr);
373372
void *target;
374373

375-
if (likely(!ndrc_g.thread.busy)) {
376-
ndrc_g.thread.addr = 0;
374+
if (likely(ndrc_g.thread.busy_addr == ~0u)) {
377375
target = ndrc_get_addr_ht_param(hash_table, regs->pc,
378376
ndrc_cm_no_compile);
379377
if (target) {
@@ -412,21 +410,21 @@ static void ari64_execute_threaded_block(struct psxRegisters *regs,
412410

413411
static void ari64_thread_sync(void)
414412
{
415-
if (!ndrc_g.thread.lock || !ndrc_g.thread.busy)
413+
if (!ndrc_g.thread.lock || ndrc_g.thread.busy_addr == ~0u)
416414
return;
417415
for (;;) {
418416
slock_lock(ndrc_g.thread.lock);
419417
slock_unlock(ndrc_g.thread.lock);
420-
if (!ndrc_g.thread.busy)
418+
if (ndrc_g.thread.busy_addr == ~0)
421419
break;
422420
retro_sleep(0);
423421
}
424422
}
425423

426424
static int ari64_thread_check_range(unsigned int start, unsigned int end)
427425
{
428-
u32 addr = ndrc_g.thread.addr;
429-
if (!addr)
426+
u32 addr = ndrc_g.thread.busy_addr;
427+
if (addr == ~0u)
430428
return 0;
431429

432430
addr &= 0x1fffffff;
@@ -451,16 +449,17 @@ static void ari64_compile_thread(void *unused)
451449
slock_lock(ndrc_g.thread.lock);
452450
while (!ndrc_g.thread.exit)
453451
{
454-
if (!ndrc_g.thread.busy)
452+
addr = *(volatile unsigned int *)&ndrc_g.thread.busy_addr;
453+
if (addr == ~0u)
455454
scond_wait(ndrc_g.thread.cond, ndrc_g.thread.lock);
456-
addr = ndrc_g.thread.addr;
457-
if (!ndrc_g.thread.busy || !addr || ndrc_g.thread.exit)
455+
addr = *(volatile unsigned int *)&ndrc_g.thread.busy_addr;
456+
if (addr == ~0u || ndrc_g.thread.exit)
458457
continue;
459458

460459
target = ndrc_get_addr_ht_param(hash_table, addr,
461460
ndrc_cm_compile_in_thread);
462461
//printf("c %08x -> %p\n", addr, target);
463-
ndrc_g.thread.busy = 0;
462+
ndrc_g.thread.busy_addr = ~0u;
464463
}
465464
slock_unlock(ndrc_g.thread.lock);
466465
(void)target;
@@ -490,7 +489,7 @@ static void ari64_thread_shutdown(void)
490489
slock_free(ndrc_g.thread.lock);
491490
ndrc_g.thread.lock = NULL;
492491
}
493-
ndrc_g.thread.busy = ndrc_g.thread.addr = 0;
492+
ndrc_g.thread.busy_addr = ~0u;
494493
}
495494

496495
static void ari64_thread_init(void)
@@ -514,7 +513,8 @@ static void ari64_thread_init(void)
514513
return;
515514

516515
ari64_thread_shutdown();
517-
ndrc_g.thread.busy = ndrc_g.thread.addr = ndrc_g.thread.exit = 0;
516+
ndrc_g.thread.exit = 0;
517+
ndrc_g.thread.busy_addr = ~0u;
518518

519519
if (enable) {
520520
ndrc_g.thread.lock = slock_new();

libpcsxcore/new_dynarec/linkage_arm.S

+10-10
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ FUNCTION(dyna_linker):
165165
beq 0f
166166
add r6, r5, r6, asr #6 /* old target */
167167
teq r0, r6
168-
moveq pc, r0 /* Stale i-cache */
168+
bxeq r0 /* Stale i-cache */
169169
mov r0, r4
170170
mov r1, r6
171171
bl ndrc_add_jump_out
@@ -176,15 +176,15 @@ FUNCTION(dyna_linker):
176176
sub r1, r1, #2
177177
add r1, r1, r2, lsr #8
178178
str r1, [r5]
179-
mov pc, r8
179+
bx r8
180180
0:
181181
mov r0, r4
182182
#else
183183
/* XXX: should be able to do better than this... */
184184
#endif
185185
ldr r1, [fp, #LO_hash_table_ptr]
186186
bl ndrc_get_addr_ht
187-
mov pc, r0
187+
bx r0
188188
.size dyna_linker, .-dyna_linker
189189

190190
.align 2
@@ -234,7 +234,7 @@ FUNCTION(jump_vaddr_r7):
234234
FUNCTION(jump_vaddr_r0):
235235
ldr r1, [fp, #LO_hash_table_ptr]
236236
bl ndrc_get_addr_ht
237-
mov pc, r0
237+
bx r0
238238
.size jump_vaddr_r0, .-jump_vaddr_r0
239239

240240
.align 2
@@ -257,10 +257,10 @@ FUNCTION(cc_interrupt):
257257
tst r2, r2
258258
ldmfdne sp!, {r4, r5, r6, r7, r8, r9, sl, fp, ip, pc}
259259
cmp r0, r9
260-
moveq pc, lr
260+
bxeq lr
261261
ldr r1, [fp, #LO_hash_table_ptr]
262262
bl ndrc_get_addr_ht
263-
mov pc, r0
263+
bx r0
264264
.size cc_interrupt, .-cc_interrupt
265265

266266
.align 2
@@ -317,7 +317,7 @@ FUNCTION(jump_to_new_pc):
317317
bne new_dyna_leave
318318
ldr r1, [fp, #LO_hash_table_ptr]
319319
bl ndrc_get_addr_ht
320-
mov pc, r0
320+
bx r0
321321
.size jump_to_new_pc, .-jump_to_new_pc
322322

323323
.align 2
@@ -427,7 +427,7 @@ new_dyna_start_at_e:
427427
ldr r10, [fp, #LO_cycle]
428428
str r1, [fp, #LO_last_count]
429429
sub r10, r10, r1
430-
mov pc, r0
430+
bx r0
431431
.size new_dyna_start, .-new_dyna_start
432432

433433
/* --------------------------------------- */
@@ -456,7 +456,7 @@ new_dyna_start_at_e:
456456
.else
457457
\readop r0, [r1, r3, lsl #\tab_shift]
458458
.endif
459-
movcc pc, lr
459+
bxcc lr
460460
mov r2, r12
461461
str r12, [fp, #LO_cycle]
462462
.endm
@@ -495,7 +495,7 @@ FUNCTION(jump_handler_read32):
495495
.else
496496
\wrtop r1, [r3, r12, lsl #\tab_shift]
497497
.endif
498-
movcc pc, lr
498+
bxcc lr
499499
ldr r12, [fp, #LO_last_count]
500500
mov r0, r1
501501
add r2, r2, r12

libpcsxcore/new_dynarec/new_dynarec.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -9010,7 +9010,7 @@ static struct block_info *new_block_info(u_int start, u_int len,
90109010
return block;
90119011
}
90129012

9013-
static int new_recompile_block(u_int addr)
9013+
static int noinline new_recompile_block(u_int addr)
90149014
{
90159015
u_int pagelimit = 0;
90169016
u_int state_rflags = 0;

libpcsxcore/new_dynarec/new_dynarec.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ struct ndrc_globals
2424
void *cond;
2525
void *dirty_start;
2626
void *dirty_end;
27-
unsigned int addr;
28-
int busy;
27+
unsigned int busy_addr; // 0 is valid, ~0 == none
2928
int exit;
3029
} thread;
3130
};

libpcsxcore/psxinterpreter.c

+5-2
Original file line numberDiff line numberDiff line change
@@ -1243,7 +1243,8 @@ static void intNotify(enum R3000Anote note, void *data) {
12431243
setupCop(psxRegs.CP0.n.SR);
12441244
// fallthrough
12451245
case R3000ACPU_NOTIFY_CACHE_ISOLATED: // Armored Core?
1246-
memset(&ICache, 0xff, sizeof(ICache));
1246+
if (fetch == fetchICache)
1247+
memset(&ICache, 0xff, sizeof(ICache));
12471248
break;
12481249
case R3000ACPU_NOTIFY_CACHE_UNISOLATED:
12491250
break;
@@ -1340,8 +1341,10 @@ void intApplyConfig() {
13401341

13411342
// the dynarec may occasionally call the interpreter, in such a case the
13421343
// cache won't work (cache only works right if all fetches go through it)
1343-
if (!Config.icache_emulation || psxCpu != &psxInt)
1344+
if (!Config.icache_emulation || psxCpu != &psxInt) {
13441345
fetch = fetchNoCache;
1346+
memset(&ICache, 0xff, sizeof(ICache));
1347+
}
13451348
else
13461349
fetch = fetchICache;
13471350

0 commit comments

Comments
 (0)