Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Promise breakpoint #58

Merged
merged 2 commits into from Nov 24, 2016
Merged

Promise breakpoint #58

merged 2 commits into from Nov 24, 2016

Conversation

ctrlpz
Copy link
Contributor

@ctrlpz ctrlpz commented Nov 22, 2016

Implementation of promise breakpoints for resolver and resolution side.

Copy link
Owner

@smarr smarr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good. Most comments are polish to keep consistent with existing style and avoid code duplication.

@@ -0,0 +1,22 @@
0 info it worked if it ends with ok
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please do not commit such logs


protected EventualMessage(final EventualMessage causalMessage, final Object[] args,
final SResolver resolver, final RootCallTarget onReceive, final boolean triggerRcvrBreakpoint) {
final SResolver resolver, final RootCallTarget onReceive, final boolean triggerRcvrBreakpoint, final boolean triggerPromiseResolveBreakpoint, final boolean triggerPromiseResolveReceiverBreakpoint) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please break the line after about 80 characters

final RootCallTarget onReceive, final boolean triggerRcvrBreakpoint) {
super(causalMessage, arguments, resolver, onReceive, triggerRcvrBreakpoint);
final RootCallTarget onReceive, final boolean triggerRcvrBreakpoint, final boolean triggerPromiseResolveSenderBreakpoint, final boolean triggerPromiseResolveReceiverBreakpoint) {
super(causalMessage, arguments, resolver, onReceive, triggerRcvrBreakpoint, triggerPromiseResolveSenderBreakpoint, triggerPromiseResolveReceiverBreakpoint);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please break the line after about 80 characters

@@ -22,15 +22,19 @@
protected final RootCallTarget onReceive;
protected final EventualMessage causalMessage;

protected final boolean triggerRcvrBreakpoint;
protected boolean triggerRcvrBreakpoint;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would be good to add a comment to the field explaining why it is not final like the other ones.

@@ -22,15 +22,19 @@
protected final RootCallTarget onReceive;
protected final EventualMessage causalMessage;

protected final boolean triggerRcvrBreakpoint;
protected boolean triggerRcvrBreakpoint;
protected final boolean triggerPromiseResolveSenderBreakpoint;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

didn't we have new terminology after the discussion with Elisa? would be good to change the code accordingly.

@@ -0,0 +1,39 @@
package tools.debugger.nodes;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please refactor these classes to avoid code duplication. The only thing that seems to be different is how the BreakpointEnabling object is retrieved. This can be factored out.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to refactor the BreakpointNode classes I think there is a problem because of the types of breakpoints. Indeed the BreakpointEnabling object is the one that makes the difference, but to be able to use only one BreakpointNode class I think that we will have to use a superclass and this will bring some changes because the most part of implementation related to breakpoints is specified by each type of breakpoint.

* Disabled breakpoint node that returns false all the time.
*
* (use mainly when the Truffle debugger is not enabled)
*
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove empty line

@@ -74,6 +74,8 @@ export class Controller {
case "AsyncMessageReceiveBreakpoint":
this.view.updateAsyncMethodRcvBreakpoint(<AsyncMethodRcvBreakpoint> bp);
break;
case "PromiseSenderBreakpoint":
case "PromiseReceiveBreakpoint": /** TODO */
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this correct? looks like there is code missing

line: line,
sourceUri: sourceUri,
enabled: false};
export type Breakpoint = LineBreakpoint | MessageBreakpoint |
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this is a broken merge/rebase.
Please see the breakpoints.ts file next to messages.ts. This here seem to duplicate the code that moved there.

source, sourceId, clickedSpan);
}

