Greg Bowyer avatar Greg Bowyer committed 0de575b

Initial C test for azul memory stuff

Comments (0)

Files changed (4)

Binary file added.

azm_mem_test/makeme.sh

+g++ -DAZNIX_API_VERSION=200 \
+    -DAZUL \
+    -DAZ_X86 \
+    -m64 \
+    -D_REENTRANT \
+    -D_XOPEN_SOURCE=600 \
+    -D_GNU_SOURCE \
+    -D_FILE_OFFSET_BITS=64 \
+    -D_LARGEFILE_SOURCE \
+    -fno-strict-aliasing \
+    -fPIC \
+    -I/usr/local/include \
+    -laznix \
+    -lpthread \
+    -o azp_test \
+    ./test.c
+
+./azp_test

azm_mem_test/test.c

+#include <stdio.h>
+#include <string.h>
+
+#include <aznix/az_memory.h>
+#include <aznix/az_pgroup.h>
+
+#include <unistd.h>
+#include <stdlib.h>
+
+/**
+ * Stupid ridiculous test to see if I can engineer
+ * at least a hello-world C program that can use the azul
+ * memory interfaces
+ */
+void os_setup_avm_launch_env() {
+
+    unsigned long avm_process_id = (unsigned long) getpid();
+    unsigned long avm_mem_max    = (unsigned long) 1000L;
+    unsigned long avm_mem_commit = (unsigned long) 500L;
+
+    printf("Process id %d\n", avm_process_id);
+
+    int retcode = az_pmem_set_account_funds(avm_process_id, AZMM_DEFAULT_ACCOUNT,
+            AZMM_COMMITTED_FUND, AZMM_OVERDRAFT_FUND);
+
+    if (retcode) {
+        printf("FUCK! [%lu] failed to set Account [%d] with funds %d\%d: %s\n",
+                avm_process_id, AZMM_DEFAULT_ACCOUNT, AZMM_COMMITTED_FUND, 
+                AZMM_OVERDRAFT_FUND, strerror(errno));
+        abort();
+    }
+
+    retcode = az_pmem_set_account_funds(avm_process_id, AZMM_JHEAP_ACCOUNT,
+                                    AZMM_COMMITTED_FUND, AZMM_OVERDRAFT_FUND);
+    if (retcode) {
+      printf("[%lu] Failed to set AC# %d with funds %d/%d: %s\n",
+               avm_process_id,
+               AZMM_JHEAP_ACCOUNT, AZMM_COMMITTED_FUND, AZMM_OVERDRAFT_FUND,
+               strerror(errno));
+        abort();
+    }
+
+    retcode = az_pmem_set_account_funds(avm_process_id, AZMM_GCPP_ACCOUNT,
+                                    AZMM_GCPP_FUND, AZMM_GCPP_FUND);
+    if (retcode) {
+      printf("[%lu] Failed to set AC# %d with funds %d/%d: %s\n",
+               avm_process_id,
+               AZMM_JHEAP_ACCOUNT, AZMM_GCPP_FUND, AZMM_GCPP_FUND,
+               strerror(errno));
+        abort();
+    }
+    printf("[%lu] Associated accts with funds\n", avm_process_id);
+
+    retcode = az_pmem_fund_account(avm_process_id, AZMM_DEFAULT_ACCOUNT, avm_mem_commit);
+    if (retcode) {
+      printf("[%lu] Failed to fund AC# %d with %lu: %s\n",
+               avm_process_id, AZMM_DEFAULT_ACCOUNT, avm_mem_commit,
+               strerror(errno));
+        abort();
+    }
+    printf("[%lu] Funded AC# %d with %lu\n",
+           avm_process_id, AZMM_DEFAULT_ACCOUNT, avm_mem_commit);
+
+    retcode = az_pmem_set_maximum(avm_process_id, avm_mem_max);
+    if (retcode) {
+      printf("[%lu] Failed to set mem_rlimit with %lu: %s\n",
+               avm_process_id, avm_mem_max,
+               strerror(errno));
+        abort();
+    }
+    printf("[%lu] Set mem_rlimit with %lu\n", avm_process_id, avm_mem_max);
+
+    retcode = az_pmem_set_account_maximum(avm_process_id, AZMM_DEFAULT_ACCOUNT, avm_mem_max);
+    if (retcode) {
+      printf("[%lu] Failed to set AC# 0 mem_rlimit with %lu: %s\n",
+               avm_process_id, avm_mem_max,
+               strerror(errno));
+        abort();
+    }
+    printf("[%lu] Set AC# 0 mem_rlimit with %lu\n",
+           avm_process_id, avm_mem_max);
+
+    // Reserve low memory upfront for VM structures
+    int flags = AZMM_BATCHABLE;
+    /*
+    size_t len = __VM_STRUCTURES_END_ADDR__ - __VM_STRUCTURES_START_ADDR__; 
+    retcode = az_mreserve((address_t)__VM_STRUCTURES_START_ADDR__, len, flags);
+    if (retcode < 0) {
+      printf("az_mreserve(VMSTRUCTS) failed: %s", strerror(errno));
+    }
+    */
+
+}
+
+int main(int argc, char** argv) {
+
+    printf("First attempt to init some az mem\n");
+    os_setup_avm_launch_env();
+
+    return 0;
+
+}

