@@ -60,19 +60,30 @@ public static bool InvokeJSUnmarshalled(string functionIdentifier, IntPtr arg0)
60
60
{
61
61
if ( _trace . IsEnabled )
62
62
{
63
- using ( WritePropertyEventTrace ( TraceProvider . UnmarshalledInvokedStart , TraceProvider . UnmarshalledInvokedEnd , functionIdentifier ) )
64
- {
65
- var ret = InnerInvokeJSUnmarshalled ( functionIdentifier , arg0 , out var exception ) ;
66
-
67
- if ( exception != null )
68
- {
69
- throw exception ;
70
- }
63
+ return InvokeJSUnmarshalledWithTrace ( functionIdentifier , arg0 ) ;
64
+ }
65
+ else
66
+ {
67
+ var ret = InnerInvokeJSUnmarshalled ( functionIdentifier , arg0 , out var exception ) ;
71
68
72
- return ret ;
69
+ if ( exception != null )
70
+ {
71
+ throw exception ;
73
72
}
73
+
74
+ return ret ;
74
75
}
75
- else
76
+ }
77
+
78
+ /// <remarks>
79
+ /// This method contains or is called by a try/catch containing method and
80
+ /// can be significantly slower than other methods as a result on WebAssembly.
81
+ /// See https://github.com/dotnet/runtime/issues/56309
82
+ /// </remarks>
83
+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
84
+ private static bool InvokeJSUnmarshalledWithTrace ( string functionIdentifier , IntPtr arg0 )
85
+ {
86
+ using ( WritePropertyEventTrace ( TraceProvider . UnmarshalledInvokedStart , TraceProvider . UnmarshalledInvokedEnd , functionIdentifier ) )
76
87
{
77
88
var ret = InnerInvokeJSUnmarshalled ( functionIdentifier , arg0 , out var exception ) ;
78
89
@@ -93,17 +104,28 @@ internal static bool InvokeJSUnmarshalled(string functionIdentifier, IntPtr arg0
93
104
{
94
105
if ( _trace . IsEnabled )
95
106
{
96
- using ( WritePropertyEventTrace ( TraceProvider . UnmarshalledInvokedStart , TraceProvider . UnmarshalledInvokedEnd , functionIdentifier ) )
97
- {
98
- return InnerInvokeJSUnmarshalled ( functionIdentifier , arg0 , out exception ) ;
99
- }
107
+ return InvokeJSUnmarshalledWithTrace ( functionIdentifier , arg0 , out exception ) ;
100
108
}
101
109
else
102
110
{
103
111
return InnerInvokeJSUnmarshalled ( functionIdentifier , arg0 , out exception ) ;
104
112
}
105
113
}
106
114
115
+ /// <remarks>
116
+ /// This method contains or is called by a try/catch containing method and
117
+ /// can be significantly slower than other methods as a result on WebAssembly.
118
+ /// See https://github.com/dotnet/runtime/issues/56309
119
+ /// </remarks>
120
+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
121
+ private static bool InvokeJSUnmarshalledWithTrace ( string functionIdentifier , IntPtr arg0 , out Exception ? exception )
122
+ {
123
+ using ( WritePropertyEventTrace ( TraceProvider . UnmarshalledInvokedStart , TraceProvider . UnmarshalledInvokedEnd , functionIdentifier ) )
124
+ {
125
+ return InnerInvokeJSUnmarshalled ( functionIdentifier , arg0 , out exception ) ;
126
+ }
127
+ }
128
+
107
129
private static bool InnerInvokeJSUnmarshalled ( string functionIdentifier , IntPtr arg0 , out Exception ? exception )
108
130
{
109
131
exception = null ;
@@ -135,17 +157,28 @@ public static bool InvokeJSUnmarshalled(string functionIdentifier, IntPtr arg0,
135
157
{
136
158
if ( _trace . IsEnabled )
137
159
{
138
- using ( WritePropertyEventTrace ( TraceProvider . UnmarshalledInvokedStart , TraceProvider . UnmarshalledInvokedEnd , functionIdentifier ) )
139
- {
140
- return InnerInvokeJSUnmarshalled ( functionIdentifier , arg0 , arg1 ) ;
141
- }
160
+ return InvokeJSUnmarshalledWithTrace ( functionIdentifier , arg0 , arg1 ) ;
142
161
}
143
162
else
144
163
{
145
164
return InnerInvokeJSUnmarshalled ( functionIdentifier , arg0 , arg1 ) ;
146
165
}
147
166
}
148
167
168
+ /// <remarks>
169
+ /// This method contains or is called by a try/catch containing method and
170
+ /// can be significantly slower than other methods as a result on WebAssembly.
171
+ /// See https://github.com/dotnet/runtime/issues/56309
172
+ /// </remarks>
173
+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
174
+ private static bool InvokeJSUnmarshalledWithTrace ( string functionIdentifier , IntPtr arg0 , IntPtr arg1 )
175
+ {
176
+ using ( WritePropertyEventTrace ( TraceProvider . UnmarshalledInvokedStart , TraceProvider . UnmarshalledInvokedEnd , functionIdentifier ) )
177
+ {
178
+ return InnerInvokeJSUnmarshalled ( functionIdentifier , arg0 , arg1 ) ;
179
+ }
180
+ }
181
+
149
182
private static bool InnerInvokeJSUnmarshalled ( string functionIdentifier , IntPtr arg0 , IntPtr arg1 )
150
183
{
151
184
var methodId = GetMethodId ( functionIdentifier ) ;
@@ -179,10 +212,7 @@ public static string InvokeJS(string str)
179
212
{
180
213
if ( _trace . IsEnabled )
181
214
{
182
- using ( WritePropertyEventTrace ( TraceProvider . InvokeStart , TraceProvider . InvokeEnd , str ) )
183
- {
184
- return InnerInvokeJS ( str ) ;
185
- }
215
+ return InvokeJSWithTrace ( str ) ;
186
216
}
187
217
else
188
218
{
@@ -203,6 +233,20 @@ public static string InvokeJS(string str)
203
233
}
204
234
}
205
235
236
+ /// <remarks>
237
+ /// This method contains or is called by a try/catch containing method and
238
+ /// can be significantly slower than other methods as a result on WebAssembly.
239
+ /// See https://github.com/dotnet/runtime/issues/56309
240
+ /// </remarks>
241
+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
242
+ private static string InvokeJSWithTrace ( string str )
243
+ {
244
+ using ( WritePropertyEventTrace ( TraceProvider . InvokeStart , TraceProvider . InvokeEnd , str ) )
245
+ {
246
+ return InnerInvokeJS ( str ) ;
247
+ }
248
+ }
249
+
206
250
private static string InnerInvokeJS ( String str )
207
251
{
208
252
if ( _logger . Value . IsEnabled ( LogLevel . Debug ) )
0 commit comments