提交 8b69ac67 编写于 作者: I iveresov

7131259: compile_method and CompilationPolicy::event shouldn't be declared TRAPS

Summary: Make sure that CompilationPolicy::event() doesn't throw exceptions
Reviewed-by: kvn, never
上级 68e13e50
...@@ -413,8 +413,9 @@ static nmethod* counter_overflow_helper(JavaThread* THREAD, int branch_bci, meth ...@@ -413,8 +413,9 @@ static nmethod* counter_overflow_helper(JavaThread* THREAD, int branch_bci, meth
} }
bci = branch_bci + offset; bci = branch_bci + offset;
} }
assert(!HAS_PENDING_EXCEPTION, "Should not have any exceptions pending");
osr_nm = CompilationPolicy::policy()->event(enclosing_method, method, branch_bci, bci, level, nm, THREAD); osr_nm = CompilationPolicy::policy()->event(enclosing_method, method, branch_bci, bci, level, nm, THREAD);
assert(!HAS_PENDING_EXCEPTION, "Event handler should not throw any exceptions");
return osr_nm; return osr_nm;
} }
......
...@@ -961,7 +961,7 @@ void CompileBroker::compile_method_base(methodHandle method, ...@@ -961,7 +961,7 @@ void CompileBroker::compile_method_base(methodHandle method,
methodHandle hot_method, methodHandle hot_method,
int hot_count, int hot_count,
const char* comment, const char* comment,
TRAPS) { Thread* thread) {
// do nothing if compiler thread(s) is not available // do nothing if compiler thread(s) is not available
if (!_initialized ) { if (!_initialized ) {
return; return;
...@@ -1037,7 +1037,7 @@ void CompileBroker::compile_method_base(methodHandle method, ...@@ -1037,7 +1037,7 @@ void CompileBroker::compile_method_base(methodHandle method,
// Acquire our lock. // Acquire our lock.
{ {
MutexLocker locker(queue->lock(), THREAD); MutexLocker locker(queue->lock(), thread);
// Make sure the method has not slipped into the queues since // Make sure the method has not slipped into the queues since
// last we checked; note that those checks were "fast bail-outs". // last we checked; note that those checks were "fast bail-outs".
...@@ -1119,7 +1119,7 @@ void CompileBroker::compile_method_base(methodHandle method, ...@@ -1119,7 +1119,7 @@ void CompileBroker::compile_method_base(methodHandle method,
nmethod* CompileBroker::compile_method(methodHandle method, int osr_bci, nmethod* CompileBroker::compile_method(methodHandle method, int osr_bci,
int comp_level, int comp_level,
methodHandle hot_method, int hot_count, methodHandle hot_method, int hot_count,
const char* comment, TRAPS) { const char* comment, Thread* THREAD) {
// make sure arguments make sense // make sure arguments make sense
assert(method->method_holder()->klass_part()->oop_is_instance(), "not an instance method"); assert(method->method_holder()->klass_part()->oop_is_instance(), "not an instance method");
assert(osr_bci == InvocationEntryBci || (0 <= osr_bci && osr_bci < method->code_size()), "bci out of range"); assert(osr_bci == InvocationEntryBci || (0 <= osr_bci && osr_bci < method->code_size()), "bci out of range");
...@@ -1173,10 +1173,10 @@ nmethod* CompileBroker::compile_method(methodHandle method, int osr_bci, ...@@ -1173,10 +1173,10 @@ nmethod* CompileBroker::compile_method(methodHandle method, int osr_bci,
assert(!HAS_PENDING_EXCEPTION, "No exception should be present"); assert(!HAS_PENDING_EXCEPTION, "No exception should be present");
// some prerequisites that are compiler specific // some prerequisites that are compiler specific
if (compiler(comp_level)->is_c2() || compiler(comp_level)->is_shark()) { if (compiler(comp_level)->is_c2() || compiler(comp_level)->is_shark()) {
method->constants()->resolve_string_constants(CHECK_0); method->constants()->resolve_string_constants(CHECK_AND_CLEAR_NULL);
// Resolve all classes seen in the signature of the method // Resolve all classes seen in the signature of the method
// we are compiling. // we are compiling.
methodOopDesc::load_signature_classes(method, CHECK_0); methodOopDesc::load_signature_classes(method, CHECK_AND_CLEAR_NULL);
} }
// If the method is native, do the lookup in the thread requesting // If the method is native, do the lookup in the thread requesting
...@@ -1230,7 +1230,7 @@ nmethod* CompileBroker::compile_method(methodHandle method, int osr_bci, ...@@ -1230,7 +1230,7 @@ nmethod* CompileBroker::compile_method(methodHandle method, int osr_bci,
return NULL; return NULL;
} }
} else { } else {
compile_method_base(method, osr_bci, comp_level, hot_method, hot_count, comment, CHECK_0); compile_method_base(method, osr_bci, comp_level, hot_method, hot_count, comment, THREAD);
} }
// return requested nmethod // return requested nmethod
......
...@@ -333,7 +333,7 @@ class CompileBroker: AllStatic { ...@@ -333,7 +333,7 @@ class CompileBroker: AllStatic {
methodHandle hot_method, methodHandle hot_method,
int hot_count, int hot_count,
const char* comment, const char* comment,
TRAPS); Thread* thread);
static CompileQueue* compile_queue(int comp_level) { static CompileQueue* compile_queue(int comp_level) {
if (is_c2_compile(comp_level)) return _c2_method_queue; if (is_c2_compile(comp_level)) return _c2_method_queue;
if (is_c1_compile(comp_level)) return _c1_method_queue; if (is_c1_compile(comp_level)) return _c1_method_queue;
...@@ -363,7 +363,7 @@ class CompileBroker: AllStatic { ...@@ -363,7 +363,7 @@ class CompileBroker: AllStatic {
int comp_level, int comp_level,
methodHandle hot_method, methodHandle hot_method,
int hot_count, int hot_count,
const char* comment, TRAPS); const char* comment, Thread* thread);
static void compiler_thread_loop(); static void compiler_thread_loop();
......
...@@ -859,7 +859,9 @@ IRT_ENTRY(nmethod*, ...@@ -859,7 +859,9 @@ IRT_ENTRY(nmethod*,
const int branch_bci = branch_bcp != NULL ? method->bci_from(branch_bcp) : InvocationEntryBci; const int branch_bci = branch_bcp != NULL ? method->bci_from(branch_bcp) : InvocationEntryBci;
const int bci = branch_bcp != NULL ? method->bci_from(fr.interpreter_frame_bcp()) : InvocationEntryBci; const int bci = branch_bcp != NULL ? method->bci_from(fr.interpreter_frame_bcp()) : InvocationEntryBci;
assert(!HAS_PENDING_EXCEPTION, "Should not have any exceptions pending");
nmethod* osr_nm = CompilationPolicy::policy()->event(method, method, branch_bci, bci, CompLevel_none, NULL, thread); nmethod* osr_nm = CompilationPolicy::policy()->event(method, method, branch_bci, bci, CompLevel_none, NULL, thread);
assert(!HAS_PENDING_EXCEPTION, "Event handler should not throw any exceptions");
if (osr_nm != NULL) { if (osr_nm != NULL) {
// We may need to do on-stack replacement which requires that no // We may need to do on-stack replacement which requires that no
......
...@@ -271,13 +271,10 @@ bool AdvancedThresholdPolicy::should_not_inline(ciEnv* env, ciMethod* callee) { ...@@ -271,13 +271,10 @@ bool AdvancedThresholdPolicy::should_not_inline(ciEnv* env, ciMethod* callee) {
} }
// Create MDO if necessary. // Create MDO if necessary.
void AdvancedThresholdPolicy::create_mdo(methodHandle mh, TRAPS) { void AdvancedThresholdPolicy::create_mdo(methodHandle mh, JavaThread* THREAD) {
if (mh->is_native() || mh->is_abstract() || mh->is_accessor()) return; if (mh->is_native() || mh->is_abstract() || mh->is_accessor()) return;
if (mh->method_data() == NULL) { if (mh->method_data() == NULL) {
methodOopDesc::build_interpreter_method_data(mh, THREAD); methodOopDesc::build_interpreter_method_data(mh, CHECK_AND_CLEAR);
if (HAS_PENDING_EXCEPTION) {
CLEAR_PENDING_EXCEPTION;
}
} }
} }
...@@ -426,22 +423,22 @@ CompLevel AdvancedThresholdPolicy::loop_event(methodOop method, CompLevel cur_le ...@@ -426,22 +423,22 @@ CompLevel AdvancedThresholdPolicy::loop_event(methodOop method, CompLevel cur_le
} }
// Update the rate and submit compile // Update the rate and submit compile
void AdvancedThresholdPolicy::submit_compile(methodHandle mh, int bci, CompLevel level, TRAPS) { void AdvancedThresholdPolicy::submit_compile(methodHandle mh, int bci, CompLevel level, JavaThread* thread) {
int hot_count = (bci == InvocationEntryBci) ? mh->invocation_count() : mh->backedge_count(); int hot_count = (bci == InvocationEntryBci) ? mh->invocation_count() : mh->backedge_count();
update_rate(os::javaTimeMillis(), mh()); update_rate(os::javaTimeMillis(), mh());
CompileBroker::compile_method(mh, bci, level, mh, hot_count, "tiered", THREAD); CompileBroker::compile_method(mh, bci, level, mh, hot_count, "tiered", thread);
} }
// Handle the invocation event. // Handle the invocation event.
void AdvancedThresholdPolicy::method_invocation_event(methodHandle mh, methodHandle imh, void AdvancedThresholdPolicy::method_invocation_event(methodHandle mh, methodHandle imh,
CompLevel level, nmethod* nm, TRAPS) { CompLevel level, nmethod* nm, JavaThread* thread) {
if (should_create_mdo(mh(), level)) { if (should_create_mdo(mh(), level)) {
create_mdo(mh, THREAD); create_mdo(mh, thread);
} }
if (is_compilation_enabled() && !CompileBroker::compilation_is_in_queue(mh, InvocationEntryBci)) { if (is_compilation_enabled() && !CompileBroker::compilation_is_in_queue(mh, InvocationEntryBci)) {
CompLevel next_level = call_event(mh(), level); CompLevel next_level = call_event(mh(), level);
if (next_level != level) { if (next_level != level) {
compile(mh, InvocationEntryBci, next_level, THREAD); compile(mh, InvocationEntryBci, next_level, thread);
} }
} }
} }
...@@ -449,13 +446,13 @@ void AdvancedThresholdPolicy::method_invocation_event(methodHandle mh, methodHan ...@@ -449,13 +446,13 @@ void AdvancedThresholdPolicy::method_invocation_event(methodHandle mh, methodHan
// Handle the back branch event. Notice that we can compile the method // Handle the back branch event. Notice that we can compile the method
// with a regular entry from here. // with a regular entry from here.
void AdvancedThresholdPolicy::method_back_branch_event(methodHandle mh, methodHandle imh, void AdvancedThresholdPolicy::method_back_branch_event(methodHandle mh, methodHandle imh,
int bci, CompLevel level, nmethod* nm, TRAPS) { int bci, CompLevel level, nmethod* nm, JavaThread* thread) {
if (should_create_mdo(mh(), level)) { if (should_create_mdo(mh(), level)) {
create_mdo(mh, THREAD); create_mdo(mh, thread);
} }
// Check if MDO should be created for the inlined method // Check if MDO should be created for the inlined method
if (should_create_mdo(imh(), level)) { if (should_create_mdo(imh(), level)) {
create_mdo(imh, THREAD); create_mdo(imh, thread);
} }
if (is_compilation_enabled()) { if (is_compilation_enabled()) {
...@@ -463,7 +460,7 @@ void AdvancedThresholdPolicy::method_back_branch_event(methodHandle mh, methodHa ...@@ -463,7 +460,7 @@ void AdvancedThresholdPolicy::method_back_branch_event(methodHandle mh, methodHa
CompLevel max_osr_level = (CompLevel)imh->highest_osr_comp_level(); CompLevel max_osr_level = (CompLevel)imh->highest_osr_comp_level();
// At the very least compile the OSR version // At the very least compile the OSR version
if (!CompileBroker::compilation_is_in_queue(imh, bci) && next_osr_level != level) { if (!CompileBroker::compilation_is_in_queue(imh, bci) && next_osr_level != level) {
compile(imh, bci, next_osr_level, THREAD); compile(imh, bci, next_osr_level, thread);
} }
// Use loop event as an opportunity to also check if there's been // Use loop event as an opportunity to also check if there's been
...@@ -502,14 +499,14 @@ void AdvancedThresholdPolicy::method_back_branch_event(methodHandle mh, methodHa ...@@ -502,14 +499,14 @@ void AdvancedThresholdPolicy::method_back_branch_event(methodHandle mh, methodHa
next_level = CompLevel_full_profile; next_level = CompLevel_full_profile;
} }
if (cur_level != next_level) { if (cur_level != next_level) {
compile(mh, InvocationEntryBci, next_level, THREAD); compile(mh, InvocationEntryBci, next_level, thread);
} }
} }
} else { } else {
cur_level = comp_level(imh()); cur_level = comp_level(imh());
next_level = call_event(imh(), cur_level); next_level = call_event(imh(), cur_level);
if (!CompileBroker::compilation_is_in_queue(imh, bci) && next_level != cur_level) { if (!CompileBroker::compilation_is_in_queue(imh, bci) && next_level != cur_level) {
compile(imh, InvocationEntryBci, next_level, THREAD); compile(imh, InvocationEntryBci, next_level, thread);
} }
} }
} }
......
...@@ -197,7 +197,7 @@ class AdvancedThresholdPolicy : public SimpleThresholdPolicy { ...@@ -197,7 +197,7 @@ class AdvancedThresholdPolicy : public SimpleThresholdPolicy {
// determines whether we should do that. // determines whether we should do that.
inline bool should_create_mdo(methodOop method, CompLevel cur_level); inline bool should_create_mdo(methodOop method, CompLevel cur_level);
// Create MDO if necessary. // Create MDO if necessary.
void create_mdo(methodHandle mh, TRAPS); void create_mdo(methodHandle mh, JavaThread* thread);
// Is method profiled enough? // Is method profiled enough?
bool is_method_profiled(methodOop method); bool is_method_profiled(methodOop method);
...@@ -208,12 +208,12 @@ protected: ...@@ -208,12 +208,12 @@ protected:
jlong start_time() const { return _start_time; } jlong start_time() const { return _start_time; }
// Submit a given method for compilation (and update the rate). // Submit a given method for compilation (and update the rate).
virtual void submit_compile(methodHandle mh, int bci, CompLevel level, TRAPS); virtual void submit_compile(methodHandle mh, int bci, CompLevel level, JavaThread* thread);
// event() from SimpleThresholdPolicy would call these. // event() from SimpleThresholdPolicy would call these.
virtual void method_invocation_event(methodHandle method, methodHandle inlinee, virtual void method_invocation_event(methodHandle method, methodHandle inlinee,
CompLevel level, nmethod* nm, TRAPS); CompLevel level, nmethod* nm, JavaThread* thread);
virtual void method_back_branch_event(methodHandle method, methodHandle inlinee, virtual void method_back_branch_event(methodHandle method, methodHandle inlinee,
int bci, CompLevel level, nmethod* nm, TRAPS); int bci, CompLevel level, nmethod* nm, JavaThread* thread);
public: public:
AdvancedThresholdPolicy() : _start_time(0) { } AdvancedThresholdPolicy() : _start_time(0) { }
// Select task is called by CompileBroker. We should return a task or NULL. // Select task is called by CompileBroker. We should return a task or NULL.
......
...@@ -306,29 +306,27 @@ bool NonTieredCompPolicy::is_mature(methodOop method) { ...@@ -306,29 +306,27 @@ bool NonTieredCompPolicy::is_mature(methodOop method) {
return (current >= initial + target); return (current >= initial + target);
} }
nmethod* NonTieredCompPolicy::event(methodHandle method, methodHandle inlinee, int branch_bci, int bci, CompLevel comp_level, nmethod* nm, TRAPS) { nmethod* NonTieredCompPolicy::event(methodHandle method, methodHandle inlinee, int branch_bci,
int bci, CompLevel comp_level, nmethod* nm, JavaThread* thread) {
assert(comp_level == CompLevel_none, "This should be only called from the interpreter"); assert(comp_level == CompLevel_none, "This should be only called from the interpreter");
NOT_PRODUCT(trace_frequency_counter_overflow(method, branch_bci, bci)); NOT_PRODUCT(trace_frequency_counter_overflow(method, branch_bci, bci));
if (JvmtiExport::can_post_interpreter_events()) { if (JvmtiExport::can_post_interpreter_events() && thread->is_interp_only_mode()) {
assert(THREAD->is_Java_thread(), "Wrong type of thread"); // If certain JVMTI events (e.g. frame pop event) are requested then the
if (((JavaThread*)THREAD)->is_interp_only_mode()) { // thread is forced to remain in interpreted code. This is
// If certain JVMTI events (e.g. frame pop event) are requested then the // implemented partly by a check in the run_compiled_code
// thread is forced to remain in interpreted code. This is // section of the interpreter whether we should skip running
// implemented partly by a check in the run_compiled_code // compiled code, and partly by skipping OSR compiles for
// section of the interpreter whether we should skip running // interpreted-only threads.
// compiled code, and partly by skipping OSR compiles for if (bci != InvocationEntryBci) {
// interpreted-only threads. reset_counter_for_back_branch_event(method);
if (bci != InvocationEntryBci) { return NULL;
reset_counter_for_back_branch_event(method);
return NULL;
}
} }
} }
if (bci == InvocationEntryBci) { if (bci == InvocationEntryBci) {
// when code cache is full, compilation gets switched off, UseCompiler // when code cache is full, compilation gets switched off, UseCompiler
// is set to false // is set to false
if (!method->has_compiled_code() && UseCompiler) { if (!method->has_compiled_code() && UseCompiler) {
method_invocation_event(method, CHECK_NULL); method_invocation_event(method, thread);
} else { } else {
// Force counter overflow on method entry, even if no compilation // Force counter overflow on method entry, even if no compilation
// happened. (The method_invocation_event call does this also.) // happened. (The method_invocation_event call does this also.)
...@@ -344,7 +342,7 @@ nmethod* NonTieredCompPolicy::event(methodHandle method, methodHandle inlinee, i ...@@ -344,7 +342,7 @@ nmethod* NonTieredCompPolicy::event(methodHandle method, methodHandle inlinee, i
NOT_PRODUCT(trace_osr_request(method, osr_nm, bci)); NOT_PRODUCT(trace_osr_request(method, osr_nm, bci));
// when code cache is full, we should not compile any more... // when code cache is full, we should not compile any more...
if (osr_nm == NULL && UseCompiler) { if (osr_nm == NULL && UseCompiler) {
method_back_branch_event(method, bci, CHECK_NULL); method_back_branch_event(method, bci, thread);
osr_nm = method->lookup_osr_nmethod_for(bci, CompLevel_highest_tier, true); osr_nm = method->lookup_osr_nmethod_for(bci, CompLevel_highest_tier, true);
} }
if (osr_nm == NULL) { if (osr_nm == NULL) {
...@@ -395,7 +393,7 @@ void NonTieredCompPolicy::trace_osr_request(methodHandle method, nmethod* osr, i ...@@ -395,7 +393,7 @@ void NonTieredCompPolicy::trace_osr_request(methodHandle method, nmethod* osr, i
// SimpleCompPolicy - compile current method // SimpleCompPolicy - compile current method
void SimpleCompPolicy::method_invocation_event( methodHandle m, TRAPS) { void SimpleCompPolicy::method_invocation_event(methodHandle m, JavaThread* thread) {
int hot_count = m->invocation_count(); int hot_count = m->invocation_count();
reset_counter_for_invocation_event(m); reset_counter_for_invocation_event(m);
const char* comment = "count"; const char* comment = "count";
...@@ -405,18 +403,18 @@ void SimpleCompPolicy::method_invocation_event( methodHandle m, TRAPS) { ...@@ -405,18 +403,18 @@ void SimpleCompPolicy::method_invocation_event( methodHandle m, TRAPS) {
if (nm == NULL ) { if (nm == NULL ) {
const char* comment = "count"; const char* comment = "count";
CompileBroker::compile_method(m, InvocationEntryBci, CompLevel_highest_tier, CompileBroker::compile_method(m, InvocationEntryBci, CompLevel_highest_tier,
m, hot_count, comment, CHECK); m, hot_count, comment, thread);
} }
} }
} }
void SimpleCompPolicy::method_back_branch_event(methodHandle m, int bci, TRAPS) { void SimpleCompPolicy::method_back_branch_event(methodHandle m, int bci, JavaThread* thread) {
int hot_count = m->backedge_count(); int hot_count = m->backedge_count();
const char* comment = "backedge_count"; const char* comment = "backedge_count";
if (is_compilation_enabled() && !m->is_not_osr_compilable() && can_be_compiled(m)) { if (is_compilation_enabled() && !m->is_not_osr_compilable() && can_be_compiled(m)) {
CompileBroker::compile_method(m, bci, CompLevel_highest_tier, CompileBroker::compile_method(m, bci, CompLevel_highest_tier,
m, hot_count, comment, CHECK); m, hot_count, comment, thread);
NOT_PRODUCT(trace_osr_completion(m->lookup_osr_nmethod_for(bci, CompLevel_highest_tier, true));) NOT_PRODUCT(trace_osr_completion(m->lookup_osr_nmethod_for(bci, CompLevel_highest_tier, true));)
} }
} }
...@@ -427,14 +425,13 @@ const char* StackWalkCompPolicy::_msg = NULL; ...@@ -427,14 +425,13 @@ const char* StackWalkCompPolicy::_msg = NULL;
// Consider m for compilation // Consider m for compilation
void StackWalkCompPolicy::method_invocation_event(methodHandle m, TRAPS) { void StackWalkCompPolicy::method_invocation_event(methodHandle m, JavaThread* thread) {
int hot_count = m->invocation_count(); int hot_count = m->invocation_count();
reset_counter_for_invocation_event(m); reset_counter_for_invocation_event(m);
const char* comment = "count"; const char* comment = "count";
if (is_compilation_enabled() && m->code() == NULL && can_be_compiled(m)) { if (is_compilation_enabled() && m->code() == NULL && can_be_compiled(m)) {
ResourceMark rm(THREAD); ResourceMark rm(thread);
JavaThread *thread = (JavaThread*)THREAD;
frame fr = thread->last_frame(); frame fr = thread->last_frame();
assert(fr.is_interpreted_frame(), "must be interpreted"); assert(fr.is_interpreted_frame(), "must be interpreted");
assert(fr.interpreter_frame_method() == m(), "bad method"); assert(fr.interpreter_frame_method() == m(), "bad method");
...@@ -461,17 +458,17 @@ void StackWalkCompPolicy::method_invocation_event(methodHandle m, TRAPS) { ...@@ -461,17 +458,17 @@ void StackWalkCompPolicy::method_invocation_event(methodHandle m, TRAPS) {
assert(top != NULL, "findTopInlinableFrame returned null"); assert(top != NULL, "findTopInlinableFrame returned null");
if (TraceCompilationPolicy) top->print(); if (TraceCompilationPolicy) top->print();
CompileBroker::compile_method(top->top_method(), InvocationEntryBci, CompLevel_highest_tier, CompileBroker::compile_method(top->top_method(), InvocationEntryBci, CompLevel_highest_tier,
m, hot_count, comment, CHECK); m, hot_count, comment, thread);
} }
} }
} }
void StackWalkCompPolicy::method_back_branch_event(methodHandle m, int bci, TRAPS) { void StackWalkCompPolicy::method_back_branch_event(methodHandle m, int bci, JavaThread* thread) {
int hot_count = m->backedge_count(); int hot_count = m->backedge_count();
const char* comment = "backedge_count"; const char* comment = "backedge_count";
if (is_compilation_enabled() && !m->is_not_osr_compilable() && can_be_compiled(m)) { if (is_compilation_enabled() && !m->is_not_osr_compilable() && can_be_compiled(m)) {
CompileBroker::compile_method(m, bci, CompLevel_highest_tier, m, hot_count, comment, CHECK); CompileBroker::compile_method(m, bci, CompLevel_highest_tier, m, hot_count, comment, thread);
NOT_PRODUCT(trace_osr_completion(m->lookup_osr_nmethod_for(bci, CompLevel_highest_tier, true));) NOT_PRODUCT(trace_osr_completion(m->lookup_osr_nmethod_for(bci, CompLevel_highest_tier, true));)
} }
......
...@@ -64,7 +64,7 @@ public: ...@@ -64,7 +64,7 @@ public:
virtual int compiler_count(CompLevel comp_level) = 0; virtual int compiler_count(CompLevel comp_level) = 0;
// main notification entry, return a pointer to an nmethod if the OSR is required, // main notification entry, return a pointer to an nmethod if the OSR is required,
// returns NULL otherwise. // returns NULL otherwise.
virtual nmethod* event(methodHandle method, methodHandle inlinee, int branch_bci, int bci, CompLevel comp_level, nmethod* nm, TRAPS) = 0; virtual nmethod* event(methodHandle method, methodHandle inlinee, int branch_bci, int bci, CompLevel comp_level, nmethod* nm, JavaThread* thread) = 0;
// safepoint() is called at the end of the safepoint // safepoint() is called at the end of the safepoint
virtual void do_safepoint_work() = 0; virtual void do_safepoint_work() = 0;
// reprofile request // reprofile request
...@@ -105,15 +105,15 @@ public: ...@@ -105,15 +105,15 @@ public:
virtual bool is_mature(methodOop method); virtual bool is_mature(methodOop method);
virtual void initialize(); virtual void initialize();
virtual CompileTask* select_task(CompileQueue* compile_queue); virtual CompileTask* select_task(CompileQueue* compile_queue);
virtual nmethod* event(methodHandle method, methodHandle inlinee, int branch_bci, int bci, CompLevel comp_level, nmethod* nm, TRAPS); virtual nmethod* event(methodHandle method, methodHandle inlinee, int branch_bci, int bci, CompLevel comp_level, nmethod* nm, JavaThread* thread);
virtual void method_invocation_event(methodHandle m, TRAPS) = 0; virtual void method_invocation_event(methodHandle m, JavaThread* thread) = 0;
virtual void method_back_branch_event(methodHandle m, int bci, TRAPS) = 0; virtual void method_back_branch_event(methodHandle m, int bci, JavaThread* thread) = 0;
}; };
class SimpleCompPolicy : public NonTieredCompPolicy { class SimpleCompPolicy : public NonTieredCompPolicy {
public: public:
virtual void method_invocation_event(methodHandle m, TRAPS); virtual void method_invocation_event(methodHandle m, JavaThread* thread);
virtual void method_back_branch_event(methodHandle m, int bci, TRAPS); virtual void method_back_branch_event(methodHandle m, int bci, JavaThread* thread);
}; };
// StackWalkCompPolicy - existing C2 policy // StackWalkCompPolicy - existing C2 policy
...@@ -121,8 +121,8 @@ class SimpleCompPolicy : public NonTieredCompPolicy { ...@@ -121,8 +121,8 @@ class SimpleCompPolicy : public NonTieredCompPolicy {
#ifdef COMPILER2 #ifdef COMPILER2
class StackWalkCompPolicy : public NonTieredCompPolicy { class StackWalkCompPolicy : public NonTieredCompPolicy {
public: public:
virtual void method_invocation_event(methodHandle m, TRAPS); virtual void method_invocation_event(methodHandle m, JavaThread* thread);
virtual void method_back_branch_event(methodHandle m, int bci, TRAPS); virtual void method_back_branch_event(methodHandle m, int bci, JavaThread* thread);
private: private:
RFrame* findTopInlinableFrame(GrowableArray<RFrame*>* stack); RFrame* findTopInlinableFrame(GrowableArray<RFrame*>* stack);
......
...@@ -177,13 +177,11 @@ void SimpleThresholdPolicy::reprofile(ScopeDesc* trap_scope, bool is_osr) { ...@@ -177,13 +177,11 @@ void SimpleThresholdPolicy::reprofile(ScopeDesc* trap_scope, bool is_osr) {
} }
nmethod* SimpleThresholdPolicy::event(methodHandle method, methodHandle inlinee, nmethod* SimpleThresholdPolicy::event(methodHandle method, methodHandle inlinee,
int branch_bci, int bci, CompLevel comp_level, nmethod* nm, TRAPS) { int branch_bci, int bci, CompLevel comp_level, nmethod* nm, JavaThread* thread) {
if (comp_level == CompLevel_none && if (comp_level == CompLevel_none &&
JvmtiExport::can_post_interpreter_events()) { JvmtiExport::can_post_interpreter_events() &&
assert(THREAD->is_Java_thread(), "Should be java thread"); thread->is_interp_only_mode()) {
if (((JavaThread*)THREAD)->is_interp_only_mode()) { return NULL;
return NULL;
}
} }
nmethod *osr_nm = NULL; nmethod *osr_nm = NULL;
...@@ -197,9 +195,9 @@ nmethod* SimpleThresholdPolicy::event(methodHandle method, methodHandle inlinee, ...@@ -197,9 +195,9 @@ nmethod* SimpleThresholdPolicy::event(methodHandle method, methodHandle inlinee,
} }
if (bci == InvocationEntryBci) { if (bci == InvocationEntryBci) {
method_invocation_event(method, inlinee, comp_level, nm, THREAD); method_invocation_event(method, inlinee, comp_level, nm, thread);
} else { } else {
method_back_branch_event(method, inlinee, bci, comp_level, nm, THREAD); method_back_branch_event(method, inlinee, bci, comp_level, nm, thread);
// method == inlinee if the event originated in the main method // method == inlinee if the event originated in the main method
int highest_level = inlinee->highest_osr_comp_level(); int highest_level = inlinee->highest_osr_comp_level();
if (highest_level > comp_level) { if (highest_level > comp_level) {
...@@ -210,7 +208,7 @@ nmethod* SimpleThresholdPolicy::event(methodHandle method, methodHandle inlinee, ...@@ -210,7 +208,7 @@ nmethod* SimpleThresholdPolicy::event(methodHandle method, methodHandle inlinee,
} }
// Check if the method can be compiled, change level if necessary // Check if the method can be compiled, change level if necessary
void SimpleThresholdPolicy::compile(methodHandle mh, int bci, CompLevel level, TRAPS) { void SimpleThresholdPolicy::compile(methodHandle mh, int bci, CompLevel level, JavaThread* thread) {
assert(level <= TieredStopAtLevel, "Invalid compilation level"); assert(level <= TieredStopAtLevel, "Invalid compilation level");
if (level == CompLevel_none) { if (level == CompLevel_none) {
return; return;
...@@ -221,7 +219,7 @@ void SimpleThresholdPolicy::compile(methodHandle mh, int bci, CompLevel level, T ...@@ -221,7 +219,7 @@ void SimpleThresholdPolicy::compile(methodHandle mh, int bci, CompLevel level, T
// pure C1. // pure C1.
if (!can_be_compiled(mh, level)) { if (!can_be_compiled(mh, level)) {
if (level == CompLevel_full_optimization && can_be_compiled(mh, CompLevel_simple)) { if (level == CompLevel_full_optimization && can_be_compiled(mh, CompLevel_simple)) {
compile(mh, bci, CompLevel_simple, THREAD); compile(mh, bci, CompLevel_simple, thread);
} }
return; return;
} }
...@@ -232,14 +230,14 @@ void SimpleThresholdPolicy::compile(methodHandle mh, int bci, CompLevel level, T ...@@ -232,14 +230,14 @@ void SimpleThresholdPolicy::compile(methodHandle mh, int bci, CompLevel level, T
if (PrintTieredEvents) { if (PrintTieredEvents) {
print_event(COMPILE, mh, mh, bci, level); print_event(COMPILE, mh, mh, bci, level);
} }
submit_compile(mh, bci, level, THREAD); submit_compile(mh, bci, level, thread);
} }
} }
// Tell the broker to compile the method // Tell the broker to compile the method
void SimpleThresholdPolicy::submit_compile(methodHandle mh, int bci, CompLevel level, TRAPS) { void SimpleThresholdPolicy::submit_compile(methodHandle mh, int bci, CompLevel level, JavaThread* thread) {
int hot_count = (bci == InvocationEntryBci) ? mh->invocation_count() : mh->backedge_count(); int hot_count = (bci == InvocationEntryBci) ? mh->invocation_count() : mh->backedge_count();
CompileBroker::compile_method(mh, bci, level, mh, hot_count, "tiered", THREAD); CompileBroker::compile_method(mh, bci, level, mh, hot_count, "tiered", thread);
} }
// Call and loop predicates determine whether a transition to a higher // Call and loop predicates determine whether a transition to a higher
...@@ -366,11 +364,11 @@ CompLevel SimpleThresholdPolicy::loop_event(methodOop method, CompLevel cur_leve ...@@ -366,11 +364,11 @@ CompLevel SimpleThresholdPolicy::loop_event(methodOop method, CompLevel cur_leve
// Handle the invocation event. // Handle the invocation event.
void SimpleThresholdPolicy::method_invocation_event(methodHandle mh, methodHandle imh, void SimpleThresholdPolicy::method_invocation_event(methodHandle mh, methodHandle imh,
CompLevel level, nmethod* nm, TRAPS) { CompLevel level, nmethod* nm, JavaThread* thread) {
if (is_compilation_enabled() && !CompileBroker::compilation_is_in_queue(mh, InvocationEntryBci)) { if (is_compilation_enabled() && !CompileBroker::compilation_is_in_queue(mh, InvocationEntryBci)) {
CompLevel next_level = call_event(mh(), level); CompLevel next_level = call_event(mh(), level);
if (next_level != level) { if (next_level != level) {
compile(mh, InvocationEntryBci, next_level, THREAD); compile(mh, InvocationEntryBci, next_level, thread);
} }
} }
} }
...@@ -378,7 +376,7 @@ void SimpleThresholdPolicy::method_invocation_event(methodHandle mh, methodHandl ...@@ -378,7 +376,7 @@ void SimpleThresholdPolicy::method_invocation_event(methodHandle mh, methodHandl
// Handle the back branch event. Notice that we can compile the method // Handle the back branch event. Notice that we can compile the method
// with a regular entry from here. // with a regular entry from here.
void SimpleThresholdPolicy::method_back_branch_event(methodHandle mh, methodHandle imh, void SimpleThresholdPolicy::method_back_branch_event(methodHandle mh, methodHandle imh,
int bci, CompLevel level, nmethod* nm, TRAPS) { int bci, CompLevel level, nmethod* nm, JavaThread* thread) {
// If the method is already compiling, quickly bail out. // If the method is already compiling, quickly bail out.
if (is_compilation_enabled() && !CompileBroker::compilation_is_in_queue(mh, bci)) { if (is_compilation_enabled() && !CompileBroker::compilation_is_in_queue(mh, bci)) {
// Use loop event as an opportinity to also check there's been // Use loop event as an opportinity to also check there's been
...@@ -391,13 +389,13 @@ void SimpleThresholdPolicy::method_back_branch_event(methodHandle mh, methodHand ...@@ -391,13 +389,13 @@ void SimpleThresholdPolicy::method_back_branch_event(methodHandle mh, methodHand
next_osr_level < CompLevel_full_optimization ? next_osr_level : cur_level); next_osr_level < CompLevel_full_optimization ? next_osr_level : cur_level);
bool is_compiling = false; bool is_compiling = false;
if (next_level != cur_level) { if (next_level != cur_level) {
compile(mh, InvocationEntryBci, next_level, THREAD); compile(mh, InvocationEntryBci, next_level, thread);
is_compiling = true; is_compiling = true;
} }
// Do the OSR version // Do the OSR version
if (!is_compiling && next_osr_level != level) { if (!is_compiling && next_osr_level != level) {
compile(mh, bci, next_osr_level, THREAD); compile(mh, bci, next_osr_level, thread);
} }
} }
} }
...@@ -67,9 +67,9 @@ protected: ...@@ -67,9 +67,9 @@ protected:
// Print policy-specific information if necessary // Print policy-specific information if necessary
virtual void print_specific(EventType type, methodHandle mh, methodHandle imh, int bci, CompLevel level) { } virtual void print_specific(EventType type, methodHandle mh, methodHandle imh, int bci, CompLevel level) { }
// Check if the method can be compiled, change level if necessary // Check if the method can be compiled, change level if necessary
void compile(methodHandle mh, int bci, CompLevel level, TRAPS); void compile(methodHandle mh, int bci, CompLevel level, JavaThread* thread);
// Submit a given method for compilation // Submit a given method for compilation
virtual void submit_compile(methodHandle mh, int bci, CompLevel level, TRAPS); virtual void submit_compile(methodHandle mh, int bci, CompLevel level, JavaThread* thread);
// Simple methods are as good being compiled with C1 as C2. // Simple methods are as good being compiled with C1 as C2.
// This function tells if it's such a function. // This function tells if it's such a function.
inline bool is_trivial(methodOop method); inline bool is_trivial(methodOop method);
...@@ -88,9 +88,9 @@ protected: ...@@ -88,9 +88,9 @@ protected:
return CompLevel_none; return CompLevel_none;
} }
virtual void method_invocation_event(methodHandle method, methodHandle inlinee, virtual void method_invocation_event(methodHandle method, methodHandle inlinee,
CompLevel level, nmethod* nm, TRAPS); CompLevel level, nmethod* nm, JavaThread* thread);
virtual void method_back_branch_event(methodHandle method, methodHandle inlinee, virtual void method_back_branch_event(methodHandle method, methodHandle inlinee,
int bci, CompLevel level, nmethod* nm, TRAPS); int bci, CompLevel level, nmethod* nm, JavaThread* thread);
public: public:
SimpleThresholdPolicy() : _c1_count(0), _c2_count(0) { } SimpleThresholdPolicy() : _c1_count(0), _c2_count(0) { }
virtual int compiler_count(CompLevel comp_level) { virtual int compiler_count(CompLevel comp_level) {
...@@ -104,7 +104,7 @@ public: ...@@ -104,7 +104,7 @@ public:
virtual void disable_compilation(methodOop method) { } virtual void disable_compilation(methodOop method) { }
virtual void reprofile(ScopeDesc* trap_scope, bool is_osr); virtual void reprofile(ScopeDesc* trap_scope, bool is_osr);
virtual nmethod* event(methodHandle method, methodHandle inlinee, virtual nmethod* event(methodHandle method, methodHandle inlinee,
int branch_bci, int bci, CompLevel comp_level, nmethod* nm, TRAPS); int branch_bci, int bci, CompLevel comp_level, nmethod* nm, JavaThread* thread);
// Select task is called by CompileBroker. We should return a task or NULL. // Select task is called by CompileBroker. We should return a task or NULL.
virtual CompileTask* select_task(CompileQueue* compile_queue); virtual CompileTask* select_task(CompileQueue* compile_queue);
// Tell the runtime if we think a given method is adequately profiled. // Tell the runtime if we think a given method is adequately profiled.
......
...@@ -189,6 +189,13 @@ class Exceptions { ...@@ -189,6 +189,13 @@ class Exceptions {
#define CHECK_NULL CHECK_(NULL) #define CHECK_NULL CHECK_(NULL)
#define CHECK_false CHECK_(false) #define CHECK_false CHECK_(false)
#define CHECK_AND_CLEAR THREAD); if (HAS_PENDING_EXCEPTION) { CLEAR_PENDING_EXCEPTION; return; } (0
#define CHECK_AND_CLEAR_(result) THREAD); if (HAS_PENDING_EXCEPTION) { CLEAR_PENDING_EXCEPTION; return result; } (0
#define CHECK_AND_CLEAR_0 CHECK_AND_CLEAR_(0)
#define CHECK_AND_CLEAR_NH CHECK_AND_CLEAR_(Handle())
#define CHECK_AND_CLEAR_NULL CHECK_AND_CLEAR_(NULL)
#define CHECK_AND_CLEAR_false CHECK_AND_CLEAR_(false)
// The THROW... macros should be used to throw an exception. They require a THREAD variable to be // The THROW... macros should be used to throw an exception. They require a THREAD variable to be
// visible within the scope containing the THROW. Usually this is achieved by declaring the function // visible within the scope containing the THROW. Usually this is achieved by declaring the function
// with a TRAPS argument. // with a TRAPS argument.
...@@ -258,7 +265,6 @@ class Exceptions { ...@@ -258,7 +265,6 @@ class Exceptions {
ShouldNotReachHere(); \ ShouldNotReachHere(); \
} (0 } (0
// ExceptionMark is a stack-allocated helper class for local exception handling. // ExceptionMark is a stack-allocated helper class for local exception handling.
// It is used with the EXCEPTION_MARK macro. // It is used with the EXCEPTION_MARK macro.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册