pypy/translator/c/test/test_newgc.py

                 funcsstr.append(func)
                 funcs0.append(None)
                 funcs1.append(None)
-            else:            
+            else:
                 numargs = len(inspect.getargspec(func)[0])
                 funcsstr.append(None)
                 if numargs == 0:
         res = self.run("adding_a_hash")
         assert res == 0
 
+class TestPauselessGC(TestSemiSpaceGC):
+    gcpolicy = "pauseless"
+    should_be_moving = True
+    GC_CAN_SHRINK_ARRAY = False
+
+    def test_gc_set_max_heap_size(self):
+        py.test.skip("not implemented")
+
+    def test_gc_heap_stats(self):
+        py.test.skip("not implemented")
+
+    def test_finalizer_order(self):
+        py.test.skip("not implemented")
+
+    def define_adding_a_hash(cls):
+        from pypy.rlib.objectmodel import compute_identity_hash
+        S1 = lltype.GcStruct('S1', ('x', lltype.Signed))
+        S2 = lltype.GcStruct('S2', ('p1', lltype.Ptr(S1)),
+                                   ('p2', lltype.Ptr(S1)),
+                                   ('p3', lltype.Ptr(S1)),
+                                   ('p4', lltype.Ptr(S1)),
+                                   ('p5', lltype.Ptr(S1)),
+                                   ('p6', lltype.Ptr(S1)),
+                                   ('p7', lltype.Ptr(S1)),
+                                   ('p8', lltype.Ptr(S1)),
+                                   ('p9', lltype.Ptr(S1)))
+        def g():
+            lltype.malloc(S1)   # forgotten, will be shifted over
+            s2 = lltype.malloc(S2)   # a big object, overlaps its old position
+            s2.p1 = lltype.malloc(S1); s2.p1.x = 1010
+            s2.p2 = lltype.malloc(S1); s2.p2.x = 1020
+            s2.p3 = lltype.malloc(S1); s2.p3.x = 1030
+            s2.p4 = lltype.malloc(S1); s2.p4.x = 1040
+            s2.p5 = lltype.malloc(S1); s2.p5.x = 1050
+            s2.p6 = lltype.malloc(S1); s2.p6.x = 1060
+            s2.p7 = lltype.malloc(S1); s2.p7.x = 1070
+            s2.p8 = lltype.malloc(S1); s2.p8.x = 1080
+            s2.p9 = lltype.malloc(S1); s2.p9.x = 1090
+            return s2
+        def f():
+            rgc.collect()
+            s2 = g()
+            h2 = compute_identity_hash(s2)
+            rgc.collect()    # shift s2 to the left, but add a hash field
+            assert s2.p1.x == 1010
+            assert s2.p2.x == 1020
+            assert s2.p3.x == 1030
+            assert s2.p4.x == 1040
+            assert s2.p5.x == 1050
+            assert s2.p6.x == 1060
+            assert s2.p7.x == 1070
+            assert s2.p8.x == 1080
+            assert s2.p9.x == 1090
+            return h2 - compute_identity_hash(s2)
+        return f
+
+    def test_adding_a_hash(self):
+        res = self.run("adding_a_hash")
+        assert res == 0
+
 class TestMiniMarkGC(TestSemiSpaceGC):
     gcpolicy = "minimark"
     should_be_moving = True
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.