Skip to content

Commit d36adba

Browse files
rmacnak-googledart-scoped@luci-project-accounts.iam.gserviceaccount.com
authored andcommitted
[vm] Remove the VM isolate.
The former contents of the VM isolate are now included into each isolate group. This makes each isolate group's heap independent, and in particular allows each heap to be allocated to a separate pointer cage (not done in this CL). The duplicated stubs that allowed PC relative calls are removed, since the originals can now be the target of PC relative calls. The bootstrapping needing to load an AppJIT or AppAOT snapshot is reduced to allocating the oddballs. The code is entirely dropped in the AOT runtime, but the JIT runtime still has it to allow for flags to affect the compilation of the stub code. Further refactoring might be able to remove this for the JIT runtime too, with only gen_snapshot knowing how to bootstrap. Class serialization no longer distinguishes predefined classes. The page containing null is marked as never-evacuate. null, false and true must not move because the compiler relies on their low bits having certain patterns for some optimizations. (Previously, the entire VM isolate heap never moved.) Compaction is disabled for IA32. Due to register pressure, some stub calls must not use a scratch register and embed the address of Code. The page containing the call-through-safepoint stub is frozen when running with --write-protect-code and the stub is created at runtime (instead of loaded from an AppJIT or AppAOT snapshot). This stub must remain executable even during a safepoint, as a foreign call might during return during a safepoint and only block after the stub directs it to the runtime. The snapshot symbols are renamed to kDartSnapshotData and kDartSnapshotText. There is no need to distinguish the VM isolate's snapshot, and snaphots are per isolate group not per isolate. Aliases with the old names are added to ease migration. Some global flags that were automatically set based on the VM isolate's snapshot are now isolate group flags and automatically set by the isolate group's snapshot. TEST=ci Change-Id: Iee82016057d609112e9b021d178fc3d4d18b5044 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/500621 Reviewed-by: Alexander Markov <alexmarkov@google.com> Reviewed-by: Tess Strickland <sstrickl@google.com> SLSA-Policy-Verified: SLSA Policy Verification Service <devtools-gerritcodereview-exitgate@google.com> Commit-Queue: Ryan Macnak <rmacnak@google.com>
1 parent ca9c12f commit d36adba

137 files changed

Lines changed: 2444 additions & 4374 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

build/rbe/rewrapper_dart.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -703,11 +703,10 @@ def parse_gen_snapshot(self):
703703
if self.get_option(['-o', '--output']):
704704
self.outputs.append(self.rebase(self.optarg))
705705
elif self.get_option([
706-
'--vm_snapshot_data',
707-
'--vm_snapshot_instructions',
708-
'--isolate_snapshot_data',
709-
'--isolate_snapshot_instructions',
706+
'--snapshot_data',
707+
'--snapshot_text',
710708
'--elf',
709+
'--macho',
711710
'--ffi_callback_stub',
712711
]):
713712
self.outputs.append(self.rebase(self.optarg))

