From 8e49fcdde4fef5a8db36823b35d409ba2c9ec47b Mon Sep 17 00:00:00 2001 From: Damon Fenacci Date: Mon, 19 Dec 2022 08:50:44 +0000 Subject: [PATCH] 8295661: CompileTask::compile_id() should be passed as int Reviewed-by: thartmann, dnsimon, never --- src/hotspot/share/ci/ciEnv.cpp | 2 +- src/hotspot/share/ci/ciEnv.hpp | 2 +- src/hotspot/share/code/codeHeapState.cpp | 52 ++++++++++---------- src/hotspot/share/code/codeHeapState.hpp | 8 +-- src/hotspot/share/compiler/compileBroker.cpp | 6 +-- src/hotspot/share/compiler/compileBroker.hpp | 4 +- src/hotspot/share/compiler/compileTask.hpp | 4 +- src/hotspot/share/jfr/metadata/metadata.xml | 10 ++-- src/hotspot/share/runtime/vmStructs.cpp | 2 +- 9 files changed, 44 insertions(+), 46 deletions(-) diff --git a/src/hotspot/share/ci/ciEnv.cpp b/src/hotspot/share/ci/ciEnv.cpp index 814b6049710..43b4d308fc6 100644 --- a/src/hotspot/share/ci/ciEnv.cpp +++ b/src/hotspot/share/ci/ciEnv.cpp @@ -1226,7 +1226,7 @@ int ciEnv::comp_level() { // ------------------------------------------------------------------ // ciEnv::compile_id -uint ciEnv::compile_id() { +int ciEnv::compile_id() { if (task() == NULL) return 0; return task()->compile_id(); } diff --git a/src/hotspot/share/ci/ciEnv.hpp b/src/hotspot/share/ci/ciEnv.hpp index 48947f99b23..21b442b6e05 100644 --- a/src/hotspot/share/ci/ciEnv.hpp +++ b/src/hotspot/share/ci/ciEnv.hpp @@ -366,7 +366,7 @@ public: // Handy forwards to the task: int comp_level(); // task()->comp_level() - uint compile_id(); // task()->compile_id() + int compile_id(); // task()->compile_id() // Register the result of a compilation. void register_method(ciMethod* target, diff --git a/src/hotspot/share/code/codeHeapState.cpp b/src/hotspot/share/code/codeHeapState.cpp index 91cb7c4c53f..fd3b203548d 100644 --- a/src/hotspot/share/code/codeHeapState.cpp +++ b/src/hotspot/share/code/codeHeapState.cpp @@ -258,7 +258,7 @@ static unsigned int used_topSizeBlocks = 0; static struct SizeDistributionElement* SizeDistributionArray = NULL; -static unsigned int latest_compilation_id = 0; +static int latest_compilation_id = 0; static volatile bool initialization_complete = false; const char* CodeHeapState::get_heapName(CodeHeap* heap) { @@ -659,27 +659,27 @@ void CodeHeapState::aggregate(outputStream* out, CodeHeap* heap, size_t granular prepare_SizeDistArray(out, nSizeDistElements, heapName); latest_compilation_id = CompileBroker::get_compilation_id(); - unsigned int highest_compilation_id = 0; - size_t usedSpace = 0; - size_t t1Space = 0; - size_t t2Space = 0; - size_t aliveSpace = 0; - size_t disconnSpace = 0; - size_t notentrSpace = 0; - size_t stubSpace = 0; - size_t freeSpace = 0; - size_t maxFreeSize = 0; - HeapBlock* maxFreeBlock = NULL; - bool insane = false; + int highest_compilation_id = 0; + size_t usedSpace = 0; + size_t t1Space = 0; + size_t t2Space = 0; + size_t aliveSpace = 0; + size_t disconnSpace = 0; + size_t notentrSpace = 0; + size_t stubSpace = 0; + size_t freeSpace = 0; + size_t maxFreeSize = 0; + HeapBlock* maxFreeBlock = NULL; + bool insane = false; - unsigned int n_methods = 0; + unsigned int n_methods = 0; for (HeapBlock *h = heap->first_block(); h != NULL && !insane; h = heap->next_block(h)) { unsigned int hb_len = (unsigned int)h->length(); // despite being size_t, length can never overflow an unsigned int. size_t hb_bytelen = ((size_t)hb_len)< age2 ? age1 : age2; + int age1 = StatArray[ix].t1_age; + int age2 = StatArray[ix].t2_age; + int agex = StatArray[ix].tx_age; + int age = age1 > age2 ? age1 : age2; age = age > agex ? age : agex; print_age_single(ast, age); } @@ -2247,9 +2247,7 @@ void CodeHeapState::print_blobType_legend(outputStream* out) { } void CodeHeapState::print_space_legend(outputStream* out) { - unsigned int indicator = 0; - unsigned int age_range = 256; - unsigned int range_beg = latest_compilation_id; + int range_beg = latest_compilation_id; out->cr(); printBox(out, '-', "Space ranges, based on granule occupancy", NULL); out->print_cr(" - 0%% == occupancy"); @@ -2263,12 +2261,12 @@ void CodeHeapState::print_space_legend(outputStream* out) { void CodeHeapState::print_age_legend(outputStream* out) { unsigned int indicator = 0; - unsigned int age_range = 256; - unsigned int range_beg = latest_compilation_id; + int age_range = 256; + int range_beg = latest_compilation_id; out->cr(); printBox(out, '-', "Age ranges, based on compilation id", NULL); while (age_range > 0) { - out->print_cr(" %d - %6d to %6d", indicator, range_beg, latest_compilation_id - latest_compilation_id/age_range); + out->print_cr(" %u - %6d to %6d", indicator, range_beg, latest_compilation_id - latest_compilation_id/age_range); range_beg = latest_compilation_id - latest_compilation_id/age_range; age_range /= 2; indicator += 1; @@ -2293,9 +2291,9 @@ void CodeHeapState::print_space_single(outputStream* out, unsigned short space) out->print("%c", fraction); } -void CodeHeapState::print_age_single(outputStream* out, unsigned int age) { +void CodeHeapState::print_age_single(outputStream* out, int age) { unsigned int indicator = 0; - unsigned int age_range = 256; + int age_range = 256; if (age > 0) { while ((age_range > 0) && (latest_compilation_id-age > latest_compilation_id/age_range)) { age_range /= 2; diff --git a/src/hotspot/share/code/codeHeapState.hpp b/src/hotspot/share/code/codeHeapState.hpp index 1bd41fdda72..6cb536ba958 100644 --- a/src/hotspot/share/code/codeHeapState.hpp +++ b/src/hotspot/share/code/codeHeapState.hpp @@ -88,7 +88,7 @@ class CodeHeapState : public CHeapObj { static void print_blobType_single(outputStream *ast, u2 /* blobType */ type); static void print_count_single(outputStream *ast, unsigned short count); static void print_space_single(outputStream *ast, unsigned short space); - static void print_age_single(outputStream *ast, unsigned int age); + static void print_age_single(outputStream *ast, int age); static void print_line_delim(outputStream* out, bufferedStream *sst, char* low_bound, unsigned int ix, unsigned int gpl); static void print_line_delim(outputStream* out, outputStream *sst, char* low_bound, unsigned int ix, unsigned int gpl); static blobType get_cbType(CodeBlob* cb); @@ -119,9 +119,9 @@ class CodeHeapState : public CHeapObj { class StatElement : public CHeapObj { public: // A note on ages: The compilation_id easily overflows unsigned short in large systems - unsigned int t1_age; // oldest compilation_id of tier1 nMethods. - unsigned int t2_age; // oldest compilation_id of tier2 nMethods. - unsigned int tx_age; // oldest compilation_id of inactive/not entrant nMethods. + int t1_age; // oldest compilation_id of tier1 nMethods. + int t2_age; // oldest compilation_id of tier2 nMethods. + int tx_age; // oldest compilation_id of inactive/not entrant nMethods. unsigned short t1_space; // in units of _segment_size to "prevent" overflow unsigned short t2_space; // in units of _segment_size to "prevent" overflow unsigned short tx_space; // in units of _segment_size to "prevent" overflow diff --git a/src/hotspot/share/compiler/compileBroker.cpp b/src/hotspot/share/compiler/compileBroker.cpp index 2231b949c68..94cbb08f048 100644 --- a/src/hotspot/share/compiler/compileBroker.cpp +++ b/src/hotspot/share/compiler/compileBroker.cpp @@ -1566,7 +1566,7 @@ int CompileBroker::assign_compile_id(const methodHandle& method, int osr_bci) { // CompileBroker::assign_compile_id_unlocked // // Public wrapper for assign_compile_id that acquires the needed locks -uint CompileBroker::assign_compile_id_unlocked(Thread* thread, const methodHandle& method, int osr_bci) { +int CompileBroker::assign_compile_id_unlocked(Thread* thread, const methodHandle& method, int osr_bci) { MutexLocker locker(thread, MethodCompileQueue_lock); return assign_compile_id(method, osr_bci); } @@ -2109,7 +2109,7 @@ void CompileBroker::invoke_compiler_on_method(CompileTask* task) { } // Common flags. - uint compile_id = task->compile_id(); + int compile_id = task->compile_id(); int osr_bci = task->osr_bci(); bool is_osr = (osr_bci != standard_entry_bci); bool should_log = (thread->log() != NULL); @@ -2432,7 +2432,7 @@ void CompileBroker::update_compile_perf_data(CompilerThread* thread, const metho void CompileBroker::collect_statistics(CompilerThread* thread, elapsedTimer time, CompileTask* task) { bool success = task->is_success(); methodHandle method (thread, task->method()); - uint compile_id = task->compile_id(); + int compile_id = task->compile_id(); bool is_osr = (task->osr_bci() != standard_entry_bci); const int comp_level = task->comp_level(); CompilerCounters* counters = thread->counters(); diff --git a/src/hotspot/share/compiler/compileBroker.hpp b/src/hotspot/share/compiler/compileBroker.hpp index 86cc3803681..417f27c1718 100644 --- a/src/hotspot/share/compiler/compileBroker.hpp +++ b/src/hotspot/share/compiler/compileBroker.hpp @@ -312,10 +312,10 @@ public: TRAPS); // Acquire any needed locks and assign a compile id - static uint assign_compile_id_unlocked(Thread* thread, const methodHandle& method, int osr_bci); + static int assign_compile_id_unlocked(Thread* thread, const methodHandle& method, int osr_bci); static void compiler_thread_loop(); - static uint get_compilation_id() { return _compilation_id; } + static int get_compilation_id() { return _compilation_id; } // Set _should_block. // Call this from the VM, with Threads_lock held and a safepoint requested. diff --git a/src/hotspot/share/compiler/compileTask.hpp b/src/hotspot/share/compiler/compileTask.hpp index 4d35976a42d..bbe1387ffe6 100644 --- a/src/hotspot/share/compiler/compileTask.hpp +++ b/src/hotspot/share/compiler/compileTask.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2022, 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 @@ -76,7 +76,7 @@ class CompileTask : public CHeapObj { private: static CompileTask* _task_free_list; Monitor* _lock; - uint _compile_id; + int _compile_id; Method* _method; jobject _method_holder; int _osr_bci; diff --git a/src/hotspot/share/jfr/metadata/metadata.xml b/src/hotspot/share/jfr/metadata/metadata.xml index 841ddca0de9..55570fc535c 100644 --- a/src/hotspot/share/jfr/metadata/metadata.xml +++ b/src/hotspot/share/jfr/metadata/metadata.xml @@ -577,7 +577,7 @@ - + @@ -591,7 +591,7 @@ description="Describes various phases of the compilation process like inlining or string optimization related phases" thread="true"> - + @@ -599,7 +599,7 @@ description="In case a JIT compilation failed, a compilation failure is triggered, reporting the reason" thread="true" startTime="false"> - + @@ -611,7 +611,7 @@ - + @@ -637,7 +637,7 @@ - + diff --git a/src/hotspot/share/runtime/vmStructs.cpp b/src/hotspot/share/runtime/vmStructs.cpp index 27eea4622ff..7bdcb019c2a 100644 --- a/src/hotspot/share/runtime/vmStructs.cpp +++ b/src/hotspot/share/runtime/vmStructs.cpp @@ -1066,7 +1066,7 @@ nonstatic_field(CompileTask, _method, Method*) \ nonstatic_field(CompileTask, _osr_bci, int) \ nonstatic_field(CompileTask, _comp_level, int) \ - nonstatic_field(CompileTask, _compile_id, uint) \ + nonstatic_field(CompileTask, _compile_id, int) \ nonstatic_field(CompileTask, _num_inlined_bytecodes, int) \ nonstatic_field(CompileTask, _next, CompileTask*) \ nonstatic_field(CompileTask, _prev, CompileTask*) \