本文整理了Java中sun.misc.Unsafe.getAddress()
方法的一些代码示例,展示了Unsafe.getAddress()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Unsafe.getAddress()
方法的具体详情如下:
包路径:sun.misc.Unsafe
类名称:Unsafe
方法名:getAddress
[英]Fetches a native pointer from a given memory address. If the address is zero, or does not point into a block obtained from #allocateMemory, the results are undefined.
If the native pointer is less than 64 bits wide, it is extended as an unsigned number to a Java long. The pointer may be indexed by any given byte offset, simply by adding that offset (as a simple integer) to the long representing the pointer. The number of bytes actually read from the target address maybe determined by consulting #addressSize.
[中]从给定的内存地址获取本机指针。如果地址为零,或未指向从#allocateMemory获得的块,则结果未定义。
如果本机指针的宽度小于64位,则会将其作为无符号数扩展到Java long。指针可以通过任何给定的字节偏移量进行索引,只需将该偏移量(作为一个简单的整数)添加到表示指针的long中即可。从目标地址实际读取的字节数可能由#addressSize决定。
代码示例来源:origin: cubedb/cubedb
@Override
public boolean hasNext() {
while (offset < map.partitionCount) {
long locationAddress =
map.unsafe.getAddress(map.partitionAddress + (offset * map.addressSize));
if (locationAddress == 0) {
offset++;
continue;
}
break;
}
return offset < map.partitionCount;
}
代码示例来源:origin: org.lwjgl.lwjgl/lwjgl_util
public static long aget(long addr) {
return INSTANCE.getAddress(addr);
}
代码示例来源:origin: cubedb/cubedb
@Override
public boolean hasNext() {
while (offset < map.partitionCount) {
long locationAddress =
map.unsafe.getAddress(map.partitionAddress + (offset * map.addressSize));
if (locationAddress == 0) {
offset++;
continue;
}
break;
}
return offset < map.partitionCount;
}
代码示例来源:origin: Devexperts/lin-check
public static final long getAddress(long address) {
return UNSAFE.getAddress(address);
}
代码示例来源:origin: serkan-ozal/mysafe
@Override
public long getAddress(Unsafe unsafe, long address) {
return unsafe.getAddress(address);
}
代码示例来源:origin: Devexperts/lin-check
private static final long pg_AvailableChunks_pop(long addressPage) {
//long availableChunks = addressPage+ZMPAGE_AVAILABLECHUNKS_OFFSET;
long head = UNSAFE.getAddress(addressPage);
if (head != NULL_ADDRESS) {
UNSAFE.putAddress(addressPage, UNSAFE.getAddress(head));
long numAvailableChunks = addressPage+ZMPAGE_NUMAVAILABLECHUNKS_OFFSET;
UNSAFE.putInt(numAvailableChunks, UNSAFE.getInt(numAvailableChunks) - 1);
}//meet a full zmalloc page when head ==0L
return head;
}
代码示例来源:origin: net.bramp.unsafe/unsafe-helper
public static long jvm7_32_sizeOf(Object object){
// This is getting the size out of the class header (at offset 12)
return unsafe.getAddress(normalize(unsafe.getInt(object, 4L)) + 12L);
}
代码示例来源:origin: bramp/unsafe
public static long jvm7_32_sizeOf(Object object) {
// This is getting the size out of the class header (at offset 12)
return unsafe.getAddress(normalize(unsafe.getInt(object, 4L)) + 12L);
}
代码示例来源:origin: Devexperts/lin-check
private static final void pg_AvailableChunks_push(long addressPage,
long addressChunk) {
//availableChunks = addressPage
long head = UNSAFE.getAddress(addressPage);
UNSAFE.putAddress(addressPage, addressChunk);
UNSAFE.putAddress(addressChunk, head);
long numAvailableChunks = addressPage+ZMPAGE_NUMAVAILABLECHUNKS_OFFSET;
UNSAFE.putInt(numAvailableChunks, UNSAFE.getInt(numAvailableChunks) + 1);
}
代码示例来源:origin: apache/mnemonic
@Override
public Customer getCustomer() throws RetrieveDurableEntityError {
if (null == m_customer_680E5D) {
long phandler = m_unsafe_0DCC8A.getAddress(m_holder_A8BF22.get() + 16);
if (0L != phandler) {
m_customer_680E5D = org.apache.mnemonic.examples.CustomerFactory.restore(m_allocator_42A80A, null, null, phandler, m_autoreclaim_FA3692, m_reclaimcontext_D713D9);
}
}
return m_customer_680E5D;
}
代码示例来源:origin: apache/mnemonic
@Override
public DurableSinglyLinkedList<Product> getItems() throws RetrieveDurableEntityError {
if (null == m_items_2E6397) {
long phandler = m_unsafe_0DCC8A.getAddress(m_holder_A8BF22.get() + 24);
if (0L != phandler) {
m_items_2E6397 = org.apache.mnemonic.collections.DurableSinglyLinkedListFactory.restore(m_allocator_42A80A, m_node_efproxies, m_node_gftypes, phandler, m_autoreclaim_FA3692, m_reclaimcontext_D713D9);
}
}
return m_items_2E6397;
}
代码示例来源:origin: apache/mnemonic
@Override
public TreeNode<E> getLeft() {
if (null == m_left_491DCA) {
long phandler = m_unsafe_EE978A.getAddress(m_holder_E5EEE3.get() + 8);
if (0L != phandler) {
m_left_491DCA = org.apache.mnemonic.collections.TreeNodeFactory.restore(m_allocator_873DA6, m_node_efproxies, m_node_gftypes, phandler, m_autoreclaim_3AECF4, m_reclaimcontext_11DAB9);
}
}
return m_left_491DCA;
}
代码示例来源:origin: apache/mnemonic
@Override
public TreeNode<E> getRight() {
if (null == m_right_EE76A8) {
long phandler = m_unsafe_EE978A.getAddress(m_holder_E5EEE3.get() + 16);
if (0L != phandler) {
m_right_EE76A8 = org.apache.mnemonic.collections.TreeNodeFactory.restore(m_allocator_873DA6, m_node_efproxies, m_node_gftypes, phandler, m_autoreclaim_3AECF4, m_reclaimcontext_11DAB9);
}
}
return m_right_EE76A8;
}
代码示例来源:origin: apache/mnemonic
@Override
public SinglyLinkedNode<E> getNext() {
if (null == m_next_AE9475) {
long phandler = m_unsafe_14FE52.getAddress(m_holder_2B4355.get() + 8);
if (0L != phandler) {
m_next_AE9475 = org.apache.mnemonic.collections.SinglyLinkedNodeFactory.restore(m_allocator_506034, m_node_efproxies, m_node_gftypes, phandler, m_autoreclaim_8BE701, m_reclaimcontext_24E34B);
}
}
return m_next_AE9475;
}
代码示例来源:origin: apache/mnemonic
@Override
public TreeNode<E> getParent() {
if (null == m_parent_CA94DC) {
long phandler = m_unsafe_EE978A.getAddress(m_holder_E5EEE3.get() + 24);
if (0L != phandler) {
m_parent_CA94DC = org.apache.mnemonic.collections.TreeNodeFactory.restore(m_allocator_873DA6, m_node_efproxies, m_node_gftypes, phandler, m_autoreclaim_3AECF4, m_reclaimcontext_11DAB9);
}
}
return m_parent_CA94DC;
}
代码示例来源:origin: apache/mnemonic
@Override
public String getId() throws RetrieveDurableEntityError {
if (null == m_id_367F9B) {
long phandler = m_unsafe_0DCC8A.getAddress(m_holder_A8BF22.get() + 0);
if (0L != phandler) {
m_id_367F9B = m_allocator_42A80A.retrieveBuffer(phandler, m_autoreclaim_FA3692, m_reclaimcontext_D713D9);
if (null == m_id_367F9B) {
throw new RetrieveDurableEntityError("Retrieve String Buffer Failure.");
}
}
}
return null == m_id_367F9B ? null : m_id_367F9B.get().asCharBuffer().toString();
}
代码示例来源:origin: apache/mnemonic
@Override
public String getName() throws RetrieveDurableEntityError {
if (null == m_name_9807CF) {
long phandler = m_unsafe_760FBE.getAddress(m_holder_68BA57.get() + 0);
if (0L != phandler) {
m_name_9807CF = m_allocator_77CA34.retrieveBuffer(phandler, m_autoreclaim_7E4A25, m_reclaimcontext_B5B531);
if (null == m_name_9807CF) {
throw new RetrieveDurableEntityError("Retrieve String Buffer Failure.");
}
}
}
return null == m_name_9807CF ? null : m_name_9807CF.get().asCharBuffer().toString();
}
代码示例来源:origin: apache/mnemonic
@Override
public String getStr() throws RetrieveDurableEntityError {
if (null == m_str_A55313) {
long phandler = m_unsafe_AE4FB2.getAddress(m_holder_5BC267.get() + 0);
if (0L != phandler) {
m_str_A55313 = m_allocator_CF10A9.retrieveBuffer(phandler, m_autoreclaim_8F4B75, m_reclaimcontext_998750);
if (null == m_str_A55313) {
throw new RetrieveDurableEntityError("Retrieve String Buffer Failure.");
}
}
}
return null == m_str_A55313 ? null : m_str_A55313.get().asCharBuffer().toString();
}
代码示例来源:origin: org.graalvm.compiler/compiler
@Override
@Operation(opcode = Opcode.READ_POINTER)
public <T extends WordBase> T readWord(WordBase offset, LocationIdentity locationIdentity) {
return box(UNSAFE.getAddress(add((Word) offset).unbox()));
}
代码示例来源:origin: org.graalvm.compiler/compiler
@Override
@Operation(opcode = Opcode.READ_POINTER)
public <T extends WordBase> T readWord(WordBase offset) {
return box(UNSAFE.getAddress(add((Word) offset).unbox()));
}
内容来源于网络,如有侵权,请联系作者删除!