mirror of
https://github.com/dart-lang/sdk
synced 2024-09-04 16:03:44 +00:00
[vm/bytecode] Switch kernel service dill to bytecode if building Dart SDK with --bytecode
Temporary setting of FLAG_enable_interpreter is avoided in the VM unit tests as this flag is global and used by kernel service isolate while running tests. Flipping this flag causes assertion failures in kernel isolate's background compiler or infinite loop between LazyCompile stub and CompileFunction as AttachBytecode doesn't set entry point to InterpretCall. The less intrusive way to ensure compilation of functions in unit tests is to set FLAG_compilation_counter_threshold to 0. Change-Id: Ia46ff8d03d66ab8b147b9d89336548c4a9c29f5d Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/113123 Commit-Queue: Alexander Markov <alexmarkov@google.com> Reviewed-by: Régis Crelier <regis@google.com>
This commit is contained in:
parent
7c3ea0af6a
commit
beee442625
|
@ -46,8 +46,10 @@ RawFunction* GetFunction(const Library& lib, const char* name) {
|
|||
|
||||
void Invoke(const Library& lib, const char* name) {
|
||||
// These tests rely on running unoptimized code to collect type feedback. The
|
||||
// interpreter does not collect type feedback for interface calls.
|
||||
SetFlagScope<bool> sfs(&FLAG_enable_interpreter, false);
|
||||
// interpreter does not collect type feedback for interface calls, so set
|
||||
// compilation threshold to 0 in order to compile invoked function
|
||||
// immediately and executed compiled code.
|
||||
SetFlagScope<int> sfs(&FLAG_compilation_counter_threshold, 0);
|
||||
|
||||
Thread* thread = Thread::Current();
|
||||
Dart_Handle api_lib = Api::NewHandle(thread, lib.raw());
|
||||
|
|
|
@ -231,14 +231,14 @@ DEFINE_RUNTIME_ENTRY(CompileFunction, 1) {
|
|||
Exceptions::PropagateError(Error::Cast(result));
|
||||
}
|
||||
}
|
||||
if (function.HasBytecode()) {
|
||||
if (function.HasBytecode() && (FLAG_compilation_counter_threshold != 0)) {
|
||||
// If interpreter is enabled and there is bytecode, LazyCompile stub
|
||||
// (which calls CompileFunction) should proceed to InterpretCall in order
|
||||
// to enter interpreter. In such case, compilation is postponed and
|
||||
// triggered by interpreter later via CompileInterpretedFunction.
|
||||
return;
|
||||
}
|
||||
// No bytecode, fall back to compilation.
|
||||
// Fall back to compilation.
|
||||
} else {
|
||||
ASSERT(!function.HasCode());
|
||||
}
|
||||
|
|
|
@ -152,7 +152,7 @@ RawObject* DartEntry::InvokeFunction(const Function& function,
|
|||
}
|
||||
|
||||
// If we have bytecode but no native code then invoke the interpreter.
|
||||
if (function.HasBytecode()) {
|
||||
if (function.HasBytecode() && (FLAG_compilation_counter_threshold != 0)) {
|
||||
ASSERT(thread->no_callback_scope_depth() == 0);
|
||||
SuspendLongJumpScope suspend_long_jump_scope(thread);
|
||||
TransitionToGenerated transition(thread);
|
||||
|
@ -160,7 +160,7 @@ RawObject* DartEntry::InvokeFunction(const Function& function,
|
|||
arguments, thread);
|
||||
}
|
||||
|
||||
// No bytecode, fall back to compilation.
|
||||
// Fall back to compilation.
|
||||
}
|
||||
|
||||
const Object& result =
|
||||
|
|
|
@ -1528,7 +1528,7 @@ ISOLATE_UNIT_TEST_CASE(Profiler_FunctionInline) {
|
|||
DisableNativeProfileScope dnps;
|
||||
DisableBackgroundCompilationScope dbcs;
|
||||
SetFlagScope<int> sfs(&FLAG_optimization_counter_threshold, 30000);
|
||||
SetFlagScope<bool> sfs2(&FLAG_enable_interpreter, false);
|
||||
SetFlagScope<int> sfs2(&FLAG_compilation_counter_threshold, 0);
|
||||
|
||||
const char* kScript =
|
||||
"class A {\n"
|
||||
|
@ -1814,7 +1814,7 @@ ISOLATE_UNIT_TEST_CASE(Profiler_InliningIntervalBoundry) {
|
|||
DisableNativeProfileScope dnps;
|
||||
DisableBackgroundCompilationScope dbcs;
|
||||
SetFlagScope<int> sfs(&FLAG_optimization_counter_threshold, 30000);
|
||||
SetFlagScope<bool> sfs2(&FLAG_enable_interpreter, false);
|
||||
SetFlagScope<int> sfs2(&FLAG_compilation_counter_threshold, 0);
|
||||
|
||||
const char* kScript =
|
||||
"class A {\n"
|
||||
|
@ -2162,8 +2162,8 @@ ISOLATE_UNIT_TEST_CASE(Profiler_BasicSourcePositionOptimized) {
|
|||
DisableNativeProfileScope dnps;
|
||||
DisableBackgroundCompilationScope dbcs;
|
||||
// Optimize quickly.
|
||||
SetFlagScope<int> sfs2(&FLAG_optimization_counter_threshold, 5);
|
||||
SetFlagScope<bool> sfs3(&FLAG_enable_interpreter, false);
|
||||
SetFlagScope<int> sfs(&FLAG_optimization_counter_threshold, 5);
|
||||
SetFlagScope<int> sfs2(&FLAG_compilation_counter_threshold, 0);
|
||||
const char* kScript =
|
||||
"class A {\n"
|
||||
" var a;\n"
|
||||
|
@ -2348,8 +2348,8 @@ ISOLATE_UNIT_TEST_CASE(Profiler_SourcePositionOptimized) {
|
|||
DisableNativeProfileScope dnps;
|
||||
DisableBackgroundCompilationScope dbcs;
|
||||
// Optimize quickly.
|
||||
SetFlagScope<int> sfs2(&FLAG_optimization_counter_threshold, 5);
|
||||
SetFlagScope<bool> sfs3(&FLAG_enable_interpreter, false);
|
||||
SetFlagScope<int> sfs(&FLAG_optimization_counter_threshold, 5);
|
||||
SetFlagScope<int> sfs2(&FLAG_compilation_counter_threshold, 0);
|
||||
|
||||
const char* kScript =
|
||||
"class A {\n"
|
||||
|
@ -2574,8 +2574,8 @@ ISOLATE_UNIT_TEST_CASE(Profiler_BinaryOperatorSourcePositionOptimized) {
|
|||
DisableNativeProfileScope dnps;
|
||||
DisableBackgroundCompilationScope dbcs;
|
||||
// Optimize quickly.
|
||||
SetFlagScope<int> sfs2(&FLAG_optimization_counter_threshold, 5);
|
||||
SetFlagScope<bool> sfs3(&FLAG_enable_interpreter, false);
|
||||
SetFlagScope<int> sfs(&FLAG_optimization_counter_threshold, 5);
|
||||
SetFlagScope<int> sfs2(&FLAG_compilation_counter_threshold, 0);
|
||||
|
||||
const char* kScript =
|
||||
"class A {\n"
|
||||
|
@ -2654,11 +2654,9 @@ ISOLATE_UNIT_TEST_CASE(Profiler_BinaryOperatorSourcePositionOptimized) {
|
|||
EXPECT(walker.Down());
|
||||
EXPECT_STREQ("DRT_AllocateObject", walker.CurrentName());
|
||||
EXPECT(walker.Down());
|
||||
if (!FLAG_enable_interpreter) {
|
||||
EXPECT_STREQ("[Stub] Allocate A", walker.CurrentName());
|
||||
EXPECT_EQ(1, walker.CurrentExclusiveTicks());
|
||||
EXPECT(walker.Down());
|
||||
}
|
||||
EXPECT_STREQ("[Stub] Allocate A", walker.CurrentName());
|
||||
EXPECT_EQ(1, walker.CurrentExclusiveTicks());
|
||||
EXPECT(walker.Down());
|
||||
EXPECT_STREQ("B.boo", walker.CurrentName());
|
||||
EXPECT_EQ(1, walker.CurrentNodeTickCount());
|
||||
EXPECT_EQ(1, walker.CurrentInclusiveTicks());
|
||||
|
|
|
@ -101,6 +101,13 @@ template("kernel_service_dill") {
|
|||
"--output=" + rebase_path(output),
|
||||
rebase_path(kernel_service_script),
|
||||
]
|
||||
|
||||
if (dart_platform_bytecode) {
|
||||
args += [
|
||||
"--gen-bytecode",
|
||||
"--drop-ast",
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue