8051415: TypeTuple::make_domain() and TypeTuple::make_range() allocate too much memory
Summary: Change memory allocation in TypeTuple::make_domain() and TypeTuple::make_range() to not allocate memory for TypeFunc::Parms.
Reviewed-by: kvn, roland
--- a/hotspot/src/share/vm/opto/type.cpp Mon Aug 25 07:44:58 2014 +0000
+++ b/hotspot/src/share/vm/opto/type.cpp Wed Aug 27 10:02:58 2014 +0200
@@ -1708,8 +1708,8 @@
// Make a TypeTuple from the range of a method signature
const TypeTuple *TypeTuple::make_range(ciSignature* sig) {
ciType* return_type = sig->return_type();
- uint total_fields = TypeFunc::Parms + return_type->size();
- const Type **field_array = fields(total_fields);
+ uint arg_cnt = return_type->size();
+ const Type **field_array = fields(arg_cnt);
switch (return_type->basic_type()) {
case T_LONG:
field_array[TypeFunc::Parms] = TypeLong::LONG;
@@ -1734,26 +1734,26 @@
default:
ShouldNotReachHere();
}
- return (TypeTuple*)(new TypeTuple(total_fields,field_array))->hashcons();
+ return (TypeTuple*)(new TypeTuple(TypeFunc::Parms + arg_cnt, field_array))->hashcons();
}
// Make a TypeTuple from the domain of a method signature
const TypeTuple *TypeTuple::make_domain(ciInstanceKlass* recv, ciSignature* sig) {
- uint total_fields = TypeFunc::Parms + sig->size();
+ uint arg_cnt = sig->size();
uint pos = TypeFunc::Parms;
const Type **field_array;
if (recv != NULL) {
- total_fields++;
- field_array = fields(total_fields);
+ arg_cnt++;
+ field_array = fields(arg_cnt);
// Use get_const_type here because it respects UseUniqueSubclasses:
field_array[pos++] = get_const_type(recv)->join_speculative(TypePtr::NOTNULL);
} else {
- field_array = fields(total_fields);
+ field_array = fields(arg_cnt);
}
int i = 0;
- while (pos < total_fields) {
+ while (pos < TypeFunc::Parms + arg_cnt) {
ciType* type = sig->type_at(i);
switch (type->basic_type()) {
@@ -1780,7 +1780,8 @@
}
i++;
}
- return (TypeTuple*)(new TypeTuple(total_fields,field_array))->hashcons();
+
+ return (TypeTuple*)(new TypeTuple(TypeFunc::Parms + arg_cnt, field_array))->hashcons();
}
const TypeTuple *TypeTuple::make( uint cnt, const Type **fields ) {
@@ -1789,6 +1790,7 @@
//------------------------------fields-----------------------------------------
// Subroutine call type with space allocated for argument types
+// Memory for Control, I_O, Memory, FramePtr, and ReturnAdr is allocated implicitly
const Type **TypeTuple::fields( uint arg_cnt ) {
const Type **flds = (const Type **)(Compile::current()->type_arena()->Amalloc_4((TypeFunc::Parms+arg_cnt)*sizeof(Type*) ));
flds[TypeFunc::Control ] = Type::CONTROL;
--- a/hotspot/src/share/vm/opto/type.hpp Mon Aug 25 07:44:58 2014 +0000
+++ b/hotspot/src/share/vm/opto/type.hpp Wed Aug 27 10:02:58 2014 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2014, 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
@@ -635,6 +635,7 @@
static const TypeTuple *make_domain(ciInstanceKlass* recv, ciSignature *sig);
// Subroutine call type with space allocated for argument types
+ // Memory for Control, I_O, Memory, FramePtr, and ReturnAdr is allocated implicitly
static const Type **fields( uint arg_cnt );
virtual const Type *xmeet( const Type *t ) const;