This commit is contained in:
Claes Redestad 2017-08-28 14:07:07 +00:00
commit ee4aeaf103
6 changed files with 30 additions and 73 deletions

View File

@ -77,9 +77,8 @@
#include "services/classLoadingService.hpp" #include "services/classLoadingService.hpp"
#include "services/diagnosticCommand.hpp" #include "services/diagnosticCommand.hpp"
#include "services/threadService.hpp" #include "services/threadService.hpp"
#include "trace/traceMacros.hpp" #include "trace/tracing.hpp"
#include "utilities/macros.hpp" #include "utilities/macros.hpp"
#include "utilities/ticks.hpp"
#if INCLUDE_CDS #if INCLUDE_CDS
#include "classfile/sharedClassUtil.hpp" #include "classfile/sharedClassUtil.hpp"
#include "classfile/systemDictionaryShared.hpp" #include "classfile/systemDictionaryShared.hpp"
@ -87,9 +86,6 @@
#if INCLUDE_JVMCI #if INCLUDE_JVMCI
#include "jvmci/jvmciRuntime.hpp" #include "jvmci/jvmciRuntime.hpp"
#endif #endif
#if INCLUDE_TRACE
#include "trace/tracing.hpp"
#endif
PlaceholderTable* SystemDictionary::_placeholders = NULL; PlaceholderTable* SystemDictionary::_placeholders = NULL;
Dictionary* SystemDictionary::_shared_dictionary = NULL; Dictionary* SystemDictionary::_shared_dictionary = NULL;
@ -615,17 +611,17 @@ InstanceKlass* SystemDictionary::handle_parallel_super_load(
return NULL; return NULL;
} }
static void post_class_load_event(const Ticks& start_time, static void post_class_load_event(EventClassLoad* event,
InstanceKlass* k, const InstanceKlass* k,
const ClassLoaderData* init_cld) { const ClassLoaderData* init_cld) {
#if INCLUDE_TRACE #if INCLUDE_TRACE
EventClassLoad event(UNTIMED); assert(event != NULL, "invariant");
if (event.should_commit()) { assert(k != NULL, "invariant");
event.set_starttime(start_time); if (event->should_commit()) {
event.set_loadedClass(k); event->set_loadedClass(k);
event.set_definingClassLoader(k->class_loader_data()); event->set_definingClassLoader(k->class_loader_data());
event.set_initiatingClassLoader(init_cld); event->set_initiatingClassLoader(init_cld);
event.commit(); event->commit();
} }
#endif // INCLUDE_TRACE #endif // INCLUDE_TRACE
} }
@ -653,7 +649,7 @@ Klass* SystemDictionary::resolve_instance_class_or_null(Symbol* name,
assert(name != NULL && !FieldType::is_array(name) && assert(name != NULL && !FieldType::is_array(name) &&
!FieldType::is_obj(name), "invalid class name"); !FieldType::is_obj(name), "invalid class name");
Ticks class_load_start_time = Ticks::now(); EventClassLoad class_load_start_event;
HandleMark hm(THREAD); HandleMark hm(THREAD);
@ -899,7 +895,7 @@ Klass* SystemDictionary::resolve_instance_class_or_null(Symbol* name,
return NULL; 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 #ifdef ASSERT
{ {
@ -1006,7 +1002,7 @@ InstanceKlass* SystemDictionary::parse_stream(Symbol* class_name,
GrowableArray<Handle>* cp_patches, GrowableArray<Handle>* cp_patches,
TRAPS) { TRAPS) {
Ticks class_load_start_time = Ticks::now(); EventClassLoad class_load_start_event;
ClassLoaderData* loader_data; ClassLoaderData* loader_data;
if (host_klass != NULL) { if (host_klass != NULL) {
@ -1064,7 +1060,7 @@ InstanceKlass* SystemDictionary::parse_stream(Symbol* class_name,
JvmtiExport::post_class_load((JavaThread *) THREAD, k); 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, assert(host_klass != NULL || NULL == cp_patches,
"cp_patches only found with host_klass"); "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->header()->is_neutral(), "invariant");
assert(inf->object() == object, "invariant"); assert(inf->object() == object, "invariant");
assert(ObjectSynchronizer::verify_objmon_isinpool(inf), "monitor is invalid"); 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; 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -28,6 +28,7 @@
#include <stddef.h> #include <stddef.h>
#include "utilities/globalDefinitions.hpp" #include "utilities/globalDefinitions.hpp"
#include "utilities/ticks.hpp"
enum { enum {
CONTENT_TYPE_NONE = 0, CONTENT_TYPE_NONE = 0,
@ -54,10 +55,11 @@ enum ReservedEvent {
NUM_RESERVED_EVENTS = JVM_CONTENT_TYPES_END NUM_RESERVED_EVENTS = JVM_CONTENT_TYPES_END
}; };
typedef enum ReservedEvent ReservedEvent;
typedef u8 traceid; typedef u8 traceid;
class ClassLoaderData;
class Klass;
class Method;
class ModuleEntry; class ModuleEntry;
class PackageEntry; class PackageEntry;
class Symbol; 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -25,6 +25,7 @@
#ifndef SHARE_VM_TRACE_TRACEEVENT_HPP #ifndef SHARE_VM_TRACE_TRACEEVENT_HPP
#define SHARE_VM_TRACE_TRACEEVENT_HPP #define SHARE_VM_TRACE_TRACEEVENT_HPP
#include "trace/traceTime.hpp"
#include "utilities/macros.hpp" #include "utilities/macros.hpp"
enum EventStartTime { enum EventStartTime {
@ -34,25 +35,18 @@ enum EventStartTime {
#if INCLUDE_TRACE #if INCLUDE_TRACE
#include "trace/traceBackend.hpp" #include "trace/traceBackend.hpp"
#include "trace/tracing.hpp"
#include "tracefiles/traceEventIds.hpp" #include "tracefiles/traceEventIds.hpp"
#include "tracefiles/traceTypes.hpp"
#include "utilities/ticks.hpp" #include "utilities/ticks.hpp"
template<typename T> template<typename T>
class TraceEvent : public StackObj { class TraceEvent {
private: private:
bool _started; bool _started;
#ifdef ASSERT
bool _committed;
bool _cancelled;
protected:
bool _ignore_check;
#endif
protected: protected:
jlong _startTime; jlong _startTime;
jlong _endTime; jlong _endTime;
DEBUG_ONLY(bool _committed;)
void set_starttime(const TracingTime& time) { void set_starttime(const TracingTime& time) {
_startTime = time; _startTime = time;
@ -67,10 +61,7 @@ class TraceEvent : public StackObj {
_endTime(0), _endTime(0),
_started(false) _started(false)
#ifdef ASSERT #ifdef ASSERT
, , _committed(false)
_committed(false),
_cancelled(false),
_ignore_check(false)
#endif #endif
{ {
if (T::is_enabled()) { if (T::is_enabled()) {
@ -100,10 +91,9 @@ class TraceEvent : public StackObj {
void commit() { void commit() {
if (!should_commit()) { if (!should_commit()) {
DEBUG_ONLY(cancel());
return; return;
} }
assert(!_cancelled, "Committing an event that has already been cancelled"); assert(!_committed, "event already committed");
if (_startTime == 0) { if (_startTime == 0) {
static_cast<T*>(this)->set_starttime(Tracing::time()); static_cast<T*>(this)->set_starttime(Tracing::time());
} else if (_endTime == 0) { } else if (_endTime == 0) {
@ -111,8 +101,8 @@ class TraceEvent : public StackObj {
} }
if (static_cast<T*>(this)->should_write()) { if (static_cast<T*>(this)->should_write()) {
static_cast<T*>(this)->writeEvent(); static_cast<T*>(this)->writeEvent();
DEBUG_ONLY(_committed = true;)
} }
DEBUG_ONLY(set_commited());
} }
static TraceEventId id() { static TraceEventId id() {
@ -134,32 +124,6 @@ class TraceEvent : public StackObj {
static bool has_stacktrace() { static bool has_stacktrace() {
return T::hasStackTrace; 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 #endif // INCLUDE_TRACE

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?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. DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
This code is free software; you can redistribute it and/or modify it This code is free software; you can redistribute it and/or modify it
@ -37,10 +37,10 @@
// INCLUDE_TRACE // INCLUDE_TRACE
#include "tracefiles/traceTypes.hpp" #include "tracefiles/traceTypes.hpp"
#include "trace/traceEvent.hpp"
#include "utilities/macros.hpp" #include "utilities/macros.hpp"
#include "utilities/ticks.hpp"
#if INCLUDE_TRACE #if INCLUDE_TRACE
#include "trace/traceEvent.hpp"
#include "trace/traceStream.hpp" #include "trace/traceStream.hpp"
#include "utilities/ostream.hpp" #include "utilities/ostream.hpp"
@ -57,7 +57,6 @@ public:
bool should_commit() const { return false; } bool should_commit() const { return false; }
static bool is_enabled() { return false; } static bool is_enabled() { return false; }
void commit() {} void commit() {}
void cancel() {}
}; };
<xsl:apply-templates select="trace/events/struct" mode="empty"/> <xsl:apply-templates select="trace/events/struct" mode="empty"/>

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?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. DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
This code is free software; you can redistribute it and/or modify it This code is free software; you can redistribute it and/or modify it
@ -32,10 +32,7 @@
#ifndef TRACEFILES_TRACETYPES_HPP #ifndef TRACEFILES_TRACETYPES_HPP
#define TRACEFILES_TRACETYPES_HPP #define TRACEFILES_TRACETYPES_HPP
#include "oops/symbol.hpp"
#include "trace/traceDataTypes.hpp" #include "trace/traceDataTypes.hpp"
#include "utilities/globalDefinitions.hpp"
#include "utilities/ticks.hpp"
enum JVMContentType { enum JVMContentType {
_not_a_content_type = (JVM_CONTENT_TYPES_START - 1), _not_a_content_type = (JVM_CONTENT_TYPES_START - 1),