MCPcopy Create free account
hub / github.com/async-profiler/async-profiler / load32

Method load32

src/safeAccess.cpp:44–61  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

42}
43
44NOINLINE
45int32_t SafeAccess::load32(int32_t* ptr, int32_t default_value) {
46#if defined(__x86_64__)
47 int32_t ret;
48 asm volatile("movl (%1), %0" : "=a"(ret) : "r"(ptr), "S"(default_value));
49#elif defined(__i386__)
50 int32_t ret;
51 asm volatile("movl (%1), %0" : "=a"(ret) : "r"(ptr), "a"(default_value));
52#elif defined(__aarch64__)
53 register int32_t ret asm("w0");
54 asm volatile("ldr %w0, [%1]" : "=r"(ret) : "r"(ptr), "r"(default_value));
55#else
56 asm volatile("" : : "r"(default_value)); // prevent compiler from optimizing the argument away
57 int32_t ret = *ptr;
58#endif
59 LABEL(load32_end);
60 return ret;
61}
62
63// When a memory access error happens in SafeAccess::load/load32,
64// this function skips the fault instruction pretending it has loaded default_value

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected