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 traces for JS exceptions #821
Conversation
85afeb7
to
beeea6f
Compare
7337c4a
to
9acbbf7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, love how the stack trace looks.
My comments are only for my personal understanding, and the PR is GTG.
@@ -1,6 +1,8 @@ | |||
<Project Sdk="Microsoft.NET.Sdk"> | |||
<PropertyGroup> | |||
<TargetFrameworks>net461;net5.0</TargetFrameworks> | |||
<AssemblyOriginatorKeyFile>..\Jint\Jint.snk</AssemblyOriginatorKeyFile> | |||
<SignAssembly>true</SignAssembly> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feels like I asked the same question recently, but what's the reason?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to get access to internal methods, like Jint.Tests has
@@ -1,4 +1,5 @@ | |||
using System.Runtime.CompilerServices; | |||
|
|||
[assembly: InternalsVisibleTo("Jint.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100bf2553c9f214cb21f1f64ed62cadad8fe4f2fa11322a5dfa1d650743145c6085aba05b145b29867af656e0bb9bfd32f5d0deb1668263a38233e7e8e5bad1a3c6edd3f2ec6c512668b4aa797283101444628650949641b4f7cb16707efba542bb754afe87ce956f3a5d43f450d14364eb9571cbf213d1061852fb9dd47a6c05c4")] | |||
[assembly: InternalsVisibleTo("Jint.Tests.Test262, PublicKey=0024000004800000940000000602000000240000525341310004000001000100bf2553c9f214cb21f1f64ed62cadad8fe4f2fa11322a5dfa1d650743145c6085aba05b145b29867af656e0bb9bfd32f5d0deb1668263a38233e7e8e5bad1a3c6edd3f2ec6c512668b4aa797283101444628650949641b4f7cb16707efba542bb754afe87ce956f3a5d43f450d14364eb9571cbf213d1061852fb9dd47a6c05c4")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, that's for the internal visible that you added the snk?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep.
/// <summary> | ||
/// Stack for struct types. | ||
/// </summary> | ||
internal sealed class RefStack<T> : IEnumerable<T> where T : struct |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tell me more about that!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basically just optimized to return refs without copies (like structs usually get copied with generic .NET data structures). Faster and simpler for specific use case.
@@ -9,7 +9,7 @@ namespace Jint.Pooling | |||
/// <summary> | |||
/// Pooling of StringBuilder instances. | |||
/// </summary> | |||
internal sealed class StringBuilderPool | |||
internal static class StringBuilderPool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not static anymore?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually now static instead of sealed, all methods are static and no instances of pool are required 😉
I needed better errors while trying to figure out problems in class implementation branch so decided to separate these changes from there. Now the exceptions start to make more sense, at least from my viewpoint.
stack
property on error, like browsers have, use more .NET like propertiesMessage
andStackTrace
inJavaScriptException
RefStack<T>
fromExecutionContextStack
so call stack can use it and thus structs more efficientlyfixes #112
fixes #190
fixes #251
fixes #258
fixes #293
fixes #735
Now in REPL:
Performance
No noticeable performance difference after enabling always having traces, mostly seems like jitter.
Esprima.Benchmark.SunSpiderBenchmark
Jint.Benchmark.DromaeoBenchmark
Jint.Benchmark.EvaluationBenchmark