本文整理汇总了C++中MVM_ASSIGN_REF函数的典型用法代码示例。如果您正苦于以下问题:C++ MVM_ASSIGN_REF函数的具体用法?C++ MVM_ASSIGN_REF怎么用?C++ MVM_ASSIGN_REF使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了MVM_ASSIGN_REF函数的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: type_object_for
/* Creates a new type object of this representation, and associates it with
* the given HOW. */
static MVMObject * type_object_for(MVMThreadContext *tc, MVMObject *HOW) {
MVMSTable *st = MVM_gc_allocate_stable(tc, &this_repr, HOW);
MVMROOT(tc, st, {
MVMObject *obj = MVM_gc_allocate_type_object(tc, st);
MVM_ASSIGN_REF(tc, &(st->header), st->WHAT, obj);
st->size = sizeof(MVMOSHandle);
});
开发者ID:cono,项目名称:MoarVM,代码行数:10,代码来源:MVMOSHandle.c
示例2: type_object_for
/* Creates a new type object of this representation, and associates it with
* the given HOW. */
static MVMObject * type_object_for(MVMThreadContext *tc, MVMObject *HOW) {
MVMSTable *st = MVM_gc_allocate_stable(tc, this_repr, HOW);
MVMROOT(tc, st, {
MVMObject *obj = MVM_gc_allocate_type_object(tc, st);
MVM_ASSIGN_REF(tc, st, st->WHAT, obj);
st->size = sizeof(HashAttrStore);
});
开发者ID:bingos,项目名称:MoarVM,代码行数:10,代码来源:HashAttrStore.c
示例3: MVM_bytecode_finish_frame
/* Finishes up reading and exploding of a frame. */
void MVM_bytecode_finish_frame(MVMThreadContext *tc, MVMCompUnit *cu,
MVMStaticFrame *sf, MVMint32 dump_only) {
MVMuint32 j;
MVMuint8 *pos;
MVMuint16 slvs;
/* Ensure we've not already done this. */
if (sf->body.fully_deserialized)
return;
/* Acquire the update mutex on the CompUnit. */
MVM_reentrantmutex_lock(tc, (MVMReentrantMutex *)cu->body.deserialize_frame_mutex);
/* Ensure no other thread has done this for us in the mean time. */
if (sf->body.fully_deserialized) {
MVM_reentrantmutex_unlock(tc, (MVMReentrantMutex *)cu->body.deserialize_frame_mutex);
return;
}
/* Locate start of frame body. */
pos = sf->body.frame_data_pos;
/* Get the number of static lex values we'll need to apply. */
slvs = read_int16(pos, 40);
/* Skip past header. */
pos += FRAME_HEADER_SIZE;
/* Read the local types. */
if (sf->body.num_locals) {
sf->body.local_types = MVM_malloc(sizeof(MVMuint16) * sf->body.num_locals);
for (j = 0; j < sf->body.num_locals; j++)
sf->body.local_types[j] = read_int16(pos, 2 * j);
pos += 2 * sf->body.num_locals;
}
/* Read the lexical types. */
if (sf->body.num_lexicals) {
/* Allocate names hash and types list. */
sf->body.lexical_types = MVM_malloc(sizeof(MVMuint16) * sf->body.num_lexicals);
/* Read in data. */
if (sf->body.num_lexicals) {
sf->body.lexical_names_list = MVM_malloc(sizeof(MVMLexicalRegistry *) * sf->body.num_lexicals);
}
for (j = 0; j < sf->body.num_lexicals; j++) {
MVMString *name = get_heap_string(tc, cu, NULL, pos, 6 * j + 2);
MVMLexicalRegistry *entry = MVM_calloc(1, sizeof(MVMLexicalRegistry));
MVM_ASSIGN_REF(tc, &(sf->common.header), entry->key, name);
sf->body.lexical_names_list[j] = entry;
entry->value = j;
sf->body.lexical_types[j] = read_int16(pos, 6 * j);
MVM_HASH_BIND(tc, sf->body.lexical_names, name, entry)
}
pos += 6 * sf->body.num_lexicals;
}
开发者ID:chipdude,项目名称:MoarVM,代码行数:59,代码来源:bytecode.c
示例4: code_pair_configure_container_spec
static void code_pair_configure_container_spec(MVMThreadContext *tc, MVMSTable *st, MVMObject *config) {
CodePairContData *data = (CodePairContData *)st->container_data;
MVMROOT(tc, config, {
MVMString *fetch = MVM_string_ascii_decode_nt(tc, tc->instance->VMString, "fetch");
MVMString *store;
if (!MVM_repr_exists_key(tc, config, fetch))
MVM_exception_throw_adhoc(tc, "Container spec 'code_pair' must be configured with a fetch");
MVM_ASSIGN_REF(tc, &(st->header), data->fetch_code, MVM_repr_at_key_o(tc, config, fetch));
store = MVM_string_ascii_decode_nt(tc, tc->instance->VMString, "store");
if (!MVM_repr_exists_key(tc, config, store))
MVM_exception_throw_adhoc(tc, "Container spec 'code_pair' must be configured with a store");
MVM_ASSIGN_REF(tc, &(st->header), data->store_code, MVM_repr_at_key_o(tc, config, store));
});
开发者ID:baby-gnu,项目名称:MoarVM,代码行数:19,代码来源:containers.c
示例5: MVM_sc_create
/* Creates a new serialization context with the specified handle. If any
* compilation units are waiting for an SC with this handle, removes it from
* their to-resolve list after installing itself in the appropriate slot. */
MVMObject * MVM_sc_create(MVMThreadContext *tc, MVMString *handle) {
MVMSerializationContext *sc;
MVMSerializationContextBody *scb;
/* Allocate. */
MVMROOT(tc, handle, {
sc = (MVMSerializationContext *)REPR(tc->instance->SCRef)->allocate(tc, STABLE(tc->instance->SCRef));
MVMROOT(tc, sc, {
/* Add to weak lookup hash. */
uv_mutex_lock(&tc->instance->mutex_sc_weakhash);
MVM_string_flatten(tc, handle);
MVM_HASH_GET(tc, tc->instance->sc_weakhash, handle, scb);
if (!scb) {
sc->body = scb = calloc(1, sizeof(MVMSerializationContextBody));
MVM_ASSIGN_REF(tc, (MVMObject *)sc, scb->handle, handle);
MVM_HASH_BIND(tc, tc->instance->sc_weakhash, handle, scb);
/* Calling repr_init will allocate, BUT if it does so, and we
* get unlucky, the GC will try to acquire mutex_sc_weakhash.
* This deadlocks. Thus, we force allocation in gen2, which
* can never trigger GC. Note that releasing the mutex early
* is not a good way to fix this, as it leaves a race to
* test/set scb->sc (between the line doing it in this block,
* and in the else clauses beneath it). */
MVM_gc_allocate_gen2_default_set(tc);
MVM_repr_init(tc, (MVMObject *)sc);
MVM_gc_allocate_gen2_default_clear(tc);
scb->sc = sc;
}
else if (scb->sc) {
/* we lost a race to create it! */
sc = scb->sc;
}
else {
scb->sc = sc;
sc->body = scb;
MVM_ASSIGN_REF(tc, sc, scb->handle, handle);
MVM_repr_init(tc, (MVMObject *)sc);
}
uv_mutex_unlock(&tc->instance->mutex_sc_weakhash);
});
});
开发者ID:etheleon,项目名称:MoarVM,代码行数:44,代码来源:sc.c
示例6: MVM_gc_allocate_stable
/* Allocates a new STable, based on the specified thread context, REPR
* and meta-object. */
MVMSTable * MVM_gc_allocate_stable(MVMThreadContext *tc, const MVMREPROps *repr, MVMObject *how) {
MVMSTable *st;
MVMROOT(tc, how, {
st = MVM_gc_allocate_zeroed(tc, sizeof(MVMSTable));
st->header.flags |= MVM_CF_STABLE;
st->header.size = sizeof(MVMSTable);
st->header.owner = tc->thread_id;
st->REPR = repr;
st->invoke = MVM_6model_invoke_default;
st->type_cache_id = MVM_6model_next_type_cache_id(tc);
MVM_ASSIGN_REF(tc, &(st->header), st->HOW, how);
});
开发者ID:nanis,项目名称:MoarVM,代码行数:14,代码来源:allocation.c
示例7: type_object_for
/* Creates a new type object of this representation, and associates it with
* the given HOW. */
static MVMObject * type_object_for(MVMThreadContext *tc, MVMObject *HOW) {
MVMSTable *st = MVM_gc_allocate_stable(tc, &this_repr, HOW);
MVMROOT(tc, st, {
MVMObject *obj = MVM_gc_allocate_type_object(tc, st);
MVMP6numREPRData *repr_data = (MVMP6numREPRData *)MVM_malloc(sizeof(MVMP6numREPRData));
repr_data->bits = sizeof(MVMnum64) * 8;
mk_storage_spec(tc, repr_data->bits, &repr_data->storage_spec);
MVM_ASSIGN_REF(tc, &(st->header), st->WHAT, obj);
st->size = sizeof(MVMP6num);
st->REPR_data = repr_data;
});
开发者ID:MattOates,项目名称:MoarVM,代码行数:15,代码来源:P6num.c
示例8: deserialize_sc_deps
/* Loads the SC dependencies list. */
static void deserialize_sc_deps(MVMThreadContext *tc, MVMCompUnit *cu, ReaderState *rs) {
MVMCompUnitBody *cu_body = &cu->body;
MVMuint32 i, sh_idx;
MVMuint8 *pos;
/* Allocate SC lists in compilation unit. */
cu_body->scs = MVM_malloc(rs->expected_scs * sizeof(MVMSerializationContext *));
cu_body->scs_to_resolve = MVM_malloc(rs->expected_scs * sizeof(MVMSerializationContextBody *));
cu_body->sc_handle_idxs = MVM_malloc(rs->expected_scs * sizeof(MVMint32));
cu_body->num_scs = rs->expected_scs;
/* Resolve all the things. */
pos = rs->sc_seg;
for (i = 0; i < rs->expected_scs; i++) {
MVMSerializationContextBody *scb;
MVMString *handle;
/* Grab string heap index. */
ensure_can_read(tc, cu, rs, pos, 4);
sh_idx = read_int32(pos, 0);
pos += 4;
/* Resolve to string. */
if (sh_idx >= cu_body->num_strings) {
cleanup_all(tc, rs);
MVM_exception_throw_adhoc(tc, "String heap index beyond end of string heap");
}
cu_body->sc_handle_idxs[i] = sh_idx;
handle = MVM_cu_string(tc, cu, sh_idx);
/* See if we can resolve it. */
uv_mutex_lock(&tc->instance->mutex_sc_weakhash);
MVM_string_flatten(tc, handle);
MVM_HASH_GET(tc, tc->instance->sc_weakhash, handle, scb);
if (scb && scb->sc) {
cu_body->scs_to_resolve[i] = NULL;
MVM_ASSIGN_REF(tc, &(cu->common.header), cu_body->scs[i], scb->sc);
}
else {
if (!scb) {
scb = MVM_calloc(1, sizeof(MVMSerializationContextBody));
scb->handle = handle;
MVM_HASH_BIND(tc, tc->instance->sc_weakhash, handle, scb);
MVM_sc_add_all_scs_entry(tc, scb);
}
cu_body->scs_to_resolve[i] = scb;
cu_body->scs[i] = NULL;
}
uv_mutex_unlock(&tc->instance->mutex_sc_weakhash);
}
}
开发者ID:tomboy-64,项目名称:MoarVM,代码行数:52,代码来源:bytecode.c
示例9: type_object_for
/* Creates a new type object of this representation, and associates it with
* the given HOW. */
static MVMObject * type_object_for(MVMThreadContext *tc, MVMObject *HOW) {
MVMSTable *st = MVM_gc_allocate_stable(tc, &this_repr, HOW);
MVMROOT(tc, st, {
MVMObject *obj = MVM_gc_allocate_type_object(tc, st);
MVMP6intREPRData *repr_data = (MVMP6intREPRData *)malloc(sizeof(MVMP6intREPRData));
repr_data->bits = sizeof(MVMint64) * 8;
repr_data->is_unsigned = 0;
MVM_ASSIGN_REF(tc, st, st->WHAT, obj);
st->size = sizeof(MVMP6int);
st->REPR_data = repr_data;
});
开发者ID:tadzik,项目名称:MoarVM,代码行数:16,代码来源:P6int.c
示例10: type_object_for
/* Creates a new type object of this representation, and associates it with
* the given HOW. */
static MVMObject * type_object_for(MVMThreadContext *tc, MVMObject *HOW) {
MVMSTable *st = MVM_gc_allocate_stable(tc, &this_repr, HOW);
MVMROOT(tc, st, {
MVMObject *obj = MVM_gc_allocate_type_object(tc, st);
MVMArrayREPRData *repr_data = (MVMArrayREPRData *)malloc(sizeof(MVMArrayREPRData));
repr_data->slot_type = MVM_ARRAY_OBJ;
repr_data->elem_size = sizeof(MVMObject *);
MVM_ASSIGN_REF(tc, st, st->WHAT, obj);
st->size = sizeof(MVMArray);
st->REPR_data = repr_data;
});
开发者ID:dagurval,项目名称:MoarVM,代码行数:16,代码来源:MVMArray.c
示例11: MVM_6model_parametric_setup
/* Takes a type and sets it up as a parametric type, provided it's OK to do so. */
void MVM_6model_parametric_setup(MVMThreadContext *tc, MVMObject *type, MVMObject *parameterizer) {
MVMSTable *st = STABLE(type);
/* Ensure that the type is not already parametric or parameterized. */
if (st->mode_flags & MVM_PARAMETRIC_TYPE)
MVM_exception_throw_adhoc(tc, "This type is already parametric");
if (st->mode_flags & MVM_PARAMETERIZED_TYPE)
MVM_exception_throw_adhoc(tc, "Cannot make a parameterized type also be parametric");
/* For now, we use a simple pairwise array, with parameters and the type
* that is based on those parameters interleaved. It does make resolution
* O(n), so we might like to do some hash in the future. */
MVMROOT(tc, st, {
MVMROOT(tc, parameterizer, {
MVMObject *lookup = MVM_repr_alloc_init(tc, tc->instance->boot_types.BOOTArray);
MVM_ASSIGN_REF(tc, &(st->header), st->paramet.ric.lookup, lookup);
});
});
开发者ID:hoelzro,项目名称:MoarVM,代码行数:19,代码来源:parametric.c
示例12: MVM_sc_create
/* Creates a new serialization context with the specified handle. If any
* compilation units are waiting for an SC with this handle, removes it from
* their to-resolve list after installing itself in the appropriate slot. */
MVMObject * MVM_sc_create(MVMThreadContext *tc, MVMString *handle) {
MVMObject *sc;
MVMCompUnit *cur_cu;
/* Allocate. */
MVMROOT(tc, handle, {
sc = REPR(tc->instance->SCRef)->allocate(tc, STABLE(tc->instance->SCRef));
MVMROOT(tc, sc, {
REPR(sc)->initialize(tc, STABLE(sc), sc, OBJECT_BODY(sc));
/* Set handle. */
MVM_ASSIGN_REF(tc, sc, ((MVMSerializationContext *)sc)->body->handle, handle);
/* Add to weak lookup hash. */
if (apr_thread_mutex_lock(tc->instance->mutex_sc_weakhash) != APR_SUCCESS)
MVM_exception_throw_adhoc(tc, "Unable to lock SC weakhash");
MVM_string_flatten(tc, handle);
MVM_HASH_BIND(tc, tc->instance->sc_weakhash, handle, ((MVMSerializationContext *)sc)->body);
if (apr_thread_mutex_unlock(tc->instance->mutex_sc_weakhash) != APR_SUCCESS)
MVM_exception_throw_adhoc(tc, "Unable to unlock SC weakhash");
/* Visit compilation units that need this SC and resolve it. */
cur_cu = tc->instance->head_compunit;
while (cur_cu) {
if (cur_cu->scs_to_resolve) {
MVMuint32 i;
for (i = 0; i < cur_cu->num_scs; i++) {
MVMString *res = cur_cu->scs_to_resolve[i];
if (res && MVM_string_equal(tc, res, handle)) {
cur_cu->scs[i] = (MVMSerializationContext *)sc;
cur_cu->scs_to_resolve[i] = NULL;
break;
}
}
}
cur_cu = cur_cu->next_compunit;
}
});
});
开发者ID:ryandietrich,项目名称:MoarVM,代码行数:42,代码来源:sc.c
示例13: run_handler
static void run_handler(MVMThreadContext *tc, LocatedHandler lh, MVMObject *ex_obj,
MVMuint32 category, MVMObject *payload) {
switch (lh.handler->action) {
case MVM_EX_ACTION_GOTO_WITH_PAYLOAD:
if (payload)
tc->last_payload = payload;
else if (ex_obj && ((MVMException *)ex_obj)->body.payload)
tc->last_payload = ((MVMException *)ex_obj)->body.payload;
else
tc->last_payload = tc->instance->VMNull;
/* Deliberate fallthrough to unwind below. */
case MVM_EX_ACTION_GOTO:
if (lh.jit_handler) {
void **labels = lh.frame->spesh_cand->jitcode->labels;
MVMuint8 *pc = lh.frame->spesh_cand->jitcode->bytecode;
MVM_frame_unwind_to(tc, lh.frame, pc, 0, NULL, labels[lh.jit_handler->goto_label]);
} else {
MVM_frame_unwind_to(tc, lh.frame, NULL, lh.handler->goto_offset, NULL, NULL);
}
break;
case MVM_EX_ACTION_INVOKE: {
/* Create active handler record. */
MVMActiveHandler *ah = MVM_malloc(sizeof(MVMActiveHandler));
MVMFrame *cur_frame = tc->cur_frame;
MVMFrame *pres_frame;
MVMObject *handler_code;
/* Ensure we have an exception object. */
if (ex_obj == NULL) {
MVMROOT3(tc, cur_frame, lh.frame, payload, {
ex_obj = MVM_repr_alloc_init(tc, tc->instance->boot_types.BOOTException);
});
((MVMException *)ex_obj)->body.category = category;
MVM_ASSIGN_REF(tc, &(ex_obj->header), ((MVMException *)ex_obj)->body.payload, payload);
}
开发者ID:MasterDuke17,项目名称:MoarVM,代码行数:38,代码来源:exceptions.c
示例14: create_stub_VMString
/* Creates a stub VMString. Note we didn't initialize the
* representation yet, so have to do this somewhat pokily. */
static void create_stub_VMString(MVMThreadContext *tc) {
/* Need to create the REPR function table "in advance"; the
* MVMString REPR specially knows not to duplicately create
* this. */
const MVMREPROps *repr = MVMString_initialize(tc);
/* Now we can create a type object; note we have no HOW yet,
* though. */
MVMSTable *st = MVM_gc_allocate_stable(tc, repr, NULL);
MVMROOT(tc, st, {
/* We can now go for the type object. */
MVMObject *obj = MVM_gc_allocate_type_object(tc, st);
/* Set the WHAT in the STable we just made to point to the type
* object (this is completely normal). */
MVM_ASSIGN_REF(tc, st, st->WHAT, obj);
/* REPR normally sets up size, but we'll have to do that manually
* here also. */
st->size = sizeof(MVMString);
tc->instance->VMString = obj;
});
开发者ID:JTimothyKing,项目名称:MoarVM,代码行数:25,代码来源:bootstrap.c
示例15: MVM_frame_invoke
//.........这里部分代码省略.........
}
if (!match)
break;
}
if (match) {
frame->effective_bytecode = cand->bytecode;
frame->effective_handlers = cand->handlers;
frame->effective_spesh_slots = cand->spesh_slots;
frame->spesh_cand = cand;
found_spesh = 1;
break;
}
}
}
/* If we didn't find any, and we're below the limit, can generate a
* specialization. */
if (!found_spesh && num_spesh < MVM_SPESH_LIMIT && tc->instance->spesh_enabled) {
MVMSpeshCandidate *cand = MVM_spesh_candidate_generate(tc, static_frame,
callsite, args);
if (cand) {
frame->effective_bytecode = cand->bytecode;
frame->effective_handlers = cand->handlers;
frame->effective_spesh_slots = cand->spesh_slots;
frame->spesh_cand = cand;
found_spesh = 1;
}
}
}
if (!found_spesh) {
frame->effective_bytecode = static_frame_body->bytecode;
frame->effective_handlers = static_frame_body->handlers;
frame->spesh_cand = NULL;
}
/* Update interpreter and thread context, so next execution will use this
* frame. */
tc->cur_frame = frame;
*(tc->interp_cur_op) = frame->effective_bytecode;
*(tc->interp_bytecode_start) = frame->effective_bytecode;
*(tc->interp_reg_base) = frame->work;
*(tc->interp_cu) = static_frame_body->cu;
/* If we need to do so, make clones of things in the lexical environment
* that need it. Note that we do this after tc->cur_frame became the
* current frame, to make sure these new objects will certainly get
* marked if GC is triggered along the way. */
if (static_frame_body->static_env_flags) {
/* Drag everything out of static_frame_body before we start,
* as GC action may invalidate it. */
MVMuint8 *flags = static_frame_body->static_env_flags;
MVMint64 numlex = static_frame_body->num_lexicals;
MVMRegister *state = NULL;
MVMint64 state_act = 0; /* 0 = none so far, 1 = first time, 2 = later */
MVMint64 i;
for (i = 0; i < numlex; i++) {
switch (flags[i]) {
case 0: break;
case 1:
frame->env[i].o = MVM_repr_clone(tc, frame->env[i].o);
break;
case 2:
redo_state:
switch (state_act) {
case 0:
if (!frame->code_ref)
MVM_exception_throw_adhoc(tc,
"Frame must have code-ref to have state variables");
state = ((MVMCode *)frame->code_ref)->body.state_vars;
if (state) {
/* Already have state vars; pull them from this. */
state_act = 2;
}
else {
/* Allocate storage for state vars. */
state = malloc(frame->static_info->body.env_size);
memset(state, 0, frame->static_info->body.env_size);
((MVMCode *)frame->code_ref)->body.state_vars = state;
state_act = 1;
/* Note that this frame should run state init code. */
frame->flags |= MVM_FRAME_FLAG_STATE_INIT;
}
goto redo_state;
case 1:
frame->env[i].o = MVM_repr_clone(tc, frame->env[i].o);
MVM_ASSIGN_REF(tc, &(frame->code_ref->header), state[i].o, frame->env[i].o);
break;
case 2:
frame->env[i].o = state[i].o;
break;
}
break;
default:
MVM_exception_throw_adhoc(tc,
"Unknown lexical environment setup flag");
}
}
}
}
开发者ID:mj41,项目名称:MoarVM,代码行数:101,代码来源:frame.c
示例16: compose
/* Composes the meta-object. */
static void compose(MVMThreadContext *tc, MVMCallsite *callsite, MVMRegister *args) {
MVMObject *self, *type_obj, *method_table, *attributes, *BOOTArray, *BOOTHash,
*repr_info_hash, *repr_info, *type_info, *attr_info_list, *parent_info;
MVMuint64 num_attrs, i;
MVMInstance *instance = tc->instance;
/* Get arguments. */
MVMArgProcContext arg_ctx; arg_ctx.named_used = NULL;
MVM_args_proc_init(tc, &arg_ctx, callsite, args);
MVM_args_checkarity(tc, &arg_ctx, 2, 2);
self = MVM_args_get_pos_obj(tc, &arg_ctx, 0, MVM_ARG_REQUIRED).arg.o;
type_obj = MVM_args_get_pos_obj(tc, &arg_ctx, 1, MVM_ARG_REQUIRED).arg.o;
MVM_args_proc_cleanup(tc, &arg_ctx);
if (!self || !IS_CONCRETE(self) || REPR(self)->ID != MVM_REPR_ID_KnowHOWREPR)
MVM_exception_throw_adhoc(tc, "KnowHOW methods must be called on object instance with REPR KnowHOWREPR");
/* Fill out STable. */
method_table = ((MVMKnowHOWREPR *)self)->body.methods;
MVM_ASSIGN_REF(tc, &(STABLE(type_obj)->header), STABLE(type_obj)->method_cache, method_table);
STABLE(type_obj)->mode_flags = MVM_METHOD_CACHE_AUTHORITATIVE;
STABLE(type_obj)->type_check_cache_length = 1;
STABLE(type_obj)->type_check_cache = MVM_malloc(sizeof(MVMObject *));
MVM_ASSIGN_REF(tc, &(STABLE(type_obj)->header), STABLE(type_obj)->type_check_cache[0], type_obj);
attributes = ((MVMKnowHOWREPR *)self)->body.attributes;
/* Next steps will allocate, so make sure we keep hold of the type
* object and ourself. */
MVM_gc_root_temp_push(tc, (MVMCollectable **)&attributes);
MVM_gc_root_temp_push(tc, (MVMCollectable **)&type_obj);
/* Use any attribute information to produce attribute protocol
* data. The protocol consists of an array... */
BOOTArray = instance->boot_types.BOOTArray;
BOOTHash = instance->boot_types.BOOTHash;
MVM_gc_root_temp_push(tc, (MVMCollectable **)&BOOTArray);
MVM_gc_root_temp_push(tc, (MVMCollectable **)&BOOTHash);
repr_info = REPR(BOOTArray)->allocate(tc, STABLE(BOOTArray));
MVM_gc_root_temp_push(tc, (MVMCollectable **)&repr_info);
/* ...which contains an array per MRO entry (just us)... */
type_info = REPR(BOOTArray)->allocate(tc, STABLE(BOOTArray));
MVM_gc_root_temp_push(tc, (MVMCollectable **)&type_info);
MVM_repr_push_o(tc, repr_info, type_info);
/* ...which in turn contains this type... */
MVM_repr_push_o(tc, type_info, type_obj);
/* ...then an array of hashes per attribute... */
attr_info_list = REPR(BOOTArray)->allocate(tc, STABLE(BOOTArray));
MVM_gc_root_temp_push(tc, (MVMCollectable **)&attr_info_list);
MVM_repr_push_o(tc, type_info, attr_info_list);
num_attrs = REPR(attributes)->elems(tc, STABLE(attributes),
attributes, OBJECT_BODY(attributes));
for (i = 0; i < num_attrs; i++) {
MVMObject *attr_info = REPR(BOOTHash)->allocate(tc, STABLE(BOOTHash));
MVMKnowHOWAttributeREPR *attribute = (MVMKnowHOWAttributeREPR *)
MVM_repr_at_pos_o(tc, attributes, i);
MVMROOT(tc, attr_info, {
MVMROOT(tc, attribute, {
if (REPR((MVMObject *)attribute)->ID != MVM_REPR_ID_KnowHOWAttributeREPR)
MVM_exception_throw_adhoc(tc, "KnowHOW attributes must use KnowHOWAttributeREPR");
MVM_repr_init(tc, attr_info);
MVM_repr_bind_key_o(tc, attr_info, instance->str_consts.name, (MVMObject *)attribute->body.name);
MVM_repr_bind_key_o(tc, attr_info, instance->str_consts.type, attribute->body.type);
if (attribute->body.box_target) {
/* Merely having the key serves as a "yes". */
MVM_repr_bind_key_o(tc, attr_info, instance->str_consts.box_target, attr_info);
}
MVM_repr_push_o(tc, attr_info_list, attr_info);
});
});
开发者ID:nanis,项目名称:MoarVM,代码行数:74,代码来源:bootstrap.c
示例17: MVM_thread_start
MVMObject * MVM_thread_start(MVMThreadContext *tc, MVMObject *invokee, MVMObject *result_type) {
int status;
ThreadStart *ts;
MVMObject *child_obj;
/* Create a thread object to wrap it up in. */
MVM_gc_root_temp_push(tc, (MVMCollectable **)&invokee);
child_obj = REPR(result_type)->allocate(tc, STABLE(result_type));
MVM_gc_root_temp_pop(tc);
if (REPR(child_obj)->ID == MVM_REPR_ID_MVMThread) {
MVMThread *child = (MVMThread *)child_obj;
MVMThread * volatile *threads;
/* Create a new thread context and set it up. */
MVMThreadContext *child_tc = MVM_tc_create(tc->instance);
child->body.tc = child_tc;
MVM_ASSIGN_REF(tc, child, child->body.invokee, invokee);
child_tc->thread_obj = child;
child_tc->thread_id = MVM_incr(&tc->instance->next_user_thread_id);
/* Create the thread. Note that we take a reference to the current frame,
* since it must survive to be the dynamic scope of where the thread was
* started, and there's no promises that the thread won't start before
* the code creating the thread returns. The count is decremented when
* the thread is done. */
ts = malloc(sizeof(ThreadStart));
ts->tc = child_tc;
ts->caller = MVM_frame_inc_ref(tc, tc->cur_frame);
ts->thread_obj = child_obj;
/* push this to the *child* tc's temp roots. */
MVM_gc_root_temp_push(child_tc, (MVMCollectable **)&ts->thread_obj);
/* Signal to the GC we have a childbirth in progress. The GC
* will null it for us. */
MVM_gc_mark_thread_blocked(child_tc);
MVM_ASSIGN_REF(tc, tc->thread_obj, tc->thread_obj->body.new_child, child);
/* push to starting threads list */
threads = &tc->instance->threads;
do {
MVMThread *curr = *threads;
MVM_ASSIGN_REF(tc, child, child->body.next, curr);
} while (MVM_casptr(threads, child->body.next, child) != child->body.next);
status = uv_thread_create(&child->body.thread, &start_thread, ts);
if (status < 0) {
MVM_panic(MVM_exitcode_compunit, "Could not spawn thread: errorcode %d", status);
}
/* need to run the GC to clear our new_child field in case we try
* try to launch another thread before the GC runs and before the
* thread starts. */
GC_SYNC_POINT(tc);
}
else {
MVM_exception_throw_adhoc(tc,
"Thread result type must have representation MVMThread");
}
return child_obj;
}
开发者ID:JTimothyKing,项目名称:MoarVM,代码行数:64,代码来源:threads.c
示例18: code_pair_deserialize
static void code_pair_deserialize(MVMThreadContext *tc, MVMSTable *st, MVMSerializationReader *reader) {
CodePairContData *data = (CodePairContData *)st->container_data;
MVM_ASSIGN_REF(tc, &(st->header), data->fetch_code, MVM_serialization_read_ref(tc, reader));
MVM_ASSIGN_REF(tc, &(st->header), data->store_code, MVM_serialization_read_ref(tc, reader));
}
开发者ID:baby-gnu,项目名称:MoarVM,代码行数:6,代码来源:containers.c
示例19: compose
/* Composes the meta-object. */
static void compose(MVMThreadContext *tc, MVMCallsite *callsite, MVMRegister *args) {
MVMObject *self, *type_obj, *method_table, *attributes, *BOOTArray, *BOOTHash,
*repr_info_hash, *repr_info, *type_info, *attr_info_list, *parent_info;
MVMint64 num_attrs, i;
/* Get arguments. */
MVMArgProcContext arg_ctx; arg_ctx.named_used = NULL;
MVM_args_proc_init(tc, &arg_ctx, callsite, args);
self = MVM_args_get_pos_obj(tc, &arg_ctx, 0, MVM_ARG_REQUIRED).arg.o;
type_obj = MVM_args_get_pos_obj(tc, &arg_ctx, 1, MVM_ARG_REQUIRED).arg.o;
MVM_args_proc_cleanup(tc, &arg_ctx);
if (!self || !IS_CONCRETE(self) || REPR(self)->ID != MVM_REPR_ID_KnowHOWREPR)
MVM_exception_throw_adhoc(tc, "KnowHOW methods must be called on object instance with REPR KnowHOWREPR");
/* Fill out STable. */
method_table = ((MVMKnowHOWREPR *)self)->body.methods;
MVM_ASSIGN_REF(tc, STABLE(type_obj), STABLE(type_obj)->method_cache, method_table);
STABLE(type_obj)->mode_flags = MVM_METHOD_CACHE_AUTHORITATIVE;
STABLE(type_obj)->type_check_cache_length = 1;
STABLE(type_obj)->type_check_cache = malloc(sizeof(MVMObject *));
MVM_ASSIGN_REF(tc, STABLE(type_obj), STABLE(type_obj)->type_check_cache[0], type_obj);
/* Next steps will allocate, so make sure we keep hold of the type
* object and ourself. */
MVM_gc_root_temp_push(tc, (MVMCollectable **)&self);
MVM_gc_root_temp_push(tc, (MVMCollectable **)&type_obj);
/* Use any attribute information to produce attribute protocol
* data. The protocol consists of an array... */
BOOTArray = tc->instance->boot_types->BOOTArray;
BOOTHash = tc->instance->boot_types->BOOTHash;
MVM_gc_root_temp_push(tc, (MVMCollectable **)&BOOTArray);
MVM_gc_root_temp_push(tc, (MVMCollectable **)&BOOTHash);
repr_info = REPR(BOOTArray)->allocate(tc, STABLE(BOOTArray));
MVM_gc_root_temp_push(tc, (MVMCollectable **)&repr_info);
REPR(repr_info)->initialize(tc, STABLE(repr_info), repr_info, OBJECT_BODY(repr_info));
/* ...which contains an array per MRO entry (just us)... */
type_info = REPR(BOOTArray)->allocate(tc, STABLE(BOOTArray));
MVM_gc_root_temp_push(tc, (MVMCollectable **)&type_info);
REPR(type_info)->initialize(tc, STABLE(type_info), type_info, OBJECT_BODY(type_info));
MVM_repr_push_o(tc, repr_info, type_info);
/* ...which in turn contains this type... */
MVM_repr_push_o(tc, type_info, type_obj);
/* ...then an array of hashes per attribute... */
attr_info_list = REPR(BOOTArray)->allocate(tc, STABLE(BOOTArray));
MVM_gc_root_temp_push(tc, (MVMCollectable **)&attr_info_list);
REPR(attr_info_list)->initialize(tc, STABLE(attr_info_list), attr_info_list,
OBJECT_BODY(attr_info_list));
MVM_repr_push_o(tc, type_info, attr_info_list);
attributes = ((MVMKnowHOWREPR *)self)->body.attributes;
MVM_gc_root_temp_push(tc, (MVMCollectable **)&attributes);
num_attrs = REPR(attributes)->elems(tc, STABLE(attributes),
attributes, OBJECT_BODY(attributes));
for (i = 0; i < num_attrs; i++) {
MVMObject *attr_info = REPR(BOOTHash)->allocate(tc, STABLE(BOOTHash));
MVMKnowHOWAttributeREPR *attribute = (MVMKnowHOWAttributeREPR *)
MVM_repr_at_pos_o(tc, attributes, i);
MVM_gc_root_temp_push(tc, (MVMCollectable **)&attr_info);
MVM_gc_root_temp_push(tc, (MVMCollectable **)&attribute);
if (REPR((MVMObject *)attribute)->ID != MVM_REPR_ID_KnowHOWAttributeREPR)
MVM_exception_throw_adhoc(tc, "KnowHOW attributes must use KnowHOWAttributeREPR");
REPR(attr_info)->initialize(tc, STABLE(attr_info), attr_info,
OBJECT_BODY(attr_info));
REPR(attr_info)->ass_funcs->bind_key_boxed(tc, STABLE(attr_info),
attr_info, OBJECT_BODY(attr_info), (MVMObject *)str_name, (MVMObject *)attribute->body.name);
REPR(attr_info)->ass_funcs->bind_key_boxed(tc, STABLE(attr_info),
attr_info, OBJECT_BODY(attr_info), (MVMObject *)str_type, attribute->body.type);
if (attribute->body.box_target) {
/* Merely having the key serves as a "yes". */
REPR(attr_info)->ass_funcs->bind_key_boxed(tc, STABLE(attr_info),
attr_info, OBJECT_BODY(attr_info), (MVMObject *)str_box_target, attr_info);
}
MVM_repr_push_o(tc, attr_info_list, attr_info);
MVM_gc_root_temp_pop_n(tc, 2);
}
/* ...followed by a list of parents (none). */
parent_info = REPR(BOOTArray)->allocate(tc, STABLE(BOOTArray));
MVM_gc_root_temp_push(tc, (MVMCollectable **)&parent_info);
REPR(parent_info)->initialize(tc, STABLE(parent_info), parent_info,
OBJECT_BODY(parent_info));
MVM_repr_push_o(tc, type_info, parent_info);
/* Finally, this all goes in a hash under the key 'attribute'. */
repr_info_hash = REPR(BOOTHash)->allocate(tc, STABLE(BOOTHash));
MVM_gc_root_temp_push(tc, (MVMCollectable **)&repr_info_hash);
REPR(repr_info_hash)->initialize(tc, STABLE(repr_info_hash), repr_info_hash, OBJECT_BODY(repr_info_hash));
REPR(repr_info_hash)->ass_funcs->bind_key_boxed(tc, STABLE(repr_info_hash),
repr_info_hash, OBJECT_BODY(repr_info_hash), (MVMObject *)str_attribute, repr_info);
/* Compose the representation using it. */
REPR(type_obj)->compose(tc, STABLE(type_obj), repr_info_hash);
/* Clear temporary roots. */
//.........这里部分代码省略.........
开发者ID:bingos,项目名称:MoarVM,代码行数:101,代码来源:bootstrap.c
注:本文中的MVM_ASSIGN_REF函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论