bool DictionaryEntry::contains_protection_domain(oop protection_domain) const { #ifdef ASSERT if(protection_domain==instanceKlass::cast(klass().as_klassOop())->protection_domain()){ // Ensure this doesn't show up in the pd_set (invariant) bool in_pd_set = false; for (ProtectionDomainEntry* current = _pd_set; current != NULL; current = current->next()) { if(current->protection_domain().as_oop()==protection_domain){ in_pd_set = true; break; } } if (in_pd_set) { assert(false, "A klass's protection domain should not show up " "in its sys. dict. PD set"); } } #endif /* ASSERT */ if (protection_domain == instanceKlass::cast(klass().as_klassOop())->protection_domain()) { // Succeeds trivially return true; } for (ProtectionDomainEntry* current = _pd_set; current != NULL; current = current->next()) { if(current->protection_domain().as_oop()==protection_domain)return true; } return false; }
void ObjectHeader::initialize_copy(STATE, Object* other) { klass(other->klass()); ivars(other->ivars()); state->shared().om->write_barrier(this, klass()); state->shared().om->write_barrier(this, ivars()); }
void test() { int A1[3]; int A2[3]; klass().foo1(A1); klass().foo2(A1, A2); }
ciType* CheckCast::exact_type() const { if (klass()->is_instance_klass()) { ciInstanceKlass* ik = (ciInstanceKlass*)klass(); if (ik->is_loaded() && ik->is_final()) { return ik; } } return NULL; }
inline void oopDesc::update_contents(ParCompactionManager* cm) { // The klass field must be updated before anything else // can be done. DEBUG_ONLY(Klass* original_klass = klass()); Klass* new_klass = klass(); if (!new_klass->oop_is_typeArray()) { // It might contain oops beyond the header, so take the virtual call. new_klass->oop_update_pointers(cm, this); } // Else skip it. The TypeArrayKlass in the header never needs scavenging. }
bool VerificationType::is_reference_assignable_from( const VerificationType& from, ClassVerifier* context, bool from_field_is_protected, TRAPS) const { instanceKlassHandle klass = context->current_class(); if (from.is_null()) { // null is assignable to any reference return true; } else if (is_null()) { return false; } else if (name() == from.name()) { return true; } else if (is_object()) { // We need check the class hierarchy to check assignability if (name() == vmSymbols::java_lang_Object()) { // any object or array is assignable to java.lang.Object return true; } Klass* obj = SystemDictionary::resolve_or_fail( name(), Handle(THREAD, klass->class_loader()), Handle(THREAD, klass->protection_domain()), true, CHECK_false); if (TraceClassResolution) { Verifier::trace_class_resolution(obj, klass()); } KlassHandle this_class(THREAD, obj); if (this_class->is_interface() && (!from_field_is_protected || from.name() != vmSymbols::java_lang_Object())) { // If we are not trying to access a protected field or method in // java.lang.Object then we treat interfaces as java.lang.Object, // including java.lang.Cloneable and java.io.Serializable. return true; } else if (from.is_object()) { Klass* from_class = SystemDictionary::resolve_or_fail( from.name(), Handle(THREAD, klass->class_loader()), Handle(THREAD, klass->protection_domain()), true, CHECK_false); if (TraceClassResolution) { Verifier::trace_class_resolution(from_class, klass()); } return InstanceKlass::cast(from_class)->is_subclass_of(this_class()); } } else if (is_array() && from.is_array()) { VerificationType comp_this = get_component(context, CHECK_false); VerificationType comp_from = from.get_component(context, CHECK_false); if (!comp_this.is_bogus() && !comp_from.is_bogus()) { return comp_this.is_component_assignable_from(comp_from, context, from_field_is_protected, CHECK_false); } } return false; }
void NearClass::print_value_on(Stream* st) { #if USE_DEBUG_PRINTING // This is called for both Java Near classes and for generic near classes const char *super_type; switch(instance_size().value()) { case InstanceSize::size_java_near: { FarClass parent = klass(); if (parent.equals(Universe::type_array_class_class())) { super_type = "TypeArray"; } else if (parent.equals(Universe::obj_array_class_class())) { super_type = "ObjArray"; } else if (parent.equals(Universe::instance_class_class())) { super_type = "Instance"; } else { super_type = "??Java??"; } break; } case InstanceSize::size_generic_near: super_type = "Generic"; break; case InstanceSize::size_obj_near: // for methods super_type = "Object"; break; default: super_type = "??"; break; } st->print("The %s NearClass ", super_type); #endif }
// ------------------------------------------------------------------ // ciInstance::field_value // // Constant value of a field. ciConstant ciInstance::field_value(ciField* field) { assert(is_loaded(), "invalid access - must be loaded"); assert(field->holder()->is_loaded(), "invalid access - holder must be loaded"); assert(field->is_static() || klass()->is_subclass_of(field->holder()), "invalid access - must be subclass"); GUARDED_VM_ENTRY(return field_value_impl(field->type()->basic_type(), field->offset());) }
//-------------------------------------------------------------- void ofApp::setup(){ python.init(); python.executeScript("mytest.py"); ofxPythonObject klass = python.getObject("myApp"); if(klass) script = klass(); }
void oopDesc::print_on(outputStream* st) const { if (this == NULL) { st->print_cr("NULL"); } else { klass()->oop_print_on(oop(this), st); } }
// ------------------------------------------------------------------ // 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(); }
// Note, doesn't append a cr void PlaceholderEntry::print() const { klass()->print_value(); if (loader() != NULL) { tty->print(", loader "); loader()->print_value(); } if (supername() != NULL) { tty->print(", supername "); supername()->print_value(); } if (definer() != NULL) { tty->print(", definer "); definer()->print_value(); } if (instanceKlass() != NULL) { tty->print(", instanceKlass "); instanceKlass()->print_value(); } tty->print("\n"); tty->print("loadInstanceThreadQ threads:"); loadInstanceThreadQ()->printActionQ(); tty->print("\n"); tty->print("superThreadQ threads:"); superThreadQ()->printActionQ(); tty->print("\n"); tty->print("defineThreadQ threads:"); defineThreadQ()->printActionQ(); tty->print("\n"); }
inline Class* Object::direct_class(STATE) const { if(reference_p()) { return klass(); } return state->globals().special_classes[((uintptr_t)this) & SPECIAL_CLASS_MASK].get(); }
void parseIDL(const char* idlFilePath, fbvector<PhpFunc>& funcVec, fbvector<PhpClass>& classVec, fbvector<PhpConst>& constVec, fbvector<PhpExtension>& extVec) { std::ostringstream jsonString; std::ifstream infile(idlFilePath); infile >> jsonString.rdbuf(); auto parsed = folly::parseJson(jsonString.str()); for (auto const& f : parsed["funcs"]) { PhpFunc func(f, ""); funcVec.push_back(func); } for (auto const& c : parsed["classes"]) { PhpClass klass(c); classVec.push_back(klass); } for (auto const& c : parsed["consts"]) { PhpConst cns(c); constVec.push_back(cns); } auto it = parsed.find("extension"); if (it != parsed.items().end()) { PhpExtension ext(it->second); extVec.push_back(ext); } }
// ------------------------------------------------------------------ // ciInstance::field_value_by_offset // // Constant value of a field at the specified offset. ciConstant ciInstance::field_value_by_offset(int field_offset) { ciInstanceKlass* ik = klass()->as_instance_klass(); ciField* field = ik->get_field_by_offset(field_offset, false); if (field == NULL) return ciConstant(); // T_ILLEGAL return field_value(field); }
// Creates an exception oop, calls the <init> method with the given signature. // and returns a Handle // Initializes the cause if cause non-null Handle Exceptions::new_exception(Thread *thread, symbolHandle h_name, symbolHandle signature, JavaCallArguments *args, Handle h_cause, Handle h_loader, Handle h_protection_domain) { assert(Universe::is_fully_initialized(), "cannot be called during initialization"); assert(thread->is_Java_thread(), "can only be called by a Java thread"); assert(!thread->has_pending_exception(), "already has exception"); Handle h_exception; // Resolve exception klass klassOop ik = SystemDictionary::resolve_or_fail(h_name, h_loader, h_protection_domain, true, thread); instanceKlassHandle klass (thread, ik); if (!thread->has_pending_exception()) { assert(klass.not_null(), "klass must exist"); // We are about to create an instance - so make sure that klass is initialized klass->initialize(thread); if (!thread->has_pending_exception()) { // Allocate new exception h_exception = klass->allocate_instance_handle(thread); if (!thread->has_pending_exception()) { JavaValue result(T_VOID); args->set_receiver(h_exception); // Call constructor JavaCalls::call_special(&result, klass, vmSymbolHandles::object_initializer_name(), signature, args, thread); } } // Future: object initializer should take a cause argument if (h_cause() != NULL) { assert(h_cause->is_a(SystemDictionary::Throwable_klass()), "exception cause is not a subclass of java/lang/Throwable"); JavaValue result1(T_OBJECT); JavaCallArguments args1; args1.set_receiver(h_exception); args1.push_oop(h_cause); JavaCalls::call_virtual(&result1, klass, vmSymbolHandles::initCause_name(), vmSymbolHandles::throwable_throwable_signature(), &args1, thread); } } // Check if another exception was thrown in the process, if so rethrow that one if (thread->has_pending_exception()) { h_exception = Handle(thread, thread->pending_exception()); thread->clear_pending_exception(); } return h_exception; }
inline void oopDesc::push_contents(PSPromotionManager* pm) { Klass* k = klass(); if (!k->oop_is_typeArray()) { // It might contain oops beyond the header, so take the virtual call. k->oop_push_contents(pm, this); } // Else skip it. The TypeArrayKlass in the header never needs scavenging. }
void PlaceholderEntry::verify() const { guarantee(loader() == NULL || loader()->is_instance(), "checking type of _loader"); guarantee(instanceKlass() == NULL || Klass::cast(instanceKlass())->oop_is_instance(), "checking type of instanceKlass result"); klass()->verify(); }
void PHPSourceFile::OnClass(const phpLexerToken& tok) { // A "complex" example: class A extends BaseClass implements C, D {} // Read until we get the class name phpLexerToken token; while(NextToken(token)) { if(token.IsAnyComment()) continue; if(token.type != kPHP_T_IDENTIFIER) { // expecting the class name return; } break; } // create new class entity PHPEntityBase::Ptr_t klass(new PHPEntityClass()); klass->SetFilename(m_filename.GetFullPath()); PHPEntityClass* pClass = klass->Cast<PHPEntityClass>(); // Is the class an interface? pClass->SetIsInterface(tok.type == kPHP_T_INTERFACE); pClass->SetIsTrait(tok.type == kPHP_T_TRAIT); pClass->SetFullName(MakeIdentifierAbsolute(token.text)); pClass->SetLine(token.lineNumber); while(NextToken(token)) { if(token.IsAnyComment()) continue; switch(token.type) { case kPHP_T_EXTENDS: { // inheritance wxString extends = ReadExtends(); if(extends.IsEmpty()) return; // No need to call 'MakeIdentifierAbsolute' it was called internally by // ReadType() pClass->SetExtends(extends); } break; case kPHP_T_IMPLEMENTS: { wxArrayString implements; ReadImplements(implements); pClass->SetImplements(implements); } break; case '{': { // entering the class body // add the current class to the current scope CurrentScope()->AddChild(klass); m_scopes.push_back(klass); Parse(m_depth - 1); if(!m_reachedEOF) { m_scopes.pop_back(); } return; } default: break; } } }
// Interates through the vtables to find the broadest access level. This // will always be monotomic for valid Java programs - but not neccesarily // for incompatible class files. klassVtable::AccessType klassVtable::vtable_accessibility_at(int i) { // This vtable is not implementing the specific method if (i >= length()) return acc_private; // Compute AccessType for current method. public or protected we are done. methodOop m = method_at(i); if (m->is_protected() || m->is_public()) return acc_publicprotected; AccessType acc = m->is_package_private() ? acc_package_private : acc_private; // Compute AccessType for method in super classes klassOop super = klass()->super(); AccessType super_acc = (super != NULL) ? instanceKlass::cast(klass()->super())->vtable()->vtable_accessibility_at(i) : acc_private; // Merge return (AccessType)MAX2((int)acc, (int)super_acc); }
void RunFinalizationDCmd::execute(DCmdSource source, TRAPS) { Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_System(), true, CHECK); instanceKlassHandle klass(THREAD, k); JavaValue result(T_VOID); JavaCalls::call_static(&result, klass, vmSymbols::run_finalization_name(), vmSymbols::void_method_signature(), CHECK); }
void oopDesc::print_value_on(outputStream* st) const { oop obj = oop(this); if (this == NULL) { st->print("NULL"); } else if (java_lang_String::is_instance(obj)) { java_lang_String::print(obj, st); if (PrintOopAddress) print_address_on(st); } else { klass()->oop_print_value_on(obj, st); } }
// FIXME: this only works from R. Could generalize, but not sure if // this caching is worth it yet. QByteArray MethodCall::cacheKey() const { QByteArray mcid(klass()->name()); mcid += ';'; mcid += _method->name(); for(int i = 0; i < length(_args); i++) { mcid += ';'; mcid += argKey(VECTOR_ELT(_args, i)); } return mcid; }
/* Allocates memory */ cell factor_vm::add_inline_cache_entry(cell cache_entries_, cell klass_, cell method_) { gc_root<array> cache_entries(cache_entries_,this); gc_root<object> klass(klass_,this); gc_root<word> method(method_,this); cell pic_size = array_capacity(cache_entries.untagged()); gc_root<array> new_cache_entries(reallot_array(cache_entries.untagged(),pic_size + 2),this); set_array_nth(new_cache_entries.untagged(),pic_size,klass.value()); set_array_nth(new_cache_entries.untagged(),pic_size + 1,method.value()); return new_cache_entries.value(); }
//-------------------------------------------------------------- void ofApp::setup(){ counter = 0; python.init(); python.executeScript("mytest.py"); ofxPythonObject klass = python.getObject("myApp"); if(klass) script = klass(); CustomCallBack * cb2 = new CustomCallBack(); ofxPythonObject func = script.attr("setCPPObject"); func(CallBack2Python(cb2)); }
void PlaceholderEntry::oops_do(OopClosure* blk) { assert(klass() != NULL, "should have a non-null klass"); blk->do_oop((oop*)klass_addr()); if (_loader != NULL) { blk->do_oop(loader_addr()); } if (_supername != NULL) { blk->do_oop((oop*)supername_addr()); } if (_instanceKlass != NULL) { blk->do_oop((oop*)instanceKlass_addr()); } }
bool VerificationType::is_reference_assignable_from( const VerificationType& from, ClassVerifier* context, bool from_field_is_protected, TRAPS) const { instanceKlassHandle klass = context->current_class(); if (from.is_null()) { // null is assignable to any reference return true; } else if (is_null()) { return false; } else if (name() == from.name()) { return true; } else if (is_object()) { // We need check the class hierarchy to check assignability if (name() == vmSymbols::java_lang_Object()) { // any object or array is assignable to java.lang.Object return true; } if (DumpSharedSpaces && SystemDictionaryShared::add_verification_constraint(klass(), name(), from.name(), from_field_is_protected, from.is_array(), from.is_object())) { // If add_verification_constraint() returns true, the resolution/check should be // delayed until runtime. return true; } return resolve_and_check_assignability(klass(), name(), from.name(), from_field_is_protected, from.is_array(), from.is_object(), THREAD); } else if (is_array() && from.is_array()) { VerificationType comp_this = get_component(context, CHECK_false); VerificationType comp_from = from.get_component(context, CHECK_false); if (!comp_this.is_bogus() && !comp_from.is_bogus()) { return comp_this.is_component_assignable_from(comp_from, context, from_field_is_protected, CHECK_false); } } return false; }
bool InlineCache::update_and_validate_private(STATE, CallFrame* call_frame, Object* recv) { if(valid_p(state, recv)) return true; set_klass(recv->lookup_begin(state)); if(!fill_private(state, name, klass())) { return false; } update_seen_classes(); run_wb(state, call_frame->cm); return true; }
PHPEntityBase::List_t PHPSourceFile::GetAliases() const { PHPEntityBase::List_t aliases; std::map<wxString, wxString>::const_iterator iter = m_aliases.begin(); for(; iter != m_aliases.end(); ++iter) { // wrap each alias with class entity PHPEntityBase::Ptr_t klass(new PHPEntityClass()); klass->SetFullName(iter->second); klass->SetShortName(iter->first); klass->SetFilename(GetFilename()); aliases.push_back(klass); } return aliases; }
void FinalizerInfoDCmd::execute(DCmdSource source, TRAPS) { ResourceMark rm; Klass* k = SystemDictionary::resolve_or_null( vmSymbols::finalizer_histogram_klass(), THREAD); assert(k != NULL, "FinalizerHistogram class is not accessible"); instanceKlassHandle klass(THREAD, k); JavaValue result(T_ARRAY); // We are calling lang.ref.FinalizerHistogram.getFinalizerHistogram() method // and expect it to return array of FinalizerHistogramEntry as Object[] JavaCalls::call_static(&result, klass, vmSymbols::get_finalizer_histogram_name(), vmSymbols::void_finalizer_histogram_entry_array_signature(), CHECK); objArrayOop result_oop = (objArrayOop) result.get_jobject(); if (result_oop->length() == 0) { output()->print_cr("No instances waiting for finalization found"); return; } oop foop = result_oop->obj_at(0); InstanceKlass* ik = InstanceKlass::cast(foop->klass()); fieldDescriptor count_fd, name_fd; Klass* count_res = ik->find_field( vmSymbols::finalizer_histogram_entry_count_field(), vmSymbols::int_signature(), &count_fd); Klass* name_res = ik->find_field( vmSymbols::finalizer_histogram_entry_name_field(), vmSymbols::string_signature(), &name_fd); assert(count_res != NULL && name_res != NULL, "Unexpected layout of FinalizerHistogramEntry"); output()->print_cr("Unreachable instances waiting for finalization"); output()->print_cr("#instances class name"); output()->print_cr("-----------------------"); for (int i = 0; i < result_oop->length(); ++i) { oop element_oop = result_oop->obj_at(i); oop str_oop = element_oop->obj_field(name_fd.offset()); char *name = java_lang_String::as_utf8_string(str_oop); int count = element_oop->int_field(count_fd.offset()); output()->print_cr("%10d %s", count, name); } }