本文整理汇总了C++中VMMethod类的典型用法代码示例。如果您正苦于以下问题:C++ VMMethod类的具体用法?C++ VMMethod怎么用?C++ VMMethod使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了VMMethod类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: test_set_breakpoint_flags
void test_set_breakpoint_flags() {
CompiledMethod* cm = CompiledMethod::create(state);
Tuple* tup = Tuple::from(state, 1, state->symbol("@blah"));
cm->literals(state, tup);
InstructionSequence* iseq = InstructionSequence::create(state, 3);
iseq->opcodes()->put(state, 0, Fixnum::from(InstructionSequence::insn_push_ivar));
iseq->opcodes()->put(state, 1, Fixnum::from(0));
iseq->opcodes()->put(state, 2, Fixnum::from(InstructionSequence::insn_push_nil));
cm->iseq(state, iseq);
VMMethod* vmm = new VMMethod(state, cm);
vmm->set_breakpoint_flags(state, 0, 1 << 24);
TS_ASSERT_EQUALS(vmm->opcodes[0], (1U << 24) | static_cast<unsigned int>(InstructionSequence::insn_push_ivar));
vmm->set_breakpoint_flags(state, 0, 7 << 24);
TS_ASSERT_EQUALS(vmm->opcodes[0], (7U << 24) | static_cast<unsigned int>(InstructionSequence::insn_push_ivar));
vmm->set_breakpoint_flags(state, 0, 0);
TS_ASSERT_EQUALS(vmm->opcodes[0], static_cast<unsigned int>(InstructionSequence::insn_push_ivar));
vmm->set_breakpoint_flags(state, 1, 1);
TS_ASSERT_EQUALS(vmm->opcodes[1], 0U);
}
开发者ID:jefflembeck,项目名称:rubinius,代码行数:26,代码来源:test_vmmethod.hpp
示例2: test_specialize_transforms_ivars_to_slots
void test_specialize_transforms_ivars_to_slots() {
CompiledMethod* cm = CompiledMethod::create(state);
Tuple* tup = Tuple::from(state, 1, state->symbol("@blah"));
cm->literals(state, tup);
InstructionSequence* iseq = InstructionSequence::create(state, 3);
iseq->opcodes()->put(state, 0, Fixnum::from(InstructionSequence::insn_push_ivar));
iseq->opcodes()->put(state, 1, Fixnum::from(0));
iseq->opcodes()->put(state, 2, Fixnum::from(InstructionSequence::insn_push_nil));
cm->iseq(state, iseq);
VMMethod* vmm = new VMMethod(state, cm);
Object::Info ti(ObjectType);
ti.slots[state->symbol("@blah")->index()] = 5;
ti.slot_locations.resize(6);
ti.slot_locations[5] = 33;
vmm->specialize(state, cm, &ti);
TS_ASSERT_EQUALS(vmm->total, 3U);
TS_ASSERT_EQUALS(vmm->opcodes[0], static_cast<unsigned int>(InstructionSequence::insn_push_my_offset));
TS_ASSERT_EQUALS(vmm->opcodes[1], 33U);
TS_ASSERT_EQUALS(vmm->opcodes[2], static_cast<unsigned int>(InstructionSequence::insn_push_nil));
}
开发者ID:jefflembeck,项目名称:rubinius,代码行数:25,代码来源:test_vmmethod.hpp
示例3: auto_mark
void CompiledMethod::Info::mark(Object* obj, ObjectMark& mark) {
auto_mark(obj, mark);
mark_inliners(obj, mark);
CompiledMethod* cm = as<CompiledMethod>(obj);
if(!cm->backend_method_) return;
VMMethod* vmm = cm->backend_method_;
vmm->set_mark();
Object* tmp;
#ifdef ENABLE_LLVM
if(cm->jit_data()) {
cm->jit_data()->set_mark();
cm->jit_data()->mark_all(cm, mark);
}
for(int i = 0; i < VMMethod::cMaxSpecializations; i++) {
if(vmm->specializations[i].jit_data) {
vmm->specializations[i].jit_data->set_mark();
vmm->specializations[i].jit_data->mark_all(cm, mark);
}
}
#endif
for(size_t i = 0; i < vmm->inline_cache_count(); i++) {
InlineCache* cache = &vmm->caches[i];
MethodCacheEntry* mce = cache->cache_;
if(mce) {
tmp = mark.call(mce);
if(tmp) {
cache->cache_ = (MethodCacheEntry*)tmp;
mark.just_set(obj, tmp);
}
}
if(cache->call_unit_) {
tmp = mark.call(cache->call_unit_);
if(tmp) {
cache->call_unit_ = (CallUnit*)tmp;
mark.just_set(obj, tmp);
}
}
for(int i = 0; i < cTrackedICHits; i++) {
Module* mod = cache->seen_classes_[i].klass();
if(mod) {
tmp = mark.call(mod);
if(tmp) {
cache->seen_classes_[i].set_klass(force_as<Class>(tmp));
mark.just_set(obj, tmp);
}
}
}
}
}
开发者ID:Gonzih,项目名称:rubinius,代码行数:60,代码来源:compiledmethod.cpp
示例4: GetFrame
void Interpreter::doSuperSend(long bytecodeIndex) {
VMSymbol* signature = static_cast<VMSymbol*>(method->GetConstant(bytecodeIndex));
VMFrame* ctxt = GetFrame()->GetOuterContext();
VMMethod* realMethod = ctxt->GetMethod();
VMClass* holder = realMethod->GetHolder();
VMClass* super = holder->GetSuperClass();
VMInvokable* invokable = static_cast<VMInvokable*>(super->LookupInvokable(signature));
if (invokable != nullptr)
(*invokable)(GetFrame());
else {
long numOfArgs = Signature::GetNumberOfArguments(signature);
vm_oop_t receiver = GetFrame()->GetStackElement(numOfArgs - 1);
VMArray* argumentsArray = GetUniverse()->NewArray(numOfArgs);
for (long i = numOfArgs - 1; i >= 0; --i) {
vm_oop_t o = GetFrame()->Pop();
argumentsArray->SetIndexableField(i, o);
}
vm_oop_t arguments[] = {signature, argumentsArray};
AS_OBJ(receiver)->Send(doesNotUnderstand, arguments, 2);
}
}
开发者ID:jdegeete,项目名称:SOMpp,代码行数:25,代码来源:Interpreter.cpp
示例5: auto_visit
void CompiledMethod::Info::visit(Object* obj, ObjectVisitor& visit) {
auto_visit(obj, visit);
visit_inliners(obj, visit);
CompiledMethod* cm = as<CompiledMethod>(obj);
if(!cm->backend_method_) return;
VMMethod* vmm = cm->backend_method_;
#ifdef ENABLE_LLVM
if(cm->jit_data()) {
cm->jit_data()->visit_all(visit);
}
for(int i = 0; i < VMMethod::cMaxSpecializations; i++) {
if(vmm->specializations[i].jit_data) {
vmm->specializations[i].jit_data->visit_all(visit);
}
}
#endif
for(size_t i = 0; i < vmm->inline_cache_count(); i++) {
InlineCache* cache = &vmm->caches[i];
MethodCacheEntry* mce = cache->cache_;
if(mce) visit.call(mce);
for(int i = 0; i < cTrackedICHits; i++) {
Module* mod = cache->seen_classes_[i].klass();
if(mod) visit.call(mod);
}
}
}
开发者ID:Gonzih,项目名称:rubinius,代码行数:34,代码来源:compiledmethod.cpp
示例6: add_specialized
void CompiledMethod::add_specialized(int spec_id, executor exec,
jit::RuntimeDataHolder* rd)
{
if(!backend_method_) rubinius::bug("specializing with no backend");
VMMethod* v = backend_method_;
// Must happen only on the first specialization
if(!v->unspecialized) {
if(execute == specialized_executor) {
rubinius::bug("cant setup unspecialized from specialized");
}
v->unspecialized = execute;
}
for(int i = 0; i < VMMethod::cMaxSpecializations; i++) {
int id = v->specializations[i].class_id;
if(id == 0 || id == spec_id) {
v->specializations[i].class_id = spec_id;
v->specializations[i].execute = exec;
v->specializations[i].jit_data = rd;
v->set_execute_status(VMMethod::eJIT);
execute = specialized_executor;
return;
}
}
// No room for the specialization, this is bad.
std::cerr << "No room for specialization!\n";
}
开发者ID:Gonzih,项目名称:rubinius,代码行数:32,代码来源:compiledmethod.cpp
示例7: popFrame
void Interpreter::popFrameAndPushResult(vm_oop_t result) {
VMFrame* prevFrame = popFrame();
VMMethod* method = prevFrame->GetMethod();
long numberOfArgs = method->GetNumberOfArguments();
for (long i = 0; i < numberOfArgs; ++i) GetFrame()->Pop();
GetFrame()->Push(result);
}
开发者ID:jdegeete,项目名称:SOMpp,代码行数:10,代码来源:Interpreter.cpp
示例8: TR_USE
VMClass* BootstrapLoader::find(VMContext* ctx, const std::string& name, bool initClass){
TR_USE(Java_Loader);
std::map<std::string,VMClass*>::iterator iter = mUninitializedClasses.find(name);
if (iter != mUninitializedClasses.end()){
VMClass* cls = iter->second;
mUninitializedClasses.erase(iter);
mClasses[name] = cls;
//delayed class init
unsigned idx = cls->findMethodIndex("<clinit>", "()V");
VMMethod* mthd = cls->getMethod(idx);
if (mthd){
TR_INFO("Delayed execution of class init method");
mthd->execute(ctx, -1);
}
return cls;
}
VMClass* entry = mClasses[name];
if (entry == 0){
//array functions
if (name[0] == '['){
entry = new VMArrayClass(this, name);
mClasses[name] = entry;
return entry;
}
else if (name.size() == 1){
//primitive types
return getPrimitiveClass(ctx, name);
}
//Java::ClassFile* clfile = new Java::ClassFile();
CGE::Reader* rdr = filenameToReader(name);
if (!rdr)
return NULL;
entry = new VMClass(ctx, this, *rdr);
delete rdr;
if (ctx->getException() != NULL){
delete entry;
return NULL;
}
if (!initClass)
mUninitializedClasses[name] = entry;
else
mClasses[name] = entry;
entry->initClass(ctx, initClass);
}
return entry;
}
开发者ID:captain-mayhem,项目名称:captainsengine,代码行数:49,代码来源:VMLoader.cpp
示例9: GetUniverse
void CloneObjectsTest::testCloneBlock() {
VMSymbol* methodSymbol = GetUniverse()->NewSymbol("someMethod");
VMMethod* method = GetUniverse()->NewMethod(methodSymbol, 0, 0);
VMBlock* orig = GetUniverse()->NewBlock(method,
GetUniverse()->GetInterpreter()->GetFrame(),
method->GetNumberOfArguments());
VMBlock* clone = orig->Clone();
CPPUNIT_ASSERT((intptr_t)orig != (intptr_t)clone);
CPPUNIT_ASSERT_EQUAL_MESSAGE("class differs!!", orig->clazz, clone->clazz);
CPPUNIT_ASSERT_EQUAL_MESSAGE("objectSize differs!!", orig->objectSize, clone->objectSize);
CPPUNIT_ASSERT_EQUAL_MESSAGE("numberOfFields differs!!", orig->numberOfFields, clone->numberOfFields);
CPPUNIT_ASSERT_EQUAL_MESSAGE("blockMethod differs!!", orig->blockMethod, clone->blockMethod);
CPPUNIT_ASSERT_EQUAL_MESSAGE("context differs!!", orig->context, clone->context);
}
开发者ID:SOM-st,项目名称:SOMpp,代码行数:15,代码来源:CloneObjectsTest.cpp
示例10: assert
bool N3ModuleProvider::Materialize(GlobalValue *GV, std::string *ErrInfo) {
Function* F = dyn_cast<Function>(GV);
assert(F && "Not a function.");
if (F->getLinkage() == GlobalValue::ExternalLinkage) return false;
if (!F->empty()) return false;
VMMethod* meth = functions->lookup(F);
if (!meth) {
// VT methods
return false;
} else {
meth->compileToNative();
return false;
}
}
开发者ID:chanwit,项目名称:vmkit,代码行数:15,代码来源:N3ModuleProvider.cpp
示例11: while
CallFrame* LLVMState::find_candidate(CompiledMethod* start, CallFrame* call_frame) {
if(!config_.jit_inline_generic) {
return call_frame;
}
int depth = cInlineMaxDepth;
if(!start) {
start = call_frame->cm;
call_frame = call_frame->previous;
depth--;
}
if(!call_frame || start->backend_method()->total > SMALL_METHOD_SIZE) {
return call_frame;
}
CallFrame* caller = call_frame;
while(depth-- > 0) {
CompiledMethod* cur = call_frame->cm;
VMMethod* vmm = cur->backend_method();
/*
if(call_frame->block_p()
|| vmm->required_args != vmm->total_args // has a splat
|| vmm->call_count < 200 // not called much
|| vmm->jitted() // already jitted
|| vmm->parent() // is a block
) return caller;
*/
if(vmm->required_args != vmm->total_args // has a splat
|| vmm->call_count < 200 // not called much
|| vmm->jitted() // already jitted
|| !vmm->no_inline_p() // method marked as not inlinable
) return caller;
CallFrame* next = call_frame->previous;
if(!next|| cur->backend_method()->total > SMALL_METHOD_SIZE) return call_frame;
caller = call_frame;
call_frame = next;
}
return caller;
}
开发者ID:FunkyFortune,项目名称:rubinius,代码行数:48,代码来源:jit.cpp
示例12: InvokeOn_With_
void _Method::InvokeOn_With_(Interpreter* interp, VMFrame* frame) {
// REM: this is a clone with _Primitive::InvokeOn_With_
VMArray* args = static_cast<VMArray*>(frame->Pop());
vm_oop_t rcvr = static_cast<vm_oop_t>(frame->Pop());
VMMethod* mthd = static_cast<VMMethod*>(frame->Pop());
frame->Push(rcvr);
size_t num_args = args->GetNumberOfIndexableFields();
for (size_t i = 0; i < num_args; i++) {
vm_oop_t arg = args->GetIndexableField(i);
frame->Push(arg);
}
mthd->Invoke(interp, frame);
}
开发者ID:SOM-st,项目名称:SOMpp,代码行数:16,代码来源:Method.cpp
示例13: mapInitialThread
static void mapInitialThread(N3* vm) {
VMClass* cl = (VMClass*)vm->coreAssembly->loadTypeFromName(
vm->asciizToUTF8("Thread"),
vm->asciizToUTF8("System.Threading"),
true, true, true, true);
declare_gcroot(VMObject*, appThread) = cl->doNew();
std::vector<VMCommonClass*> args;
args.push_back(MSCorlib::pVoid);
args.push_back(cl);
args.push_back(MSCorlib::pIntPtr);
VMMethod* ctor = cl->lookupMethod(vm->asciizToUTF8(".ctor"), args,
false, false);
VMThread* myth = VMThread::get();
ctor->compileToNative()->invokeVoid(appThread, myth);
myth->ooo_appThread = appThread;
}
开发者ID:chanwit,项目名称:vmkit,代码行数:17,代码来源:PNetMSCorlib.cpp
示例14: test_validate_ip
void test_validate_ip() {
CompiledMethod* cm = CompiledMethod::create(state);
Tuple* tup = Tuple::from(state, 1, state->symbol("@blah"));
cm->literals(state, tup);
InstructionSequence* iseq = InstructionSequence::create(state, 3);
iseq->opcodes()->put(state, 0, Fixnum::from(InstructionSequence::insn_push_ivar));
iseq->opcodes()->put(state, 1, Fixnum::from(0));
iseq->opcodes()->put(state, 2, Fixnum::from(InstructionSequence::insn_push_nil));
cm->iseq(state, iseq);
VMMethod* vmm = new VMMethod(state, cm);
TS_ASSERT_EQUALS(vmm->validate_ip(state, 0), true);
TS_ASSERT_EQUALS(vmm->validate_ip(state, 1), false);
TS_ASSERT_EQUALS(vmm->validate_ip(state, 2), true);
}
开发者ID:jefflembeck,项目名称:rubinius,代码行数:17,代码来源:test_vmmethod.hpp
示例15: os
VMMethod* CompiledMethod::internalize(STATE, GCToken gct,
const char** reason, int* ip)
{
VMMethod* vmm = backend_method_;
atomic::memory_barrier();
if(vmm) return vmm;
CompiledMethod* self = this;
OnStack<1> os(state, self);
self->hard_lock(state, gct);
vmm = self->backend_method_;
if(!vmm) {
{
BytecodeVerification bv(self);
if(!bv.verify(state)) {
if(reason) *reason = bv.failure_reason();
if(ip) *ip = bv.failure_ip();
std::cerr << "Error validating bytecode: " << bv.failure_reason() << "\n";
return 0;
}
}
vmm = new VMMethod(state, self);
if(self->resolve_primitive(state)) {
vmm->fallback = execute;
} else {
vmm->setup_argument_handler(self);
}
// We need to have an explicit memory barrier here, because we need to
// be sure that vmm is completely initialized before it's set.
// Otherwise another thread might see a partially initialized
// VMMethod.
atomic::memory_barrier();
backend_method_ = vmm;
}
self->hard_unlock(state, gct);
return vmm;
}
开发者ID:Gonzih,项目名称:rubinius,代码行数:45,代码来源:compiledmethod.cpp
示例16: test_get_breakpoint_flags
void test_get_breakpoint_flags() {
CompiledMethod* cm = CompiledMethod::create(state);
Tuple* tup = Tuple::from(state, 1, state->symbol("@blah"));
cm->literals(state, tup);
InstructionSequence* iseq = InstructionSequence::create(state, 3);
iseq->opcodes()->put(state, 0, Fixnum::from(InstructionSequence::insn_push_ivar));
iseq->opcodes()->put(state, 1, Fixnum::from(0));
iseq->opcodes()->put(state, 2, Fixnum::from(4 << 24 | InstructionSequence::insn_push_nil));
cm->iseq(state, iseq);
VMMethod* vmm = new VMMethod(state, cm);
TS_ASSERT_EQUALS(vmm->get_breakpoint_flags(state, 0), 0U);
TS_ASSERT_EQUALS(vmm->get_breakpoint_flags(state, 2), (4U << 24));
TS_ASSERT_EQUALS(vmm->get_breakpoint_flags(state, 1), 0U);
}
开发者ID:jefflembeck,项目名称:rubinius,代码行数:18,代码来源:test_vmmethod.hpp
示例17: VMClass
VMClass* BootstrapLoader::getPrimitiveClass(VMContext* ctx, std::string name){
VMClass* entry = mClasses[name];
if (entry == 0){
entry = new VMClass(this);
entry->setName(name);
mClasses[name] = entry;
//entry->print(std::cout);
//entry->initFields(ctx);
VMClass* cls = find(ctx, "java/lang/Class");
VMMethod* clsmthd = cls->getMethod(cls->findMethodIndex("<init>", "()V"));
entry->init(ctx, cls);
ctx->push((VMObject*)cls);
clsmthd->execute(ctx, -1);
}
return entry;
}
开发者ID:captain-mayhem,项目名称:captainsengine,代码行数:19,代码来源:VMLoader.cpp
示例18: invoke
Object* BlockEnvironment::invoke(STATE, CallFrame* previous,
BlockEnvironment* const env, Arguments& args,
BlockInvocation& invocation)
{
#ifdef ENABLE_LLVM
VMMethod* vmm = env->vmmethod(state);
if(!vmm) {
Exception::internal_error(state, previous, "invalid bytecode method");
return 0;
}
if(void* ptr = vmm->native_function()) {
return (*((BlockExecutor)ptr))(state, previous, env, args, invocation);
}
#endif
return execute_interpreter(state, previous, env, args, invocation);
}
开发者ID:BRIMIL01,项目名称:rubinius,代码行数:19,代码来源:block_environment.cpp
示例19: under_call_frame
BlockEnvironment* BlockEnvironment::under_call_frame(STATE, CompiledMethod* cm,
VMMethod* caller, CallFrame* call_frame, size_t index)
{
BlockEnvironment* be = state->new_object<BlockEnvironment>(G(blokenv));
VMMethod* vmm = cm->internalize(state);
if(!vmm) {
Exception::internal_error(state, call_frame, "invalid bytecode method");
return 0;
}
vmm->set_parent(caller);
be->scope(state, call_frame->promote_scope(state));
be->top_scope(state, call_frame->top_scope(state));
be->code(state, cm);
be->module(state, call_frame->module());
return be;
}
开发者ID:BRIMIL01,项目名称:rubinius,代码行数:19,代码来源:block_environment.cpp
示例20: load_ptr
void Interpreter::doPushBlock(long bytecodeIndex) {
// Short cut the negative case of #ifTrue: and #ifFalse:
if (currentBytecodes[bytecodeIndexGlobal] == BC_SEND) {
if (GetFrame()->GetStackElement(0) == load_ptr(falseObject) &&
method->GetConstant(bytecodeIndexGlobal) == load_ptr(symbolIfTrue)) {
GetFrame()->Push(load_ptr(nilObject));
return;
} else if (GetFrame()->GetStackElement(0) == load_ptr(trueObject) &&
method->GetConstant(bytecodeIndexGlobal) == load_ptr(symbolIfFalse)) {
GetFrame()->Push(load_ptr(nilObject));
return;
}
}
VMMethod* blockMethod = static_cast<VMMethod*>(method->GetConstant(bytecodeIndex));
long numOfArgs = blockMethod->GetNumberOfArguments();
GetFrame()->Push(GetUniverse()->NewBlock(blockMethod, GetFrame(), numOfArgs));
}
开发者ID:jdegeete,项目名称:SOMpp,代码行数:20,代码来源:Interpreter.cpp
注:本文中的VMMethod类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论