Beispiel #1
0
/* Squeal if the target of the write wasn't allocated by us. */
void MVM_cross_thread_write_check(MVMThreadContext *tc, MVMObject *written, MVMint16 guilty) {
    if (written->header.owner != tc->thread_id && !filtered_out(tc, written)) {
        char *guilty_desc = "did something to";
        switch (guilty) {
            case MVM_CTW_BIND_ATTR:
                guilty_desc = "bound to an attribute of";
                break;
            case MVM_CTW_BIND_POS:
                guilty_desc = "bound to an array slot of";
                break;
            case MVM_CTW_PUSH:
                guilty_desc = "pushed to";
                break;
            case MVM_CTW_POP:
                guilty_desc = "popped";
                break;
            case MVM_CTW_SHIFT:
                guilty_desc = "shifted";
                break;
            case MVM_CTW_UNSHIFT:
                guilty_desc = "unshifted to";
                break;
            case MVM_CTW_SPLICE:
                guilty_desc = "spliced";
                break;
            case MVM_CTW_BIND_KEY:
                guilty_desc = "bound to a hash key of";
                break;
            case MVM_CTW_DELETE_KEY:
                guilty_desc = "deleted a hash key of";
                break;
            case MVM_CTW_ASSIGN:
                guilty_desc = "assigned to";
                break;
            case MVM_CTW_REBLESS:
                guilty_desc = "reblessed";
                break;
        }
        uv_mutex_lock(&(tc->instance->mutex_cross_thread_write_logging));
        fprintf(stderr, "Thread %d %s an object allocated by thread %d\n",
            tc->thread_id, guilty_desc, written->header.owner);
        MVM_dump_backtrace(tc);
        fprintf(stderr, "\n");
        uv_mutex_unlock(&(tc->instance->mutex_cross_thread_write_logging));
    }
}
Beispiel #2
0
/* Frame exit handler, used for unwind and normal exit. */
static void log_exit(MVMThreadContext *tc, MVMuint32 unwind) {
    MVMProfileThreadData *ptd = get_thread_data(tc);

    /* Ensure we've a current frame; panic if not. */
    /* XXX in future, don't panic, try to cope. This is for debugging
     * profiler issues. */
    MVMProfileCallNode *pcn = ptd->current_call;
    if (!pcn /*|| !unwind && pcn->sf != tc->cur_frame->static_info*/) {
        MVM_dump_backtrace(tc);
        MVM_panic(1, "Profiler lost sequence");
    }

    /* Add to total time. */
    pcn->total_time += (uv_hrtime() - pcn->cur_entry_time) - pcn->cur_skip_time;

    /* Move back to predecessor in call graph. */
    ptd->current_call = pcn->pred;
}