mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-22 03:54:33 +02:00
8138892: C1: Improve counter overflow checking
Reviewed-by: iveresov, goetz, twisti, vlivanov
This commit is contained in:
parent
dd76bcc4c2
commit
28115bceae
6 changed files with 31 additions and 13 deletions
|
@ -41,7 +41,9 @@
|
|||
|
||||
void CounterOverflowStub::emit_code(LIR_Assembler* ce) {
|
||||
__ bind(_entry);
|
||||
ce->store_parameter(_method->as_register(), 1);
|
||||
Metadata *m = _method->as_constant_ptr()->as_metadata();
|
||||
__ mov_metadata(rscratch1, m);
|
||||
ce->store_parameter(rscratch1, 1);
|
||||
ce->store_parameter(_bci, 0);
|
||||
__ far_call(RuntimeAddress(Runtime1::entry_for(Runtime1::counter_overflow_id)));
|
||||
ce->add_call_info_here(_info);
|
||||
|
|
|
@ -94,8 +94,10 @@ void PredicateFailedStub::emit_code(LIR_Assembler* ce) {
|
|||
void CounterOverflowStub::emit_code(LIR_Assembler* ce) {
|
||||
__ bind(_entry);
|
||||
__ set(_bci, G4);
|
||||
Metadata *m = _method->as_constant_ptr()->as_metadata();
|
||||
__ set_metadata_constant(m, G5);
|
||||
__ call(Runtime1::entry_for(Runtime1::counter_overflow_id), relocInfo::runtime_call_type);
|
||||
__ delayed()->mov_or_nop(_method->as_register(), G5);
|
||||
__ delayed()->nop();
|
||||
ce->add_call_info_here(_info);
|
||||
ce->verify_oop_map(_info);
|
||||
|
||||
|
|
|
@ -81,7 +81,8 @@ void ConversionStub::emit_code(LIR_Assembler* ce) {
|
|||
|
||||
void CounterOverflowStub::emit_code(LIR_Assembler* ce) {
|
||||
__ bind(_entry);
|
||||
ce->store_parameter(_method->as_register(), 1);
|
||||
Metadata *m = _method->as_constant_ptr()->as_metadata();
|
||||
ce->store_parameter(m, 1);
|
||||
ce->store_parameter(_bci, 0);
|
||||
__ call(RuntimeAddress(Runtime1::entry_for(Runtime1::counter_overflow_id)));
|
||||
ce->add_call_info_here(_info);
|
||||
|
|
|
@ -2971,6 +2971,14 @@ void LIR_Assembler::store_parameter(jobject o, int offset_from_rsp_in_words) {
|
|||
}
|
||||
|
||||
|
||||
void LIR_Assembler::store_parameter(Metadata* m, int offset_from_rsp_in_words) {
|
||||
assert(offset_from_rsp_in_words >= 0, "invalid offset from rsp");
|
||||
int offset_from_rsp_in_bytes = offset_from_rsp_in_words * BytesPerWord;
|
||||
assert(offset_from_rsp_in_bytes < frame_map()->reserved_argument_area_size(), "invalid offset");
|
||||
__ mov_metadata(Address(rsp, offset_from_rsp_in_bytes), m);
|
||||
}
|
||||
|
||||
|
||||
// This code replaces a call to arraycopy; no exception may
|
||||
// be thrown in this code, they must be thrown in the System.arraycopy
|
||||
// activation frame; we could save some checks if this would not be the case
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2015, 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
|
||||
|
@ -49,9 +49,10 @@
|
|||
Register recv, Label* update_done);
|
||||
public:
|
||||
|
||||
void store_parameter(Register r, int offset_from_esp_in_words);
|
||||
void store_parameter(jint c, int offset_from_esp_in_words);
|
||||
void store_parameter(jobject c, int offset_from_esp_in_words);
|
||||
void store_parameter(Register r, int offset_from_esp_in_words);
|
||||
void store_parameter(jint c, int offset_from_esp_in_words);
|
||||
void store_parameter(jobject c, int offset_from_esp_in_words);
|
||||
void store_parameter(Metadata* c, int offset_from_esp_in_words);
|
||||
|
||||
enum { call_stub_size = NOT_LP64(15) LP64_ONLY(28),
|
||||
exception_handler_size = DEBUG_ONLY(1*K) NOT_DEBUG(175),
|
||||
|
|
|
@ -3429,14 +3429,18 @@ void LIRGenerator::increment_event_counter_impl(CodeEmitInfo* info,
|
|||
__ add(result, LIR_OprFact::intConst(InvocationCounter::count_increment), result);
|
||||
__ store(result, counter);
|
||||
if (notify) {
|
||||
LIR_Opr mask = load_immediate(frequency << InvocationCounter::count_shift, T_INT);
|
||||
LIR_Opr meth = new_register(T_METADATA);
|
||||
__ metadata2reg(method->constant_encoding(), meth);
|
||||
__ logical_and(result, mask, result);
|
||||
__ cmp(lir_cond_equal, result, LIR_OprFact::intConst(0));
|
||||
LIR_Opr meth = LIR_OprFact::metadataConst(method->constant_encoding());
|
||||
// The bci for info can point to cmp for if's we want the if bci
|
||||
CodeStub* overflow = new CounterOverflowStub(info, bci, meth);
|
||||
__ branch(lir_cond_equal, T_INT, overflow);
|
||||
int freq = frequency << InvocationCounter::count_shift;
|
||||
if (freq == 0) {
|
||||
__ branch(lir_cond_always, T_ILLEGAL, overflow);
|
||||
} else {
|
||||
LIR_Opr mask = load_immediate(freq, T_INT);
|
||||
__ logical_and(result, mask, result);
|
||||
__ cmp(lir_cond_equal, result, LIR_OprFact::intConst(0));
|
||||
__ branch(lir_cond_equal, T_INT, overflow);
|
||||
}
|
||||
__ branch_destination(overflow->continuation());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue