8179040: Avoid Ticks::now calls when EventClassLoad is not enabled

Co-authored-by: Markus Gronlund <markus.gronlund@oracle.com>
Reviewed-by: ehelin, mgronlun, dholmes, iklam
This commit is contained in:
Claes Redestad 2017-08-28 00:20:35 +02:00
parent 437d3f2c3b
commit 52f9c55e24
6 changed files with 30 additions and 73 deletions

View File

@ -77,9 +77,8 @@
#include "services/classLoadingService.hpp"
#include "services/diagnosticCommand.hpp"
#include "services/threadService.hpp"
#include "trace/traceMacros.hpp"
#include "trace/tracing.hpp"
#include "utilities/macros.hpp"
#include "utilities/ticks.hpp"
#if INCLUDE_CDS
#include "classfile/sharedClassUtil.hpp"
#include "classfile/systemDictionaryShared.hpp"
@ -87,9 +86,6 @@
#if INCLUDE_JVMCI
#include "jvmci/jvmciRuntime.hpp"
#endif
#if INCLUDE_TRACE
#include "trace/tracing.hpp"
#endif
PlaceholderTable* SystemDictionary::_placeholders = NULL;
Dictionary* SystemDictionary::_shared_dictionary = NULL;
@ -615,17 +611,17 @@ InstanceKlass* SystemDictionary::handle_parallel_super_load(
return NULL;
}
static void post_class_load_event(const Ticks& start_time,
InstanceKlass* k,
static void post_class_load_event(EventClassLoad* event,
const InstanceKlass* k,
const ClassLoaderData* init_cld) {
#if INCLUDE_TRACE
EventClassLoad event(UNTIMED);
if (event.should_commit()) {
event.set_starttime(start_time);
event.set_loadedClass(k);
event.set_definingClassLoader(k->class_loader_data());
event.set_initiatingClassLoader(init_cld);
event.commit();
assert(event != NULL, "invariant");
assert(k != NULL, "invariant");
if (event->should_commit()) {
event->set_loadedClass(k);
event->set_definingClassLoader(k->class_loader_data());
event->set_initiatingClassLoader(init_cld);
event->commit();
}
#endif // INCLUDE_TRACE
}
@ -653,7 +649,7 @@ Klass* SystemDictionary::resolve_instance_class_or_null(Symbol* name,
assert(name != NULL && !FieldType::is_array(name) &&
!FieldType::is_obj(name), "invalid class name");
Ticks class_load_start_time = Ticks::now();
EventClassLoad class_load_start_event;
HandleMark hm(THREAD);
@ -899,7 +895,7 @@ Klass* SystemDictionary::resolve_instance_class_or_null(Symbol* name,
return NULL;
}
post_class_load_event(class_load_start_time, k, loader_data);
post_class_load_event(&class_load_start_event, k, loader_data);
#ifdef ASSERT
{
@ -1006,7 +1002,7 @@ InstanceKlass* SystemDictionary::parse_stream(Symbol* class_name,
GrowableArray<Handle>* cp_patches,
TRAPS) {
Ticks class_load_start_time = Ticks::now();
EventClassLoad class_load_start_event;
ClassLoaderData* loader_data;
if (host_klass != NULL) {
@ -1064,7 +1060,7 @@ InstanceKlass* SystemDictionary::parse_stream(Symbol* class_name,
JvmtiExport::post_class_load((JavaThread *) THREAD, k);
}
post_class_load_event(class_load_start_time, k, loader_data);
post_class_load_event(&class_load_start_event, k, loader_data);
}
assert(host_klass != NULL || NULL == cp_patches,
"cp_patches only found with host_klass");

View File

@ -1407,7 +1407,6 @@ ObjectMonitor* ObjectSynchronizer::inflate(Thread * Self,
assert(inf->header()->is_neutral(), "invariant");
assert(inf->object() == object, "invariant");
assert(ObjectSynchronizer::verify_objmon_isinpool(inf), "monitor is invalid");
event.cancel(); // let's not post an inflation event, unless we did the deed ourselves
return inf;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2017, 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
@ -28,6 +28,7 @@
#include <stddef.h>
#include "utilities/globalDefinitions.hpp"
#include "utilities/ticks.hpp"
enum {
CONTENT_TYPE_NONE = 0,
@ -54,10 +55,11 @@ enum ReservedEvent {
NUM_RESERVED_EVENTS = JVM_CONTENT_TYPES_END
};
typedef enum ReservedEvent ReservedEvent;
typedef u8 traceid;
class ClassLoaderData;
class Klass;
class Method;
class ModuleEntry;
class PackageEntry;
class Symbol;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2017, 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
@ -25,6 +25,7 @@
#ifndef SHARE_VM_TRACE_TRACEEVENT_HPP
#define SHARE_VM_TRACE_TRACEEVENT_HPP
#include "trace/traceTime.hpp"
#include "utilities/macros.hpp"
enum EventStartTime {
@ -34,25 +35,18 @@ enum EventStartTime {
#if INCLUDE_TRACE
#include "trace/traceBackend.hpp"
#include "trace/tracing.hpp"
#include "tracefiles/traceEventIds.hpp"
#include "tracefiles/traceTypes.hpp"
#include "utilities/ticks.hpp"
template<typename T>
class TraceEvent : public StackObj {
class TraceEvent {
private:
bool _started;
#ifdef ASSERT
bool _committed;
bool _cancelled;
protected:
bool _ignore_check;
#endif
protected:
jlong _startTime;
jlong _endTime;
DEBUG_ONLY(bool _committed;)
void set_starttime(const TracingTime& time) {
_startTime = time;
@ -67,10 +61,7 @@ class TraceEvent : public StackObj {
_endTime(0),
_started(false)
#ifdef ASSERT
,
_committed(false),
_cancelled(false),
_ignore_check(false)
, _committed(false)
#endif
{
if (T::is_enabled()) {
@ -100,10 +91,9 @@ class TraceEvent : public StackObj {
void commit() {
if (!should_commit()) {
DEBUG_ONLY(cancel());
return;
}
assert(!_cancelled, "Committing an event that has already been cancelled");
assert(!_committed, "event already committed");
if (_startTime == 0) {
static_cast<T*>(this)->set_starttime(Tracing::time());
} else if (_endTime == 0) {
@ -111,8 +101,8 @@ class TraceEvent : public StackObj {
}
if (static_cast<T*>(this)->should_write()) {
static_cast<T*>(this)->writeEvent();
DEBUG_ONLY(_committed = true;)
}
DEBUG_ONLY(set_commited());
}
static TraceEventId id() {
@ -134,32 +124,6 @@ class TraceEvent : public StackObj {
static bool has_stacktrace() {
return T::hasStackTrace;
}
void cancel() {
assert(!_committed && !_cancelled,
"event was already committed/cancelled");
DEBUG_ONLY(_cancelled = true);
}
~TraceEvent() {
if (_started) {
assert(_ignore_check || _committed || _cancelled,
"event was not committed/cancelled");
}
}
#ifdef ASSERT
protected:
void ignoreCheck() {
_ignore_check = true;
}
private:
void set_commited() {
assert(!_committed, "event has already been committed");
_committed = true;
}
#endif // ASSERT
};
#endif // INCLUDE_TRACE

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2012, 2017, 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
@ -37,10 +37,10 @@
// INCLUDE_TRACE
#include "tracefiles/traceTypes.hpp"
#include "trace/traceEvent.hpp"
#include "utilities/macros.hpp"
#include "utilities/ticks.hpp"
#if INCLUDE_TRACE
#include "trace/traceEvent.hpp"
#include "trace/traceStream.hpp"
#include "utilities/ostream.hpp"
@ -57,7 +57,6 @@ public:
bool should_commit() const { return false; }
static bool is_enabled() { return false; }
void commit() {}
void cancel() {}
};
<xsl:apply-templates select="trace/events/struct" mode="empty"/>

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2012, 2017, 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
@ -32,10 +32,7 @@
#ifndef TRACEFILES_TRACETYPES_HPP
#define TRACEFILES_TRACETYPES_HPP
#include "oops/symbol.hpp"
#include "trace/traceDataTypes.hpp"
#include "utilities/globalDefinitions.hpp"
#include "utilities/ticks.hpp"
enum JVMContentType {
_not_a_content_type = (JVM_CONTENT_TYPES_START - 1),