1 |
/* |
2 |
* $Id: new_test_loadstore_b.c,v 1.4 2005/07/22 20:01:25 debug Exp $ |
3 |
* |
4 |
* Experimenting with dynamic-but-not-binary-translation load/store. |
5 |
*/ |
6 |
|
7 |
#include <stdio.h> |
8 |
#include <stdlib.h> |
9 |
|
10 |
#include "new_test_loadstore.h" |
11 |
|
12 |
/* These are in new_test_loadstore_a.c: */ |
13 |
void x(struct cpu *cpu, struct ic *ic); |
14 |
void y(struct cpu *cpu, struct ic *ic); |
15 |
|
16 |
int main(int argc, char *argv[]) |
17 |
{ |
18 |
int x1 = 72, x2 = 1234; |
19 |
struct ic ic = { 0, &x1, 5, &x2 }; |
20 |
struct ic ic2 = { 0, &x2, 9, &x1 }; |
21 |
struct cpu cpu; |
22 |
int i; |
23 |
char *page = malloc(4096); |
24 |
|
25 |
#ifdef AAA |
26 |
/* cpu.table0 = malloc(sizeof(void *) * 1048576); */ |
27 |
for (i=0; i<1048576; i++) |
28 |
cpu.table0[i] = page; |
29 |
#else |
30 |
cpu.table0[0] = malloc(sizeof(void *) * 2 * 1024); |
31 |
for (i=0; i<1024; i++) { |
32 |
cpu.table0[0][i*2+0] = page; |
33 |
cpu.table0[0][i*2+1] = page; |
34 |
} |
35 |
#endif |
36 |
printf("A: 100 Million loads + 100 Million stores\n"); |
37 |
printf("y=%i\n", x2); |
38 |
for (i=0; i<10000000; i++) { |
39 |
x(&cpu, &ic); |
40 |
y(&cpu, &ic2); |
41 |
|
42 |
x(&cpu, &ic); |
43 |
y(&cpu, &ic2); |
44 |
|
45 |
x(&cpu, &ic); |
46 |
y(&cpu, &ic2); |
47 |
|
48 |
x(&cpu, &ic); |
49 |
y(&cpu, &ic2); |
50 |
|
51 |
x(&cpu, &ic); |
52 |
y(&cpu, &ic2); |
53 |
|
54 |
x(&cpu, &ic); |
55 |
y(&cpu, &ic2); |
56 |
|
57 |
x(&cpu, &ic); |
58 |
y(&cpu, &ic2); |
59 |
|
60 |
x(&cpu, &ic); |
61 |
y(&cpu, &ic2); |
62 |
|
63 |
x(&cpu, &ic); |
64 |
y(&cpu, &ic2); |
65 |
|
66 |
x(&cpu, &ic); |
67 |
y(&cpu, &ic2); |
68 |
} |
69 |
printf("y=%i\n", x2); |
70 |
printf("B\n"); |
71 |
|
72 |
return 0; |
73 |
} |