Skip to content

Commit 982b9fa

Browse files
sstricklCommit Queue
authored andcommitted
[vm] Turn on entry point checking in JIT mode.
Now that Flutter tests that access entry points from native code have been annotated[1], we can turn on entry point checking in JIT mode. This CL also removes the A flag category from flag_list.h and the AOT_FLAG_MACRO definitions and uses from flags.[cc,h], as they were created as a temporary measure until this flag could be unconditionally defaulted to true. [1] See the following PRs: * flutter/engine#57158 * flutter/flutter#160158 * flutter/flutter#160421 TEST=vm/dart/entrypoints_verification_test vm/cc/IRTest vm/cc/StreamingFlowGraphBuilder vm/cc/STC vm/cc/TTS Issue: #50649 Issue: flutter/flutter#118608 Cq-Include-Trybots: luci.dart.try:vm-aot-linux-product-x64-try,vm-aot-linux-debug-x64-try,vm-aot-mac-release-arm64-try,vm-aot-mac-product-arm64-try,vm-aot-dwarf-linux-product-x64-try,vm-linux-debug-x64-try,vm-linux-release-x64-try,vm-appjit-linux-product-x64-try Change-Id: Ibe5b21bb74f1a6fb88824b71ff87b9e555216dbf Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/400301 Reviewed-by: Martin Kustermann <[email protected]> Commit-Queue: Tess Strickland <[email protected]>
1 parent 04530d5 commit 982b9fa

File tree

11 files changed

+97
-36
lines changed

11 files changed

+97
-36
lines changed

runtime/tests/vm/dart/entrypoints_verification_test.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44
//
5-
// VMOptions=--verify-entry-points=true
65
// SharedObjects=entrypoints_verification_test
76

87
import 'dart:ffi';

