Merge

Sat, 01 Jun 2013 09:28:26 -0700

author
dcubed
date
Sat, 01 Jun 2013 09:28:26 -0700
changeset 5212
532c55335fb6
parent 5200
b7569f617285
parent 5211
efe8b7d64424
child 5213
4552a7633a07

Merge

     1.1 --- a/src/share/vm/classfile/defaultMethods.cpp	Fri May 31 10:04:00 2013 -0700
     1.2 +++ b/src/share/vm/classfile/defaultMethods.cpp	Sat Jun 01 09:28:26 2013 -0700
     1.3 @@ -1349,6 +1349,7 @@
     1.4  
     1.5    // Replace klass methods with new merged lists
     1.6    klass->set_methods(merged_methods);
     1.7 +  klass->set_initial_method_idnum(new_size);
     1.8  
     1.9    ClassLoaderData* cld = klass->class_loader_data();
    1.10    MetadataFactory::free_array(cld, original_methods);
     2.1 --- a/src/share/vm/memory/allocation.cpp	Fri May 31 10:04:00 2013 -0700
     2.2 +++ b/src/share/vm/memory/allocation.cpp	Sat Jun 01 09:28:26 2013 -0700
     2.3 @@ -60,10 +60,11 @@
     2.4  void  _ValueObj::operator delete [](void* p)    { ShouldNotCallThis(); }
     2.5  
     2.6  void* MetaspaceObj::operator new(size_t size, ClassLoaderData* loader_data,
     2.7 -                                size_t word_size, bool read_only, TRAPS) {
     2.8 +                                 size_t word_size, bool read_only,
     2.9 +                                 MetaspaceObj::Type type, TRAPS) {
    2.10    // Klass has it's own operator new
    2.11    return Metaspace::allocate(loader_data, word_size, read_only,
    2.12 -                             Metaspace::NonClassType, CHECK_NULL);
    2.13 +                             type, CHECK_NULL);
    2.14  }
    2.15  
    2.16  bool MetaspaceObj::is_shared() const {
     3.1 --- a/src/share/vm/memory/allocation.hpp	Fri May 31 10:04:00 2013 -0700
     3.2 +++ b/src/share/vm/memory/allocation.hpp	Sat Jun 01 09:28:26 2013 -0700
     3.3 @@ -268,8 +268,55 @@
     3.4    bool is_shared() const;
     3.5    void print_address_on(outputStream* st) const;  // nonvirtual address printing
     3.6  
     3.7 +#define METASPACE_OBJ_TYPES_DO(f) \
     3.8 +  f(Unknown) \
     3.9 +  f(Class) \
    3.10 +  f(Symbol) \
    3.11 +  f(TypeArrayU1) \
    3.12 +  f(TypeArrayU2) \
    3.13 +  f(TypeArrayU4) \
    3.14 +  f(TypeArrayU8) \
    3.15 +  f(TypeArrayOther) \
    3.16 +  f(Method) \
    3.17 +  f(ConstMethod) \
    3.18 +  f(MethodData) \
    3.19 +  f(ConstantPool) \
    3.20 +  f(ConstantPoolCache) \
    3.21 +  f(Annotation) \
    3.22 +  f(MethodCounters)
    3.23 +
    3.24 +#define METASPACE_OBJ_TYPE_DECLARE(name) name ## Type,
    3.25 +#define METASPACE_OBJ_TYPE_NAME_CASE(name) case name ## Type: return #name;
    3.26 +
    3.27 +  enum Type {
    3.28 +    // Types are MetaspaceObj::ClassType, MetaspaceObj::SymbolType, etc
    3.29 +    METASPACE_OBJ_TYPES_DO(METASPACE_OBJ_TYPE_DECLARE)
    3.30 +    _number_of_types
    3.31 +  };
    3.32 +
    3.33 +  static const char * type_name(Type type) {
    3.34 +    switch(type) {
    3.35 +    METASPACE_OBJ_TYPES_DO(METASPACE_OBJ_TYPE_NAME_CASE)
    3.36 +    default:
    3.37 +      ShouldNotReachHere();
    3.38 +      return NULL;
    3.39 +    }
    3.40 +  }
    3.41 +
    3.42 +  static MetaspaceObj::Type array_type(size_t elem_size) {
    3.43 +    switch (elem_size) {
    3.44 +    case 1: return TypeArrayU1Type;
    3.45 +    case 2: return TypeArrayU2Type;
    3.46 +    case 4: return TypeArrayU4Type;
    3.47 +    case 8: return TypeArrayU8Type;
    3.48 +    default:
    3.49 +      return TypeArrayOtherType;
    3.50 +    }
    3.51 +  }
    3.52 +
    3.53    void* operator new(size_t size, ClassLoaderData* loader_data,
    3.54 -                     size_t word_size, bool read_only, Thread* thread);
    3.55 +                     size_t word_size, bool read_only,
    3.56 +                     Type type, Thread* thread);
    3.57                       // can't use TRAPS from this header file.
    3.58    void operator delete(void* p) { ShouldNotCallThis(); }
    3.59  };
     4.1 --- a/src/share/vm/memory/metaspace.cpp	Fri May 31 10:04:00 2013 -0700
     4.2 +++ b/src/share/vm/memory/metaspace.cpp	Sat Jun 01 09:28:26 2013 -0700
     4.3 @@ -713,6 +713,23 @@
     4.4  #ifdef ASSERT
     4.5    void verify_allocated_blocks_words();
     4.6  #endif
     4.7 +
     4.8 +  size_t get_raw_word_size(size_t word_size) {
     4.9 +    // If only the dictionary is going to be used (i.e., no
    4.10 +    // indexed free list), then there is a minimum size requirement.
    4.11 +    // MinChunkSize is a placeholder for the real minimum size JJJ
    4.12 +    size_t byte_size = word_size * BytesPerWord;
    4.13 +
    4.14 +    size_t byte_size_with_overhead = byte_size + Metablock::overhead();
    4.15 +
    4.16 +    size_t raw_bytes_size = MAX2(byte_size_with_overhead,
    4.17 +                                 Metablock::min_block_byte_size());
    4.18 +    raw_bytes_size = ARENA_ALIGN(raw_bytes_size);
    4.19 +    size_t raw_word_size = raw_bytes_size / BytesPerWord;
    4.20 +    assert(raw_word_size * BytesPerWord == raw_bytes_size, "Size problem");
    4.21 +
    4.22 +    return raw_word_size;
    4.23 +  }
    4.24  };
    4.25  
    4.26  uint const SpaceManager::_small_chunk_limit = 4;
    4.27 @@ -2320,19 +2337,7 @@
    4.28  MetaWord* SpaceManager::allocate(size_t word_size) {
    4.29    MutexLockerEx cl(lock(), Mutex::_no_safepoint_check_flag);
    4.30  
    4.31 -  // If only the dictionary is going to be used (i.e., no
    4.32 -  // indexed free list), then there is a minimum size requirement.
    4.33 -  // MinChunkSize is a placeholder for the real minimum size JJJ
    4.34 -  size_t byte_size = word_size * BytesPerWord;
    4.35 -
    4.36 -  size_t byte_size_with_overhead = byte_size + Metablock::overhead();
    4.37 -
    4.38 -  size_t raw_bytes_size = MAX2(byte_size_with_overhead,
    4.39 -                               Metablock::min_block_byte_size());
    4.40 -  raw_bytes_size = ARENA_ALIGN(raw_bytes_size);
    4.41 -  size_t raw_word_size = raw_bytes_size / BytesPerWord;
    4.42 -  assert(raw_word_size * BytesPerWord == raw_bytes_size, "Size problem");
    4.43 -
    4.44 +  size_t raw_word_size = get_raw_word_size(word_size);
    4.45    BlockFreelist* fl =  block_freelists();
    4.46    MetaWord* p = NULL;
    4.47    // Allocation from the dictionary is expensive in the sense that
    4.48 @@ -2896,6 +2901,9 @@
    4.49    if (class_chunk != NULL) {
    4.50      class_vsm()->add_chunk(class_chunk, true);
    4.51    }
    4.52 +
    4.53 +  _alloc_record_head = NULL;
    4.54 +  _alloc_record_tail = NULL;
    4.55  }
    4.56  
    4.57  size_t Metaspace::align_word_size_up(size_t word_size) {
    4.58 @@ -3000,12 +3008,14 @@
    4.59  }
    4.60  
    4.61  Metablock* Metaspace::allocate(ClassLoaderData* loader_data, size_t word_size,
    4.62 -                              bool read_only, MetadataType mdtype, TRAPS) {
    4.63 +                              bool read_only, MetaspaceObj::Type type, TRAPS) {
    4.64    if (HAS_PENDING_EXCEPTION) {
    4.65      assert(false, "Should not allocate with exception pending");
    4.66      return NULL;  // caller does a CHECK_NULL too
    4.67    }
    4.68  
    4.69 +  MetadataType mdtype = (type == MetaspaceObj::ClassType) ? ClassType : NonClassType;
    4.70 +
    4.71    // SSS: Should we align the allocations and make sure the sizes are aligned.
    4.72    MetaWord* result = NULL;
    4.73  
    4.74 @@ -3015,13 +3025,13 @@
    4.75    // with the SymbolTable_lock.  Dumping is single threaded for now.  We'll have
    4.76    // to revisit this for application class data sharing.
    4.77    if (DumpSharedSpaces) {
    4.78 -    if (read_only) {
    4.79 -      result = loader_data->ro_metaspace()->allocate(word_size, NonClassType);
    4.80 -    } else {
    4.81 -      result = loader_data->rw_metaspace()->allocate(word_size, NonClassType);
    4.82 -    }
    4.83 +    assert(type > MetaspaceObj::UnknownType && type < MetaspaceObj::_number_of_types, "sanity");
    4.84 +    Metaspace* space = read_only ? loader_data->ro_metaspace() : loader_data->rw_metaspace();
    4.85 +    result = space->allocate(word_size, NonClassType);
    4.86      if (result == NULL) {
    4.87        report_out_of_shared_space(read_only ? SharedReadOnly : SharedReadWrite);
    4.88 +    } else {
    4.89 +      space->record_allocation(result, type, space->vsm()->get_raw_word_size(word_size));
    4.90      }
    4.91      return Metablock::initialize(result, word_size);
    4.92    }
    4.93 @@ -3056,6 +3066,38 @@
    4.94    return Metablock::initialize(result, word_size);
    4.95  }
    4.96  
    4.97 +void Metaspace::record_allocation(void* ptr, MetaspaceObj::Type type, size_t word_size) {
    4.98 +  assert(DumpSharedSpaces, "sanity");
    4.99 +
   4.100 +  AllocRecord *rec = new AllocRecord((address)ptr, type, (int)word_size * HeapWordSize);
   4.101 +  if (_alloc_record_head == NULL) {
   4.102 +    _alloc_record_head = _alloc_record_tail = rec;
   4.103 +  } else {
   4.104 +    _alloc_record_tail->_next = rec;
   4.105 +    _alloc_record_tail = rec;
   4.106 +  }
   4.107 +}
   4.108 +
   4.109 +void Metaspace::iterate(Metaspace::AllocRecordClosure *closure) {
   4.110 +  assert(DumpSharedSpaces, "unimplemented for !DumpSharedSpaces");
   4.111 +
   4.112 +  address last_addr = (address)bottom();
   4.113 +
   4.114 +  for (AllocRecord *rec = _alloc_record_head; rec; rec = rec->_next) {
   4.115 +    address ptr = rec->_ptr;
   4.116 +    if (last_addr < ptr) {
   4.117 +      closure->doit(last_addr, MetaspaceObj::UnknownType, ptr - last_addr);
   4.118 +    }
   4.119 +    closure->doit(ptr, rec->_type, rec->_byte_size);
   4.120 +    last_addr = ptr + rec->_byte_size;
   4.121 +  }
   4.122 +
   4.123 +  address top = ((address)bottom()) + used_bytes_slow(Metaspace::NonClassType);
   4.124 +  if (last_addr < top) {
   4.125 +    closure->doit(last_addr, MetaspaceObj::UnknownType, top - last_addr);
   4.126 +  }
   4.127 +}
   4.128 +
   4.129  void Metaspace::purge() {
   4.130    MutexLockerEx cl(SpaceManager::expand_lock(),
   4.131                     Mutex::_no_safepoint_check_flag);
     5.1 --- a/src/share/vm/memory/metaspace.hpp	Fri May 31 10:04:00 2013 -0700
     5.2 +++ b/src/share/vm/memory/metaspace.hpp	Sat Jun 01 09:28:26 2013 -0700
     5.3 @@ -1,5 +1,5 @@
     5.4  /*
     5.5 - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
     5.6 + * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
     5.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     5.8   *
     5.9   * This code is free software; you can redistribute it and/or modify it
    5.10 @@ -127,6 +127,23 @@
    5.11    static VirtualSpaceList* space_list()       { return _space_list; }
    5.12    static VirtualSpaceList* class_space_list() { return _class_space_list; }
    5.13  
    5.14 +  // This is used by DumpSharedSpaces only, where only _vsm is used. So we will
    5.15 +  // maintain a single list for now.
    5.16 +  void record_allocation(void* ptr, MetaspaceObj::Type type, size_t word_size);
    5.17 +
    5.18 +  class AllocRecord : public CHeapObj<mtClass> {
    5.19 +  public:
    5.20 +    AllocRecord(address ptr, MetaspaceObj::Type type, int byte_size)
    5.21 +      : _next(NULL), _ptr(ptr), _type(type), _byte_size(byte_size) {}
    5.22 +    AllocRecord *_next;
    5.23 +    address _ptr;
    5.24 +    MetaspaceObj::Type _type;
    5.25 +    int _byte_size;
    5.26 +  };
    5.27 +
    5.28 +  AllocRecord * _alloc_record_head;
    5.29 +  AllocRecord * _alloc_record_tail;
    5.30 +
    5.31   public:
    5.32  
    5.33    Metaspace(Mutex* lock, MetaspaceType type);
    5.34 @@ -148,8 +165,8 @@
    5.35    size_t used_bytes_slow(MetadataType mdtype) const;
    5.36    size_t capacity_bytes_slow(MetadataType mdtype) const;
    5.37  
    5.38 -  static Metablock* allocate(ClassLoaderData* loader_data, size_t size,
    5.39 -                            bool read_only, MetadataType mdtype, TRAPS);
    5.40 +  static Metablock* allocate(ClassLoaderData* loader_data, size_t word_size,
    5.41 +                             bool read_only, MetaspaceObj::Type type, TRAPS);
    5.42    void deallocate(MetaWord* ptr, size_t byte_size, bool is_class);
    5.43  
    5.44    MetaWord* expand_and_allocate(size_t size,
    5.45 @@ -166,6 +183,13 @@
    5.46    void print_on(outputStream* st) const;
    5.47    // Debugging support
    5.48    void verify();
    5.49 +
    5.50 +  class AllocRecordClosure :  public StackObj {
    5.51 +  public:
    5.52 +    virtual void doit(address ptr, MetaspaceObj::Type type, int byte_size) = 0;
    5.53 +  };
    5.54 +
    5.55 +  void iterate(AllocRecordClosure *closure);
    5.56  };
    5.57  
    5.58  class MetaspaceAux : AllStatic {
     6.1 --- a/src/share/vm/memory/metaspaceShared.cpp	Fri May 31 10:04:00 2013 -0700
     6.2 +++ b/src/share/vm/memory/metaspaceShared.cpp	Sat Jun 01 09:28:26 2013 -0700
     6.3 @@ -243,6 +243,147 @@
     6.4    bool reading() const { return false; }
     6.5  };
     6.6  
     6.7 +// This is for dumping detailed statistics for the allocations
     6.8 +// in the shared spaces.
     6.9 +class DumpAllocClosure : public Metaspace::AllocRecordClosure {
    6.10 +public:
    6.11 +
    6.12 +  // Here's poor man's enum inheritance
    6.13 +#define SHAREDSPACE_OBJ_TYPES_DO(f) \
    6.14 +  METASPACE_OBJ_TYPES_DO(f) \
    6.15 +  f(SymbolHashentry) \
    6.16 +  f(SymbolBuckets) \
    6.17 +  f(Other)
    6.18 +
    6.19 +#define SHAREDSPACE_OBJ_TYPE_DECLARE(name) name ## Type,
    6.20 +#define SHAREDSPACE_OBJ_TYPE_NAME_CASE(name) case name ## Type: return #name;
    6.21 +
    6.22 +  enum Type {
    6.23 +    // Types are MetaspaceObj::ClassType, MetaspaceObj::SymbolType, etc
    6.24 +    SHAREDSPACE_OBJ_TYPES_DO(SHAREDSPACE_OBJ_TYPE_DECLARE)
    6.25 +    _number_of_types
    6.26 +  };
    6.27 +
    6.28 +  static const char * type_name(Type type) {
    6.29 +    switch(type) {
    6.30 +    SHAREDSPACE_OBJ_TYPES_DO(SHAREDSPACE_OBJ_TYPE_NAME_CASE)
    6.31 +    default:
    6.32 +      ShouldNotReachHere();
    6.33 +      return NULL;
    6.34 +    }
    6.35 +  }
    6.36 +
    6.37 +public:
    6.38 +  enum {
    6.39 +    RO = 0,
    6.40 +    RW = 1
    6.41 +  };
    6.42 +
    6.43 +  int _counts[2][_number_of_types];
    6.44 +  int _bytes [2][_number_of_types];
    6.45 +  int _which;
    6.46 +
    6.47 +  DumpAllocClosure() {
    6.48 +    memset(_counts, 0, sizeof(_counts));
    6.49 +    memset(_bytes,  0, sizeof(_bytes));
    6.50 +  };
    6.51 +
    6.52 +  void iterate_metaspace(Metaspace* space, int which) {
    6.53 +    assert(which == RO || which == RW, "sanity");
    6.54 +    _which = which;
    6.55 +    space->iterate(this);
    6.56 +  }
    6.57 +
    6.58 +  virtual void doit(address ptr, MetaspaceObj::Type type, int byte_size) {
    6.59 +    assert(int(type) >= 0 && type < MetaspaceObj::_number_of_types, "sanity");
    6.60 +    _counts[_which][type] ++;
    6.61 +    _bytes [_which][type] += byte_size;
    6.62 +  }
    6.63 +
    6.64 +  void dump_stats(int ro_all, int rw_all, int md_all, int mc_all);
    6.65 +};
    6.66 +
    6.67 +void DumpAllocClosure::dump_stats(int ro_all, int rw_all, int md_all, int mc_all) {
    6.68 +  rw_all += (md_all + mc_all); // md and mc are all mapped Read/Write
    6.69 +  int other_bytes = md_all + mc_all;
    6.70 +
    6.71 +  // Calculate size of data that was not allocated by Metaspace::allocate()
    6.72 +  int symbol_count = _counts[RO][MetaspaceObj::SymbolType];
    6.73 +  int symhash_bytes = symbol_count * sizeof (HashtableEntry<Symbol*, mtSymbol>);
    6.74 +  int symbuck_count = SymbolTable::the_table()->table_size();
    6.75 +  int symbuck_bytes = symbuck_count * sizeof(HashtableBucket<mtSymbol>);
    6.76 +
    6.77 +  _counts[RW][SymbolHashentryType] = symbol_count;
    6.78 +  _bytes [RW][SymbolHashentryType] = symhash_bytes;
    6.79 +  other_bytes -= symhash_bytes;
    6.80 +
    6.81 +  _counts[RW][SymbolBucketsType] = symbuck_count;
    6.82 +  _bytes [RW][SymbolBucketsType] = symbuck_bytes;
    6.83 +  other_bytes -= symbuck_bytes;
    6.84 +
    6.85 +  // TODO: count things like dictionary, vtable, etc
    6.86 +  _bytes[RW][OtherType] =  other_bytes;
    6.87 +
    6.88 +  // prevent divide-by-zero
    6.89 +  if (ro_all < 1) {
    6.90 +    ro_all = 1;
    6.91 +  }
    6.92 +  if (rw_all < 1) {
    6.93 +    rw_all = 1;
    6.94 +  }
    6.95 +
    6.96 +  int all_ro_count = 0;
    6.97 +  int all_ro_bytes = 0;
    6.98 +  int all_rw_count = 0;
    6.99 +  int all_rw_bytes = 0;
   6.100 +
   6.101 +  const char *fmt = "%-20s: %8d %10d %5.1f | %8d %10d %5.1f | %8d %10d %5.1f";
   6.102 +  const char *sep = "--------------------+---------------------------+---------------------------+--------------------------";
   6.103 +  const char *hdr = "                        ro_cnt   ro_bytes     % |   rw_cnt   rw_bytes     % |  all_cnt  all_bytes     %";
   6.104 +
   6.105 +  tty->print_cr("Detailed metadata info (rw includes md and mc):");
   6.106 +  tty->print_cr(hdr);
   6.107 +  tty->print_cr(sep);
   6.108 +  for (int type = 0; type < int(_number_of_types); type ++) {
   6.109 +    const char *name = type_name((Type)type);
   6.110 +    int ro_count = _counts[RO][type];
   6.111 +    int ro_bytes = _bytes [RO][type];
   6.112 +    int rw_count = _counts[RW][type];
   6.113 +    int rw_bytes = _bytes [RW][type];
   6.114 +    int count = ro_count + rw_count;
   6.115 +    int bytes = ro_bytes + rw_bytes;
   6.116 +
   6.117 +    double ro_perc = 100.0 * double(ro_bytes) / double(ro_all);
   6.118 +    double rw_perc = 100.0 * double(rw_bytes) / double(rw_all);
   6.119 +    double perc    = 100.0 * double(bytes)    / double(ro_all + rw_all);
   6.120 +
   6.121 +    tty->print_cr(fmt, name,
   6.122 +                  ro_count, ro_bytes, ro_perc,
   6.123 +                  rw_count, rw_bytes, rw_perc,
   6.124 +                  count, bytes, perc);
   6.125 +
   6.126 +    all_ro_count += ro_count;
   6.127 +    all_ro_bytes += ro_bytes;
   6.128 +    all_rw_count += rw_count;
   6.129 +    all_rw_bytes += rw_bytes;
   6.130 +  }
   6.131 +
   6.132 +  int all_count = all_ro_count + all_rw_count;
   6.133 +  int all_bytes = all_ro_bytes + all_rw_bytes;
   6.134 +
   6.135 +  double all_ro_perc = 100.0 * double(all_ro_bytes) / double(ro_all);
   6.136 +  double all_rw_perc = 100.0 * double(all_rw_bytes) / double(rw_all);
   6.137 +  double all_perc    = 100.0 * double(all_bytes)    / double(ro_all + rw_all);
   6.138 +
   6.139 +  tty->print_cr(sep);
   6.140 +  tty->print_cr(fmt, "Total",
   6.141 +                all_ro_count, all_ro_bytes, all_ro_perc,
   6.142 +                all_rw_count, all_rw_bytes, all_rw_perc,
   6.143 +                all_count, all_bytes, all_perc);
   6.144 +
   6.145 +  assert(all_ro_bytes == ro_all, "everything should have been counted");
   6.146 +  assert(all_rw_bytes == rw_all, "everything should have been counted");
   6.147 +}
   6.148  
   6.149  // Populate the shared space.
   6.150  
   6.151 @@ -454,6 +595,14 @@
   6.152    mapinfo->close();
   6.153  
   6.154    memmove(vtbl_list, saved_vtbl, vtbl_list_size * sizeof(void*));
   6.155 +
   6.156 +  if (PrintSharedSpaces) {
   6.157 +    DumpAllocClosure dac;
   6.158 +    dac.iterate_metaspace(_loader_data->ro_metaspace(), DumpAllocClosure::RO);
   6.159 +    dac.iterate_metaspace(_loader_data->rw_metaspace(), DumpAllocClosure::RW);
   6.160 +
   6.161 +    dac.dump_stats(int(ro_bytes), int(rw_bytes), int(md_bytes), int(mc_bytes));
   6.162 +  }
   6.163  }
   6.164  
   6.165  static void link_shared_classes(Klass* obj, TRAPS) {
     7.1 --- a/src/share/vm/oops/annotations.cpp	Fri May 31 10:04:00 2013 -0700
     7.2 +++ b/src/share/vm/oops/annotations.cpp	Sat Jun 01 09:28:26 2013 -0700
     7.3 @@ -33,7 +33,7 @@
     7.4  
     7.5  // Allocate annotations in metadata area
     7.6  Annotations* Annotations::allocate(ClassLoaderData* loader_data, TRAPS) {
     7.7 -  return new (loader_data, size(), true, THREAD) Annotations();
     7.8 +  return new (loader_data, size(), true, MetaspaceObj::AnnotationType, THREAD) Annotations();
     7.9  }
    7.10  
    7.11  // helper
     8.1 --- a/src/share/vm/oops/constMethod.cpp	Fri May 31 10:04:00 2013 -0700
     8.2 +++ b/src/share/vm/oops/constMethod.cpp	Sat Jun 01 09:28:26 2013 -0700
     8.3 @@ -40,7 +40,7 @@
     8.4                                     MethodType method_type,
     8.5                                     TRAPS) {
     8.6    int size = ConstMethod::size(byte_code_size, sizes);
     8.7 -  return new (loader_data, size, true, THREAD) ConstMethod(
     8.8 +  return new (loader_data, size, true, MetaspaceObj::ConstMethodType, THREAD) ConstMethod(
     8.9        byte_code_size, sizes, method_type, size);
    8.10  }
    8.11  
     9.1 --- a/src/share/vm/oops/constantPool.cpp	Fri May 31 10:04:00 2013 -0700
     9.2 +++ b/src/share/vm/oops/constantPool.cpp	Sat Jun 01 09:28:26 2013 -0700
     9.3 @@ -55,7 +55,7 @@
     9.4    // the resolved_references array, which is recreated at startup time.
     9.5    // But that could be moved to InstanceKlass (although a pain to access from
     9.6    // assembly code).  Maybe it could be moved to the cpCache which is RW.
     9.7 -  return new (loader_data, size, false, THREAD) ConstantPool(tags);
     9.8 +  return new (loader_data, size, false, MetaspaceObj::ConstantPoolType, THREAD) ConstantPool(tags);
     9.9  }
    9.10  
    9.11  ConstantPool::ConstantPool(Array<u1>* tags) {
    10.1 --- a/src/share/vm/oops/cpCache.cpp	Fri May 31 10:04:00 2013 -0700
    10.2 +++ b/src/share/vm/oops/cpCache.cpp	Sat Jun 01 09:28:26 2013 -0700
    10.3 @@ -542,7 +542,8 @@
    10.4                                       const intStack& invokedynamic_map, TRAPS) {
    10.5    int size = ConstantPoolCache::size(length);
    10.6  
    10.7 -  return new (loader_data, size, false, THREAD) ConstantPoolCache(length, index_map, invokedynamic_map);
    10.8 +  return new (loader_data, size, false, MetaspaceObj::ConstantPoolCacheType, THREAD)
    10.9 +    ConstantPoolCache(length, index_map, invokedynamic_map);
   10.10  }
   10.11  
   10.12  void ConstantPoolCache::initialize(const intArray& inverse_index_map,
    11.1 --- a/src/share/vm/oops/klass.cpp	Fri May 31 10:04:00 2013 -0700
    11.2 +++ b/src/share/vm/oops/klass.cpp	Sat Jun 01 09:28:26 2013 -0700
    11.3 @@ -140,7 +140,7 @@
    11.4  
    11.5  void* Klass::operator new(size_t size, ClassLoaderData* loader_data, size_t word_size, TRAPS) {
    11.6    return Metaspace::allocate(loader_data, word_size, /*read_only*/false,
    11.7 -                             Metaspace::ClassType, CHECK_NULL);
    11.8 +                             MetaspaceObj::ClassType, CHECK_NULL);
    11.9  }
   11.10  
   11.11  Klass::Klass() {
    12.1 --- a/src/share/vm/oops/method.cpp	Fri May 31 10:04:00 2013 -0700
    12.2 +++ b/src/share/vm/oops/method.cpp	Sat Jun 01 09:28:26 2013 -0700
    12.3 @@ -74,7 +74,7 @@
    12.4  
    12.5    int size = Method::size(access_flags.is_native());
    12.6  
    12.7 -  return new (loader_data, size, false, THREAD) Method(cm, access_flags, size);
    12.8 +  return new (loader_data, size, false, MetaspaceObj::MethodType, THREAD) Method(cm, access_flags, size);
    12.9  }
   12.10  
   12.11  Method::Method(ConstMethod* xconst, AccessFlags access_flags, int size) {
    13.1 --- a/src/share/vm/oops/methodCounters.cpp	Fri May 31 10:04:00 2013 -0700
    13.2 +++ b/src/share/vm/oops/methodCounters.cpp	Sat Jun 01 09:28:26 2013 -0700
    13.3 @@ -26,7 +26,7 @@
    13.4  #include "runtime/thread.inline.hpp"
    13.5  
    13.6  MethodCounters* MethodCounters::allocate(ClassLoaderData* loader_data, TRAPS) {
    13.7 -  return new(loader_data, size(), false, THREAD) MethodCounters();
    13.8 +  return new(loader_data, size(), false, MetaspaceObj::MethodCountersType, THREAD) MethodCounters();
    13.9  }
   13.10  
   13.11  void MethodCounters::clear_counters() {
    14.1 --- a/src/share/vm/oops/methodData.cpp	Fri May 31 10:04:00 2013 -0700
    14.2 +++ b/src/share/vm/oops/methodData.cpp	Sat Jun 01 09:28:26 2013 -0700
    14.3 @@ -388,7 +388,8 @@
    14.4  MethodData* MethodData::allocate(ClassLoaderData* loader_data, methodHandle method, TRAPS) {
    14.5    int size = MethodData::compute_allocation_size_in_words(method);
    14.6  
    14.7 -  return new (loader_data, size, false, THREAD) MethodData(method(), size, CHECK_NULL);
    14.8 +  return new (loader_data, size, false, MetaspaceObj::MethodDataType, THREAD)
    14.9 +    MethodData(method(), size, CHECK_NULL);
   14.10  }
   14.11  
   14.12  int MethodData::bytecode_cell_count(Bytecodes::Code code) {
    15.1 --- a/src/share/vm/oops/symbol.cpp	Fri May 31 10:04:00 2013 -0700
    15.2 +++ b/src/share/vm/oops/symbol.cpp	Sat Jun 01 09:28:26 2013 -0700
    15.3 @@ -55,7 +55,7 @@
    15.4    address res;
    15.5    int alloc_size = size(len)*HeapWordSize;
    15.6    res = (address) Metaspace::allocate(loader_data, size(len), true,
    15.7 -                                      Metaspace::NonClassType, CHECK_NULL);
    15.8 +                                      MetaspaceObj::SymbolType, CHECK_NULL);
    15.9    return res;
   15.10  }
   15.11  
    16.1 --- a/src/share/vm/runtime/reflection.cpp	Fri May 31 10:04:00 2013 -0700
    16.2 +++ b/src/share/vm/runtime/reflection.cpp	Sat Jun 01 09:28:26 2013 -0700
    16.3 @@ -1,5 +1,5 @@
    16.4  /*
    16.5 - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
    16.6 + * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
    16.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    16.8   *
    16.9   * This code is free software; you can redistribute it and/or modify it
   16.10 @@ -375,7 +375,7 @@
   16.11      }
   16.12    }
   16.13    klass = klass->array_klass(dim, CHECK_NULL);
   16.14 -  oop obj = ArrayKlass::cast(klass)->multi_allocate(len, dimensions, THREAD);
   16.15 +  oop obj = ArrayKlass::cast(klass)->multi_allocate(len, dimensions, CHECK_NULL);
   16.16    assert(obj->is_array(), "just checking");
   16.17    return arrayOop(obj);
   16.18  }
   16.19 @@ -817,6 +817,10 @@
   16.20      typeArrayOop an_oop = Annotations::make_java_array(method->parameter_annotations(), CHECK_NULL);
   16.21      java_lang_reflect_Constructor::set_parameter_annotations(ch(), an_oop);
   16.22    }
   16.23 +  if (java_lang_reflect_Constructor::has_type_annotations_field()) {
   16.24 +    typeArrayOop an_oop = Annotations::make_java_array(method->type_annotations(), CHECK_NULL);
   16.25 +    java_lang_reflect_Constructor::set_type_annotations(ch(), an_oop);
   16.26 +  }
   16.27    return ch();
   16.28  }
   16.29  
    17.1 --- a/src/share/vm/utilities/array.hpp	Fri May 31 10:04:00 2013 -0700
    17.2 +++ b/src/share/vm/utilities/array.hpp	Sat Jun 01 09:28:26 2013 -0700
    17.3 @@ -1,5 +1,5 @@
    17.4  /*
    17.5 - * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
    17.6 + * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
    17.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    17.8   *
    17.9   * This code is free software; you can redistribute it and/or modify it
   17.10 @@ -320,7 +320,7 @@
   17.11    void* operator new(size_t size, ClassLoaderData* loader_data, int length, bool read_only, TRAPS) {
   17.12      size_t word_size = Array::size(length);
   17.13      return (void*) Metaspace::allocate(loader_data, word_size, read_only,
   17.14 -                        Metaspace::NonClassType, CHECK_NULL);
   17.15 +                                       MetaspaceObj::array_type(sizeof(T)), CHECK_NULL);
   17.16    }
   17.17  
   17.18    static size_t byte_sizeof(int length) { return sizeof(Array<T>) + MAX2(length - 1, 0) * sizeof(T); }
    18.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    18.2 +++ b/test/compiler/8015436/Test8015436.java	Sat Jun 01 09:28:26 2013 -0700
    18.3 @@ -0,0 +1,74 @@
    18.4 +/*
    18.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
    18.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    18.7 + *
    18.8 + * This code is free software; you can redistribute it and/or modify it
    18.9 + * under the terms of the GNU General Public License version 2 only, as
   18.10 + * published by the Free Software Foundation.
   18.11 + *
   18.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   18.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   18.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   18.15 + * version 2 for more details (a copy is included in the LICENSE file that
   18.16 + * accompanied this code).
   18.17 + *
   18.18 + * You should have received a copy of the GNU General Public License version
   18.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   18.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   18.21 + *
   18.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   18.23 + * or visit www.oracle.com if you need additional information or have any
   18.24 + * questions.
   18.25 + */
   18.26 +
   18.27 +/*
   18.28 + * @test
   18.29 + * @bug 8015436
   18.30 + * @summary the IK _initial_method_idnum value must be adjusted if overpass methods are added
   18.31 + * @run main Test8015436
   18.32 + *
   18.33 + */
   18.34 +
   18.35 +/*
   18.36 + * The test checks that a MemberName for the defaultMethod() is cached in
   18.37 + * the class MemberNameTable without a crash in the VM fastdebug mode.
   18.38 + * The original issue was that the InstanceKlass _initial_method_idnum was
   18.39 + * not adjusted properly when the overpass methods are added to the class.
   18.40 + * The expected/correct behavior: The test does not crash nor throw any exceptions.
   18.41 + * All the invocations of the defaultMethod() must be completed successfully.
   18.42 + */
   18.43 +
   18.44 +import java.lang.invoke.*;
   18.45 +
   18.46 +interface InterfaceWithDefaultMethod {
   18.47 +    public void someMethod();
   18.48 +
   18.49 +    default public void defaultMethod(String str){
   18.50 +        System.out.println("defaultMethod() " + str);
   18.51 +    }
   18.52 +}
   18.53 +
   18.54 +class Test8015436 implements InterfaceWithDefaultMethod {
   18.55 +    @Override
   18.56 +    public void someMethod() {
   18.57 +        System.out.println("someMethod() invoked");
   18.58 +    }
   18.59 +
   18.60 +    public static void main(String[] args) throws Throwable {
   18.61 +        Test8015436 testObj = new Test8015436();
   18.62 +        testObj.someMethod();
   18.63 +        testObj.defaultMethod("invoked directly");
   18.64 +
   18.65 +        MethodHandles.Lookup lookup = MethodHandles.lookup();
   18.66 +        MethodType   mt = MethodType.methodType(void.class, String.class);
   18.67 +        MethodHandle mh = lookup.findVirtual(Test8015436.class, "defaultMethod", mt);
   18.68 +        mh.invokeExact(testObj, "invoked via a MethodHandle");
   18.69 +    }
   18.70 +}
   18.71 +
   18.72 +/*
   18.73 + * A successful execution gives the output:
   18.74 + *   someMethod() invoked
   18.75 + *   defaultMethod() invoked directly
   18.76 + *   defaultMethod() invoked via a MethodHandle
   18.77 + */
    19.1 --- a/test/runtime/8007320/ConstMethodTest.java	Fri May 31 10:04:00 2013 -0700
    19.2 +++ b/test/runtime/8007320/ConstMethodTest.java	Sat Jun 01 09:28:26 2013 -0700
    19.3 @@ -23,7 +23,7 @@
    19.4  
    19.5  /*
    19.6   * @test
    19.7 - * @bug 8007320
    19.8 + * @bug 8007320 8014709
    19.9   * @summary Test all optional fields in ConstMethod
   19.10   * @compile -g -parameters ConstMethodTest.java
   19.11   * @run main ConstMethodTest
   19.12 @@ -74,6 +74,11 @@
   19.13  
   19.14  @MyAnnotation(name="someName", value = "Hello World")
   19.15  public class ConstMethodTest {
   19.16 +    public @TypeAnno("constructor") ConstMethodTest() { }
   19.17 +
   19.18 +    public ConstMethodTest(int i) {
   19.19 +        // needs a second unannotated constructor
   19.20 +    }
   19.21  
   19.22      private static void check(boolean b) {
   19.23          if (!b)
   19.24 @@ -139,10 +144,26 @@
   19.25          }
   19.26      }
   19.27  
   19.28 +    private static void testConstructor() throws Exception {
   19.29 +        for (Constructor c : ConstMethodTest.class.getDeclaredConstructors()) {
   19.30 +            Annotation[] aa = c.getAnnotatedReturnType().getAnnotations();
   19.31 +            if (c.getParameterTypes().length == 1) { // should be un-annotated
   19.32 +                check(aa.length == 0);
   19.33 +            } else if (c.getParameterTypes().length == 0) { //should be annotated
   19.34 +                check(aa.length == 1);
   19.35 +                check(((TypeAnno)aa[0]).value().equals("constructor"));
   19.36 +            } else {
   19.37 +                //should not happen
   19.38 +                check(false);
   19.39 +            }
   19.40 +        }
   19.41 +    }
   19.42 +
   19.43      public static void main(java.lang.String[] unused) throws Throwable {
   19.44          // pass 5 so kitchenSinkFunc is instantiated with an int
   19.45          kitchenSinkFunc("parameter", "param2", 5);
   19.46          test1();
   19.47 +        testConstructor();
   19.48      }
   19.49  };
   19.50  
    20.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    20.2 +++ b/test/runtime/memory/MultiAllocateNullCheck.java	Sat Jun 01 09:28:26 2013 -0700
    20.3 @@ -0,0 +1,45 @@
    20.4 +/*
    20.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
    20.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    20.7 + *
    20.8 + * This code is free software; you can redistribute it and/or modify it
    20.9 + * under the terms of the GNU General Public License version 2 only, as
   20.10 + * published by the Free Software Foundation.
   20.11 + *
   20.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   20.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   20.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   20.15 + * version 2 for more details (a copy is included in the LICENSE file that
   20.16 + * accompanied this code).
   20.17 + *
   20.18 + * You should have received a copy of the GNU General Public License version
   20.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   20.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   20.21 + *
   20.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   20.23 + * or visit www.oracle.com if you need additional information or have any
   20.24 + * questions.
   20.25 + */
   20.26 +
   20.27 +/*
   20.28 + * @test MultiAllocateNullCheck
   20.29 + * @bug 6726963
   20.30 + * @summary multi_allocate() call does not CHECK_NULL and causes crash in fastdebug bits
   20.31 + * @run main/othervm -Xmx32m MultiAllocateNullCheck
   20.32 + */
   20.33 +
   20.34 +import java.lang.reflect.Array;
   20.35 +
   20.36 +public class MultiAllocateNullCheck {
   20.37 +      public static void main(String[] args) throws Exception {
   20.38 +        Object x = null;
   20.39 +        try
   20.40 +        {
   20.41 +            x = Array.newInstance(String.class, new int[]
   20.42 +                {Integer.MAX_VALUE, Integer.MAX_VALUE});
   20.43 +            System.out.println("Array was created");
   20.44 +        } catch (OutOfMemoryError e) {
   20.45 +            System.out.println("Out of memory occured, which is OK in this case");
   20.46 +        }
   20.47 +    }
   20.48 +}

mercurial