| 1 |
# Copyright 2018 Google LLC |
| 2 |
# SPDX-License-Identifier: MIT |
| 3 |
from .common.codegen import CodeGen, VulkanWrapperGenerator |
| 4 |
from .common.vulkantypes import VulkanAPI, makeVulkanTypeSimple, iterateVulkanType, VulkanTypeInfo,\ |
| 5 |
VulkanType |
| 6 |
|
| 7 |
from .reservedmarshaling import VulkanReservedMarshalingCodegen |
| 8 |
from .transform import TransformCodegen |
| 9 |
|
| 10 |
from .wrapperdefs import API_PREFIX_RESERVEDUNMARSHAL |
| 11 |
from .wrapperdefs import MAX_PACKET_LENGTH |
| 12 |
from .wrapperdefs import ROOT_TYPE_DEFAULT_VALUE |
| 13 |
|
| 14 |
|
| 15 |
decoder_decl_preamble = """ |
| 16 |
""" |
| 17 |
|
| 18 |
decoder_impl_preamble = """ |
| 19 |
""" |
| 20 |
|
| 21 |
global_state_prefix = "this->on_" |
| 22 |
|
| 23 |
READ_STREAM = "readStream" |
| 24 |
WRITE_STREAM = "vkStream" |
| 25 |
|
| 26 |
SNAPSHOT_API_CALL_HANDLE_VARNAME = "snapshotApiCallHandle" |
| 27 |
|
| 28 |
# Driver workarounds for APIs that don't work well multithreaded |
| 29 |
driver_workarounds_global_lock_apis = [ |
| 30 |
"vkCreatePipelineLayout", |
| 31 |
"vkDestroyPipelineLayout", |
| 32 |
] |
| 33 |
|
| 34 |
MAX_STACK_ITEMS = "16" |
| 35 |
|
| 36 |
|
| 37 |
def emit_param_decl_for_reading(param, cgen): |
| 38 |
if param.staticArrExpr: |
| 39 |
cgen.stmt( |
| 40 |
cgen.makeRichCTypeDecl(param.getForNonConstAccess())) |
| 41 |
else: |
| 42 |
cgen.stmt( |
| 43 |
cgen.makeRichCTypeDecl(param)) |
| 44 |
|
| 45 |
if param.pointerIndirectionLevels > 0: |
| 46 |
lenAccess = cgen.generalLengthAccess(param) |
| 47 |
if not lenAccess: |
| 48 |
lenAccess = "1" |
| 49 |
arrSize = "1" if "1" == lenAccess else "MAX_STACK_ITEMS" |
| 50 |
|
| 51 |
typeHere = "uint8_t*" if "void" == param.typeName else param.typeName |
| 52 |
cgen.stmt("%s%s stack_%s[%s]" % ( |
| 53 |
typeHere, "*" * (param.pointerIndirectionLevels - 1), param.paramName, arrSize)) |
| 54 |
|
| 55 |
|
| 56 |
def emit_unmarshal(typeInfo, param, cgen, output=False, destroy=False, noUnbox=False): |
| 57 |
if destroy: |
| 58 |
iterateVulkanType(typeInfo, param, VulkanReservedMarshalingCodegen( |
| 59 |
cgen, |
| 60 |
"host", |
| 61 |
READ_STREAM, |
| 62 |
ROOT_TYPE_DEFAULT_VALUE, |
| 63 |
param.paramName, |
| 64 |
"readStreamPtrPtr", |
| 65 |
API_PREFIX_RESERVEDUNMARSHAL, |
| 66 |
"", |
| 67 |
direction="read", |
| 68 |
dynAlloc=True)) |
| 69 |
lenAccess = cgen.generalLengthAccess(param) |
| 70 |
lenAccessGuard = cgen.generalLengthAccessGuard(param) |
| 71 |
if None == lenAccess or "1" == lenAccess: |
| 72 |
cgen.stmt("boxed_%s_preserve = %s" % |
| 73 |
(param.paramName, param.paramName)) |
| 74 |
cgen.stmt("%s = unbox_%s(%s)" % |
| 75 |
(param.paramName, param.typeName, param.paramName)) |
| 76 |
else: |
| 77 |
if lenAccessGuard is not None: |
| 78 |
self.cgen.beginIf(lenAccessGuard) |
| 79 |
cgen.beginFor("uint32_t i = 0", "i < %s" % lenAccess, "++i") |
| 80 |
cgen.stmt("boxed_%s_preserve[i] = %s[i]" % |
| 81 |
(param.paramName, param.paramName)) |
| 82 |
cgen.stmt("((%s*)(%s))[i] = unbox_%s(%s[i])" % (param.typeName, |
| 83 |
param.paramName, param.typeName, param.paramName)) |
| 84 |
cgen.endFor() |
| 85 |
if lenAccessGuard is not None: |
| 86 |
self.cgen.endIf() |
| 87 |
else: |
| 88 |
if noUnbox: |
| 89 |
cgen.line("// No unbox for %s" % (param.paramName)) |
| 90 |
|
| 91 |
lenAccess = cgen.generalLengthAccess(param) |
| 92 |
if not lenAccess: |
| 93 |
lenAccess = "1" |
| 94 |
arrSize = "1" if "1" == lenAccess else "MAX_STACK_ITEMS" |
| 95 |
|
| 96 |
iterateVulkanType(typeInfo, param, VulkanReservedMarshalingCodegen( |
| 97 |
cgen, |
| 98 |
"host", |
| 99 |
READ_STREAM, |
| 100 |
ROOT_TYPE_DEFAULT_VALUE, |
| 101 |
param.paramName, |
| 102 |
"readStreamPtrPtr", |
| 103 |
API_PREFIX_RESERVEDUNMARSHAL, |
| 104 |
"" if (output or noUnbox) else "unbox_", |
| 105 |
direction="read", |
| 106 |
dynAlloc=True, |
| 107 |
stackVar="stack_%s" % param.paramName, |
| 108 |
stackArrSize=arrSize)) |
| 109 |
|
| 110 |
|
| 111 |
def emit_dispatch_unmarshal(typeInfo, param, cgen, globalWrapped): |
| 112 |
if globalWrapped: |
| 113 |
cgen.stmt( |
| 114 |
"// Begin global wrapped dispatchable handle unboxing for %s" % param.paramName) |
| 115 |
iterateVulkanType(typeInfo, param, VulkanReservedMarshalingCodegen( |
| 116 |
cgen, |
| 117 |
"host", |
| 118 |
READ_STREAM, |
| 119 |
ROOT_TYPE_DEFAULT_VALUE, |
| 120 |
param.paramName, |
| 121 |
"readStreamPtrPtr", |
| 122 |
API_PREFIX_RESERVEDUNMARSHAL, |
| 123 |
"", |
| 124 |
direction="read", |
| 125 |
dynAlloc=True)) |
| 126 |
else: |
| 127 |
cgen.stmt( |
| 128 |
"// Begin non wrapped dispatchable handle unboxing for %s" % param.paramName) |
| 129 |
# cgen.stmt("%s->unsetHandleMapping()" % READ_STREAM) |
| 130 |
iterateVulkanType(typeInfo, param, VulkanReservedMarshalingCodegen( |
| 131 |
cgen, |
| 132 |
"host", |
| 133 |
READ_STREAM, |
| 134 |
ROOT_TYPE_DEFAULT_VALUE, |
| 135 |
param.paramName, |
| 136 |
"readStreamPtrPtr", |
| 137 |
API_PREFIX_RESERVEDUNMARSHAL, |
| 138 |
"", |
| 139 |
direction="read", |
| 140 |
dynAlloc=True)) |
| 141 |
cgen.stmt("auto unboxed_%s = unbox_%s(%s)" % |
| 142 |
(param.paramName, param.typeName, param.paramName)) |
| 143 |
cgen.stmt("auto vk = dispatch_%s(%s)" % |
| 144 |
(param.typeName, param.paramName)) |
| 145 |
cgen.stmt("// End manual dispatchable handle unboxing for %s" % |
| 146 |
param.paramName) |
| 147 |
|
| 148 |
|
| 149 |
def emit_transform(typeInfo, param, cgen, variant="tohost"): |
| 150 |
res = \ |
| 151 |
iterateVulkanType(typeInfo, param, TransformCodegen( |
| 152 |
cgen, param.paramName, "globalstate", "transform_%s_" % variant, variant)) |
| 153 |
if not res: |
| 154 |
cgen.stmt("(void)%s" % param.paramName) |
| 155 |
|
| 156 |
# Everything here elides the initial arg |
| 157 |
|
| 158 |
|
| 159 |
class DecodingParameters(object): |
| 160 |
def __init__(self, api: VulkanAPI): |
| 161 |
self.params: list[VulkanType] = [] |
| 162 |
self.toRead: list[VulkanType] = [] |
| 163 |
self.toWrite: list[VulkanType] = [] |
| 164 |
|
| 165 |
for i, param in enumerate(api.parameters[1:]): |
| 166 |
if i == 0 and param.isDispatchableHandleType(): |
| 167 |
param.dispatchHandle = True |
| 168 |
|
| 169 |
if param.isNonDispatchableHandleType() and param.isCreatedBy(api): |
| 170 |
param.nonDispatchableHandleCreate = True |
| 171 |
|
| 172 |
if param.isNonDispatchableHandleType() and param.isDestroyedBy(api): |
| 173 |
param.nonDispatchableHandleDestroy = True |
| 174 |
|
| 175 |
if param.isDispatchableHandleType() and param.isCreatedBy(api): |
| 176 |
param.dispatchableHandleCreate = True |
| 177 |
|
| 178 |
if param.isDispatchableHandleType() and param.isDestroyedBy(api): |
| 179 |
param.dispatchableHandleDestroy = True |
| 180 |
|
| 181 |
self.toRead.append(param) |
| 182 |
|
| 183 |
if param.possiblyOutput(): |
| 184 |
self.toWrite.append(param) |
| 185 |
|
| 186 |
self.params.append(param) |
| 187 |
|
| 188 |
|
| 189 |
def emit_call_log(api, cgen): |
| 190 |
decodingParams = DecodingParameters(api) |
| 191 |
paramsToRead = decodingParams.toRead |
| 192 |
|
| 193 |
# cgen.beginIf("m_logCalls") |
| 194 |
paramLogFormat = "%p" |
| 195 |
paramLogArgs = ["(void*)boxed_dispatchHandle"] |
| 196 |
|
| 197 |
for p in paramsToRead: |
| 198 |
paramLogFormat += "0x%llx " |
| 199 |
for p in paramsToRead: |
| 200 |
paramLogArgs.append("(unsigned long long)%s" % (p.paramName)) |
| 201 |
# cgen.stmt("fprintf(stderr, \"substream %%p: call %s %s\\n\", readStream, %s)" % (api.name, paramLogFormat, ", ".join(paramLogArgs))) |
| 202 |
# cgen.endIf() |
| 203 |
|
| 204 |
|
| 205 |
def emit_decode_parameters(typeInfo, api, cgen, globalWrapped=False): |
| 206 |
|
| 207 |
decodingParams = DecodingParameters(api) |
| 208 |
|
| 209 |
paramsToRead = decodingParams.toRead |
| 210 |
|
| 211 |
for p in paramsToRead: |
| 212 |
emit_param_decl_for_reading(p, cgen) |
| 213 |
|
| 214 |
i = 0 |
| 215 |
for p in paramsToRead: |
| 216 |
lenAccess = cgen.generalLengthAccess(p) |
| 217 |
|
| 218 |
if p.dispatchHandle: |
| 219 |
emit_dispatch_unmarshal(typeInfo, p, cgen, globalWrapped) |
| 220 |
else: |
| 221 |
destroy = p.nonDispatchableHandleDestroy or p.dispatchableHandleDestroy |
| 222 |
noUnbox = False |
| 223 |
|
| 224 |
if p.nonDispatchableHandleDestroy or p.dispatchableHandleDestroy: |
| 225 |
destroy = True |
| 226 |
cgen.stmt( |
| 227 |
"// Begin manual non dispatchable handle destroy unboxing for %s" % p.paramName) |
| 228 |
if None == lenAccess or "1" == lenAccess: |
| 229 |
cgen.stmt("%s boxed_%s_preserve" % |
| 230 |
(p.typeName, p.paramName)) |
| 231 |
else: |
| 232 |
cgen.stmt("%s* boxed_%s_preserve; %s->alloc((void**)&boxed_%s_preserve, %s * sizeof(%s))" % |
| 233 |
(p.typeName, p.paramName, READ_STREAM, p.paramName, lenAccess, p.typeName)) |
| 234 |
|
| 235 |
if p.possiblyOutput(): |
| 236 |
cgen.stmt( |
| 237 |
"// Begin manual dispatchable handle unboxing for %s" % p.paramName) |
| 238 |
cgen.stmt("%s->unsetHandleMapping()" % READ_STREAM) |
| 239 |
|
| 240 |
emit_unmarshal(typeInfo, p, cgen, output=p.possiblyOutput( |
| 241 |
), destroy=destroy, noUnbox=noUnbox) |
| 242 |
i += 1 |
| 243 |
|
| 244 |
for p in paramsToRead: |
| 245 |
emit_transform(typeInfo, p, cgen, variant="tohost") |
| 246 |
|
| 247 |
emit_call_log(api, cgen) |
| 248 |
|
| 249 |
def emit_snapshot_call(api, cgen): |
| 250 |
apiForSnapshot = \ |
| 251 |
api.withCustomReturnType(makeVulkanTypeSimple(False, "void", 0, "void")) |
| 252 |
customParamsSnapshot = ["pool", SNAPSHOT_API_CALL_HANDLE_VARNAME, "nullptr", "0"] |
| 253 |
retTypeName = api.getRetTypeExpr() |
| 254 |
if retTypeName != "void": |
| 255 |
retVar = api.getRetVarExpr() |
| 256 |
customParamsSnapshot.append(retVar) |
| 257 |
customParamsSnapshot.append("(VkCommandBuffer)(boxed_dispatchHandle)") |
| 258 |
customParamsSnapshot = customParamsSnapshot + list(map(lambda p: p.paramName, api.parameters[1:])) |
| 259 |
cgen.beginIf("snapshotsEnabled()") |
| 260 |
cgen.vkApiCall(apiForSnapshot, customPrefix="this->snapshot()->", customParameters=customParamsSnapshot) |
| 261 |
cgen.endIf() |
| 262 |
|
| 263 |
def emit_dispatch_call(api, cgen): |
| 264 |
|
| 265 |
decodingParams = DecodingParameters(api) |
| 266 |
|
| 267 |
customParams = ["(VkCommandBuffer)dispatchHandle"] |
| 268 |
|
| 269 |
for (i, p) in enumerate(api.parameters[1:]): |
| 270 |
customParam = p.paramName |
| 271 |
if decodingParams.params[i].dispatchHandle: |
| 272 |
customParam = "unboxed_%s" % p.paramName |
| 273 |
customParams.append(customParam) |
| 274 |
|
| 275 |
if api.name in driver_workarounds_global_lock_apis: |
| 276 |
cgen.stmt("lock()") |
| 277 |
|
| 278 |
cgen.vkApiCall(api, customPrefix="vk->", customParameters=customParams, |
| 279 |
checkForDeviceLost=True, globalStatePrefix=global_state_prefix, |
| 280 |
checkDispatcher="CC_LIKELY(vk)") |
| 281 |
|
| 282 |
emit_snapshot_call(api, cgen) |
| 283 |
|
| 284 |
if api.name in driver_workarounds_global_lock_apis: |
| 285 |
cgen.stmt("unlock()") |
| 286 |
|
| 287 |
|
| 288 |
def emit_global_state_wrapped_call(api, cgen, context=False): |
| 289 |
customParams = ["pool", SNAPSHOT_API_CALL_HANDLE_VARNAME, "(VkCommandBuffer)(boxed_dispatchHandle)"] + \ |
| 290 |
list(map(lambda p: p.paramName, api.parameters[1:])) |
| 291 |
if context: |
| 292 |
customParams += ["context"]; |
| 293 |
cgen.vkApiCall(api, customPrefix=global_state_prefix, |
| 294 |
customParameters=customParams, checkForDeviceLost=True, |
| 295 |
globalStatePrefix=global_state_prefix, checkDispatcher="CC_LIKELY(vk)") |
| 296 |
emit_snapshot_call(api, cgen) |
| 297 |
|
| 298 |
|
| 299 |
def emit_default_decoding(typeInfo, api, cgen): |
| 300 |
emit_decode_parameters(typeInfo, api, cgen) |
| 301 |
emit_dispatch_call(api, cgen) |
| 302 |
|
| 303 |
|
| 304 |
def emit_global_state_wrapped_decoding(typeInfo, api, cgen): |
| 305 |
emit_decode_parameters(typeInfo, api, cgen, globalWrapped=True) |
| 306 |
emit_global_state_wrapped_call(api, cgen) |
| 307 |
|
| 308 |
def emit_global_state_wrapped_decoding_with_context(typeInfo, api, cgen): |
| 309 |
emit_decode_parameters(typeInfo, api, cgen, globalWrapped=True) |
| 310 |
emit_global_state_wrapped_call(api, cgen, context=True) |
| 311 |
|
| 312 |
custom_decodes = { |
| 313 |
"vkCmdCopyBufferToImage": emit_global_state_wrapped_decoding_with_context, |
| 314 |
"vkCmdCopyImage": emit_global_state_wrapped_decoding, |
| 315 |
"vkCmdCopyImageToBuffer": emit_global_state_wrapped_decoding, |
| 316 |
"vkCmdCopyBufferToImage2": emit_global_state_wrapped_decoding_with_context, |
| 317 |
"vkCmdCopyImage2": emit_global_state_wrapped_decoding, |
| 318 |
"vkCmdCopyImageToBuffer2": emit_global_state_wrapped_decoding, |
| 319 |
"vkCmdCopyBufferToImage2KHR": emit_global_state_wrapped_decoding_with_context, |
| 320 |
"vkCmdCopyImage2KHR": emit_global_state_wrapped_decoding, |
| 321 |
"vkCmdCopyImageToBuffer2KHR": emit_global_state_wrapped_decoding, |
| 322 |
"vkCmdExecuteCommands": emit_global_state_wrapped_decoding, |
| 323 |
"vkBeginCommandBuffer": emit_global_state_wrapped_decoding_with_context, |
| 324 |
"vkEndCommandBuffer": emit_global_state_wrapped_decoding_with_context, |
| 325 |
"vkResetCommandBuffer": emit_global_state_wrapped_decoding, |
| 326 |
"vkCmdPipelineBarrier": emit_global_state_wrapped_decoding, |
| 327 |
"vkCmdPipelineBarrier2": emit_global_state_wrapped_decoding, |
| 328 |
"vkCmdBindPipeline": emit_global_state_wrapped_decoding, |
| 329 |
"vkCmdBindDescriptorSets": emit_global_state_wrapped_decoding, |
| 330 |
"vkCmdCopyQueryPoolResults": emit_global_state_wrapped_decoding, |
| 331 |
"vkBeginCommandBufferAsyncGOOGLE": emit_global_state_wrapped_decoding_with_context, |
| 332 |
"vkEndCommandBufferAsyncGOOGLE": emit_global_state_wrapped_decoding_with_context, |
| 333 |
"vkResetCommandBufferAsyncGOOGLE": emit_global_state_wrapped_decoding, |
| 334 |
"vkCommandBufferHostSyncGOOGLE": emit_global_state_wrapped_decoding, |
| 335 |
"vkCmdBeginRenderPass" : emit_global_state_wrapped_decoding, |
| 336 |
"vkCmdBeginRenderPass2" : emit_global_state_wrapped_decoding, |
| 337 |
"vkCmdBeginRenderPass2KHR" : emit_global_state_wrapped_decoding, |
| 338 |
"vkCmdSetEvent" : emit_global_state_wrapped_decoding, |
| 339 |
"vkCmdResetEvent" : emit_global_state_wrapped_decoding, |
| 340 |
} |
| 341 |
|
| 342 |
|
| 343 |
class VulkanSubDecoder(VulkanWrapperGenerator): |
| 344 |
def __init__(self, module, typeInfo): |
| 345 |
VulkanWrapperGenerator.__init__(self, module, typeInfo) |
| 346 |
self.typeInfo = typeInfo |
| 347 |
self.cgen = CodeGen() |
| 348 |
|
| 349 |
def onBegin(self,): |
| 350 |
self.module.appendImpl( |
| 351 |
"#define MAX_STACK_ITEMS %s\n" % MAX_STACK_ITEMS) |
| 352 |
|
| 353 |
self.module.appendImpl( |
| 354 |
"#define MAX_PACKET_LENGTH %s\n" % MAX_PACKET_LENGTH) |
| 355 |
self.module.appendImpl( |
| 356 |
"#define CC_LIKELY(exp) (__builtin_expect( !!(exp), true ))\n") |
| 357 |
self.module.appendImpl( |
| 358 |
"#define CC_UNLIKELY(exp) (__builtin_expect( !!(exp), false ))\n") |
| 359 |
|
| 360 |
self.module.appendImpl( |
| 361 |
"size_t subDecode(VulkanMemReadingStream* readStream, VulkanDispatch* vk, VkSnapshotApiCallHandle %s, void* boxed_dispatchHandle, void* dispatchHandle, VkDeviceSize subDecodeDataSize, const void* pSubDecodeData, const VkDecoderContext& context)\n" % SNAPSHOT_API_CALL_HANDLE_VARNAME) |
| 362 |
|
| 363 |
self.cgen.beginBlock() # function body |
| 364 |
|
| 365 |
self.cgen.stmt("uint32_t count = 0") |
| 366 |
self.cgen.stmt("unsigned char *buf = (unsigned char *)pSubDecodeData") |
| 367 |
self.cgen.stmt("gfxstream::base::BumpPool* pool = readStream->pool()") |
| 368 |
self.cgen.stmt("unsigned char *ptr = (unsigned char *)pSubDecodeData") |
| 369 |
self.cgen.stmt( |
| 370 |
"const unsigned char* const end = (const unsigned char*)buf + subDecodeDataSize") |
| 371 |
self.cgen.stmt( |
| 372 |
"VkDecoderGlobalState* globalstate = VkDecoderGlobalState::get()") |
| 373 |
|
| 374 |
self.cgen.line("while (end - ptr >= 8)") |
| 375 |
self.cgen.beginBlock() # while loop |
| 376 |
|
| 377 |
self.cgen.stmt("uint32_t opcode = *(uint32_t *)ptr") |
| 378 |
self.cgen.stmt("uint32_t packetLen = *(uint32_t *)(ptr + 4)") |
| 379 |
self.cgen.line(""" |
| 380 |
// packetLen should be at least 8 (op code and packet length) and should not be excessively large |
| 381 |
if (packetLen < 8 || packetLen > MAX_PACKET_LENGTH) { |
| 382 |
GFXSTREAM_WARNING("Bad packet length %d detected, subdecode may fail", packetLen); |
| 383 |
} |
| 384 |
""") |
| 385 |
self.cgen.stmt("if (end - ptr < packetLen) return ptr - (unsigned char*)buf") |
| 386 |
|
| 387 |
|
| 388 |
self.cgen.stmt("%s->setBuf((uint8_t*)(ptr + 8))" % READ_STREAM) |
| 389 |
self.cgen.stmt( |
| 390 |
"uint8_t* readStreamPtr = %s->getBuf(); uint8_t** readStreamPtrPtr = &readStreamPtr" % READ_STREAM) |
| 391 |
self.cgen.line("switch (opcode)") |
| 392 |
self.cgen.beginBlock() # switch stmt |
| 393 |
|
| 394 |
self.module.appendImpl(self.cgen.swapCode()) |
| 395 |
|
| 396 |
def onGenCmd(self, cmdinfo, name, alias): |
| 397 |
typeInfo = self.typeInfo |
| 398 |
cgen = self.cgen |
| 399 |
api = typeInfo.apis[name] |
| 400 |
|
| 401 |
if "commandBuffer" != api.parameters[0].paramName: |
| 402 |
return |
| 403 |
|
| 404 |
cgen.line("case OP_%s:" % name) |
| 405 |
cgen.beginBlock() |
| 406 |
cgen.stmt("GFXSTREAM_TRACE_EVENT(GFXSTREAM_TRACE_DECODER_CATEGORY, \"VkSubDecoder %s\")" % name) |
| 407 |
|
| 408 |
if api.name in custom_decodes.keys(): |
| 409 |
custom_decodes[api.name](typeInfo, api, cgen) |
| 410 |
else: |
| 411 |
emit_default_decoding(typeInfo, api, cgen) |
| 412 |
|
| 413 |
cgen.stmt("break") |
| 414 |
cgen.endBlock() |
| 415 |
self.module.appendImpl(self.cgen.swapCode()) |
| 416 |
|
| 417 |
def onEnd(self,): |
| 418 |
self.cgen.line("default:") |
| 419 |
self.cgen.beginBlock() |
| 420 |
self.cgen.stmt( |
| 421 |
"GFXSTREAM_FATAL(\"Unrecognized opcode %\" PRIu32, opcode)") |
| 422 |
self.cgen.endBlock() |
| 423 |
|
| 424 |
self.cgen.endBlock() # switch stmt |
| 425 |
|
| 426 |
self.cgen.stmt("++count; if (count % 1000 == 0) { pool->freeAll(); }") |
| 427 |
self.cgen.stmt("ptr += packetLen") |
| 428 |
self.cgen.endBlock() # while loop |
| 429 |
|
| 430 |
self.cgen.stmt("pool->freeAll()") |
| 431 |
self.cgen.stmt("return ptr - (unsigned char*)buf;") |
| 432 |
self.cgen.endBlock() # function body |
| 433 |
self.module.appendImpl(self.cgen.swapCode()) |