MCPcopy Create free account
hub / github.com/danoon2/Boxedwine / flatten

Method flatten

lib/asmjit/asmjit/core/codeholder.cpp:1082–1121  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1080// ======================
1081
1082Error CodeHolder::flatten() noexcept {
1083 uint64_t offset = 0;
1084 for (Section* section : _sections_by_order) {
1085 uint64_t real_size = section->real_size();
1086 if (real_size) {
1087 uint64_t aligned_offset = Support::align_up(offset, section->alignment());
1088 if (ASMJIT_UNLIKELY(aligned_offset < offset)) {
1089 return make_error(Error::kTooLarge);
1090 }
1091
1092 Support::FastUInt8 of = 0;
1093 offset = Support::add_overflow(aligned_offset, real_size, &of);
1094
1095 if (ASMJIT_UNLIKELY(of)) {
1096 return make_error(Error::kTooLarge);
1097 }
1098 }
1099 }
1100
1101 // Now we know that we can assign offsets of all sections properly.
1102 Section* prev = nullptr;
1103 offset = 0;
1104 for (Section* section : _sections_by_order) {
1105 uint64_t real_size = section->real_size();
1106 if (real_size) {
1107 offset = Support::align_up(offset, section->alignment());
1108 }
1109 section->_offset = offset;
1110
1111 // Make sure the previous section extends a bit to cover the alignment.
1112 if (prev) {
1113 prev->_virtual_size = offset - prev->_offset;
1114 }
1115
1116 prev = section;
1117 offset += real_size;
1118 }
1119
1120 return Error::kOk;
1121}
1122
1123size_t CodeHolder::code_size() const noexcept {
1124 Support::FastUInt8 of = 0;

Callers 5

write_empty_function_atFunction · 0.80
run_archMethod · 0.80
_addMethod · 0.80
getBufferSizeMethod · 0.80
getBufferSizeMethod · 0.80

Calls 5

align_upFunction · 0.85
make_errorFunction · 0.85
add_overflowFunction · 0.85
real_sizeMethod · 0.80
alignmentMethod · 0.45

Tested by 1

write_empty_function_atFunction · 0.64