Skip to content

Commit 0bed1ac

Browse files
rmacnak-googleCommit Queue
authored andcommitted
[test] Disable the background compiler during vm/cc/DartAPI_OptimizedExternalByteDataAccess.
This avoid racy access to the optimization counter threshold. TEST=tsan Change-Id: I5bba52e88957022007060893159e26ebe47e40a8 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/419421 Commit-Queue: Ryan Macnak <[email protected]> Reviewed-by: Alexander Aprelev <[email protected]>
1 parent 4ab313c commit 0bed1ac

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

runtime/vm/dart_api_impl_test.cc

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2622,8 +2622,6 @@ TEST_CASE(DartAPI_ExternalByteDataFinalizer) {
26222622
EXPECT(byte_data_finalizer_run);
26232623
}
26242624

2625-
#ifndef PRODUCT
2626-
26272625
static constexpr intptr_t kOptExtLength = 16;
26282626
static int8_t opt_data[kOptExtLength] = {
26292627
0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
@@ -2651,6 +2649,8 @@ static Dart_NativeFunction OptExternalByteDataNativeResolver(
26512649
}
26522650

26532651
TEST_CASE(DartAPI_OptimizedExternalByteDataAccess) {
2652+
NoBackgroundCompilerScope no_background_compiler(thread);
2653+
26542654
const char* kScriptChars = R"(
26552655
import 'dart:typed_data';
26562656
class Expect {
@@ -2686,15 +2686,13 @@ ByteData main() {
26862686
EXPECT_VALID(result);
26872687

26882688
// Invoke 'main' function.
2689-
int old_oct = FLAG_optimization_counter_threshold;
2690-
FLAG_optimization_counter_threshold = 5;
2691-
result = Dart_Invoke(lib, NewString("main"), 0, nullptr);
2689+
{
2690+
SetFlagScope<int> sfs(&FLAG_optimization_counter_threshold, 5);
2691+
result = Dart_Invoke(lib, NewString("main"), 0, nullptr);
2692+
}
26922693
EXPECT_VALID(result);
2693-
FLAG_optimization_counter_threshold = old_oct;
26942694
}
26952695

2696-
#endif // !PRODUCT
2697-
26982696
static void TestTypedDataDirectAccess() {
26992697
Dart_Handle str = Dart_NewStringFromCString("junk");
27002698
Dart_Handle byte_array = Dart_NewTypedData(Dart_TypedData_kUint8, 10);

0 commit comments

Comments
 (0)