mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-18 10:04:42 +02:00
8196199: Remove miscellaneous oop comparison operators
Co-authored-by: Kim Barrett <kim.barrett@oracle.com> Reviewed-by: hseigel, lfoltan
This commit is contained in:
parent
2b3d492b43
commit
aa51ac19b3
7 changed files with 48 additions and 39 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2018, 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
|
||||
|
@ -143,6 +143,21 @@ class oopDesc {
|
|||
inline static bool is_null(oop obj) { return obj == NULL; }
|
||||
inline static bool is_null(narrowOop obj) { return obj == 0; }
|
||||
|
||||
// Standard compare function returns negative value if o1 < o2
|
||||
// 0 if o1 == o2
|
||||
// positive value if o1 > o2
|
||||
inline static int compare(oop o1, oop o2) {
|
||||
void* o1_addr = (void*)o1;
|
||||
void* o2_addr = (void*)o2;
|
||||
if (o1_addr < o2_addr) {
|
||||
return -1;
|
||||
} else if (o1_addr > o2_addr) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Decode an oop pointer from a narrowOop if compressed.
|
||||
// These are overloaded for oop and narrowOop as are the other functions
|
||||
// below so that they can be called in template functions.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue