Lines Matching refs:ctx

190 static void flush_hpsg_chunk(HeapChunkContext *ctx)
192 if (ctx->pieceLenField == NULL && ctx->needHeader) {
198 assert(ctx->buf <= ctx->pieceLenField &&
199 ctx->pieceLenField <= ctx->p);
200 set4BE(ctx->pieceLenField, ctx->totalAllocationUnits);
204 dvmDbgDdmSendChunk(ctx->type, ctx->p - ctx->buf, ctx->buf);
208 ctx->p = ctx->buf;
209 ctx->totalAllocationUnits = 0;
210 ctx->needHeader = true;
211 ctx->pieceLenField = NULL;
214 static void append_chunk(HeapChunkContext *ctx, u1 state, void* ptr, size_t length) {
222 size_t bytesLeft = ctx->bufLen - (size_t)(ctx->p - ctx->buf);
224 flush_hpsg_chunk(ctx);
226 bytesLeft = ctx->bufLen - (size_t)(ctx->p - ctx->buf);
233 if (ctx->needHeader) {
239 set4BE(ctx->p, DEFAULT_HEAP_ID); ctx->p += 4;
242 *ctx->p++ = 8;
245 set4BE(ctx->p, (uintptr_t)ptr); ctx->p += 4;
248 set4BE(ctx->p, 0); ctx->p += 4;
254 ctx->pieceLenField = ctx->p;
255 set4BE(ctx->p, 0x55555555); ctx->p += 4;
257 ctx->needHeader = false;
262 ctx->totalAllocationUnits += length;
264 *ctx->p++ = state | HPSG_PARTIAL;
265 *ctx->p++ = 255; // length - 1
268 *ctx->p++ = state;
269 *ctx->p++ = length - 1;
284 HeapChunkContext *ctx = (HeapChunkContext *)arg;
290 ctx->startOfNextMemoryChunk = NULL;
291 flush_hpsg_chunk(ctx);
301 bool native = ctx->type == CHUNK_TYPE("NHSG");
303 if (ctx->startOfNextMemoryChunk != NULL) {
308 if (start > ctx->startOfNextMemoryChunk) {
310 void* freeStart = ctx->startOfNextMemoryChunk;
314 append_chunk(ctx, HPSG_STATE(SOLIDITY_FREE, 0),
320 ctx->startOfNextMemoryChunk = NULL;
321 flush_hpsg_chunk(ctx);
328 //TODO: if ctx.merge, see if this chunk is different from the last chunk.
373 append_chunk(ctx, state, start, used_bytes + HEAP_SOURCE_CHUNK_OVERHEAD);
374 ctx->startOfNextMemoryChunk =
396 HeapChunkContext ctx;
398 memset(&ctx, 0, sizeof(ctx));
399 ctx.bufLen = HPSx_CHUNK_SIZE;
400 ctx.buf = (u1 *)malloc(ctx.bufLen);
401 if (ctx.buf == NULL) {
405 ctx.merge = merge;
407 ctx.type = CHUNK_TYPE("NHSG");
409 if (ctx.merge) {
410 ctx.type = CHUNK_TYPE("HPSG");
412 ctx.type = CHUNK_TYPE("HPSO");
416 ctx.p = ctx.buf;
417 ctx.needHeader = true;
419 dlmalloc_inspect_all(heap_chunk_callback, (void*)&ctx);
421 dvmHeapSourceWalk(heap_chunk_callback, (void *)&ctx);
423 if (ctx.p > ctx.buf) {
424 flush_hpsg_chunk(&ctx);
427 free(ctx.buf);