提交 dda865b7 编写于 作者: S sspitsyn

8014288: perf regression in nashorn JDK-8008448.js test after 8008511 changes

Summary: The fix of perf regression is to use method_idnum() for direct indexing into NMT
Reviewed-by: twisti, kvn, coleenp, dholmes
Contributed-by: serguei.spitsyn@oracle.com
上级 525b9fa8
......@@ -2754,15 +2754,28 @@ nmethod* InstanceKlass::lookup_osr_nmethod(const Method* m, int bci, int comp_le
return NULL;
}
void InstanceKlass::add_member_name(Handle mem_name) {
void InstanceKlass::add_member_name(int index, Handle mem_name) {
jweak mem_name_wref = JNIHandles::make_weak_global(mem_name);
MutexLocker ml(MemberNameTable_lock);
assert(0 <= index && index < idnum_allocated_count(), "index is out of bounds");
DEBUG_ONLY(No_Safepoint_Verifier nsv);
if (_member_names == NULL) {
_member_names = new (ResourceObj::C_HEAP, mtClass) MemberNameTable();
_member_names = new (ResourceObj::C_HEAP, mtClass) MemberNameTable(idnum_allocated_count());
}
_member_names->add_member_name(mem_name_wref);
_member_names->add_member_name(index, mem_name_wref);
}
oop InstanceKlass::get_member_name(int index) {
MutexLocker ml(MemberNameTable_lock);
assert(0 <= index && index < idnum_allocated_count(), "index is out of bounds");
DEBUG_ONLY(No_Safepoint_Verifier nsv);
if (_member_names == NULL) {
return NULL;
}
oop mem_name =_member_names->get_member_name(index);
return mem_name;
}
// -----------------------------------------------------------------------------------------------------
......
......@@ -1022,7 +1022,8 @@ public:
// JSR-292 support
MemberNameTable* member_names() { return _member_names; }
void set_member_names(MemberNameTable* member_names) { _member_names = member_names; }
void add_member_name(Handle member_name);
void add_member_name(int index, Handle member_name);
oop get_member_name(int index);
public:
// JVMTI support
......
/*
* Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -232,7 +232,8 @@ oop MethodHandles::init_method_MemberName(Handle mname, Method* m, bool do_dispa
// This is done eagerly, since it is readily available without
// constructing any new objects.
// TO DO: maybe intern mname_oop
m->method_holder()->add_member_name(mname);
m->method_holder()->add_member_name(m->method_idnum(), mname);
return mname();
}
......@@ -301,7 +302,6 @@ oop MethodHandles::init_field_MemberName(Handle mname, KlassHandle field_holder,
// Although the fieldDescriptor::_index would also identify the field,
// we do not use it, because it is harder to decode.
// TO DO: maybe intern mname_oop
InstanceKlass::cast(field_holder())->add_member_name(mname);
return mname();
}
......@@ -943,7 +943,8 @@ int MethodHandles::find_MemberNames(KlassHandle k,
// MemberNameTable
//
MemberNameTable::MemberNameTable() : GrowableArray<jweak>(10, true) {
MemberNameTable::MemberNameTable(int methods_cnt)
: GrowableArray<jweak>(methods_cnt, true) {
assert_locked_or_safepoint(MemberNameTable_lock);
}
......@@ -957,29 +958,18 @@ MemberNameTable::~MemberNameTable() {
}
}
// Return entry index if found, return -1 otherwise.
int MemberNameTable::find_member_name(oop mem_name) {
void MemberNameTable::add_member_name(int index, jweak mem_name_wref) {
assert_locked_or_safepoint(MemberNameTable_lock);
int len = this->length();
for (int idx = 0; idx < len; idx++) {
jweak ref = this->at(idx);
oop entry = JNIHandles::resolve(ref);
if (entry == mem_name) {
return idx;
}
}
return -1;
this->at_put_grow(index, mem_name_wref);
}
void MemberNameTable::add_member_name(jweak mem_name_wref) {
// Return a member name oop or NULL.
oop MemberNameTable::get_member_name(int index) {
assert_locked_or_safepoint(MemberNameTable_lock);
oop mem_name = JNIHandles::resolve(mem_name_wref);
// Each member name may appear just once: add only if not found
if (find_member_name(mem_name) == -1) {
this->append(mem_name_wref);
}
jweak ref = this->at(index);
oop mem_name = JNIHandles::resolve(ref);
return mem_name;
}
#if INCLUDE_JVMTI
......
/*
* Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -219,7 +219,6 @@ public:
}
};
//------------------------------------------------------------------------------
// MethodHandlesAdapterGenerator
//
......@@ -233,13 +232,13 @@ public:
//------------------------------------------------------------------------------
// MemberNameTable
//
class MemberNameTable : public GrowableArray<jweak> {
public:
MemberNameTable();
MemberNameTable(int methods_cnt);
~MemberNameTable();
void add_member_name(jweak mem_name_ref);
private:
int find_member_name(oop mem_name);
void add_member_name(int index, jweak mem_name_ref);
oop get_member_name(int index);
#if INCLUDE_JVMTI
public:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册