MCPcopy Create free account
hub / github.com/ZDoom/Raze / UNIT

Function UNIT

libraries/asmjit/asmjit/base/constpool.cpp:348–505  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

346
347#if defined(ASMJIT_TEST)
348UNIT(base_constpool) {
349 Zone zone(32384 - Zone::kZoneOverhead);
350 ConstPool pool(&zone);
351
352 uint32_t i;
353 uint32_t kCount = 1000000;
354
355 INFO("Adding %u constants to the pool.", kCount);
356 {
357 size_t prevOffset;
358 size_t curOffset;
359 uint64_t c = ASMJIT_UINT64_C(0x0101010101010101);
360
361 EXPECT(pool.add(&c, 8, prevOffset) == kErrorOk,
362 "pool.add() - Returned error");
363 EXPECT(prevOffset == 0,
364 "pool.add() - First constant should have zero offset");
365
366 for (i = 1; i < kCount; i++) {
367 c++;
368 EXPECT(pool.add(&c, 8, curOffset) == kErrorOk,
369 "pool.add() - Returned error");
370 EXPECT(prevOffset + 8 == curOffset,
371 "pool.add() - Returned incorrect curOffset");
372 EXPECT(pool.getSize() == (i + 1) * 8,
373 "pool.getSize() - Reported incorrect size");
374 prevOffset = curOffset;
375 }
376
377 EXPECT(pool.getAlignment() == 8,
378 "pool.getAlignment() - Expected 8-byte alignment");
379 }
380
381 INFO("Retrieving %u constants from the pool.", kCount);
382 {
383 uint64_t c = ASMJIT_UINT64_C(0x0101010101010101);
384
385 for (i = 0; i < kCount; i++) {
386 size_t offset;
387 EXPECT(pool.add(&c, 8, offset) == kErrorOk,
388 "pool.add() - Returned error");
389 EXPECT(offset == i * 8,
390 "pool.add() - Should have reused constant");
391 c++;
392 }
393 }
394
395 INFO("Checking if the constants were split into 4-byte patterns");
396 {
397 uint32_t c = 0x01010101;
398 for (i = 0; i < kCount; i++) {
399 size_t offset;
400 EXPECT(pool.add(&c, 4, offset) == kErrorOk,
401 "pool.add() - Returned error");
402 EXPECT(offset == i * 8,
403 "pool.add() - Should reuse existing constant");
404 c++;
405 }

Callers

nothing calls this directly

Calls 4

addMethod · 0.45
getSizeMethod · 0.45
getAlignmentMethod · 0.45
resetMethod · 0.45

Tested by

no test coverage detected