changeset 212:6e03cee9733e

can use r
author tobaru
date Thu, 23 Jan 2020 21:16:42 +0900
parents 66db83ec1ec2
children f4effd36aefc
files src/impl/vm_impl.cbc src/impl/vm_impl_private.cbc
diffstat 2 files changed, 14 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/impl/vm_impl.cbc	Thu Jan 23 20:48:16 2020 +0900
+++ b/src/impl/vm_impl.cbc	Thu Jan 23 21:16:42 2020 +0900
@@ -76,10 +76,9 @@
   goto next(...);
 }
 __code kpt_allocvm_impl(struct vm_impl* vm, __code next(...)) {
-  struct run *r;
   acquire(&kpt_mem.lock);
 
-  goto kpt_alloc_check_impl(vm_impl, r, next(...));
+  goto kpt_alloc_check_impl(vm_impl, next(...));
 
   goto next(...);
 }
--- a/src/impl/vm_impl_private.cbc	Thu Jan 23 20:48:16 2020 +0900
+++ b/src/impl/vm_impl_private.cbc	Thu Jan 23 21:16:42 2020 +0900
@@ -107,8 +107,20 @@
     goto next(...);
 }
 
+struct run {
+    struct run *next;
+};
+
+struct {
+    struct spinlock lock;
+    struct run* freelist;
+} kpt_mem;
+
 __code kpt_alloc_check_impl(struct vm_impl* vm_impl, __code next(...)) { 
-    
+    struct run* r;    
+    if ((r = kpt_mem.freelist) != NULL ) {
+        kpt_mem.freelist = r->next;
+    }
    goto kpt_alloc_check_inital_page(vm_impl, next(...));
 }