changeset 9567:57a0726f3c0a

Merge
author andrew
date Wed, 18 Nov 2020 06:47:51 +0000
parents 91bed84d3ef3 3b255f489efa
children 312e9cb580c5
files
diffstat 4 files changed, 55 insertions(+), 68 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp	Tue Nov 03 05:58:49 2020 +0000
+++ b/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp	Wed Nov 18 06:47:51 2020 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2020, 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
@@ -1130,11 +1130,11 @@
     _rs_length_diff_seq->add((double) rs_length_diff);
 
     size_t freed_bytes = _heap_used_bytes_before_gc - cur_used_bytes;
-    size_t copied_bytes = _collection_set_bytes_used_before - freed_bytes;
-    double cost_per_byte_ms = 0.0;
 
-    if (copied_bytes > 0) {
-      cost_per_byte_ms = phase_times()->average_time_ms(G1GCPhaseTimes::ObjCopy) / (double) copied_bytes;
+    if (_collection_set_bytes_used_before > freed_bytes) {
+      size_t copied_bytes = _collection_set_bytes_used_before - freed_bytes;
+      double average_copy_time = phase_times()->average_time_ms(G1GCPhaseTimes::ObjCopy);
+      double cost_per_byte_ms = average_copy_time / (double) copied_bytes;
       if (_in_marking_window) {
         _cost_per_byte_ms_during_cm_seq->add(cost_per_byte_ms);
       } else {
--- a/src/share/vm/jfr/recorder/checkpoint/types/jfrTypeSet.cpp	Tue Nov 03 05:58:49 2020 +0000
+++ b/src/share/vm/jfr/recorder/checkpoint/types/jfrTypeSet.cpp	Wed Nov 18 06:47:51 2020 +0000
@@ -263,13 +263,17 @@
   assert(k != NULL, "invariant");
   const InstanceKlass* const ik = (const InstanceKlass*)k;
   if (ik->is_anonymous()) {
-    CStringEntryPtr entry =
-      artifacts->map_cstring(JfrSymbolId::anonymous_klass_name_hash_code(ik));
+    CStringEntryPtr entry = NULL;
+    {
+      ResourceMark rm;
+      uintptr_t hashcode = JfrSymbolId::anonymous_klass_name_hash_code(ik);
+      entry = artifacts->map_cstring(JfrSymbolId::get_anonymous_klass_chars(ik, hashcode), hashcode);
+    }
     assert(entry != NULL, "invariant");
     return write__artifact__cstring__entry__(writer, entry);
   }
 
-  SymbolEntryPtr entry = artifacts->map_symbol(JfrSymbolId::regular_klass_name_hash_code(ik));
+  SymbolEntryPtr entry = artifacts->map_symbol(ik->name());
   return write__artifact__symbol__entry__(writer, entry);
 }
 
@@ -326,8 +330,12 @@
   assert(_predicate(klass), "invariant");
   const InstanceKlass* const ik = (const InstanceKlass*)klass;
   if (ik->is_anonymous()) {
-    CStringEntryPtr entry =
-      this->_artifacts->map_cstring(JfrSymbolId::anonymous_klass_name_hash_code(ik));
+    CStringEntryPtr entry = NULL;
+    {
+      ResourceMark rm;
+      uintptr_t hashcode = JfrSymbolId::anonymous_klass_name_hash_code(ik);
+      entry = _artifacts->map_cstring(JfrSymbolId::get_anonymous_klass_chars(ik, hashcode), hashcode);
+    }
     assert(entry != NULL, "invariant");
     return _unique_predicate(entry->id()) ? write__artifact__cstring__entry__(this->_writer, entry) : 0;
   }
@@ -345,7 +353,7 @@
   const Klass* class_loader_klass = cld->class_loader() != NULL ? cld->class_loader()->klass() : NULL;
   if (class_loader_klass == NULL) {
     // (primordial) boot class loader
-    CStringEntryPtr entry = this->_artifacts->map_cstring(0);
+    CStringEntryPtr entry = this->_artifacts->map_cstring(BOOTSTRAP_LOADER_NAME, 0);
     assert(entry != NULL, "invariant");
     assert(strncmp(entry->literal(),
       BOOTSTRAP_LOADER_NAME,
--- a/src/share/vm/jfr/recorder/checkpoint/types/jfrTypeSetUtils.cpp	Tue Nov 03 05:58:49 2020 +0000
+++ b/src/share/vm/jfr/recorder/checkpoint/types/jfrTypeSetUtils.cpp	Wed Nov 18 06:47:51 2020 +0000
@@ -75,10 +75,7 @@
   const char* const anonymous_symbol =
     create_anonymous_klass_symbol((const InstanceKlass*)k, anonymous_symbol_hash_code);
 
-  if (anonymous_symbol == NULL) {
-    return 0;
-  }
-
+  assert(anonymous_symbol != NULL, "create_anonymous_klass_symbol fail");
   assert(anonymous_symbol_hash_code != 0, "invariant");
   traceid symbol_id = mark(anonymous_symbol, anonymous_symbol_hash_code);
   assert(mark(anonymous_symbol, anonymous_symbol_hash_code) == symbol_id, "invariant");
@@ -89,12 +86,8 @@
   return _sym_table->lookup_only(symbol, (uintptr_t)const_cast<Symbol*>(symbol)->identity_hash());
 }
 
-const JfrSymbolId::SymbolEntry* JfrSymbolId::map_symbol(uintptr_t hash) const {
-  return _sym_table->lookup_only(NULL, hash);
-}
-
-const JfrSymbolId::CStringEntry* JfrSymbolId::map_cstring(uintptr_t hash) const {
-  return _cstring_table->lookup_only(NULL, hash);
+const JfrSymbolId::CStringEntry* JfrSymbolId::map_cstring(const char* const str, uintptr_t hash) const {
+  return _cstring_table->lookup_only(str, hash);
 }
 
 void JfrSymbolId::assign_id(SymbolEntry* entry) {
@@ -104,10 +97,10 @@
 }
 
 bool JfrSymbolId::equals(const Symbol* query, uintptr_t hash, const SymbolEntry* entry) {
-  // query might be NULL
   assert(entry != NULL, "invariant");
   assert(entry->hash() == hash, "invariant");
-  return true;
+  assert(query != NULL, "invariant");
+  return query == entry->literal();
 }
 
 void JfrSymbolId::assign_id(CStringEntry* entry) {
@@ -116,11 +109,18 @@
   entry->set_id(++_symbol_id_counter);
 }
 
+static bool string_compare(const char* query, const char* candidate) {
+  assert(query != NULL, "invariant");
+  assert(candidate != NULL, "invariant");
+  const size_t length = strlen(query);
+  return strncmp(query, candidate, length) == 0;
+}
+
 bool JfrSymbolId::equals(const char* query, uintptr_t hash, const CStringEntry* entry) {
-  // query might be NULL
   assert(entry != NULL, "invariant");
   assert(entry->hash() == hash, "invariant");
-  return true;
+  assert(query != NULL, "invariant");
+  return string_compare(query, entry->literal());
 }
 
 traceid JfrSymbolId::mark(const Klass* k) {
@@ -182,6 +182,22 @@
   return (uintptr_t)mirror->identity_hash();
 }
 
+const char* JfrSymbolId::get_anonymous_klass_chars(const InstanceKlass* ik, uintptr_t hashcode) {
+  assert(ik != NULL, "invariant");
+  assert(ik->is_anonymous(), "invariant");
+  assert(0 != hashcode, "invariant");
+  char hash_buf[40];
+  sprintf(hash_buf, "/" UINTX_FORMAT, hashcode);
+  const size_t hash_len = strlen(hash_buf);
+  const size_t result_len = ik->name()->utf8_length();
+  char* anonymous_symbol = NEW_RESOURCE_ARRAY(char, result_len + hash_len + 1);
+  ik->name()->as_klass_external_name(anonymous_symbol, (int)result_len + 1);
+  assert(strlen(anonymous_symbol) == result_len, "invariant");
+  strcpy(anonymous_symbol + result_len, hash_buf);
+  assert(strlen(anonymous_symbol) == result_len + hash_len, "invariant");
+  return anonymous_symbol;
+}
+
 const char* JfrSymbolId::create_anonymous_klass_symbol(const InstanceKlass* ik, uintptr_t& hashcode) {
   assert(ik != NULL, "invariant");
   assert(ik->is_anonymous(), "invariant");
@@ -189,17 +205,8 @@
   char* anonymous_symbol = NULL;
   const oop mirror = ik->java_mirror();
   assert(mirror != NULL, "invariant");
-  char hash_buf[40];
   hashcode = anonymous_klass_name_hash_code(ik);
-  sprintf(hash_buf, "/" UINTX_FORMAT, hashcode);
-  const size_t hash_len = strlen(hash_buf);
-  const size_t result_len = ik->name()->utf8_length();
-  anonymous_symbol = NEW_RESOURCE_ARRAY(char, result_len + hash_len + 1);
-  ik->name()->as_klass_external_name(anonymous_symbol, (int)result_len + 1);
-  assert(strlen(anonymous_symbol) == result_len, "invariant");
-  strcpy(anonymous_symbol + result_len, hash_buf);
-  assert(strlen(anonymous_symbol) == result_len + hash_len, "invariant");
-  return anonymous_symbol;
+  return get_anonymous_klass_chars(ik, hashcode);
 }
 
 uintptr_t JfrSymbolId::regular_klass_name_hash_code(const Klass* k) {
@@ -264,12 +271,8 @@
   return _symbol_id->map_symbol(symbol);
 }
 
-const JfrSymbolId::SymbolEntry* JfrArtifactSet::map_symbol(uintptr_t hash) const {
-  return _symbol_id->map_symbol(hash);
-}
-
-const JfrSymbolId::CStringEntry* JfrArtifactSet::map_cstring(uintptr_t hash) const {
-  return _symbol_id->map_cstring(hash);
+const JfrSymbolId::CStringEntry* JfrArtifactSet::map_cstring(const char* const str, uintptr_t hash) const {
+  return _symbol_id->map_cstring(str, hash);
 }
 
 bool JfrArtifactSet::has_klass_entries() const {
--- a/src/share/vm/jfr/recorder/checkpoint/types/jfrTypeSetUtils.hpp	Tue Nov 03 05:58:49 2020 +0000
+++ b/src/share/vm/jfr/recorder/checkpoint/types/jfrTypeSetUtils.hpp	Wed Nov 18 06:47:51 2020 +0000
@@ -243,6 +243,7 @@
 
  public:
   static bool is_anonymous_klass(const Klass* k);
+  static const char* get_anonymous_klass_chars(const InstanceKlass* ik, uintptr_t hashcode);
   static const char* create_anonymous_klass_symbol(const InstanceKlass* ik, uintptr_t& hashcode);
   static uintptr_t anonymous_klass_name_hash_code(const InstanceKlass* ik);
   static uintptr_t regular_klass_name_hash_code(const Klass* k);
@@ -266,31 +267,7 @@
   }
 
   const SymbolEntry* map_symbol(const Symbol* symbol) const;
-  const SymbolEntry* map_symbol(uintptr_t hash) const;
-  const CStringEntry* map_cstring(uintptr_t hash) const;
-
-  template <typename T>
-  void symbol(T& functor, const Klass* k) {
-    if (is_anonymous_klass(k)) {
-      return;
-    }
-    functor(map_symbol(regular_klass_name_hash_code(k)));
-  }
-
-  template <typename T>
-  void symbol(T& functor, const Method* method) {
-    assert(method != NULL, "invariant");
-    functor(map_symbol((uintptr_t)method->name()->identity_hash()));
-    functor(map_symbol((uintptr_t)method->signature()->identity_hash()));
-  }
-
-  template <typename T>
-  void cstring(T& functor, const Klass* k) {
-    if (!is_anonymous_klass(k)) {
-      return;
-    }
-    functor(map_cstring(anonymous_klass_name_hash_code((const InstanceKlass*)k)));
-  }
+  const CStringEntry* map_cstring(const char* const str, uintptr_t hash) const;
 
   template <typename T>
   void iterate_symbols(T& functor) {
@@ -344,8 +321,7 @@
   traceid markPackage(const char* const name, uintptr_t hash);
 
   const JfrSymbolId::SymbolEntry* map_symbol(const Symbol* symbol) const;
-  const JfrSymbolId::SymbolEntry* map_symbol(uintptr_t hash) const;
-  const JfrSymbolId::CStringEntry* map_cstring(uintptr_t hash) const;
+  const JfrSymbolId::CStringEntry* map_cstring(const char* const str, uintptr_t hash) const;
 
   bool has_klass_entries() const;
   int entries() const;