/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
#include "classfile/javaClasses.hpp"
#include "memory/allocation.hpp"
#include "runtime/thread.hpp"
// The following classes are used for operations
// initiated by a Java thread but that must
// take place in the VMThread.
// Note: When new VM_XXX comes up, add 'XXX' to the template table.
#define VM_OPS_DO(template) \
template(Dummy) \
template(ThreadStop) \
template(ThreadDump) \
template(PrintThreads) \
template(FindDeadlocks) \
template(ForceSafepoint) \
template(ForceAsyncSafepoint) \
template(Deoptimize) \
template(DeoptimizeFrame) \
template(DeoptimizeAll) \
template(ZombieAll) \
template(UnlinkSymbols) \
template(HandleFullCodeCache) \
template(Verify) \
template(PrintJNI) \
template(HeapDumper) \
template(DeoptimizeTheWorld) \
template(GC_HeapInspection) \
template(GenCollectFull) \
template(GenCollectFullConcurrent) \
template(GenCollectForAllocation) \
template(GenCollectForPermanentAllocation) \
template(ParallelGCFailedAllocation) \
template(ParallelGCFailedPermanentAllocation) \
template(ParallelGCSystemGC) \
template(CGC_Operation) \
template(CMS_Initial_Mark) \
template(CMS_Final_Remark) \
template(G1CollectFull) \
template(G1CollectForAllocation) \
template(G1IncCollectionPause) \
template(EnableBiasedLocking) \
template(RevokeBias) \
template(BulkRevokeBias) \
template(PopulateDumpSharedSpace) \
template(JNIFunctionTableCopier) \
template(RedefineClasses) \
template(GetOwnedMonitorInfo) \
template(GetObjectMonitorUsage) \
template(GetCurrentContendedMonitor) \
template(GetStackTrace) \
template(GetMultipleStackTraces) \
template(GetAllStackTraces) \
template(GetThreadListStackTraces) \
template(GetFrameCount) \
template(GetFrameLocation) \
template(ChangeBreakpoints) \
template(GetOrSetLocal) \
template(GetCurrentLocation) \
template(EnterInterpOnlyMode) \
template(ChangeSingleStep) \
template(HeapWalkOperation) \
template(HeapIterateOperation) \
template(ReportJavaOutOfMemory) \
template(JFRCheckpoint) \
template(Exit) \
template(LinuxDllLoad) \
public:
enum Mode {
};
enum VMOp_Type {
};
private:
long _timestamp;
// The VM operation name array
static const char* _names[];
public:
virtual ~VM_Operation() {}
// VM operation support (used by VM thread)
// Called by VM thread - does in turn invoke doit(). Do not override this
void evaluate();
// evaluate() is called by the VMThread and in turn calls doit().
// If the thread invoking VMThread::execute((VM_Operation*) is a JavaThread,
// doit_prologue() is called in that thread before transferring control to
// the VMThread.
// If doit_prologue() returns true the VM operation will proceed, and
// doit_epilogue() will be called by the JavaThread once the VM operation
// completes. If doit_prologue() returns false the VM operation is cancelled.
virtual void doit() = 0;
virtual bool doit_prologue() { return true; };
// Type test
virtual bool is_methodCompiler() const { return false; }
// Linking
// Configuration. Override these appropriatly in subclasses.
virtual bool allow_nested_vm_operations() const { return false; }
virtual bool is_cheap_allocated() const { return false; }
// CAUTION: <don't hang yourself with following rope>
// If you override these methods, make sure that the evaluation
// of these methods is race-free and non-blocking, since these
// methods may be evaluated either by the mutators or by the
// vm thread, either concurrently with mutators or with the mutators
// stopped. In other words, taking locks is verboten, and if there
// are any races in evaluating the conditions, they'd better be benign.
virtual bool evaluate_at_safepoint() const {
return evaluation_mode() == _safepoint ||
}
virtual bool evaluate_concurrently() const {
return evaluation_mode() == _concurrent ||
}
// Debugging
}
#ifndef PRODUCT
#endif
};
private:
public:
// All oops are passed as JNI handles, since there is no guarantee that a GC might happen before the
// VM operation is executed.
}
void doit();
// We deoptimize if top-most frame is compiled - this might require a C2I adapter to be generated
bool allow_nested_vm_operations() const { return true; }
bool is_cheap_allocated() const { return true; }
// GC support
}
};
// dummy vm op, evaluated just to force a safepoint
public:
VM_ForceSafepoint() {}
void doit() {}
};
// dummy vm op, evaluated just to force a safepoint
public:
void doit() {}
bool is_cheap_allocated() const { return true; }
};
public:
VM_Deoptimize() {}
void doit();
bool allow_nested_vm_operations() const { return true; }
};
// Deopt helper that can deoptimize frames in threads other than the
// current thread. Only used through Deoptimization::deoptimize_frame.
friend class Deoptimization;
private:
public:
void doit();
bool allow_nested_vm_operations() const { return true; }
};
private:
bool _is_full;
public:
void doit();
bool allow_nested_vm_operations() const { return true; }
};
#ifndef PRODUCT
private:
public:
VM_DeoptimizeAll() {}
void doit();
bool allow_nested_vm_operations() const { return true; }
};
public:
VM_ZombieAll() {}
void doit();
bool allow_nested_vm_operations() const { return true; }
};
#endif // PRODUCT
public:
VM_UnlinkSymbols() {}
void doit();
bool allow_nested_vm_operations() const { return true; }
};
private:
public:
VM_Verify() {}
void doit();
};
private:
bool _print_concurrent_locks;
public:
VM_PrintThreads(outputStream* out, bool print_concurrent_locks) { _out = out; _print_concurrent_locks = print_concurrent_locks; }
void doit();
bool doit_prologue();
void doit_epilogue();
};
private:
public:
void doit();
};
class DeadlockCycle;
private:
bool _concurrent_locks;
public:
VM_FindDeadlocks(bool concurrent_locks) : _concurrent_locks(concurrent_locks), _out(NULL), _deadlocks(NULL) {};
~VM_FindDeadlocks();
void doit();
bool doit_prologue();
};
class ThreadDumpResult;
class ThreadSnapshot;
class ThreadConcurrentLocks;
private:
int _num_threads;
int _max_depth;
bool _with_locked_monitors;
public:
int max_depth, // -1 indicates entire stack
bool with_locked_monitors,
bool with_locked_synchronizers);
int num_threads, // -1 indicates entire stack
int max_depth,
bool with_locked_monitors,
bool with_locked_synchronizers);
void doit();
bool doit_prologue();
void doit_epilogue();
};
private:
int _exit_code;
static volatile bool _vm_exited;
static void wait_if_vm_exited();
public:
}
static int wait_for_threads_in_native_to_block();
static int set_vm_exited();
static void block_if_vm_exited() {
if (_vm_exited) {
}
}
void doit();
};
#endif // SHARE_VM_RUNTIME_VM_OPERATIONS_HPP