本文整理汇总了C++中ConstantPool类的典型用法代码示例。如果您正苦于以下问题:C++ ConstantPool类的具体用法?C++ ConstantPool怎么用?C++ ConstantPool使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ConstantPool类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: method
bool BytecodePrinter::check_index(int i, int& cp_index, outputStream* st) {
ConstantPool* constants = method()->constants();
int ilimit = constants->length();
Bytecodes::Code code = raw_code();
ConstantPoolCache* cache = NULL;
if (Bytecodes::uses_cp_cache(code)) {
bool okay = true;
switch (code) {
case Bytecodes::_fast_aldc:
case Bytecodes::_fast_aldc_w:
okay = check_obj_index(i, cp_index, st);
break;
case Bytecodes::_invokedynamic:
okay = check_invokedynamic_index(i, cp_index, st);
break;
default:
okay = check_cp_cache_index(i, cp_index, st);
break;
}
if (!okay) return false;
}
// check cp index
if (cp_index >= 0 && cp_index < ilimit) {
if (WizardMode) st->print(" cp[%d]", cp_index);
return true;
}
st->print_cr(" CP[%d] not in CP", cp_index);
return false;
}
示例2: emitConstantPool
static void emitConstantPool(MCStreamer &Streamer, const MCSection *Section,
ConstantPool &CP) {
if (!CP.empty()) {
Streamer.SwitchSection(Section);
CP.emitEntries(Streamer);
}
}
示例3: ConstantPool
void InterpretTest::gcTest()
{
ConstantPool * pool = new ConstantPool();
Class * cls = initClass("GCTest", pool);
const char code[] =
{
PUSH, 0x00, 0x00,
STORE_LOCAL, 0x00,
PUSH, 0x01, 0x00, //label1
LOAD_LOCAL, 0x00,
SUB,
IF_GE, 0x0D,//if(i < 1000)
PUSH, 0x01, 0x00,
NEW_ARRAY,
STORE_LOCAL, 0x01,
LOAD_LOCAL, 0x00,
INC,
STORE_LOCAL, 0x00,
JMP, -21,
RET_VOID
};
Method * m = initMethod("gcTest", code, sizeof(code), 0, 2, 0);
ClassLoader cl("");
Interpret instance(&cl);
IntConst i;
i.value = 0;
pool->addItem(&i, INT_CONST);//0
i.value = 1000;
pool->addItem(&i, INT_CONST);//1
cls->addMethod(m);
cl.addClass(cls);
instance.run(cls->getName().c_str(), m->getName().c_str());
}
示例4: check_uncommon_or_static_method
//interpreteur put fast_invoke_virtual_final not only for
//static methods but also for final methods of Object class!
void check_uncommon_or_static_method(int index JVM_TRAPS) {
ConstantPool cp = method()->constants();
if (!cp.tag_at(index).is_resolved_final_uncommon_interface_method()) {
check_static(index JVM_CHECK);
}
}
示例5: assert
oop Bytecode_loadconstant::resolve_constant(TRAPS) const {
assert(_method.not_null(), "must supply method to resolve constant");
int index = raw_index();
ConstantPool* constants = _method->constants();
if (has_cache_index()) {
return constants->resolve_cached_constant_at(index, THREAD);
} else {
return constants->resolve_constant_at(index, THREAD);
}
}
示例6: switchover_constant_pool
static void switchover_constant_pool(BytecodeConstantPool* bpool,
InstanceKlass* klass, GrowableArray<Method*>* new_methods, TRAPS) {
if (new_methods->length() > 0) {
ConstantPool* cp = bpool->create_constant_pool(CHECK);
if (cp != klass->constants()) {
klass->class_loader_data()->add_to_deallocate_list(klass->constants());
klass->set_constants(cp);
cp->set_pool_holder(klass);
for (int i = 0; i < new_methods->length(); ++i) {
new_methods->at(i)->set_constants(cp);
}
for (int i = 0; i < klass->methods()->length(); ++i) {
Method* mo = klass->methods()->at(i);
mo->set_constants(cp);
}
}
}
}
示例7: create_constant_pool
ConstantPool* BytecodeConstantPool::create_constant_pool(TRAPS) const {
if (_entries.length() == 0) {
return _orig;
}
ConstantPool* cp = ConstantPool::allocate(
_orig->pool_holder()->class_loader_data(),
_orig->length() + _entries.length(), CHECK_NULL);
cp->set_pool_holder(_orig->pool_holder());
_orig->copy_cp_to(1, _orig->length() - 1, cp, 1, CHECK_NULL);
for (int i = 0; i < _entries.length(); ++i) {
BytecodeCPEntry entry = _entries.at(i);
int idx = i + _orig->length();
switch (entry._tag) {
case BytecodeCPEntry::UTF8:
entry._u.utf8->increment_refcount();
cp->symbol_at_put(idx, entry._u.utf8);
break;
case BytecodeCPEntry::KLASS:
cp->unresolved_klass_at_put(
idx, cp->symbol_at(entry._u.klass));
break;
case BytecodeCPEntry::STRING:
cp->unresolved_string_at_put(
idx, cp->symbol_at(entry._u.string));
break;
case BytecodeCPEntry::NAME_AND_TYPE:
cp->name_and_type_at_put(idx,
entry._u.name_and_type.name_index,
entry._u.name_and_type.type_index);
break;
case BytecodeCPEntry::METHODREF:
cp->method_at_put(idx,
entry._u.methodref.class_index,
entry._u.methodref.name_and_type_index);
break;
default:
ShouldNotReachHere();
}
}
return cp;
}
示例8: switch
void BytecodePrinter::print_attributes(int bci, outputStream* st) {
// Show attributes of pre-rewritten codes
Bytecodes::Code code = Bytecodes::java_code(raw_code());
// If the code doesn't have any fields there's nothing to print.
// note this is ==1 because the tableswitch and lookupswitch are
// zero size (for some reason) and we want to print stuff out for them.
if (Bytecodes::length_for(code) == 1) {
st->cr();
return;
}
switch(code) {
// Java specific bytecodes only matter.
case Bytecodes::_bipush:
st->print_cr(" " INT32_FORMAT, get_byte());
break;
case Bytecodes::_sipush:
st->print_cr(" " INT32_FORMAT, get_short());
break;
case Bytecodes::_ldc:
if (Bytecodes::uses_cp_cache(raw_code())) {
print_constant(get_index_u1_cpcache(), st);
} else {
print_constant(get_index_u1(), st);
}
break;
case Bytecodes::_ldc_w:
case Bytecodes::_ldc2_w:
if (Bytecodes::uses_cp_cache(raw_code())) {
print_constant(get_index_u2_cpcache(), st);
} else {
print_constant(get_index_u2(), st);
}
break;
case Bytecodes::_iload:
case Bytecodes::_lload:
case Bytecodes::_fload:
case Bytecodes::_dload:
case Bytecodes::_aload:
case Bytecodes::_istore:
case Bytecodes::_lstore:
case Bytecodes::_fstore:
case Bytecodes::_dstore:
case Bytecodes::_astore:
st->print_cr(" #%d", get_index_special());
break;
case Bytecodes::_iinc:
{ int index = get_index_special();
jint offset = is_wide() ? get_short(): get_byte();
st->print_cr(" #%d " INT32_FORMAT, index, offset);
}
break;
case Bytecodes::_newarray: {
BasicType atype = (BasicType)get_index_u1();
const char* str = type2name(atype);
if (str == NULL || atype == T_OBJECT || atype == T_ARRAY) {
assert(false, "Unidentified basic type");
}
st->print_cr(" %s", str);
}
break;
case Bytecodes::_anewarray: {
int klass_index = get_index_u2();
ConstantPool* constants = method()->constants();
Symbol* name = constants->klass_name_at(klass_index);
st->print_cr(" %s ", name->as_C_string());
}
break;
case Bytecodes::_multianewarray: {
int klass_index = get_index_u2();
int nof_dims = get_index_u1();
ConstantPool* constants = method()->constants();
Symbol* name = constants->klass_name_at(klass_index);
st->print_cr(" %s %d", name->as_C_string(), nof_dims);
}
break;
case Bytecodes::_ifeq:
case Bytecodes::_ifnull:
case Bytecodes::_iflt:
case Bytecodes::_ifle:
case Bytecodes::_ifne:
case Bytecodes::_ifnonnull:
case Bytecodes::_ifgt:
case Bytecodes::_ifge:
case Bytecodes::_if_icmpeq:
case Bytecodes::_if_icmpne:
case Bytecodes::_if_icmplt:
case Bytecodes::_if_icmpgt:
case Bytecodes::_if_icmple:
case Bytecodes::_if_icmpge:
case Bytecodes::_if_acmpeq:
case Bytecodes::_if_acmpne:
case Bytecodes::_goto:
case Bytecodes::_jsr:
st->print_cr(" %d", bci + get_short());
//.........这里部分代码省略.........
示例9: v
Struct_CP_Table::Struct_CP_Table(ConstantPool const &constantPool)
{
CPMaker v(constants);
constantPool.accept(v);
}