pkg/native_compiler/lib/runtime/vm_defs.dart

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,6 @@ extension ComputedOffsets on VMOffsets {
152152
// Symbol names used in Dart snapshots.
153153

154154
const String snapshotBuildIdAsmSymbol = "_kDartSnapshotBuildId";
155-
const String vmSnapshotDataAsmSymbol = "_kDartVmSnapshotData";
156-
const String vmSnapshotInstructionsAsmSymbol = "_kDartVmSnapshotInstructions";
157-
const String vmSnapshotBssAsmSymbol = "_kDartVmSnapshotBss";
158-
const String isolateSnapshotDataAsmSymbol = "_kDartIsolateSnapshotData";
159-
const String isolateSnapshotInstructionsAsmSymbol =
160-
"_kDartIsolateSnapshotInstructions";
161-
const String isolateSnapshotBssAsmSymbol = "_kDartIsolateSnapshotBss";
155+
const String snapshotDataAsmSymbol = "_kDartSnapshotData";
156+
const String snapshotTextAsmSymbol = "_kDartSnapshotText";
157+
const String snapshotBssAsmSymbol = "_kDartSnapshotBss";

pkg/native_compiler/lib/runtime/vm_offsets.g.dart

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -894,35 +894,35 @@ final class Arm64VMOffsets extends VMOffsets {
894894
@override
895895
int get ObjectStore_int_type_offset => 0x168;
896896
@override
897-
int get ObjectStore_record_field_names_offset => 0x430;
897+
int get ObjectStore_record_field_names_offset => 0x440;
898898
@override
899899
int get ObjectStore_string_type_offset => 0x1e0;
900900
@override
901901
int get ObjectStore_type_type_offset => 0x140;
902902
@override
903-
int get ObjectStore_ffi_callback_code_offset => 0x530;
903+
int get ObjectStore_ffi_callback_code_offset => 0x540;
904904
@override
905-
int get ObjectStore_suspend_state_await_offset => 0x480;
905+
int get ObjectStore_suspend_state_await_offset => 0x490;
906906
@override
907-
int get ObjectStore_suspend_state_await_with_type_check_offset => 0x488;
907+
int get ObjectStore_suspend_state_await_with_type_check_offset => 0x498;
908908
@override
909-
int get ObjectStore_suspend_state_handle_exception_offset => 0x4c8;
909+
int get ObjectStore_suspend_state_handle_exception_offset => 0x4d8;
910910
@override
911-
int get ObjectStore_suspend_state_init_async_offset => 0x478;
911+
int get ObjectStore_suspend_state_init_async_offset => 0x488;
912912
@override
913-
int get ObjectStore_suspend_state_init_async_star_offset => 0x4a0;
913+
int get ObjectStore_suspend_state_init_async_star_offset => 0x4b0;
914914
@override
915-
int get ObjectStore_suspend_state_init_sync_star_offset => 0x4b8;
915+
int get ObjectStore_suspend_state_init_sync_star_offset => 0x4c8;
916916
@override
917-
int get ObjectStore_suspend_state_return_async_offset => 0x490;
917+
int get ObjectStore_suspend_state_return_async_offset => 0x4a0;
918918
@override
919-
int get ObjectStore_suspend_state_return_async_not_future_offset => 0x498;
919+
int get ObjectStore_suspend_state_return_async_not_future_offset => 0x4a8;
920920
@override
921-
int get ObjectStore_suspend_state_return_async_star_offset => 0x4b0;
921+
int get ObjectStore_suspend_state_return_async_star_offset => 0x4c0;
922922
@override
923-
int get ObjectStore_suspend_state_suspend_sync_star_at_start_offset => 0x4c0;
923+
int get ObjectStore_suspend_state_suspend_sync_star_at_start_offset => 0x4d0;
924924
@override
925-
int get ObjectStore_suspend_state_yield_async_star_offset => 0x4a8;
925+
int get ObjectStore_suspend_state_yield_async_star_offset => 0x4b8;
926926
@override
927927
int get OneByteString_data_offset => 0x10;
928928
@override
@@ -1372,7 +1372,7 @@ final class Arm64VMOffsets extends VMOffsets {
13721372
@override
13731373
int get Capability_InstanceSize => 0x10;
13741374
@override
1375-
int get Class_InstanceSize => 0xc8;
1375+
int get Class_InstanceSize => 0xd8;
13761376
@override
13771377
int get ClosureData_InstanceSize => 0x28;
13781378
@override
@@ -1857,35 +1857,35 @@ final class Arm64ProductVMOffsets extends VMOffsets {
18571857
@override
18581858
int get ObjectStore_int_type_offset => 0x168;
18591859
@override
1860-
int get ObjectStore_record_field_names_offset => 0x430;
1860+
int get ObjectStore_record_field_names_offset => 0x440;
18611861
@override
18621862
int get ObjectStore_string_type_offset => 0x1e0;
18631863
@override
18641864
int get ObjectStore_type_type_offset => 0x140;
18651865
@override
1866-
int get ObjectStore_ffi_callback_code_offset => 0x530;
1866+
int get ObjectStore_ffi_callback_code_offset => 0x540;
18671867
@override
1868-
int get ObjectStore_suspend_state_await_offset => 0x480;
1868+
int get ObjectStore_suspend_state_await_offset => 0x490;
18691869
@override
1870-
int get ObjectStore_suspend_state_await_with_type_check_offset => 0x488;
1870+
int get ObjectStore_suspend_state_await_with_type_check_offset => 0x498;
18711871
@override
1872-
int get ObjectStore_suspend_state_handle_exception_offset => 0x4c8;
1872+
int get ObjectStore_suspend_state_handle_exception_offset => 0x4d8;
18731873
@override
1874-
int get ObjectStore_suspend_state_init_async_offset => 0x478;
1874+
int get ObjectStore_suspend_state_init_async_offset => 0x488;
18751875
@override
1876-
int get ObjectStore_suspend_state_init_async_star_offset => 0x4a0;
1876+
int get ObjectStore_suspend_state_init_async_star_offset => 0x4b0;
18771877
@override
1878-
int get ObjectStore_suspend_state_init_sync_star_offset => 0x4b8;
1878+
int get ObjectStore_suspend_state_init_sync_star_offset => 0x4c8;
18791879
@override
1880-
int get ObjectStore_suspend_state_return_async_offset => 0x490;
1880+
int get ObjectStore_suspend_state_return_async_offset => 0x4a0;
18811881
@override
1882-
int get ObjectStore_suspend_state_return_async_not_future_offset => 0x498;
1882+
int get ObjectStore_suspend_state_return_async_not_future_offset => 0x4a8;
18831883
@override
1884-
int get ObjectStore_suspend_state_return_async_star_offset => 0x4b0;
1884+
int get ObjectStore_suspend_state_return_async_star_offset => 0x4c0;
18851885
@override
1886-
int get ObjectStore_suspend_state_suspend_sync_star_at_start_offset => 0x4c0;
1886+
int get ObjectStore_suspend_state_suspend_sync_star_at_start_offset => 0x4d0;
18871887
@override
1888-
int get ObjectStore_suspend_state_yield_async_star_offset => 0x4a8;
1888+
int get ObjectStore_suspend_state_yield_async_star_offset => 0x4b8;
18891889
@override
18901890
int get OneByteString_data_offset => 0x10;
18911891
@override
@@ -2333,7 +2333,7 @@ final class Arm64ProductVMOffsets extends VMOffsets {
23332333
@override
23342334
int get Capability_InstanceSize => 0x10;
23352335
@override
2336-
int get Class_InstanceSize => 0xc0;
2336+
int get Class_InstanceSize => 0xd0;
23372337
@override
23382338
int get ClosureData_InstanceSize => 0x28;
23392339
@override

pkg/native_compiler/lib/snapshot/macho/macho_image_writer.dart

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,14 @@ final class MachoImageWriter extends ImageWriter {
162162

163163
MachoImageWriter(this.targetCPU, this.libraryName) {
164164
header = Header(this);
165-
symbolTable.addSymbol(isolateSnapshotInstructionsAsmSymbol, textSection, 0);
166-
symbolTable.addSymbol(isolateSnapshotDataAsmSymbol, constSection, 0);
165+
symbolTable.addSymbol(snapshotTextAsmSymbol, textSection, 0);
166+
symbolTable.addSymbol(snapshotDataAsmSymbol, constSection, 0);
167+
168+
// TRANSITION
169+
symbolTable.addSymbol("_kDartVmSnapshotInstructions", textSection, 0);
170+
symbolTable.addSymbol("_kDartIsolateSnapshotInstructions", textSection, 0);
171+
symbolTable.addSymbol("_kDartVmSnapshotData", constSection, 0);
172+
symbolTable.addSymbol("_kDartIsolateSnapshotData", constSection, 0);
167173
}
168174

169175
@override

pkg/native_compiler/lib/snapshot/snapshot.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import 'package:native_compiler/runtime/vm_defs.dart';
2626

2727
/// Kinds of Dart snapshots.
2828
/// Should match Snapshot::Kind enum in runtime/vm/snapshot.h.
29-
enum SnapshotKind { full, fullCore, fullJIT, fullAOT, module, none, invalid }
29+
enum SnapshotKind { full, fullJIT, fullAOT, module, invalid }
3030

3131
/// Dart snapshot constants.
3232
class Snapshot {

pkg/native_stack_traces/bin/decode.dart

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -258,10 +258,6 @@ void find(ArgResults options) {
258258
}
259259
vmStart = address;
260260
}
261-
if (vmStart == null) {
262-
return usageError('no VM start address found, one must be specified '
263-
'with --vm_start');
264-
}
265261

266262
var isolateStart = dwarf.isolateStartAddress();
267263
if (options['isolate_start'] != null) {

pkg/native_stack_traces/lib/elf.dart

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,7 @@
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-
export 'src/constants.dart'
6-
show
7-
isolateDataSymbolName,
8-
isolateSymbolName,
9-
vmDataSymbolName,
10-
vmSymbolName;
5+
export 'src/constants.dart' show dataSymbolName, textSymbolName;
116
export 'src/elf.dart'
127
show
138
DynamicTable,

pkg/native_stack_traces/lib/src/constants.dart

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,23 @@ const int buildIdNoteType = 3;
99
// The name of a build ID note.
1010
const String buildIdNoteName = 'GNU';
1111

12+
// The dynamic symbol name for the isolate instructions section.
13+
const String textSymbolName = '_kDartSnapshotText';
14+
15+
// The dynamic symbol name for the isolate data section.
16+
const String dataSymbolName = '_kDartSnapshotData';
17+
18+
// The ID for the root loading unit.
19+
const int rootLoadingUnitId = 1;
20+
1221
// The dynamic symbol name for the VM instructions section.
13-
const String vmSymbolName = '_kDartVmSnapshotInstructions';
22+
const String oldVmSymbolName = '_kDartVmSnapshotInstructions';
1423

1524
// The dynamic symbol name for the VM data section.
16-
const String vmDataSymbolName = '_kDartVmSnapshotData';
25+
const String oldVmDataSymbolName = '_kDartVmSnapshotData';
1726

1827
// The dynamic symbol name for the isolate instructions section.
19-
const String isolateSymbolName = '_kDartIsolateSnapshotInstructions';
28+
const String oldIsolateSymbolName = '_kDartIsolateSnapshotInstructions';
2029

2130
// The dynamic symbol name for the isolate data section.
22-
const String isolateDataSymbolName = '_kDartIsolateSnapshotData';
23-
24-
// The ID for the root loading unit.
25-
const int rootLoadingUnitId = 1;
31+
const String oldIsolateDataSymbolName = '_kDartIsolateSnapshotData';

pkg/native_stack_traces/lib/src/convert.dart

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ class StackTraceHeader {
119119
int? get isolateStart => _isolateStart;
120120
int? get isolateDsoBase => _isolateDsoBase;
121121

122-
static StackTraceHeader fromStarts(int isolateStart, int vmStart,
122+
static StackTraceHeader fromStarts(int isolateStart, int? vmStart,
123123
{String? architecture}) =>
124124
StackTraceHeader()
125125
.._isolateStart = isolateStart
@@ -375,9 +375,11 @@ class StackTraceHeader {
375375
}
376376
if (offset == null) return null;
377377
switch (symbolString) {
378-
case constants.vmSymbolName:
378+
case constants.oldVmSymbolName:
379379
return (InstructionsSection.vm, offset);
380-
case constants.isolateSymbolName:
380+
case constants.oldIsolateSymbolName:
381+
return (InstructionsSection.isolate, offset);
382+
case constants.dataSymbolName:
381383
return (InstructionsSection.isolate, offset);
382384
default:
383385
break;
@@ -420,9 +422,11 @@ PCOffset? tryParseSymbolOffset(String s,
420422
/// - The path to the snapshot, if it was loaded as a dynamic library,
421423
/// otherwise the string `"<unknown>"`.
422424
const _symbolOffsetREString = r'(?<symbol>' +
423-
constants.vmSymbolName +
425+
constants.textSymbolName +
426+
r'|' +
427+
constants.oldVmSymbolName +
424428
r'|' +
425-
constants.isolateSymbolName +
429+
constants.oldIsolateSymbolName +
426430
r')\+(?<offset>(?:0x)?[\da-f]+)';
427431
final _symbolOffsetRE = RegExp(_symbolOffsetREString);
428432
final _traceLineRE = RegExp(r'\s*#(\d+) abs (?<absolute>[\da-f]+)'

pkg/native_stack_traces/lib/src/elf.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1283,11 +1283,12 @@ class Elf extends DwarfContainer {
12831283
}
12841284

12851285
@override
1286-
int? get vmStartAddress => dynamicSymbolFor(constants.vmSymbolName)?.value;
1286+
int? get vmStartAddress => dynamicSymbolFor(constants.oldVmSymbolName)?.value;
12871287

12881288
@override
12891289
int? get isolateStartAddress =>
1290-
dynamicSymbolFor(constants.isolateSymbolName)?.value;
1290+
dynamicSymbolFor(constants.textSymbolName)?.value ??
1291+
dynamicSymbolFor(constants.oldIsolateSymbolName)?.value;
12911292

12921293
@override
12931294
String? get buildId {

0 commit comments

Comments
 (0)