int caml_page_table_lookup(void * addr) { uintnat h, e; h = Hash(Page(addr)); /* The first hit is almost always successful, so optimize for this case */ e = caml_page_table.entries[h]; if (Page_entry_matches(e, (uintnat)addr)) return e & 0xFF; while(1) { if (e == 0) return 0; h = (h + 1) & caml_page_table.mask; e = caml_page_table.entries[h]; if (Page_entry_matches(e, (uintnat)addr)) return e & 0xFF; } }
static int caml_page_table_modify(uintnat page, int toclear, int toset) { uintnat h; Assert ((page & ~Page_mask) == 0); /* Resize to keep load factor below 1/2 */ if (caml_page_table.occupancy * 2 >= caml_page_table.size) { if (caml_page_table_resize() != 0) return -1; } h = Hash(Page(page)); while (1) { if (caml_page_table.entries[h] == 0) { caml_page_table.entries[h] = page | toset; caml_page_table.occupancy++; break; } if (Page_entry_matches(caml_page_table.entries[h], page)) { caml_page_table.entries[h] = (caml_page_table.entries[h] & ~toclear) | toset; break; } h = (h + 1) & caml_page_table.mask; } return 0; }
static int caml_page_table_modify(uintnat page, int toclear, int toset) { uintnat h; Assert ((page & ~Page_mask) == 0); #ifdef USE_STATIC_VMEM /* All pages above HYPERVISOR_VIRT_END are part of the OCaml heap */ if (page >= HYPERVISOR_VIRT_END) return 0; #if 0 else printf("modify: %p %d %d\n", page, toclear, toset); #endif #endif /* Resize to keep load factor below 1/2 */ if (caml_page_table.occupancy * 2 >= caml_page_table.size) { if (caml_page_table_resize() != 0) return -1; } h = Hash(Page(page)); while (1) { if (caml_page_table.entries[h] == 0) { caml_page_table.entries[h] = page | toset; caml_page_table.occupancy++; break; } if (Page_entry_matches(caml_page_table.entries[h], page)) { caml_page_table.entries[h] = (caml_page_table.entries[h] & ~toclear) | toset; break; } h = (h + 1) & caml_page_table.mask; } return 0; }
int caml_page_table_lookup(void * addr) { #ifdef USE_STATIC_VMEM if (addr >= (void *)MAJOR_HEAP_BASE) return In_heap; else if (addr >= (void *)MINOR_HEAP_BASE) return In_young; else if ((unsigned long)addr >= mlstart && (unsigned long)addr < mlend) return In_static_data; #endif uintnat h, e; h = Hash(Page(addr)); /* The first hit is almost always successful, so optimize for this case */ e = caml_page_table.entries[h]; if (Page_entry_matches(e, (uintnat)addr)) return e & 0xFF; while(1) { if (e == 0) return 0; h = (h + 1) & caml_page_table.mask; e = caml_page_table.entries[h]; if (Page_entry_matches(e, (uintnat)addr)) return e & 0xFF; } }
int caml_page_table_lookup(void * addr) { #ifdef USE_STATIC_VMEM if (addr >= HYPERVISOR_VIRT_END) return In_heap; if ((unsigned long)addr >= mlstart && (unsigned long)addr < mlend) return In_static_data; /* XXX need minor heap area also. In_code area is mapped to In_static_data. */ return 0; #else uintnat h, e; h = Hash(Page(addr)); /* The first hit is almost always successful, so optimize for this case */ e = caml_page_table.entries[h]; if (Page_entry_matches(e, (uintnat)addr)) return e & 0xFF; while(1) { if (e == 0) return 0; h = (h + 1) & caml_page_table.mask; e = caml_page_table.entries[h]; if (Page_entry_matches(e, (uintnat)addr)) return e & 0xFF; } #endif }