mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-20 19:14:38 +02:00
7017732: move static fields into Class to prepare for perm gen removal
Reviewed-by: kvn, coleenp, twisti, stefank
This commit is contained in:
parent
f5ef48f3b9
commit
6e8a263a06
66 changed files with 1031 additions and 461 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2011, 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
|
||||
|
@ -1202,11 +1202,15 @@ const TypePtr *Compile::flatten_alias_type( const TypePtr *tj ) const {
|
|||
// Oop pointers need some flattening
|
||||
const TypeInstPtr *to = tj->isa_instptr();
|
||||
if( to && _AliasLevel >= 2 && to != TypeOopPtr::BOTTOM ) {
|
||||
ciInstanceKlass *k = to->klass()->as_instance_klass();
|
||||
if( ptr == TypePtr::Constant ) {
|
||||
// No constant oop pointers (such as Strings); they alias with
|
||||
// unknown strings.
|
||||
assert(!is_known_inst, "not scalarizable allocation");
|
||||
tj = to = TypeInstPtr::make(TypePtr::BotPTR,to->klass(),false,0,offset);
|
||||
if (to->klass() != ciEnv::current()->Class_klass() ||
|
||||
offset < k->size_helper() * wordSize) {
|
||||
// No constant oop pointers (such as Strings); they alias with
|
||||
// unknown strings.
|
||||
assert(!is_known_inst, "not scalarizable allocation");
|
||||
tj = to = TypeInstPtr::make(TypePtr::BotPTR,to->klass(),false,0,offset);
|
||||
}
|
||||
} else if( is_known_inst ) {
|
||||
tj = to; // Keep NotNull and klass_is_exact for instance type
|
||||
} else if( ptr == TypePtr::NotNull || to->klass_is_exact() ) {
|
||||
|
@ -1216,7 +1220,6 @@ const TypePtr *Compile::flatten_alias_type( const TypePtr *tj ) const {
|
|||
tj = to = TypeInstPtr::make(TypePtr::BotPTR,to->klass(),false,0,offset);
|
||||
}
|
||||
// Canonicalize the holder of this field
|
||||
ciInstanceKlass *k = to->klass()->as_instance_klass();
|
||||
if (offset >= 0 && offset < instanceOopDesc::base_offset_in_bytes()) {
|
||||
// First handle header references such as a LoadKlassNode, even if the
|
||||
// object's klass is unloaded at compile time (4965979).
|
||||
|
@ -1224,9 +1227,13 @@ const TypePtr *Compile::flatten_alias_type( const TypePtr *tj ) const {
|
|||
tj = to = TypeInstPtr::make(TypePtr::BotPTR, env()->Object_klass(), false, NULL, offset);
|
||||
}
|
||||
} else if (offset < 0 || offset >= k->size_helper() * wordSize) {
|
||||
to = NULL;
|
||||
tj = TypeOopPtr::BOTTOM;
|
||||
offset = tj->offset();
|
||||
// Static fields are in the space above the normal instance
|
||||
// fields in the java.lang.Class instance.
|
||||
if (to->klass() != ciEnv::current()->Class_klass()) {
|
||||
to = NULL;
|
||||
tj = TypeOopPtr::BOTTOM;
|
||||
offset = tj->offset();
|
||||
}
|
||||
} else {
|
||||
ciInstanceKlass *canonical_holder = k->get_canonical_holder(offset);
|
||||
if (!k->equals(canonical_holder) || tj->offset() != offset) {
|
||||
|
@ -1399,7 +1406,7 @@ void Compile::grow_alias_types() {
|
|||
|
||||
|
||||
//--------------------------------find_alias_type------------------------------
|
||||
Compile::AliasType* Compile::find_alias_type(const TypePtr* adr_type, bool no_create) {
|
||||
Compile::AliasType* Compile::find_alias_type(const TypePtr* adr_type, bool no_create, ciField* original_field) {
|
||||
if (_AliasLevel == 0)
|
||||
return alias_type(AliasIdxBot);
|
||||
|
||||
|
@ -1464,22 +1471,28 @@ Compile::AliasType* Compile::find_alias_type(const TypePtr* adr_type, bool no_cr
|
|||
// but the base pointer type is not distinctive enough to identify
|
||||
// references into JavaThread.)
|
||||
|
||||
// Check for final instance fields.
|
||||
// Check for final fields.
|
||||
const TypeInstPtr* tinst = flat->isa_instptr();
|
||||
if (tinst && tinst->offset() >= instanceOopDesc::base_offset_in_bytes()) {
|
||||
ciInstanceKlass *k = tinst->klass()->as_instance_klass();
|
||||
ciField* field = k->get_field_by_offset(tinst->offset(), false);
|
||||
ciField* field;
|
||||
if (tinst->const_oop() != NULL &&
|
||||
tinst->klass() == ciEnv::current()->Class_klass() &&
|
||||
tinst->offset() >= (tinst->klass()->as_instance_klass()->size_helper() * wordSize)) {
|
||||
// static field
|
||||
ciInstanceKlass* k = tinst->const_oop()->as_instance()->java_lang_Class_klass()->as_instance_klass();
|
||||
field = k->get_field_by_offset(tinst->offset(), true);
|
||||
} else {
|
||||
ciInstanceKlass *k = tinst->klass()->as_instance_klass();
|
||||
field = k->get_field_by_offset(tinst->offset(), false);
|
||||
}
|
||||
assert(field == NULL ||
|
||||
original_field == NULL ||
|
||||
(field->holder() == original_field->holder() &&
|
||||
field->offset() == original_field->offset() &&
|
||||
field->is_static() == original_field->is_static()), "wrong field?");
|
||||
// Set field() and is_rewritable() attributes.
|
||||
if (field != NULL) alias_type(idx)->set_field(field);
|
||||
}
|
||||
const TypeKlassPtr* tklass = flat->isa_klassptr();
|
||||
// Check for final static fields.
|
||||
if (tklass && tklass->klass()->is_instance_klass()) {
|
||||
ciInstanceKlass *k = tklass->klass()->as_instance_klass();
|
||||
ciField* field = k->get_field_by_offset(tklass->offset(), true);
|
||||
// Set field() and is_rewritable() attributes.
|
||||
if (field != NULL) alias_type(idx)->set_field(field);
|
||||
}
|
||||
}
|
||||
|
||||
// Fill the cache for next time.
|
||||
|
@ -1502,10 +1515,10 @@ Compile::AliasType* Compile::find_alias_type(const TypePtr* adr_type, bool no_cr
|
|||
Compile::AliasType* Compile::alias_type(ciField* field) {
|
||||
const TypeOopPtr* t;
|
||||
if (field->is_static())
|
||||
t = TypeKlassPtr::make(field->holder());
|
||||
t = TypeInstPtr::make(field->holder()->java_mirror());
|
||||
else
|
||||
t = TypeOopPtr::make_from_klass_raw(field->holder());
|
||||
AliasType* atp = alias_type(t->add_offset(field->offset_in_bytes()));
|
||||
AliasType* atp = alias_type(t->add_offset(field->offset_in_bytes()), field);
|
||||
assert(field->is_final() == !atp->is_rewritable(), "must get the rewritable bits correct");
|
||||
return atp;
|
||||
}
|
||||
|
@ -1522,7 +1535,7 @@ bool Compile::have_alias_type(const TypePtr* adr_type) {
|
|||
if (adr_type == NULL) return true;
|
||||
if (adr_type == TypePtr::BOTTOM) return true;
|
||||
|
||||
return find_alias_type(adr_type, true) != NULL;
|
||||
return find_alias_type(adr_type, true, NULL) != NULL;
|
||||
}
|
||||
|
||||
//-----------------------------must_alias--------------------------------------
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue