Skip to content

Commit

Permalink
Rename WasmInstrumentableFunctionNode to functionNode.
Browse files Browse the repository at this point in the history
  • Loading branch information
woess committed Sep 13, 2023
1 parent a96d9fa commit fd7f2f9
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@
*/
public class WasmMemoryOverheadModeRootNode extends WasmRootNode {

public WasmMemoryOverheadModeRootNode(TruffleLanguage<?> language, FrameDescriptor frameDescriptor, WasmInstrumentableFunctionNode function) {
super(language, frameDescriptor, function);
public WasmMemoryOverheadModeRootNode(TruffleLanguage<?> language, FrameDescriptor frameDescriptor, WasmInstrumentableFunctionNode functionNode) {
super(language, frameDescriptor, functionNode);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@
@NodeInfo(language = WasmLanguage.ID, description = "The root node of all WebAssembly functions")
public class WasmRootNode extends RootNode {
private SourceSection sourceSection;
@Child private WasmInstrumentableFunctionNode function;
@Child private WasmInstrumentableFunctionNode functionNode;
private final BranchProfile nonLinkedProfile = BranchProfile.create();

public WasmRootNode(TruffleLanguage<?> language, FrameDescriptor frameDescriptor, WasmInstrumentableFunctionNode function) {
public WasmRootNode(TruffleLanguage<?> language, FrameDescriptor frameDescriptor, WasmInstrumentableFunctionNode functionNode) {
super(language, frameDescriptor);
this.function = function;
this.functionNode = functionNode;
}

protected final WasmContext getContext() {
Expand All @@ -92,7 +92,7 @@ protected final WasmContext getContext() {
* Overridden by {@link org.graalvm.wasm.predefined.WasmBuiltinRootNode}.
*/
protected WasmModule module() {
return function.module();
return functionNode.module();
}

@SuppressWarnings("static-method")
Expand All @@ -110,7 +110,7 @@ public final void tryInitialize(WasmContext context, WasmInstance instance) {
* Overridden by {@link org.graalvm.wasm.predefined.WasmBuiltinRootNode}.
*/
protected WasmInstance instance(VirtualFrame frame) {
return function.instance(frame);
return functionNode.instance(frame);
}

protected final WasmMemory memory(VirtualFrame frame) {
Expand Down Expand Up @@ -141,30 +141,30 @@ public Object executeWithContext(VirtualFrame frame, WasmContext context) {
// The reason for this is that the operand stack cannot be passed
// as an argument to the loop-node's execute method,
// and must be restored at the beginning of the loop body.
final int localCount = function.localCount();
final int localCount = functionNode.localCount();
moveArgumentsToLocals(frame);

// WebAssembly rules dictate that a function's locals must be initialized to zero before
// function invocation. For more information, check the specification:
// https://webassembly.github.io/spec/core/exec/instructions.html#function-calls
initializeLocals(frame);

final int resultCount = function.resultCount();
final int resultCount = functionNode.resultCount();
CompilerAsserts.partialEvaluationConstant(resultCount);
if (resultCount > 1) {
context.resizeMultiValueStack(resultCount);
}

try {
function.execute(frame, context);
functionNode.execute(frame, context);
} catch (StackOverflowError e) {
function.enterErrorBranch();
functionNode.enterErrorBranch();
throw WasmException.create(Failure.CALL_STACK_EXHAUSTED);
}
if (resultCount == 0) {
return WasmConstant.VOID;
} else if (resultCount == 1) {
final byte resultType = function.resultType(0);
final byte resultType = functionNode.resultType(0);
CompilerAsserts.partialEvaluationConstant(resultType);
switch (resultType) {
case WasmType.VOID_TYPE:
Expand Down Expand Up @@ -195,7 +195,7 @@ private void moveResultValuesToMultiValueStack(VirtualFrame frame, WasmContext c
final long[] multiValueStack = context.primitiveMultiValueStack();
final Object[] referenceMultiValueStack = context.referenceMultiValueStack();
for (int i = 0; i < resultCount; i++) {
final int resultType = function.resultType(i);
final int resultType = functionNode.resultType(i);
CompilerAsserts.partialEvaluationConstant(resultType);
switch (resultType) {
case WasmType.I32_TYPE:
Expand Down Expand Up @@ -223,11 +223,11 @@ private void moveResultValuesToMultiValueStack(VirtualFrame frame, WasmContext c
@ExplodeLoop
private void moveArgumentsToLocals(VirtualFrame frame) {
Object[] args = frame.getArguments();
int paramCount = function.paramCount();
int paramCount = functionNode.paramCount();
assert WasmArguments.getArgumentCount(args) == paramCount : "Expected number of params " + paramCount + ", actual " + args.length;
for (int i = 0; i != paramCount; ++i) {
final Object arg = WasmArguments.getArgument(args, i);
byte type = function.localType(i);
byte type = functionNode.localType(i);
switch (type) {
case WasmType.I32_TYPE:
pushInt(frame, i, (int) arg);
Expand All @@ -251,9 +251,9 @@ private void moveArgumentsToLocals(VirtualFrame frame) {

@ExplodeLoop
private void initializeLocals(VirtualFrame frame) {
int paramCount = function.paramCount();
for (int i = paramCount; i != function.localCount(); ++i) {
byte type = function.localType(i);
int paramCount = functionNode.paramCount();
for (int i = paramCount; i != functionNode.localCount(); ++i) {
byte type = functionNode.localType(i);
switch (type) {
case WasmType.I32_TYPE:
pushInt(frame, i, 0);
Expand Down Expand Up @@ -282,34 +282,34 @@ public final String toString() {

@Override
public String getName() {
if (function == null) {
if (functionNode == null) {
return "function";
}
return function.name();
return functionNode.name();
}

@Override
public final String getQualifiedName() {
if (function == null) {
if (functionNode == null) {
return getName();
}
return function.qualifiedName();
return functionNode.qualifiedName();
}

@Override
@TruffleBoundary
protected boolean isInstrumentable() {
return function != null && function.isInstrumentable();
return functionNode != null && functionNode.isInstrumentable();
}

@Override
@TruffleBoundary
public final SourceSection getSourceSection() {
if (function == null) {
if (functionNode == null) {
return null;
}
if (sourceSection == null) {
sourceSection = function.getSourceSection();
sourceSection = functionNode.getSourceSection();
if (sourceSection == null) {
sourceSection = module().source().createUnavailableSection();
}
Expand Down

0 comments on commit fd7f2f9

Please sign in to comment.