tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test-ExecutableAllocator.cpp (1181B)


      1 #include "gdb-tests.h"
      2 
      3 #include "jit/ExecutableAllocator.h"
      4 #include "vm/JSContext.h"
      5 
      6 FRAGMENT(ExecutableAllocator, empty) {
      7  using namespace js::jit;
      8  ExecutableAllocator execAlloc;
      9 
     10  breakpoint();
     11 
     12  use(execAlloc);
     13 }
     14 
     15 FRAGMENT(ExecutableAllocator, onepool) {
     16  using namespace js::jit;
     17  ExecutablePool* pool = nullptr;
     18  ExecutableAllocator execAlloc;
     19  execAlloc.alloc(cx, 16 * 1024, &pool, CodeKind::Baseline);
     20 
     21  breakpoint();
     22 
     23  use(pool);
     24  use(execAlloc);
     25 }
     26 
     27 FRAGMENT(ExecutableAllocator, twopools) {
     28  using namespace js::jit;
     29  const size_t INIT_ALLOC_SIZE = 16 * 1024;
     30  const size_t ALLOC_SIZE = 32 * 1024;
     31  ExecutablePool* init = nullptr;
     32  ExecutablePool* pool = nullptr;
     33  ExecutableAllocator execAlloc;
     34  size_t allocated = 0;
     35 
     36  execAlloc.alloc(cx, INIT_ALLOC_SIZE, &init, CodeKind::Baseline);
     37 
     38  do {  // Keep allocating until we get a second pool.
     39    execAlloc.alloc(cx, ALLOC_SIZE, &pool, CodeKind::Ion);
     40    allocated += ALLOC_SIZE;
     41  } while (pool == init);
     42 
     43  breakpoint();
     44 
     45  use(execAlloc);
     46  init->release(INIT_ALLOC_SIZE, CodeKind::Baseline);
     47  init->release(allocated - ALLOC_SIZE, CodeKind::Ion);
     48  pool->release(ALLOC_SIZE, CodeKind::Ion);
     49 }