runtime/vm/compiler/backend/il_test.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ ISOLATE_UNIT_TEST_CASE(IRTest_EliminateWriteBarrier) {
6262
6363
Container<int> x = Container<int>();
6464
65+
@pragma("vm:entry-point", "call")
6566
foo() {
6667
for (int i = 0; i < 10; ++i) {
6768
x[i] = i;
@@ -689,6 +690,7 @@ ISOLATE_UNIT_TEST_CASE(IRTest_LoadThread) {
689690
auto kScript = R"(
690691
import 'dart:ffi';
691692
693+
@pragma("vm:entry-point", "call")
692694
int myFunction() {
693695
return 100;
694696
}
@@ -780,6 +782,7 @@ ISOLATE_UNIT_TEST_CASE(IRTest_CachableIdempotentCall) {
780782
return increment();
781783
}
782784
785+
@pragma("vm:entry-point", "call")
783786
int multipleIncrement() {
784787
int returnValue = 0;
785788
for(int i = 0; i < 10; i++) {
@@ -943,6 +946,7 @@ ISOLATE_UNIT_TEST_CASE(IRTest_FfiCallInstrLeafDoesntSpill) {
943946
void placeholder() {}
944947
945948
// Will call the "doFfiCall" and exercise its code.
949+
@pragma("vm:entry-point", "call")
946950
bool invokeDoFfiCall() {
947951
final double result = doFfiCall(1, 2, 3, 1.0, 2.0, 3.0);
948952
if (result != (2 + 3 + 4 + 2.0 + 3.0 + 4.0)) {
@@ -971,6 +975,7 @@ ISOLATE_UNIT_TEST_CASE(IRTest_FfiCallInstrLeafDoesntSpill) {
971975
typedef NT = Void Function();
972976
typedef DT = void Function();
973977
Pointer<NativeFunction<NT>> ptr = Pointer.fromAddress(0);
978+
@pragma("vm:entry-point", "call")
974979
DT getFfiTrampolineClosure() => ptr.asFunction(isLeaf:true);
975980
)";
976981

runtime/vm/compiler/backend/memory_copy_test.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,12 +157,14 @@ static void RunMemoryCopyInstrTest(intptr_t src_start,
157157
CStringUniquePtr kScript(OS::SCreate(nullptr, R"(
158158
import 'dart:ffi';
159159
160+
@pragma("vm:entry-point", "call")
160161
void copyConst() {
161162
final pointer = Pointer<Uint8>.fromAddress(%s%p);
162163
final pointer2 = Pointer<Uint8>.fromAddress(%s%p);
163164
noop();
164165
}
165166
167+
@pragma("vm:entry-point", "call")
166168
void callNonConstCopy() {
167169
final pointer = Pointer<Uint8>.fromAddress(%s%p);
168170
final pointer2 = Pointer<Uint8>.fromAddress(%s%p);

runtime/vm/compiler/backend/redundancy_elimination_test.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1480,6 +1480,7 @@ ISOLATE_UNIT_TEST_CASE(DelayAllocations_DelayAcrossCalls) {
14801480
@pragma("vm:never-inline")
14811481
dynamic use(v) {}
14821482
1483+
@pragma("vm:entry-point", "call")
14831484
void test() {
14841485
A a = new A(foo(1), foo(2));
14851486
use(a);
@@ -1738,10 +1739,12 @@ ISOLATE_UNIT_TEST_CASE(AllocationSinking_NoViewDataMaterialization) {
17381739
return x is int;
17391740
}
17401741
1742+
@pragma("vm:entry-point", "call")
17411743
bool %s() {
17421744
return %s(0xABCC);
17431745
}
17441746
1747+
@pragma("vm:entry-point", "call")
17451748
bool %s() {
17461749
return %s(1.0);
17471750
}

runtime/vm/compiler/backend/yield_position_test.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ void RunTestInMode(CompilerPass::PipelineMode mode) {
5252
R"(
5353
import 'dart:async';
5454
55+
@pragma("vm:entry-point", "call")
5556
Future foo() async {
5657
print('pos-0');
5758
await 0;
@@ -81,9 +82,9 @@ void RunTestInMode(CompilerPass::PipelineMode mode) {
8182
auto validate_indices = [](const YieldPoints& yield_points) {
8283
EXPECT_EQ(3, yield_points.length());
8384

84-
EXPECT_EQ(88, yield_points[0].Pos());
85-
EXPECT_EQ(129, yield_points[1].Pos());
86-
EXPECT_EQ(170, yield_points[2].Pos());
85+
EXPECT_EQ(128, yield_points[0].Pos());
86+
EXPECT_EQ(169, yield_points[1].Pos());
87+
EXPECT_EQ(210, yield_points[2].Pos());
8788
};
8889

8990
validate_indices(*GetYieldPointsFromGraph(flow_graph));

runtime/vm/compiler/frontend/kernel_binary_flowgraph_test.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ ISOLATE_UNIT_TEST_CASE(StreamingFlowGraphBuilder_ConstFoldStringConcats) {
1515
// "Adjacent strings are implicitly concatenated to form a single string
1616
// literal."
1717
const char* kScript = R"(
18+
@pragma("vm:entry-point", "call")
1819
test() {
1920
var s = 'aaaa'
2021
'bbbb'
@@ -252,6 +253,7 @@ ISOLATE_UNIT_TEST_CASE(StreamingFlowGraphBuilder_ConcatStringLits) {
252253

253254
ISOLATE_UNIT_TEST_CASE(StreamingFlowGraphBuilder_InvariantFlagInListLiterals) {
254255
const char* kScript = R"(
256+
@pragma("vm:entry-point", "call")
255257
test() {
256258
return [...[], 42];
257259
}
@@ -314,6 +316,7 @@ ISOLATE_UNIT_TEST_CASE(StreamingFlowGraphBuilder_TypedClosureCall) {
314316
//
315317
const char* kScript = R"(
316318
int callClosure(int Function(int) fun, int value) => fun(value);
319+
@pragma("vm:entry-point", "call")
317320
test() => callClosure((int a) => a + 1, 10);
318321
)";
319322

@@ -354,6 +357,7 @@ ISOLATE_UNIT_TEST_CASE(
354357
StreamingFlowGraphBuilder_StaticGetFinalFieldWithTrivialInitializer) {
355358
const char* kScript = R"(
356359
final int x = 0xFEEDFEED;
360+
@pragma("vm:entry-point", "call")
357361
test() {
358362
return x;
359363
}

runtime/vm/flag_list.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,18 +69,15 @@ constexpr bool FLAG_support_il_printer = false;
6969
// * R elease flags: Generally available flags except when building product.
7070
// * pre C ompile flags: Generally available flags except when building product
7171
// or precompiled runtime.
72-
// * A ot flags: Generally available flags except when building precompiled
73-
// runtime. (Unlike C, these flags are available in product mode.)
7472
// * D ebug flags: Can only be set in debug VMs, which also have C++ assertions
7573
// enabled.
7674
//
7775
// Usage:
7876
// P(name, type, default_value, comment)
7977
// R(name, product_value, type, default_value, comment)
8078
// C(name, precompiled_value, product_value, type, default_value, comment)
81-
// A(name, precompiled_value, type, default_value, comment)
8279
// D(name, type, default_value, comment)
83-
#define FLAG_LIST(P, R, C, A, D) \
80+
#define FLAG_LIST(P, R, C, D) \
8481
VM_GLOBAL_FLAG_LIST(P, R, C, D) \
8582
DISASSEMBLE_FLAGS(P, R, C, D) \
8683
P(abort_on_oom, bool, false, \
@@ -249,7 +246,7 @@ constexpr bool FLAG_support_il_printer = false;
249246
R(eliminate_type_checks, true, bool, true, \
250247
"Eliminate type checks when allowed by static type analysis.") \
251248
D(support_rr, bool, false, "Support running within RR.") \
252-
A(verify_entry_points, true, bool, false, \
249+
P(verify_entry_points, bool, true, \
253250
"Throw API error on invalid member access through native API. See " \
254251
"entry_point_pragma.md") \
255252
C(branch_coverage, false, false, bool, false, "Enable branch coverage") \

runtime/vm/flags.cc

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,13 @@ DEFINE_FLAG(bool,
3535
// Nothing to be done for the precompilation flag definitions.
3636
#define PRECOMPILE_FLAG_MACRO(name, pre_value, product_value, type, \
3737
default_value, comment)
38-
// Nothing to be done for the AOT flag definitions.
39-
#define AOT_FLAG_MACRO(name, pre_value, type, default_value, comment)
4038

4139
#elif defined(PRODUCT) // !PRECOMPILED
4240
// Nothing to be done for the product flag definitions.
4341
#define RELEASE_FLAG_MACRO(name, product_value, type, default_value, comment)
4442
// Nothing to be done for the precompilation flag definitions.
4543
#define PRECOMPILE_FLAG_MACRO(name, pre_value, product_value, type, \
4644
default_value, comment)
47-
#define AOT_FLAG_MACRO(name, pre_value, type, default_value, comment) \
48-
type FLAG_##name = \
49-
Flags::Register_##type(&FLAG_##name, #name, default_value, comment);
5045

5146
#elif defined(DART_PRECOMPILED_RUNTIME) // !PRODUCT
5247
#define RELEASE_FLAG_MACRO(name, product_value, type, default_value, comment) \
@@ -55,8 +50,6 @@ DEFINE_FLAG(bool,
5550
// Nothing to be done for the precompilation flag definitions.
5651
#define PRECOMPILE_FLAG_MACRO(name, pre_value, product_value, type, \
5752
default_value, comment)
58-
// Nothing to be done for the AOT flag definitions.
59-
#define AOT_FLAG_MACRO(name, pre_value, type, default_value, comment)
6053

6154
#else // !PRODUCT && !PRECOMPILED
6255
#define RELEASE_FLAG_MACRO(name, product_value, type, default_value, comment) \
@@ -66,22 +59,17 @@ DEFINE_FLAG(bool,
6659
default_value, comment) \
6760
type FLAG_##name = \
6861
Flags::Register_##type(&FLAG_##name, #name, default_value, comment);
69-
#define AOT_FLAG_MACRO(name, pre_value, type, default_value, comment) \
70-
type FLAG_##name = \
71-
Flags::Register_##type(&FLAG_##name, #name, default_value, comment);
7262
#endif
7363

7464
// Define all of the non-product flags here.
7565
FLAG_LIST(PRODUCT_FLAG_MACRO,
7666
RELEASE_FLAG_MACRO,
7767
PRECOMPILE_FLAG_MACRO,
78-
AOT_FLAG_MACRO,
7968
DEBUG_FLAG_MACRO)
8069

8170
#undef PRODUCT_FLAG_MACRO
8271
#undef RELEASE_FLAG_MACRO
8372
#undef PRECOMPILE_FLAG_MACRO
84-
#undef AOT_FLAG_MACRO
8573
#undef DEBUG_FLAG_MACRO
8674

8775
#if defined(DART_PRECOMPILER)

runtime/vm/flags.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -124,49 +124,39 @@ class Flags {
124124
#define PRECOMPILE_FLAG_MACRO(name, precompiled_value, product_value, type, \
125125
default_value, comment) \
126126
const type FLAG_##name = precompiled_value;
127-
#define AOT_FLAG_MACRO(name, precompiled_value, type, default_value, comment) \
128-
const type FLAG_##name = precompiled_value;
129127

130128
#elif defined(PRODUCT) // !PRECOMPILED
131129
#define RELEASE_FLAG_MACRO(name, product_value, type, default_value, comment) \
132130
const type FLAG_##name = product_value;
133131
#define PRECOMPILE_FLAG_MACRO(name, precompiled_value, product_value, type, \
134132
default_value, comment) \
135133
const type FLAG_##name = product_value;
136-
#define AOT_FLAG_MACRO(name, precompiled_value, type, default_value, comment) \
137-
extern type FLAG_##name;
138134

139135
#elif defined(DART_PRECOMPILED_RUNTIME) // !PRODUCT
140136
#define RELEASE_FLAG_MACRO(name, product_value, type, default_value, comment) \
141137
extern type FLAG_##name;
142138
#define PRECOMPILE_FLAG_MACRO(name, precompiled_value, product_value, type, \
143139
default_value, comment) \
144140
const type FLAG_##name = precompiled_value;
145-
#define AOT_FLAG_MACRO(name, precompiled_value, type, default_value, comment) \
146-
const type FLAG_##name = precompiled_value;
147141

148142
#else // !PRODUCT && !PRECOMPILED
149143
#define RELEASE_FLAG_MACRO(name, product_value, type, default_value, comment) \
150144
extern type FLAG_##name;
151145
#define PRECOMPILE_FLAG_MACRO(name, precompiled_value, product_value, type, \
152146
default_value, comment) \
153147
extern type FLAG_##name;
154-
#define AOT_FLAG_MACRO(name, precompiled_value, type, default_value, comment) \
155-
extern type FLAG_##name;
156148

157149
#endif
158150

159151
// Now declare all flags here.
160152
FLAG_LIST(PRODUCT_FLAG_MACRO,
161153
RELEASE_FLAG_MACRO,
162154
PRECOMPILE_FLAG_MACRO,
163-
AOT_FLAG_MACRO,
164155
DEBUG_FLAG_MACRO)
165156

166157
#undef RELEASE_FLAG_MACRO
167158
#undef DEBUG_FLAG_MACRO
168159
#undef PRODUCT_FLAG_MACRO
169-
#undef AOT_FLAG_MACRO
170160
#undef PRECOMPILE_FLAG_MACRO
171161

172162
#if defined(DART_PRECOMPILER)

runtime/vm/object_test.cc

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8436,15 +8436,23 @@ static void SubtypeTestCacheTest(Thread* thread,
84368436
intptr_t num_classes,
84378437
bool expect_hash) {
84388438
TextBuffer buffer(MB);
8439-
buffer.AddString("class D {}\n");
8440-
buffer.AddString("D createInstanceD() => D();");
8441-
buffer.AddString("D Function() createClosureD() => () => D();\n");
8439+
buffer.AddString(R"(
8440+
class D {}
8441+
8442+
@pragma('vm:entry-point', 'call')
8443+
D createInstanceD() => D();
8444+
8445+
@pragma('vm:entry-point', 'call')
8446+
D Function() createClosureD() => () => D();
8447+
)");
84428448
for (intptr_t i = 0; i < num_classes; i++) {
84438449
buffer.Printf(R"(class C%)" Pd R"( extends D {}
84448450
)"
8451+
"@pragma('vm:entry-point', 'call')\n"
84458452
R"(C%)" Pd R"( createInstanceC%)" Pd R"(() => C%)" Pd
84468453
R"(();
84478454
)"
8455+
"@pragma('vm:entry-point', 'call')\n"
84488456
R"(C%)" Pd R"( Function() createClosureC%)" Pd
84498457
R"(() => () => C%)" Pd
84508458
R"(();

0 commit comments

Comments
 (0)