Skip to content

Commit 1069ee6

Browse files
committed
Match the -X NoAdaptiveCompilation regex once per module
1 parent 413a756 commit 1069ee6

4 files changed

Lines changed: 9 additions & 9 deletions

File tree

‎src/core/IronPython/Compiler/Ast/ScopeStatement.cs‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,8 @@ internal bool ShouldInterpret {
169169
// code from compile, exec and eval is compiled adaptively, unless -X NoAdaptiveCompilation applies to it
170170
return !GlobalParent.IsAdaptiveCompilationDisabled;
171171
}
172-
CompilerContext context = GlobalParent.CompilerContext;
173172

174-
return ((PythonContext)context.SourceUnit.LanguageContext).ShouldInterpret((PythonCompilerOptions)context.Options, context.SourceUnit);
173+
return PyContext.ShouldInterpret(GlobalParent);
175174
}
176175
}
177176

‎src/core/IronPython/Compiler/PythonScriptCode.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ private LookupCompilationDelegate CompileBody(LightExpression<LookupCompilationD
123123
}
124124

125125
private bool ShouldInterpret(PythonContext pc) {
126-
return pc.ShouldInterpret((PythonCompilerOptions)Ast.CompilerContext.Options, Ast.CompilerContext.SourceUnit);
126+
return pc.ShouldInterpret(Ast);
127127
}
128128

129129
private static PythonConstantExpression ExtractConstant(LightExpression<LookupCompilationDelegate> lambda) {

‎src/core/IronPython/Compiler/RuntimeScriptCode.cs‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,9 @@ private void EnsureCompiled() {
105105
}
106106

107107
private Func<FunctionCode, object>/*!*/ Compile() {
108-
var pco = (PythonCompilerOptions)Ast.CompilerContext.Options;
109108
var pc = (PythonContext)SourceUnit.LanguageContext;
110-
111-
if (pc.ShouldInterpret(pco, SourceUnit)) {
109+
110+
if (pc.ShouldInterpret(Ast)) {
112111
return ((Microsoft.Scripting.Ast.LightExpression<Func<FunctionCode, object>>)Ast.GetLambda()).Compile(pc.Options.CompilationThreshold);
113112
} else {
114113
return ((Microsoft.Scripting.Ast.LightExpression<Func<FunctionCode, object>>)Ast.GetLambda()).ReduceToLambda().Compile(pc.EmitDebugSymbols(SourceUnit));

‎src/core/IronPython/Runtime/PythonContext.cs‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -774,14 +774,16 @@ private void InitializeSysFlags() {
774774
flags.utf8_mode = PythonOptions.Utf8Mode ? 1 : 0;
775775
}
776776

777-
internal bool ShouldInterpret(PythonCompilerOptions options, SourceUnit source) {
778-
if (IsAdaptiveCompilationDisabled(source)) {
777+
internal bool ShouldInterpret(PyAst.PythonAst ast) {
778+
if (ast.IsAdaptiveCompilationDisabled) {
779779
return false;
780780
}
781781

782+
CompilerContext context = ast.CompilerContext;
783+
782784
// We have to turn off adaptive compilation in debug mode to
783785
// support mangaged debuggers.
784-
return options.Interpreted || !EmitDebugSymbols(source);
786+
return ((PythonCompilerOptions)context.Options).Interpreted || !EmitDebugSymbols(context.SourceUnit);
785787
}
786788

787789
/// <summary>

0 commit comments

Comments
 (0)