Skip to content

Commit 16af4b7

Browse files
sjindel-googlecommit-bot@chromium.org
authored andcommitted
[vm] Set all entrypoints when reading JIT snapshots.
Fixes #39397 Change-Id: I328f6707e9f316decb5207cc11872886431fe5f7 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/125410 Commit-Queue: Samir Jindel <[email protected]> Reviewed-by: Martin Kustermann <[email protected]>
1 parent 369fdb7 commit 16af4b7

3 files changed

Lines changed: 32 additions & 30 deletions

File tree

runtime/vm/clustered_snapshot.cc

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1514,25 +1514,15 @@ class CodeDeserializationCluster : public DeserializationCluster {
15141514

15151515
RawInstructions* instr = d->ReadInstructions();
15161516

1517-
code->ptr()->entry_point_ = Instructions::EntryPoint(instr);
1518-
code->ptr()->monomorphic_entry_point_ =
1519-
Instructions::MonomorphicEntryPoint(instr);
1520-
code->ptr()->unchecked_entry_point_ =
1521-
Instructions::UncheckedEntryPoint(instr);
1522-
code->ptr()->monomorphic_unchecked_entry_point_ =
1523-
Instructions::MonomorphicUncheckedEntryPoint(instr);
1517+
Code::InitializeCachedEntryPointsFrom(code, instr);
15241518
NOT_IN_PRECOMPILED(code->ptr()->active_instructions_ = instr);
15251519
code->ptr()->instructions_ = instr;
15261520

15271521
#if !defined(DART_PRECOMPILED_RUNTIME)
15281522
if (d->kind() == Snapshot::kFullJIT) {
15291523
RawInstructions* instr = d->ReadInstructions();
15301524
code->ptr()->active_instructions_ = instr;
1531-
code->ptr()->entry_point_ = Instructions::EntryPoint(instr);
1532-
code->ptr()->monomorphic_entry_point_ =
1533-
Instructions::MonomorphicEntryPoint(instr);
1534-
code->ptr()->unchecked_entry_point_ =
1535-
Instructions::UncheckedEntryPoint(instr);
1525+
Code::InitializeCachedEntryPointsFrom(code, instr);
15361526
}
15371527
#endif // !DART_PRECOMPILED_RUNTIME
15381528

runtime/vm/object.cc

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13003,25 +13003,28 @@ static int PrintVarInfo(char* buffer,
1300313003
const RawLocalVarDescriptors::VarInfoKind kind = info.kind();
1300413004
const int32_t index = info.index();
1300513005
if (kind == RawLocalVarDescriptors::kContextLevel) {
13006-
return Utils::SNPrint(buffer, len, "%2" Pd
13007-
" %-13s level=%-3d"
13008-
" begin=%-3d end=%d\n",
13006+
return Utils::SNPrint(buffer, len,
13007+
"%2" Pd
13008+
" %-13s level=%-3d"
13009+
" begin=%-3d end=%d\n",
1300913010
i, LocalVarDescriptors::KindToCString(kind), index,
1301013011
static_cast<int>(info.begin_pos.value()),
1301113012
static_cast<int>(info.end_pos.value()));
1301213013
} else if (kind == RawLocalVarDescriptors::kContextVar) {
1301313014
return Utils::SNPrint(
13014-
buffer, len, "%2" Pd
13015-
" %-13s level=%-3d index=%-3d"
13016-
" begin=%-3d end=%-3d name=%s\n",
13015+
buffer, len,
13016+
"%2" Pd
13017+
" %-13s level=%-3d index=%-3d"
13018+
" begin=%-3d end=%-3d name=%s\n",
1301713019
i, LocalVarDescriptors::KindToCString(kind), info.scope_id, index,
1301813020
static_cast<int>(info.begin_pos.Pos()),
1301913021
static_cast<int>(info.end_pos.Pos()), var_name.ToCString());
1302013022
} else {
1302113023
return Utils::SNPrint(
13022-
buffer, len, "%2" Pd
13023-
" %-13s scope=%-3d index=%-3d"
13024-
" begin=%-3d end=%-3d name=%s\n",
13024+
buffer, len,
13025+
"%2" Pd
13026+
" %-13s scope=%-3d index=%-3d"
13027+
" begin=%-3d end=%-3d name=%s\n",
1302513028
i, LocalVarDescriptors::KindToCString(kind), info.scope_id, index,
1302613029
static_cast<int>(info.begin_pos.Pos()),
1302713030
static_cast<int>(info.end_pos.Pos()), var_name.ToCString());
@@ -15194,6 +15197,18 @@ void Code::DisableStubCode() const {
1519415197
StoreNonPointer(&raw_ptr()->unchecked_entry_point_, raw_ptr()->entry_point_);
1519515198
}
1519615199

15200+
void Code::InitializeCachedEntryPointsFrom(RawCode* code,
15201+
RawInstructions* instructions) {
15202+
NoSafepointScope _;
15203+
code->ptr()->entry_point_ = Instructions::EntryPoint(instructions);
15204+
code->ptr()->monomorphic_entry_point_ =
15205+
Instructions::MonomorphicEntryPoint(instructions);
15206+
code->ptr()->unchecked_entry_point_ =
15207+
Instructions::UncheckedEntryPoint(instructions);
15208+
code->ptr()->monomorphic_unchecked_entry_point_ =
15209+
Instructions::MonomorphicUncheckedEntryPoint(instructions);
15210+
}
15211+
1519715212
void Code::SetActiveInstructions(const Instructions& instructions) const {
1519815213
#if defined(DART_PRECOMPILED_RUNTIME)
1519915214
UNREACHABLE();
@@ -15202,15 +15217,7 @@ void Code::SetActiveInstructions(const Instructions& instructions) const {
1520215217
// RawInstructions are never allocated in New space and hence a
1520315218
// store buffer update is not needed here.
1520415219
StorePointer(&raw_ptr()->active_instructions_, instructions.raw());
15205-
StoreNonPointer(&raw_ptr()->entry_point_,
15206-
Instructions::EntryPoint(instructions.raw()));
15207-
StoreNonPointer(&raw_ptr()->monomorphic_entry_point_,
15208-
Instructions::MonomorphicEntryPoint(instructions.raw()));
15209-
StoreNonPointer(&raw_ptr()->unchecked_entry_point_,
15210-
Instructions::UncheckedEntryPoint(instructions.raw()));
15211-
StoreNonPointer(
15212-
&raw_ptr()->monomorphic_unchecked_entry_point_,
15213-
Instructions::MonomorphicUncheckedEntryPoint(instructions.raw()));
15220+
Code::InitializeCachedEntryPointsFrom(raw(), instructions.raw());
1521415221
#endif
1521515222
}
1521615223

runtime/vm/object.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5798,6 +5798,10 @@ class Code : public Object {
57985798
#endif
57995799
}
58005800

5801+
// Initializes 4 cached entrypoint addresses in 'code' from 'instructions'.
5802+
static void InitializeCachedEntryPointsFrom(RawCode* code,
5803+
RawInstructions* instructions);
5804+
58015805
void SetActiveInstructions(const Instructions& instructions) const;
58025806

58035807
void set_instructions(const Instructions& instructions) const {
@@ -5838,6 +5842,7 @@ class Code : public Object {
58385842
friend class Precompiler; // for set_object_pool
58395843
friend class FunctionSerializationCluster;
58405844
friend class CodeSerializationCluster;
5845+
friend class CodeDeserializationCluster;
58415846
friend class StubCode; // for set_object_pool
58425847
friend class MegamorphicCacheTable; // for set_object_pool
58435848
friend class CodePatcher; // for set_instructions

0 commit comments

Comments
 (0)