Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright (c) 2019, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.oracle.svm.truffle.isolated;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
import org.graalvm.nativeimage.c.function.CEntryPoint;
import org.graalvm.nativeimage.c.type.CCharPointer;
import org.graalvm.nativeimage.c.type.CTypeConversion;
import com.oracle.svm.core.meta.SubstrateObjectConstant;
import com.oracle.svm.graal.isolated.ClientHandle;
import com.oracle.svm.graal.isolated.ClientIsolateThread;
import com.oracle.svm.graal.isolated.CompilerHandle;
import com.oracle.svm.graal.isolated.CompilerIsolateThread;
import com.oracle.svm.graal.isolated.IsolatedCompileClient;
import com.oracle.svm.graal.isolated.IsolatedCompileContext;
import com.oracle.svm.graal.isolated.IsolatedHandles;
import com.oracle.svm.graal.isolated.IsolatedObjectConstant;
import com.oracle.svm.graal.isolated.IsolatedObjectProxy;
import com.oracle.svm.truffle.api.SubstrateCompilableTruffleAST;
import com.oracle.svm.truffle.isolated.BinaryOutput.ByteArrayBinaryOutput;
import com.oracle.truffle.compiler.TruffleCompilable;
import com.oracle.truffle.compiler.TruffleCompilationTask;
import com.oracle.truffle.compiler.TruffleSourceLanguagePosition;
import jdk.vm.ci.meta.JavaConstant;
final class IsolatedTruffleCompilationTask extends IsolatedObjectProxy implements TruffleCompilationTask {
IsolatedTruffleCompilationTask(ClientHandle handle) {
super(handle);
}
@Override
public boolean isCancelled() {
return isCancelled0(IsolatedCompileContext.get().getClient(), handle);
}
@Override
public boolean isLastTier() {
return isLastTier0(IsolatedCompileContext.get().getClient(), handle);
}
@Override
public boolean isFirstTier() {
return isFirstTier0(IsolatedCompileContext.get().getClient(), handle);
}
@Override
public boolean hasNextTier() {
return hasNextTier0(IsolatedCompileContext.get().getClient(), handle);
}
@Override
public TruffleSourceLanguagePosition getPosition(JavaConstant nodeConstant) {
if (!(nodeConstant instanceof IsolatedObjectConstant)) {
return null; // not an AST node, therefore not handled by this method
}
ClientHandle> nodeConstantHandle = ((IsolatedObjectConstant) nodeConstant).getHandle();
CompilerHandle position = getPosition0(IsolatedCompileContext.get().getClient(), handle, nodeConstantHandle);
return IsolatedCompileContext.get().unhand(position);
}
@Override
public Map getDebugProperties(JavaConstant nodeConstant) {
if (!(nodeConstant instanceof IsolatedObjectConstant)) {
return Collections.emptyMap(); // not an AST node, therefore not handled by this method
}
ClientHandle> nodeConstantHandle = ((IsolatedObjectConstant) nodeConstant).getHandle();
Map debugProperties = new LinkedHashMap<>();
var debugPropertiesHandle = IsolatedCompileContext.get().hand(debugProperties);
getDebugProperties0(IsolatedCompileContext.get().getClient(), handle, nodeConstantHandle, debugPropertiesHandle);
return debugProperties;
}
@Override
public void addTargetToDequeue(TruffleCompilable target) {
ClientHandle targetHandle = ((IsolatedCompilableTruffleAST) target).getHandle();
addTargetToDequeue0(IsolatedCompileContext.get().getClient(), handle, targetHandle);
}
@Override
public void setCallCounts(int total, int inlined) {
setCallCounts0(IsolatedCompileContext.get().getClient(), handle, total, inlined);
}
@Override
public void addInlinedTarget(TruffleCompilable target) {
ClientHandle targetHandle = ((IsolatedCompilableTruffleAST) target).getHandle();
addInlinedTarget0(IsolatedCompileContext.get().getClient(), handle, targetHandle);
}
@CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished)
private static boolean isCancelled0(@SuppressWarnings("unused") ClientIsolateThread client, ClientHandle taskHandle) {
return IsolatedCompileClient.get().unhand(taskHandle).isCancelled();
}
@CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished)
private static boolean isLastTier0(@SuppressWarnings("unused") ClientIsolateThread client, ClientHandle taskHandle) {
return IsolatedCompileClient.get().unhand(taskHandle).isLastTier();
}
@CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished)
private static boolean isFirstTier0(@SuppressWarnings("unused") ClientIsolateThread client, ClientHandle taskHandle) {
return IsolatedCompileClient.get().unhand(taskHandle).isFirstTier();
}
@CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished)
private static boolean hasNextTier0(@SuppressWarnings("unused") ClientIsolateThread client, ClientHandle taskHandle) {
return IsolatedCompileClient.get().unhand(taskHandle).hasNextTier();
}
@CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished)
private static CompilerHandle getPosition0(@SuppressWarnings("unused") ClientIsolateThread client,
ClientHandle extends TruffleCompilationTask> inliningHandle, ClientHandle> callNodeConstantHandle) {
TruffleCompilationTask task = IsolatedCompileClient.get().unhand(inliningHandle);
JavaConstant callNodeConstant = SubstrateObjectConstant.forObject(IsolatedCompileClient.get().unhand(callNodeConstantHandle));
TruffleSourceLanguagePosition position = task.getPosition(callNodeConstant);
if (position == null) {
return IsolatedHandles.nullHandle();
}
return createPositionInCompiler(IsolatedCompileClient.get().getCompiler(), IsolatedCompileClient.get().hand(position),
position.getLineNumber(), position.getOffsetStart(), position.getOffsetEnd(), position.getNodeId());
}
@CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = CEntryPoint.Publish.NotPublished)
@SuppressWarnings("unused")
private static void fillDebugProperties0(@CEntryPoint.IsolateThreadContext CompilerIsolateThread context,
ClientIsolateThread client, CCharPointer buffer, int bufferLength,
CompilerHandle