From 2648e362af745fce6b0244905ea917049b933c33 Mon Sep 17 00:00:00 2001 From: carmen Date: Thu, 10 Oct 2019 16:06:57 +0200 Subject: [PATCH] Changes to get actor mailbox information - add three entries in the trace for the send operation entity. Add a symbol id to record the selector of the message. Add a targetActorId to record the receiver actor of the message. Add a source section corresponding to the origin of the send operation. Update the corresponding usages of this method. - the targetActorId is needed because in the case of a PROMISE_MSG the target of the send operation is a promise, but we need the information of the target actor of the original message. - the source section is already recorded for the dynamic scopes, however, dynamic scopes are created when the message is processed. To show the origin of a message sent in the mailbox, the source section is needed at the point where a message is sent but not yet processed. --- .../interpreter/actors/EventualSendNode.java | 14 +++++++---- src/som/primitives/actors/PromisePrims.java | 8 +++---- src/tools/concurrency/KomposTrace.java | 24 ++++++++++++------- src/tools/concurrency/TracingChannel.java | 2 +- src/tools/debugger/entities/SendOp.java | 7 +++++- 5 files changed, 36 insertions(+), 19 deletions(-) diff --git a/src/som/interpreter/actors/EventualSendNode.java b/src/som/interpreter/actors/EventualSendNode.java index 7cf2a5c94..3bd06fa37 100644 --- a/src/som/interpreter/actors/EventualSendNode.java +++ b/src/som/interpreter/actors/EventualSendNode.java @@ -212,7 +212,7 @@ protected void sendDirectMessage(final Object[] args, final Actor owner, if (VmSettings.KOMPOS_TRACING) { KomposTrace.sendOperation(SendOp.ACTOR_MSG, msg.getMessageId(), - target.getId()); + target.getId(), msg.getSelector(), msg.getTarget().getId(), msg.getTargetSourceSection()); } target.send(msg, actorPool); @@ -227,9 +227,15 @@ protected void sendPromiseMessage(final Object[] args, final SPromise rcvr, messageReceiverBreakpoint.executeShouldHalt(), promiseResolverBreakpoint.executeShouldHalt()); + Actor target = null; + if (isFarRefRcvr(args)) { + SFarReference farReference = (SFarReference) args[0]; + target = farReference.getActor(); + } + if (VmSettings.KOMPOS_TRACING) { KomposTrace.sendOperation(SendOp.PROMISE_MSG, msg.getMessageId(), - rcvr.getPromiseId()); + rcvr.getPromiseId(), msg.getSelector(), target != null ? target.getId() : -1, msg.getTargetSourceSection()); } registerNode.register(rcvr, msg, rcvr.getOwner()); @@ -286,7 +292,7 @@ public final SPromise toNearRefWithResultPromise(final Object[] args) { if (VmSettings.KOMPOS_TRACING) { KomposTrace.sendOperation(SendOp.ACTOR_MSG, msg.getMessageId(), - current.getId()); + current.getId(), msg.getSelector(), msg.getTarget().getId(), msg.getTargetSourceSection()); } current.send(msg, actorPool); @@ -322,7 +328,7 @@ public final Object toNearRefWithoutResultPromise(final Object[] args) { if (VmSettings.KOMPOS_TRACING) { KomposTrace.sendOperation(SendOp.ACTOR_MSG, msg.getMessageId(), - current.getId()); + current.getId(), msg.getSelector(), msg.getTarget().getId(), msg.getTargetSourceSection()); } current.send(msg, actorPool); diff --git a/src/som/primitives/actors/PromisePrims.java b/src/som/primitives/actors/PromisePrims.java index d64b91782..86abf383c 100644 --- a/src/som/primitives/actors/PromisePrims.java +++ b/src/som/primitives/actors/PromisePrims.java @@ -175,7 +175,7 @@ protected final SPromise registerWhenResolved(final SPromise rcvr, if (VmSettings.KOMPOS_TRACING) { KomposTrace.sendOperation(SendOp.PROMISE_MSG, pcm.getMessageId(), - rcvr.getPromiseId()); + rcvr.getPromiseId(), pcm.getSelector(), rcvr.getOwner().getId(), pcm.getTargetSourceSection()); } registerNode.register(rcvr, pcm, current); @@ -242,7 +242,7 @@ protected final SPromise registerOnError(final SPromise rcvr, if (VmSettings.KOMPOS_TRACING) { KomposTrace.sendOperation(SendOp.PROMISE_MSG, msg.getMessageId(), - rcvr.getPromiseId()); + rcvr.getPromiseId(), msg.getSelector(), rcvr.getOwner().getId(), msg.getTargetSourceSection()); } registerNode.register(rcvr, msg, current); @@ -321,9 +321,9 @@ protected final SPromise registerWhenResolvedOrError(final SPromise rcvr, if (VmSettings.KOMPOS_TRACING) { KomposTrace.sendOperation(SendOp.PROMISE_MSG, onResolved.getMessageId(), - rcvr.getPromiseId()); + rcvr.getPromiseId(), onResolved.getSelector(), onResolved.getTarget().getId(), onResolved.getTargetSourceSection()); KomposTrace.sendOperation(SendOp.PROMISE_MSG, onError.getMessageId(), - rcvr.getPromiseId()); + rcvr.getPromiseId(), onError.getSelector(), onError.getTarget().getId(), onResolved.getTargetSourceSection()); } synchronized (rcvr) { diff --git a/src/tools/concurrency/KomposTrace.java b/src/tools/concurrency/KomposTrace.java index 3e4bec913..db72c6eab 100644 --- a/src/tools/concurrency/KomposTrace.java +++ b/src/tools/concurrency/KomposTrace.java @@ -28,7 +28,7 @@ public static void recordMainActor(final Actor mainActor, KomposTraceBuffer buffer = KomposTraceBuffer.create(0); buffer.recordCurrentActivity(mainActor); buffer.recordMainActor(mainActor, objectSystem); - buffer.recordSendOperation(SendOp.ACTOR_MSG, 0, mainActor.getId(), mainActor); + buffer.recordSendOperation(SendOp.ACTOR_MSG, 0, mainActor.getId(), mainActor, (short) 0, 0, null); buffer.returnBuffer(null); } @@ -84,7 +84,7 @@ public static void promiseResolution(final long promiseId, final Object value) { ((KomposTraceBuffer) t.getBuffer()).recordSendOperation(SendOp.PROMISE_RESOLUTION, 0, promiseId, - t.getActivity()); + t.getActivity(), (short) 0, 0, null); t.resolvedPromises++; } @@ -94,7 +94,7 @@ public static void promiseError(final long promiseId, final Object value) { TracingActivityThread t = (TracingActivityThread) current; ((KomposTraceBuffer) t.getBuffer()).recordSendOperation(SendOp.PROMISE_RESOLUTION, 0, promiseId, - t.getActivity()); + t.getActivity(), (short) 0, 0, null); t.erroredPromises++; } @@ -107,15 +107,15 @@ public static void promiseError(final long promiseId, final Object value) { public static void promiseChained(final long promiseValueId, final long promiseId) { TracingActivityThread t = getThread(); ((KomposTraceBuffer) t.getBuffer()).recordSendOperation( - SendOp.PROMISE_RESOLUTION, promiseValueId, promiseId, t.getActivity()); + SendOp.PROMISE_RESOLUTION, promiseValueId, promiseId, t.getActivity(), (short) 0, 0, null); t.resolvedPromises++; } public static void sendOperation(final SendOp op, final long entityId, - final long targetId) { + final long targetId, final SSymbol selector, long targetActorId, SourceSection msgSourceCoordinate) { TracingActivityThread t = getThread(); ((KomposTraceBuffer) t.getBuffer()).recordSendOperation(op, entityId, targetId, - t.getActivity()); + t.getActivity(), selector.getSymbolId(), targetActorId, msgSourceCoordinate); } public static void receiveOperation(final ReceiveOp op, final long sourceId) { @@ -334,7 +334,7 @@ public void recordReceiveOperation(final ReceiveOp op, final long sourceId, } public void recordSendOperation(final SendOp op, final long entityId, - final long targetId, final Activity current) { + final long targetId, final Activity current, final short symbolId, long targetActorId, SourceSection msgSourceCoordinate) { int requiredSpace = op.getSize(); ensureSufficientSpace(requiredSpace, current); @@ -342,6 +342,12 @@ public void recordSendOperation(final SendOp op, final long entityId, put(op.getId()); putLong(entityId); putLong(targetId); + putLong(targetActorId); + putShort(symbolId); + + if (VmSettings.KOMPOS_TRACING) { + writeSourceSection(msgSourceCoordinate); + } assert position == start + requiredSpace; } @@ -391,8 +397,8 @@ public synchronized void recordReceiveOperation(final ReceiveOp op, @Override public synchronized void recordSendOperation(final SendOp op, - final long entityId, final long targetId, final Activity current) { - super.recordSendOperation(op, entityId, targetId, current); + final long entityId, final long targetId, final Activity current, final short symbol, final long targetActorId, final SourceSection section) { + super.recordSendOperation(op, entityId, targetId, current, symbol, targetActorId, section); } } } diff --git a/src/tools/concurrency/TracingChannel.java b/src/tools/concurrency/TracingChannel.java index 349f3c663..b8cf5422f 100644 --- a/src/tools/concurrency/TracingChannel.java +++ b/src/tools/concurrency/TracingChannel.java @@ -55,7 +55,7 @@ public void write(final Object value, final RecordTwoEvent traceWrite) super.write(value, traceWrite); } finally { KomposTrace.sendOperation( - SendOp.CHANNEL_SEND, current.messageId, current.channelId); + SendOp.CHANNEL_SEND, current.messageId, current.channelId, null, 0, null); } } } diff --git a/src/tools/debugger/entities/SendOp.java b/src/tools/debugger/entities/SendOp.java index 89f5577a2..fa92ea0fa 100644 --- a/src/tools/debugger/entities/SendOp.java +++ b/src/tools/debugger/entities/SendOp.java @@ -1,5 +1,7 @@ package tools.debugger.entities; +import tools.TraceData; + public enum SendOp { ACTOR_MSG(Marker.ACTOR_MSG_SEND, EntityType.ACT_MSG, EntityType.ACTOR), PROMISE_MSG(Marker.PROMISE_MSG_SEND, EntityType.ACT_MSG, EntityType.PROMISE), @@ -10,6 +12,9 @@ public enum SendOp { private final EntityType entity; private final EntityType target; + private static final int SYMBOL_ID_SIZE = 2; + private static final int RECEIVER_ACTOR_ID_SIZE = 8; + SendOp(final byte id, final EntityType entity, final EntityType target) { this.id = id; this.entity = entity; @@ -29,6 +34,6 @@ public EntityType getTarget() { } public int getSize() { - return 17; + return 17 + RECEIVER_ACTOR_ID_SIZE + SYMBOL_ID_SIZE + TraceData.SOURCE_SECTION_SIZE; } }