Skip to content

Commit c1b0e65

Browse files
authored
Only use the ILEmitTrieJumpTable if dynamic code is compiled (#27865)
* Only use the ILEmitTrieJumpTable if dynamic code is interpreted - This will avoid trying to emit runtime code on platforms that will end up interpreting the IL or ones that don't support dynamic codegen in the first place * Fixed comment
1 parent bdaebb1 commit c1b0e65

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/Http/Routing/src/Matching/JumpTableBuilder.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
// Copyright (c) .NET Foundation. All rights reserved.
1+
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

44
using System;
5+
using System.Runtime.CompilerServices;
56

67
namespace Microsoft.AspNetCore.Routing.Matching
78
{
@@ -84,7 +85,13 @@ public static JumpTable Build(int defaultDestination, int exitDestination, (stri
8485
fallback = new DictionaryJumpTable(defaultDestination, exitDestination, pathEntries);
8586
}
8687

87-
return new ILEmitTrieJumpTable(defaultDestination, exitDestination, pathEntries, vectorize: null, fallback);
88+
// Use the ILEmitTrieJumpTable if the IL is going to be compiled (not interpreted)
89+
if (RuntimeFeature.IsDynamicCodeCompiled)
90+
{
91+
return new ILEmitTrieJumpTable(defaultDestination, exitDestination, pathEntries, vectorize: null, fallback);
92+
}
93+
94+
return fallback;
8895
}
8996
}
9097
}

0 commit comments

Comments
 (0)