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

Stack trace for errors #108

Merged
merged 5 commits into from
Feb 21, 2019
Merged

Stack trace for errors #108

merged 5 commits into from
Feb 21, 2019

Conversation

geseq
Copy link
Collaborator

@geseq geseq commented Feb 21, 2019

PR for stack trace.

#93

@geseq
Copy link
Collaborator Author

geseq commented Feb 21, 2019

I'm working on further optimization (unrelated to this). I will make a separate PR when I'm done.

@geseq
Copy link
Collaborator Author

geseq commented Feb 21, 2019

What do you think about introducing another Operator (something like OpBinaryOp) that'd be emitted before all the operators that call Object.BinaryOp()?

I've been testing it out and it gets rid of a lot of redundant duplicate code without any loss of performance (a slight performance gain in fact, but probably not one to make it worth it just for the performance, especially for fib(35) which relies significantly on binary operations).

@geseq
Copy link
Collaborator Author

geseq commented Feb 21, 2019

Resolves #106


filePos := v.fileSet.Position(v.curFrame.fn.SourceMap[v.curFrame.ip-1])
err = fmt.Errorf("%s\nin %s", err.Error(), filePos)
}
Copy link
Owner

Choose a reason for hiding this comment

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

I think this can be further reduced?

for v.framesIndex > 1 {
	v.framesIndex--
	v.curFrame = &v.frames[v.framesIndex-1]

	filePos := v.fileSet.Position(v.curFrame.fn.SourceMap[v.curFrame.ip-1])
	err = fmt.Errorf("%s\nin %s", err.Error(), filePos)
}

Copy link
Owner

@d5 d5 Feb 21, 2019

Choose a reason for hiding this comment

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

Actually, now that I think about this, we're mutating the VM state partially, so we probably need to either

  1. remove v.FrameInfo() because it may return partially correct info, or,
  2. mutate everything as if VM actually returned from all function calls

I guess #1 is easier because the main purpose of v.FrameInfo was to see where the error occurred during test in the first place. Now that we have stack info in error messages, it's not needed anymore.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated.

True, I don't think v.FrameInfo adds any more useful information for debugging. Shall I remove it?

Copy link
Owner

Choose a reason for hiding this comment

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

Yes please

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

@d5
Copy link
Owner

d5 commented Feb 21, 2019

Tell me more about OpBinaryOp. I'm not sure if I understand what you're trying to do. Probably seeing some code is easier 😄 .

@geseq
Copy link
Collaborator Author

geseq commented Feb 21, 2019

I'll make a separate PR with the OpBinaryOp tomorrow.

@d5 d5 merged commit f265f17 into d5:master Feb 21, 2019
@geseq geseq deleted the vmerrmsg branch February 26, 2019 06:01
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