// ------------------------------------------------------------------ // ciInstance::field_value_impl ciConstant ciInstance::field_value_impl(BasicType field_btype, int offset) { Handle obj = get_oop(); assert(!obj.is_null(), "bad oop"); switch(field_btype) { case T_BYTE: return ciConstant(field_btype, obj->byte_field(offset)); case T_CHAR: return ciConstant(field_btype, obj->char_field(offset)); case T_SHORT: return ciConstant(field_btype, obj->short_field(offset)); case T_BOOLEAN: return ciConstant(field_btype, obj->bool_field(offset)); case T_INT: return ciConstant(field_btype, obj->int_field(offset)); case T_FLOAT: return ciConstant(obj->float_field(offset)); case T_DOUBLE: return ciConstant(obj->double_field(offset)); case T_LONG: return ciConstant(obj->long_field(offset)); case T_OBJECT: // fall through case T_ARRAY: { oop o = obj->obj_field(offset); // A field will be "constant" if it is known always to be // a non-null reference to an instance of a particular class, // or to a particular array. This can happen even if the instance // or array is not perm. In such a case, an "unloaded" ciArray // or ciInstance is created. The compiler may be able to use // information about the object's class (which is exact) or length. if (o == NULL) { return ciConstant(field_btype, ciNullObject::make()); } else { return ciConstant(field_btype, CURRENT_ENV->get_object(o)); } } } fatal("no field value: %s", type2name(field_btype)); return ciConstant(); }
// ------------------------------------------------------------------ // ciMethodHandle::get_vmtarget // // Return: MH.form -> LF.vmentry -> MN.vmtarget ciMethod* ciMethodHandle::get_vmtarget() const { VM_ENTRY_MARK; oop form_oop = java_lang_invoke_MethodHandle::form(get_oop()); oop vmentry_oop = java_lang_invoke_LambdaForm::vmentry(form_oop); oop vmtarget_oop = java_lang_invoke_MemberName::vmtarget(vmentry_oop); return CURRENT_ENV->get_object(vmtarget_oop)->as_method(); }
// ------------------------------------------------------------------ // ciInstance::field_value // // Constant value of a field. ciConstant ciInstance::field_value(ciField* field) { assert(is_loaded() && field->holder()->is_loaded() && klass()->is_subclass_of(field->holder()), "invalid access"); VM_ENTRY_MARK; ciConstant result; oop obj = get_oop(); assert(obj != NULL, "bad oop"); BasicType field_btype = field->type()->basic_type(); int offset = field->offset(); switch(field_btype) { case T_BYTE: return ciConstant(field_btype, obj->byte_field(offset)); break; case T_CHAR: return ciConstant(field_btype, obj->char_field(offset)); break; case T_SHORT: return ciConstant(field_btype, obj->short_field(offset)); break; case T_BOOLEAN: return ciConstant(field_btype, obj->bool_field(offset)); break; case T_INT: return ciConstant(field_btype, obj->int_field(offset)); break; case T_FLOAT: return ciConstant(obj->float_field(offset)); break; case T_DOUBLE: return ciConstant(obj->double_field(offset)); break; case T_LONG: return ciConstant(obj->long_field(offset)); break; case T_OBJECT: case T_ARRAY: { oop o = obj->obj_field(offset); // A field will be "constant" if it is known always to be // a non-null reference to an instance of a particular class, // or to a particular array. This can happen even if the instance // or array is not perm. In such a case, an "unloaded" ciArray // or ciInstance is created. The compiler may be able to use // information about the object's class (which is exact) or length. if (o == NULL) { return ciConstant(field_btype, ciNullObject::make()); } else { return ciConstant(field_btype, CURRENT_ENV->get_object(o)); } } } ShouldNotReachHere(); // to shut up the compiler return ciConstant(); }
// ------------------------------------------------------------------ // ciKlass::ciKlass ciKlass::ciKlass(KlassHandle h_k) : ciType(h_k) { assert(get_oop()->is_klass(), "wrong type"); Klass* k = get_Klass(); _layout_helper = k->layout_helper(); symbolOop klass_name = k->name(); assert(klass_name != NULL, "wrong ciKlass constructor"); _name = CURRENT_ENV->get_object(klass_name)->as_symbol(); }
// ------------------------------------------------------------------ // ciMethodHandle::get_adapter // // Return an adapter for this MethodHandle. ciMethod* ciMethodHandle::get_adapter(bool is_invokedynamic) const { VM_ENTRY_MARK; Handle h(get_oop()); methodHandle callee(_callee->get_methodOop()); MethodHandleCompiler mhc(h, callee, is_invokedynamic, THREAD); methodHandle m = mhc.compile(CHECK_NULL); return CURRENT_ENV->get_object(m())->as_method(); }
bool evaluator::process_line() { char line[200]; if (!get_line(line)) return false; TokenStream st(line); if (st.eos()) return true; if (st.is_hat()) { st.advance(); dispatchTable::reset(); eval_message(&st); return true; } else { if (st.is_help()) { print_help(); return true; } if (st.is_step()) { dispatchTable::intercept_for_step(); return false; } if (st.is_next()) { dispatchTable::intercept_for_next(saved_frame); return false; } if (st.is_end()) { dispatchTable::intercept_for_return(saved_frame); return false; } if (st.is_cont()) { dispatchTable::reset(); return false; } if (st.is_stack()) { DeltaProcess::active()->trace_stack(); return true; } if (st.is_quit()) { os::fatalExit(0); return true; } if (st.is_break()) { fatal("evaluator break"); return true; } if (st.is_events()) { eventLog->print(); return true; } if (st.is_top()) { top_command(&st); return true; } if (st.is_show()) { show_command(&st); return true; } if (st.is_plus()) { change_debug_flag(&st, true); return true; } if (st.is_minus()) { change_debug_flag(&st, false); return true; } if (st.is_status()) { print_status(); return true; } if (st.is_abort()) { if (DeltaProcess::active()->is_scheduler()) { std->print_cr("You cannot abort in the scheduler"); std->print_cr("Try another command"); } else { dispatchTable::reset(); is_aborting = true; return false; } } if (st.is_genesis()) { dispatchTable::reset(); VM_Genesis op; VMProcess::execute(&op); return false; } oop receiver; if (get_oop(&st, &receiver)) { st.advance(); if (!st.eos()) { std->print_cr("warning: garbage at end"); } receiver->print(); std->cr(); return true; } } print_mini_help(); return true; }
// ------------------------------------------------------------------ // ciMethodHandle::get_vmtarget // // Return: MH.form -> LF.vmentry -> MN.vmtarget ciMethod* ciMethodHandle::get_vmtarget() const { VM_ENTRY_MARK; oop form_oop = java_lang_invoke_MethodHandle::form(get_oop()); oop vmentry_oop = java_lang_invoke_LambdaForm::vmentry(form_oop); // FIXME: Share code with ciMemberName::get_vmtarget Metadata* vmtarget = java_lang_invoke_MemberName::vmtarget(vmentry_oop); if (vmtarget->is_method()) return CURRENT_ENV->get_method((Method*) vmtarget); // FIXME: What if the vmtarget is a Klass? assert(false, ""); return NULL; }
void evaluator::eval_message(TokenStream* st) { oop receiver; oop result = nilObj; symbolOop selector; if (st->eos()) return; if (!get_oop(st, &receiver)) return; if (st->eos()) { receiver->print(); } else if (st->is_unary()) { symbolOop selector = oopFactory::new_symbol(st->current()); if (!validate_lookup(receiver, selector)) return; result = Delta::call(receiver, selector); } else if (st->is_binary()) { selector = oopFactory::new_symbol(st->current()); if (!validate_lookup(receiver, selector)) return; oop argument; st->advance(); if (!get_oop(st, &argument)) return; result = Delta::call(receiver, selector, argument); } else if (st->is_keyword()) { char name[100]; oop arguments[10]; int nofArgs = 0; name[0] = '\0'; while (!st->eos()) { strcat(name, st->current()); st->advance(); oop arg; if (!get_oop(st, &arg)) return; arguments[nofArgs++] = arg; } selector = oopFactory::new_symbol(name); if (!validate_lookup(receiver, selector)) return; static DeltaCallCache cache; result = Delta::call_generic(&cache, receiver, selector, nofArgs, arguments); } result->print_value(); std->cr(); }
// ------------------------------------------------------------------ // ciObject::klass // // Get the ciKlass of this ciObject. ciKlass* ciObject::klass() { if (_klass == NULL) { if (_handle == NULL) { // When both _klass and _handle are NULL, we are dealing // with the distinguished instance of ciNullObject. // No one should ask it for its klass. assert(is_null_object(), "must be null object"); ShouldNotReachHere(); return NULL; } GUARDED_VM_ENTRY( oop o = get_oop(); _klass = CURRENT_ENV->get_object(o->klass())->as_klass(); ); }
// ------------------------------------------------------------------ // ciObject::java_mirror_type ciType* ciInstance::java_mirror_type() { VM_ENTRY_MARK; oop m = get_oop(); // Return NULL if it is not java.lang.Class. if (m == NULL || m->klass() != SystemDictionary::class_klass()) { return NULL; } // Return either a primitive type or a klass. if (java_lang_Class::is_primitive(m)) { return ciType::make(java_lang_Class::primitive_type(m)); } else { klassOop k = java_lang_Class::as_klassOop(m); assert(k != NULL, ""); return CURRENT_THREAD_ENV->get_object(k)->as_klass(); } }
arrayOop get_arrayOop() { return (arrayOop)get_oop(); }
klassOop get_klassOop() const { klassOop k = (klassOop)get_oop(); assert(k != NULL, "illegal use of unloaded klass"); return k; }
symbolOop get_symbolOop() { return (symbolOop)get_oop(); }
ciKlass* ciInstance::java_lang_Class_klass() { VM_ENTRY_MARK; return CURRENT_ENV->get_object(java_lang_Class::as_klassOop(get_oop()))->as_klass(); }
ciKlass* ciInstance::java_lang_Class_klass() { VM_ENTRY_MARK; return CURRENT_ENV->get_metadata(java_lang_Class::as_Klass(get_oop()))->as_klass(); }
arrayOop get_arrayOop() const { return (arrayOop)get_oop(); }
instanceOop get_instanceOop() { return (instanceOop)get_oop(); }
methodOop get_method_handle_target() { klassOop receiver_limit_oop = NULL; int flags = 0; return MethodHandles::decode_method(get_oop(), receiver_limit_oop, flags); }
// ------------------------------------------------------------------ // ciMethodHandle::print_impl // // Implementation of the print method. void ciMethodHandle::print_impl(outputStream* st) { st->print(" type="); get_oop()->print(); }
constantPoolCacheOop get_cpCacheOop() { // must be called inside a VM_ENTRY_MARK return (constantPoolCacheOop) get_oop(); }
// ------------------------------------------------------------------ // ciKlass::ciKlass // // Nameless klass variant. ciKlass::ciKlass(KlassHandle h_k, ciSymbol* name) : ciType(h_k) { assert(get_oop()->is_klass(), "wrong type"); _name = name; _layout_helper = Klass::_lh_neutral_value; }
methodOop get_method_handle_target() { KlassHandle receiver_limit; int flags = 0; methodHandle m = MethodHandles::decode_method(get_oop(), receiver_limit, flags); return m(); }
methodOop get_methodOop() const { methodOop m = (methodOop)get_oop(); assert(m != NULL, "illegal use of unloaded method"); return m; }
// ------------------------------------------------------------------ // ciCallSite::get_target // // Return the target MethodHandle of this CallSite. ciMethodHandle* ciCallSite::get_target() const { VM_ENTRY_MARK; oop method_handle_oop = java_dyn_CallSite::target(get_oop()); return CURRENT_ENV->get_object(method_handle_oop)->as_method_handle(); }