Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
8235765: Use of the long type should be avoided in shared code
Changed some long declarations to uint64_t/int64_t or unsigned int, depending on context.

Reviewed-by: lfoltan, kvn, dholmes
  • Loading branch information
coleenp committed Aug 17, 2020
1 parent 69a95c6 commit 178c45c8db78f2ea53a6ee0750486c58283668dd
Show file tree
Hide file tree
Showing 11 changed files with 33 additions and 34 deletions.
@@ -61,7 +61,7 @@ class SharedClassPathEntry {
bool _is_module_path;
bool _from_class_path_attr;
time_t _timestamp; // jar timestamp, 0 if is directory, modules image or other
long _filesize; // jar/jimage file size, -1 if is directory, -2 if other
int64_t _filesize; // jar/jimage file size, -1 if is directory, -2 if other
Array<char>* _name;
Array<u1>* _manifest;

@@ -84,7 +84,6 @@ class SharedClassPathEntry {
}
bool from_class_path_attr() { return _from_class_path_attr; }
time_t timestamp() const { return _timestamp; }
long filesize() const { return _filesize; }
const char* name() const;
const char* manifest() const {
return (_manifest == NULL) ? NULL : (const char*)_manifest->data();
@@ -54,9 +54,9 @@ class KlassInfoEntry: public CHeapObj<mtInternal> {
private:
KlassInfoEntry* _next;
Klass* _klass;
long _instance_count;
uint64_t _instance_count;
size_t _instance_words;
long _index;
int64_t _index;
bool _do_print; // True if we should print this class when printing the class hierarchy.
GrowableArray<KlassInfoEntry*>* _subclasses;

@@ -68,13 +68,13 @@ class KlassInfoEntry: public CHeapObj<mtInternal> {
~KlassInfoEntry();
KlassInfoEntry* next() const { return _next; }
bool is_equal(const Klass* k) { return k == _klass; }
Klass* klass() const { return _klass; }
long count() const { return _instance_count; }
void set_count(long ct) { _instance_count = ct; }
size_t words() const { return _instance_words; }
void set_words(size_t wds) { _instance_words = wds; }
void set_index(long index) { _index = index; }
long index() const { return _index; }
Klass* klass() const { return _klass; }
uint64_t count() const { return _instance_count; }
void set_count(uint64_t ct) { _instance_count = ct; }
size_t words() const { return _instance_words; }
void set_words(size_t wds) { _instance_words = wds; }
void set_index(int64_t index) { _index = index; }
int64_t index() const { return _index; }
GrowableArray<KlassInfoEntry*>* subclasses() const { return _subclasses; }
void add_subclass(KlassInfoEntry* cie);
void set_do_print(bool do_print) { _do_print = do_print; }
@@ -2000,7 +2000,7 @@ CellTypeState *GenerateOopMap::signature_to_effect(const Symbol* sig, int bci, C
return vCTS; // Otherwise
}

long GenerateOopMap::_total_byte_count = 0;
uint64_t GenerateOopMap::_total_byte_count = 0;
elapsedTimer GenerateOopMap::_total_oopmap_time;

// This function assumes "bcs" is at a "ret" instruction and that the vars
@@ -317,7 +317,7 @@ class GenerateOopMap {

// Timing and statistics
static elapsedTimer _total_oopmap_time; // Holds cumulative oopmap generation time
static long _total_byte_count; // Holds cumulative number of bytes inspected
static uint64_t _total_byte_count; // Holds cumulative number of bytes inspected

// Cell type methods
void init_state();
@@ -1604,8 +1604,8 @@ void klassVtable::print_statistics() {
tty->print_cr("%6d bytes total", total);
}

int klassItable::_total_classes; // Total no. of classes with itables
long klassItable::_total_size; // Total no. of bytes used for itables
int klassItable::_total_classes; // Total no. of classes with itables
size_t klassItable::_total_size; // Total no. of bytes used for itables

void klassItable::print_statistics() {
tty->print_cr("itable statistics:");
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2020, 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
@@ -320,7 +320,7 @@ class klassItable {

// Statistics
NOT_PRODUCT(static int _total_classes;) // Total no. of classes with itables
NOT_PRODUCT(static long _total_size;) // Total no. of bytes used for itables
NOT_PRODUCT(static size_t _total_size;) // Total no. of bytes used for itables

static void update_stats(int size) PRODUCT_RETURN NOT_PRODUCT({ _total_classes++; _total_size += size; })
};
@@ -74,9 +74,9 @@ VMNativeEntryWrapper::~VMNativeEntryWrapper() {
if (GCALotAtAllSafepoints) InterfaceSupport::check_gc_alot();
}

long InterfaceSupport::_scavenge_alot_counter = 1;
long InterfaceSupport::_fullgc_alot_counter = 1;
long InterfaceSupport::_fullgc_alot_invocation = 0;
unsigned int InterfaceSupport::_scavenge_alot_counter = 1;
unsigned int InterfaceSupport::_fullgc_alot_counter = 1;
int InterfaceSupport::_fullgc_alot_invocation = 0;

Histogram* RuntimeHistogram;

@@ -134,8 +134,8 @@ void InterfaceSupport::gc_alot() {
unsigned int invocations = Universe::heap()->total_full_collections();
// Compute new interval
if (FullGCALotInterval > 1) {
_fullgc_alot_counter = 1+(long)((double)FullGCALotInterval*os::random()/(max_jint+1.0));
log_trace(gc)("Full gc no: %u\tInterval: %ld", invocations, _fullgc_alot_counter);
_fullgc_alot_counter = 1+(unsigned int)((double)FullGCALotInterval*os::random()/(max_jint+1.0));
log_trace(gc)("Full gc no: %u\tInterval: %u", invocations, _fullgc_alot_counter);
} else {
_fullgc_alot_counter = 1;
}
@@ -152,8 +152,8 @@ void InterfaceSupport::gc_alot() {
unsigned int invocations = Universe::heap()->total_collections() - Universe::heap()->total_full_collections();
// Compute new interval
if (ScavengeALotInterval > 1) {
_scavenge_alot_counter = 1+(long)((double)ScavengeALotInterval*os::random()/(max_jint+1.0));
log_trace(gc)("Scavenge no: %u\tInterval: %ld", invocations, _scavenge_alot_counter);
_scavenge_alot_counter = 1+(unsigned int)((double)ScavengeALotInterval*os::random()/(max_jint+1.0));
log_trace(gc)("Scavenge no: %u\tInterval: %u", invocations, _scavenge_alot_counter);
} else {
_scavenge_alot_counter = 1;
}
@@ -48,9 +48,9 @@
class InterfaceSupport: AllStatic {
# ifdef ASSERT
public:
static long _scavenge_alot_counter;
static long _fullgc_alot_counter;
static long _fullgc_alot_invocation;
static unsigned int _scavenge_alot_counter;
static unsigned int _fullgc_alot_counter;
static int _fullgc_alot_invocation;

// Helper methods used to implement +ScavengeALot and +FullGCALot
static void check_gc_alot() { if (ScavengeALot || FullGCALot) gc_alot(); }
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2020, 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
@@ -185,7 +185,7 @@ void Monitor::assert_wait_lock_state(Thread* self) {
}
#endif // ASSERT

bool Monitor::wait_without_safepoint_check(long timeout) {
bool Monitor::wait_without_safepoint_check(int64_t timeout) {
Thread* const self = Thread::current();

// timeout is in milliseconds - with zero meaning never timeout
@@ -205,7 +205,7 @@ bool Monitor::wait_without_safepoint_check(long timeout) {
return wait_status != 0; // return true IFF timeout
}

bool Monitor::wait(long timeout, bool as_suspend_equivalent) {
bool Monitor::wait(int64_t timeout, bool as_suspend_equivalent) {
Thread* const self = Thread::current();

// timeout is in milliseconds - with zero meaning never timeout
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2020, 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
@@ -198,9 +198,9 @@ class Monitor : public Mutex {
// Defaults are to make safepoint checks, wait time is forever (i.e.,
// zero), and not a suspend-equivalent condition. Returns true if wait
// times out; otherwise returns false.
bool wait(long timeout = 0,
bool wait(int64_t timeout = 0,
bool as_suspend_equivalent = !_as_suspend_equivalent_flag);
bool wait_without_safepoint_check(long timeout = 0);
bool wait_without_safepoint_check(int64_t timeout = 0);
void notify();
void notify_all();
};
@@ -250,7 +250,7 @@ class MonitorLocker: public MutexLocker {
assert(_monitor != NULL, "NULL monitor not allowed");
}

bool wait(long timeout = 0,
bool wait(int64_t timeout = 0,
bool as_suspend_equivalent = !Mutex::_as_suspend_equivalent_flag) {
if (_flag == Mutex::_safepoint_check_flag) {
return _monitor->wait(timeout, as_suspend_equivalent);

0 comments on commit 178c45c

Please sign in to comment.