void knh_makeEvidence(Ctx *ctx, const char *ns, const char *event, int p, const char *fmt, ...) { if(p > LOG_WARNING && !knh_isSystemVerbose()) return; va_list ap; va_start(ap , fmt); if(fmt[0] == '*') { char newfmt[512]; knh_snprintf(newfmt, sizeof(newfmt), K_EVENT_FORMAT "%s", ns, event, fmt+1); ctx->share->ebiSPI->vsyslog(p, newfmt, ap); } else { DBG_ASSERT(ctx->bufa != NULL); knh_cwb_t cwbbuf, *cwb = knh_cwb_open(ctx, &cwbbuf); knh_printf(ctx, cwb->w, K_EVENT_FORMAT, ns, event); if(ctx->gma != NULL && SP(ctx->gma)->line != 0) { knh_write_uline(ctx, cwb->w, SP(ctx->gma)->uri, SP(ctx->gma)->line); } knh_vprintf(ctx, cwb->w, fmt, ap); ctx->share->ebiSPI->syslog(p, knh_cwb_tochar(ctx, cwb)); knh_cwb_clear(cwb, 0); } va_end(ap); if(p == LOG_EMERG || p == LOG_CRIT) { #if defined(K_USING_DEBUG) DBG_ABORT(); #endif knh_exit(ctx, 0); } }
void TRACE_free(Ctx *ctx, void *p, size_t size TRACEARG0) { DBG_ASSERT_FREE(); DBG_ASSERT(size != 0); size_t *block = ((size_t*)p) - 1; if(unlikely(size != block[0])) { fprintf(stderr, "%s:%d(%s) ptr = %p, block.size = %d, free.size=%d\n", _file, _line, _func, p, (int)block[0], (int)size); DBG_ABORT(); } block[0]=0; SECURE_bzero(block, size + sizeof(size_t)); free(block); knh_unuseMemory(ctx, size); }
static void handleExpr(KonohaContext *kctx, IRBuilder *builder, kExpr *expr) { int a = builder->a; int espidx = builder->espidx; int shift = builder->shift; switch(expr->build) { case TEXPR_CONST: builder->api.visitConstExpr(kctx, builder, expr); break; case TEXPR_NEW: builder->api.visitNewExpr(kctx, builder, expr); break; case TEXPR_NULL: builder->api.visitNullExpr(kctx, builder, expr); break; case TEXPR_NCONST: builder->api.visitNConstExpr(kctx, builder, expr); break; case TEXPR_LOCAL: builder->api.visitLocalExpr(kctx, builder, expr); break; case TEXPR_BLOCK: builder->api.visitBlockExpr(kctx, builder, expr); break; case TEXPR_FIELD: builder->api.visitFieldExpr(kctx, builder, expr); break; case TEXPR_CALL: builder->api.visitCallExpr(kctx, builder, expr); break; case TEXPR_AND: builder->api.visitAndExpr(kctx, builder, expr); break; case TEXPR_OR: builder->api.visitOrExpr(kctx, builder, expr); break; case TEXPR_LET: builder->api.visitLetExpr(kctx, builder, expr); break; case TEXPR_STACKTOP: builder->api.visitStackTopExpr(kctx, builder, expr);break; default: DBG_ABORT("unknown expr=%d", expr->build); } builder->a = a; builder->espidx = espidx; builder->shift = shift; }
static void EXPR_asm(KonohaContext *kctx, kStmt *stmt, int a, kExpr *expr, int shift, int espidx) { DBG_ASSERT(expr != NULL); //DBG_P("a=%d, shift=%d, espidx=%d", a, shift, espidx); switch(expr->build) { case TEXPR_CONST : { kObject *v = expr->objectConstValue; DBG_ASSERT(!TY_isUnbox(expr->ty)); DBG_ASSERT(Expr_hasObjectConstValue(expr)); v = BUILD_addConstPool(kctx, v); ASM(NSET, OC_(a), (uintptr_t)v, CT_(expr->ty)); break; } case TEXPR_NEW : { ASM(NEW, OC_(a), expr->index, CT_(expr->ty)); break; } case TEXPR_NULL : { if(TY_isUnbox(expr->ty)) { ASM(NSET, NC_(a), 0, CT_(expr->ty)); } else { ASM(NULL, OC_(a), CT_(expr->ty)); } break; } case TEXPR_NCONST : { ASM(NSET, NC_(a), expr->unboxConstValue, CT_(expr->ty)); break; } case TEXPR_LOCAL : { NMOV_asm(kctx, a, expr->ty, expr->index); break; } case TEXPR_BLOCK : { DBG_ASSERT(IS_Block(expr->block)); BLOCK_asm(kctx, expr->block, espidx); NMOV_asm(kctx, a, expr->ty, /*expr->index*/ espidx); break; } case TEXPR_FIELD : { kshort_t index = (kshort_t)expr->index; kshort_t xindex = (kshort_t)(expr->index >> (sizeof(kshort_t)*8)); if(TY_isUnbox(expr->ty)) { ASM(NMOVx, NC_(a), OC_(index), xindex, CT_(expr->ty)); } else { ASM(NMOVx, OC_(a), OC_(index), xindex, CT_(expr->ty)); } break; } case TEXPR_CALL : CALL_asm(kctx, stmt, a, expr, shift, espidx); if(a != espidx) { NMOV_asm(kctx, a, expr->ty, espidx); } break; case TEXPR_AND : AND_asm(kctx, stmt, a, expr, shift, espidx); break; case TEXPR_OR : OR_asm(kctx, stmt, a, expr, shift, espidx); break; case TEXPR_LET : LETEXPR_asm(kctx, stmt, a, expr, shift, espidx); break; case TEXPR_STACKTOP : //DBG_P("STACKTOP mov %d, %d, < %d", a, expr->index + shift, espidx); DBG_ASSERT(expr->index + shift < espidx); NMOV_asm(kctx, a, expr->ty, expr->index + shift); break; default: DBG_ABORT("unknown expr=%d", expr->build); } }