summaryrefslogtreecommitdiff
path: root/v
diff options
context:
space:
mode:
authorAndrew Waterman <waterman@cs.berkeley.edu>2016-06-15 18:34:30 -0700
committerAndrew Waterman <waterman@cs.berkeley.edu>2016-06-15 18:59:39 -0700
commit260b6fff32036dcfc8299aa21dd7cd443b18bb6a (patch)
tree1795e3eab96364b622af81f98272fb512231116e /v
parent4944be4d45cafabce0519f223124d2934b9dcac5 (diff)
downloadenv-260b6fff32036dcfc8299aa21dd7cd443b18bb6a.zip
env-260b6fff32036dcfc8299aa21dd7cd443b18bb6a.tar.gz
env-260b6fff32036dcfc8299aa21dd7cd443b18bb6a.tar.bz2
Speed up VM tests
Diffstat (limited to 'v')
-rw-r--r--v/riscv_test.h1
-rw-r--r--v/string.c15
-rw-r--r--v/vm.c20
3 files changed, 27 insertions, 9 deletions
diff --git a/v/riscv_test.h b/v/riscv_test.h
index 880544a..0dd3a1f 100644
--- a/v/riscv_test.h
+++ b/v/riscv_test.h
@@ -15,7 +15,6 @@
#undef RVTEST_CODE_BEGIN
#define RVTEST_CODE_BEGIN \
.text; \
- .align 13; \
.global userstart; \
userstart: \
init
diff --git a/v/string.c b/v/string.c
index 46cd989..4ffedc0 100644
--- a/v/string.c
+++ b/v/string.c
@@ -59,6 +59,21 @@ int strcmp(const char* s1, const char* s2)
int memcmp(const void* s1, const void* s2, size_t n)
{
+ if ((((uintptr_t)s1 | (uintptr_t)s2) & (sizeof(uintptr_t)-1)) == 0) {
+ const uintptr_t* u1 = s1;
+ const uintptr_t* u2 = s2;
+ const uintptr_t* end = u1 + (n / sizeof(uintptr_t));
+ while (u1 < end) {
+ if (*u1 != *u2)
+ break;
+ u1++;
+ u2++;
+ }
+ n -= (const void*)u1 - s1;
+ s1 = u1;
+ s2 = u2;
+ }
+
while (n--) {
unsigned char c1 = *(const unsigned char*)s1++;
unsigned char c2 = *(const unsigned char*)s2++;
diff --git a/v/vm.c b/v/vm.c
index 9fc2ea4..2524363 100644
--- a/v/vm.c
+++ b/v/vm.c
@@ -59,18 +59,22 @@ void wtf()
terminate(3); \
} while(0)
-typedef struct { pte_t addr; void* next; } freelist_t;
-
-pte_t l1pt[PTES_PER_PT] __attribute__((aligned(PGSIZE)));
-pte_t user_l2pt[PTES_PER_PT] __attribute__((aligned(PGSIZE)));
-pte_t kernel_l2pt[PTES_PER_PT] __attribute__((aligned(PGSIZE)));
+#define l1pt pt[0]
+#define user_l2pt pt[1]
+#define kernel_l2pt pt[2]
#ifdef __riscv64
-pte_t user_l3pt[PTES_PER_PT] __attribute__((aligned(PGSIZE)));
-pte_t kernel_l3pt[PTES_PER_PT] __attribute__((aligned(PGSIZE)));
+# define NPT 5
+# define user_l3pt pt[3]
+# define kernel_l3pt pt[4]
#else
+# define NPT 3
# define user_l3pt user_l2pt
# define kernel_l3pt kernel_l2pt
#endif
+pte_t pt[NPT][PTES_PER_PT] __attribute__((aligned(PGSIZE)));
+
+typedef struct { pte_t addr; void* next; } freelist_t;
+
freelist_t user_mapping[MAX_TEST_PAGES];
freelist_t freelist_nodes[MAX_TEST_PAGES];
freelist_t *freelist_head, *freelist_tail;
@@ -88,7 +92,7 @@ void printhex(uint64_t x)
cputstring(str);
}
-void evict(unsigned long addr)
+static void evict(unsigned long addr)
{
assert(addr >= PGSIZE && addr < MAX_TEST_PAGES * PGSIZE);
addr = addr/PGSIZE*PGSIZE;