Modifier and Type | Field and Description |
---|---|
private static char[] |
dumpBuffer
Pre-allocate the dump buffer, since dump() might get called inside GC.
|
private static int |
dumpBufferLock |
private static Offset |
dumpBufferLockOffset
Reset at boot time.
|
private static char[] |
hexDigitCharacter
A map of hexadecimal digit values to their character representations.
|
private static int |
INT_BUFFER_SIZE
How many characters we need to have in a buffer for building string
representations of
long s, such as intBuffer . |
private static char[] |
intBuffer
A buffer for building string representations of
long s |
private static int |
intBufferLock
A lock for
intBuffer |
private static Offset |
intBufferLockOffset
The offset of
intBufferLock in this class's TIB. |
static int |
MAX_DUMP_LEN
Biggest buffer you would possibly need for
RVMThread.dump(char[], int)
Modify this if you modify that method. |
Constructor and Description |
---|
Services() |
Modifier and Type | Method and Description |
---|---|
static String |
addressAsHexString(Address addr)
Format a 32/64 bit number as "0x" followed by 8/16 hex digits.
|
static void |
boot()
Called during the boot sequence, any time before we go multi-threaded.
|
static void |
breakStub() |
static byte[] |
getArrayNoBarrier(byte[][] src,
int index)
Gets an element of an array of byte arrays without causing the potential
thread switch point that array accesses normally cause.
|
static byte |
getArrayNoBarrier(byte[] src,
int index)
Gets an element of a byte array without invoking any read barrier
or bounds check.
|
static char |
getArrayNoBarrier(char[] src,
int index)
Gets an element of a char array without invoking any read barrier
or performing bounds check.
|
static int |
getArrayNoBarrier(int[] src,
int index)
Gets an element of an int array without invoking any read barrier
or performing bounds checks.
|
static Object |
getArrayNoBarrier(Object[] src,
int index)
Gets an element of an Object array without invoking any read
barrier or performing bounds checks.
|
static String |
getHexString(int i,
boolean blank) |
static char[] |
grabDumpBuffer() |
private static char[] |
grabIntBuffer()
Gets exclusive access to
intBuffer , the buffer for building
string representations of integers. |
static String |
intAsHexString(int number)
Format a 32 bit number as "0x" followed by 8 hex digits.
|
static String |
longAsHexString(long number)
Format a 64 bit number as "0x" followed by 16 hex digits.
|
static void |
percentage(int numerator,
int denominator,
String quantity) |
(package private) static void |
percentage(long numerator,
long denominator,
String quantity) |
(package private) static void |
print(int i) |
(package private) static void |
print(String s) |
(package private) static void |
print(String s,
int i) |
(package private) static void |
println() |
(package private) static void |
println(int i) |
(package private) static void |
println(String s) |
(package private) static void |
println(String s,
int i) |
static void |
releaseDumpBuffer() |
private static void |
releaseIntBuffer()
Release
intBuffer , the buffer for building string
representations of integers. |
static void |
setArrayNoBarrier(char[] dst,
int index,
char value)
Sets an element of a char array without invoking any write
barrier.
|
static void |
setArrayUninterruptible(Object[] dst,
int index,
Object value)
Sets an element of a object array without possibly losing control.
|
static int |
sprintf(char[] dest,
int destOffset,
char c) |
static int |
sprintf(char[] dest,
int destOffset,
char[] src) |
static int |
sprintf(char[] dest,
int destOffset,
char[] src,
int srcStart,
int srcEnd)
Copies characters from
src into the destination character
array dest . |
static int |
sprintf(char[] dest,
int offset,
long l)
Copy the printed decimal representation of a long into
a character array.
|
static int |
sprintf(char[] dest,
int destOffset,
String s)
Copy a String into a character array.
|
public static final int MAX_DUMP_LEN
RVMThread.dump(char[], int)
Modify this if you modify that method.private static final char[] dumpBuffer
private static int dumpBufferLock
private static Offset dumpBufferLockOffset
private static final char[] hexDigitCharacter
XXX We currently only use '0' through '9'. The rest are here pending possibly merging this code with the similar code in Log.java, or breaking this code out into a separate utility class.
private static final int INT_BUFFER_SIZE
long
s, such as intBuffer
. A
long
is a signed 64-bit integer in the range -2^63 to
2^63+1. The number of digits in the decimal representation of 2^63 is
ceiling(log10(2^63)) == ceiling(63 * log10(2)) == 19. An extra character
may be required for a minus sign (-). So the maximum number of characters
is 20.private static final char[] intBuffer
long
sprivate static int intBufferLock
intBuffer
private static Offset intBufferLockOffset
intBufferLock
in this class's TIB.
This is set properly at boot time, even though it's a
private
variable. .public Services()
public static void boot()
public static char[] grabDumpBuffer()
public static void releaseDumpBuffer()
public static int sprintf(char[] dest, int destOffset, String s)
This function may be called during GC and may be used in conjunction
with the MMTk Log
class. It avoids write barriers and allocation.
XXX This function should probably be moved to a sensible location where we can use it as a utility. Suggestions welcome.
dest
- char array to copy into.destOffset
- Offset into dest
where we start copyings
- string to printoffset
. This is intended to represent the first
unused position in the array dest
. However, it also
serves as a pseudo-overflow check: It may have the value
dest.length
, if the array dest
was
completely filled by the call, or it may have a value greater
than dest.length
, if the info needs more than
dest.length - offset
characters of space. If
destOffset
is negative, return -1.
the MMTk Log
class).public static int sprintf(char[] dest, int destOffset, char[] src)
public static int sprintf(char[] dest, int destOffset, char[] src, int srcStart, int srcEnd)
src
into the destination character
array dest
.
The first character to be copied is at index srcBegin
; the
last character to be copied is at index srcEnd-1
. (This is
the same convention as followed by java.lang.String#getChars).
dest
- char array to copy into.destOffset
- Offset into dest
where we start copyingsrc
- Char array to copy fromsrcStart
- index of the first character of src
to copy.srcEnd
- index after the last character of src
to copy.offset
. This is intended to represent the first
unused position in the array dest
. However, it also
serves as a pseudo-overflow check: It may have the value
dest.length
, if the array dest
was
completely filled by the call, or it may have a value greater
than dest.length
, if the info needs more than
dest.length - offset
characters of space. If
destOffset
is negative, return -1.public static int sprintf(char[] dest, int destOffset, char c)
public static int sprintf(char[] dest, int offset, long l)
This function may be called during GC and may be used in conjunction with the Log class. It avoids write barriers and allocation.
XXX This function should probably be moved to a sensible location where we can use it as a utility. Suggestions welcome.
XXX This method's implementation is stolen from the Log
class.
dest
- char array to copy into.offset
- Offset into dest
where we start copyingl
- a whole number to write before the stringoffset
. This is intended to represent the first
unused position in the array dest
. However, it also
serves as a pseudo-overflow check: It may have the value
dest.length
, if the array dest
was
completely filled by the call, or it may have a value greater
than dest.length
, if the info needs more than
dest.length - offset
characters of space. If
offset
is negative, return -1.private static char[] grabIntBuffer()
intBuffer
, the buffer for building
string representations of integers.private static void releaseIntBuffer()
intBuffer
, the buffer for building string
representations of integers.public static String getHexString(int i, boolean blank)
public static void breakStub()
static void println()
static void print(int i)
static void println(int i)
public static void percentage(int numerator, int denominator, String quantity)
static void percentage(long numerator, long denominator, String quantity)
public static String intAsHexString(int number)
number
- the number to formatpublic static String longAsHexString(long number)
number
- the number to formatpublic static String addressAsHexString(Address addr)
addr
- The 32/64 bit number to format.public static void setArrayUninterruptible(Object[] dst, int index, Object value)
dst
- the destination arrayindex
- the index of the element to setvalue
- the new value for the elementpublic static void setArrayNoBarrier(char[] dst, int index, char value)
dst
- the destination arrayindex
- the index of the element to setvalue
- the new value for the elementpublic static Object getArrayNoBarrier(Object[] src, int index)
src
- the source arrayindex
- the natural array index of the element to getpublic static int getArrayNoBarrier(int[] src, int index)
src
- the source arrayindex
- the natural array index of the element to getpublic static char getArrayNoBarrier(char[] src, int index)
src
- the source arrayindex
- the natural array index of the element to getpublic static byte getArrayNoBarrier(byte[] src, int index)
src
- the source arrayindex
- the natural array index of the element to getpublic static byte[] getArrayNoBarrier(byte[][] src, int index)
src
- the source arrayindex
- the index of the element to get