export function createMsgBreakpoint(source: Source,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the only difference between the various breakpoints is here the type. Please factor out this code to create the object that is passed to the constructor into a helper method to avoid code duplication.

Copy link
Owner

@smarr smarr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some naming, cosmetics, and the breakpoint class

* It is not final because its value can be updated in order that other breakpoints
* can reuse the stepping strategy implemented for message receiver breakpoints.
*/
protected boolean triggerRcvrBreakpoint;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

triggerRcvrBreakpoint should be named triggerMessageReceiverBreakpoint to be unambiguous within the new set of breakpoints

@@ -131,8 +144,8 @@ protected static Actor determineTargetAndWrapArguments(final Object[] arguments,
protected final Actor originalSender; // initial owner of the arguments

public PromiseMessage(final EventualMessage causalMessage, final Object[] arguments, final Actor originalSender,
final SResolver resolver, final RootCallTarget onReceive, final boolean triggerRcvrBreakpoint) {
super(causalMessage, arguments, resolver, onReceive, triggerRcvrBreakpoint);
final SResolver resolver, final RootCallTarget onReceive, final boolean triggerRcvrBreakpoint, final boolean triggerPromiseResolverBreakpoint, final boolean triggerPromiseResolutionBreakpoint) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please keep lines within 80 chars

@@ -114,7 +112,9 @@ public static boolean isParentResultUsed(final Node current, final Node child) {

protected final SourceSection source;

protected final AbstractBreakpointNode breakpoint;
protected final AbstractBreakpointNode messageReceivedBreakpoint;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

messageReceivedBreakpoint -> messageReceiverBreakpoint

public NullResolver(final SourceSection source) {
super(false, source);
}

@Override
public Object executeEvaluated(final VirtualFrame frame, final SResolver receiver, final Object argument) {
public Object executeEvaluated(final VirtualFrame frame, final SResolver receiver, final Object argument, final boolean isBreakpointOnResolutionAtSender, final boolean isBreakpointOnResolutionAtRcvr) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please keep it to 80chars

if (isBreakpointOnResolutionAtSender) {
haltNode.executeEvaluated(frame, argument);
}
if (isBreakpointOnResolutionAtRcvr) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, please avoid committing your todo items as empty if statements

protected final BreakpointEnabling<?> breakpoint;

protected BreakpointNode(final SourceSection sourceSection, final MessageBreakpointType type) {
switch (type) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move this out of the constructor to the corresponding code and please don't use a switch.


/** Only to be used by the DisabledBreakpointNode. */
protected BreakpointNode() {
this.breakpoint = null;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not used anymore since DisabledBreakpoint inherits directly from AbstractBreakpointNode, right?
If so, please remove.

receiverBreakpoints.put(coord, existingBP);
} else {
existingBP.setEnabled(bId.isEnabled());
}
}

public synchronized void addOrUpdate(final PromiseResolverBreakpoint bId) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this code looks repetitive, looks like one could factor out a helper method here.

Copy link
Contributor Author

@ctrlpz ctrlpz Nov 24, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I refactored the addOrUpdate for MessageSenderBreakpoint and AsyncMessageReceiverBreakpoint...But for the case of MessageReceiverBreakpoint and the promises breakpoints I have been trying to do something like this:

 public synchronized void addOrUpdate(final PromiseResolutionBreakpoint bId) {
    saveBreakpointsEnabling(bId, promiseResolutionBreakpoints);
  }

  private void saveBreakpointsEnabling(final SectionBreakpoint bId, final Map<FullSourceCoordinate, BreakpointEnabling<? extends SectionBreakpoint>> map) {
    FullSourceCoordinate coord = bId.getCoordinate();
    BreakpointEnabling<? extends SectionBreakpoint> existingBP = map.get(coord);
    if (existingBP == null) {
      existingBP = new BreakpointEnabling<>(bId);
      map.put(coord, existingBP);
    } else {
      existingBP.setEnabled(bId.isEnabled());
    }
  }

the problem is that the argument types are not applicable for '? extends SectionBreakpoint', I'm not sure if there is a way of refactoring these three methods. The only difference between them is the map (receiverBreakpoints, promiseResolverBreakpoints, promiseResolutionBreakpoints)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At this point you don't really need the info about extends SectionBreakpoint or do you?
Guess it would work if you drop that part?

Copy link
Contributor Author

@ctrlpz ctrlpz Nov 24, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it keeps saying it is not applicable for the arguments :(

private void saveBreakpointsEnabling(final SectionBreakpoint bId, final Map<FullSourceCoordinate, BreakpointEnabling<?>> map) { FullSourceCoordinate coord = bId.getCoordinate(); BreakpointEnabling<?> existingBP = map.get(coord); if (existingBP == null) { existingBP = new BreakpointEnabling<>(bId); map.put(coord, existingBP); } else { existingBP.setEnabled(bId.isEnabled()); } }

* It has two possible states, enable or disable.
*/
public abstract class BreakpointNode extends AbstractBreakpointNode {
protected final BreakpointEnabling<?> breakpoint;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make this a proper generic type. Replace ? with T. And add T as a generic argument to BreakpointNode

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the generic argument T should extend of BreakpointInfo too as BreakpointEnabling?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

T extends BreakpointInfo seems useful, yes

@@ -98,7 +98,7 @@ export interface FarRefData {
export type BreakpointData = LineBreakpointData | SectionBreakpointData;

export type SectionBreakpointType = "MessageSenderBreakpoint" |
"MessageReceiveBreakpoint" | "AsyncMessageReceiveBreakpoint";
"MessageReceiverBreakpoint" | "AsyncMessageReceiverBreakpoint" | "PromiseResolverBreakpoint" | "PromiseResolutionBreakpoint" ;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please keep within 80 chars per line

bp = Breakpoint.newBuilder(bId.getCoordinate().uri).
lineIs(bId.getCoordinate().startLine).
columnIs(bId.getCoordinate().startColumn).
sectionLength(bId.getCoordinate().charLength).
build();
bp.setCondition(BreakWhenActivatedByAsyncMessage.INSTANCE);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ctrlpz this is a problem, this line is essential :( and we really need tests for these things

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, I did not notice I removed it...yes we need the tests

ctrlpz and others added 2 commits November 24, 2016 16:54
- add options to frontend for promise breakpoint on sender and
  receiver side
- change button names in popover
- add breakpoint classes
- move classes related to breakpoint node from EventualSendNode
  to an independent package
- add SuspendExecutionNode for halting the execution before
  the promise is resolved (todo: needs to be replaced by stepping strategy)
- add helper method to create SectionBreakpointData object to avoid code
  duplication between the different breakpoints

- remove CoverallsTruffle from Eclipse classpath (project is already
  part of SOMns-deps
Signed-off-by: Stefan Marr <git@stefan-marr.de>
@smarr smarr merged commit b46f6bb into smarr:master Nov 24, 2016
@smarr smarr deleted the promise-breakpoint branch November 24, 2016 16:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants