8282191: Implementation of Foreign Function & Memory API (Preview)

Reviewed-by: erikj, jvernee, psandoz, dholmes, mchung
This commit is contained in:
Maurizio Cimadamore 2022-05-12 16:17:45 +00:00
parent 3be394e160
commit 2c5d136260
303 changed files with 33474 additions and 9186 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 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
@ -27,10 +27,10 @@ package java.nio;
import java.io.FileDescriptor;
import java.io.UncheckedIOException;
import java.lang.foreign.MemorySegment;
import java.lang.ref.Reference;
import java.util.Objects;
import jdk.internal.access.foreign.MemorySegmentProxy;
import jdk.internal.access.foreign.UnmapperProxy;
import jdk.internal.misc.ScopedMemoryAccess;
import jdk.internal.misc.Unsafe;
@ -96,20 +96,20 @@ public abstract sealed class MappedByteBuffer
// This should only be invoked by the DirectByteBuffer constructors
//
MappedByteBuffer(int mark, int pos, int lim, int cap, // package-private
FileDescriptor fd, boolean isSync, MemorySegmentProxy segment) {
FileDescriptor fd, boolean isSync, MemorySegment segment) {
super(mark, pos, lim, cap, segment);
this.fd = fd;
this.isSync = isSync;
}
MappedByteBuffer(int mark, int pos, int lim, int cap, // package-private
boolean isSync, MemorySegmentProxy segment) {
boolean isSync, MemorySegment segment) {
super(mark, pos, lim, cap, segment);
this.fd = null;
this.isSync = isSync;
}
MappedByteBuffer(int mark, int pos, int lim, int cap, MemorySegmentProxy segment) { // package-private
MappedByteBuffer(int mark, int pos, int lim, int cap, MemorySegment segment) { // package-private
super(mark, pos, lim, cap, segment);
this.fd = null;
this.isSync = false;
@ -189,7 +189,7 @@ public abstract sealed class MappedByteBuffer
if (fd == null) {
return true;
}
return SCOPED_MEMORY_ACCESS.isLoaded(scope(), address, isSync, capacity());
return SCOPED_MEMORY_ACCESS.isLoaded(session(), address, isSync, capacity());
}
/**
@ -207,7 +207,7 @@ public abstract sealed class MappedByteBuffer
return this;
}
try {
SCOPED_MEMORY_ACCESS.load(scope(), address, isSync, capacity());
SCOPED_MEMORY_ACCESS.load(session(), address, isSync, capacity());
} finally {
Reference.reachabilityFence(this);
}
@ -307,7 +307,7 @@ public abstract sealed class MappedByteBuffer
if ((address != 0) && (capacity != 0)) {
// check inputs
Objects.checkFromIndexSize(index, length, capacity);
SCOPED_MEMORY_ACCESS.force(scope(), fd, address, isSync, index, length);
SCOPED_MEMORY_ACCESS.force(session(), fd, address, isSync, index, length);
}
return this;
}