Skip to content

Commit

Permalink
[vm] Guard against double finalization from annotations on fields.
Browse files Browse the repository at this point in the history
Bug: #37544
Change-Id: Ie3620dd9adf8382afc018cf764965b4ff74d2b75
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/109440
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
  • Loading branch information
rmacnak-google authored and commit-bot@chromium.org committed Jul 18, 2019
1 parent f664a80 commit 6312030
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions runtime/vm/compiler/backend/il_arm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2486,6 +2486,7 @@ void StoreInstanceFieldInstr::EmitNativeCode(FlowGraphCompiler* compiler) {

const Register instance_reg = locs()->in(0).reg();
const intptr_t offset_in_bytes = OffsetInBytes();
ASSERT(offset_in_bytes > 0); // Field is finalized and points after header.

if (IsUnboxedStore() && compiler->is_optimizing()) {
const DRegister value = EvenDRegisterOf(locs()->in(1).fpu_reg());
Expand Down
1 change: 1 addition & 0 deletions runtime/vm/compiler/backend/il_arm64.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2156,6 +2156,7 @@ void StoreInstanceFieldInstr::EmitNativeCode(FlowGraphCompiler* compiler) {

const Register instance_reg = locs()->in(0).reg();
const intptr_t offset_in_bytes = OffsetInBytes();
ASSERT(offset_in_bytes > 0); // Field is finalized and points after header.

if (IsUnboxedStore() && compiler->is_optimizing()) {
const VRegister value = locs()->in(1).fpu_reg();
Expand Down
1 change: 1 addition & 0 deletions runtime/vm/compiler/backend/il_dbc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1139,6 +1139,7 @@ EMIT_NATIVE_CODE(AllocateObject,
}

EMIT_NATIVE_CODE(StoreInstanceField, 2) {
ASSERT(OffsetInBytes() > 0); // Field is finalized and points after header.
ASSERT(OffsetInBytes() % kWordSize == 0);
if (compiler->is_optimizing()) {
const Register value = locs()->in(1).reg();
Expand Down
1 change: 1 addition & 0 deletions runtime/vm/compiler/backend/il_ia32.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2055,6 +2055,7 @@ void StoreInstanceFieldInstr::EmitNativeCode(FlowGraphCompiler* compiler) {

const Register instance_reg = locs()->in(0).reg();
const intptr_t offset_in_bytes = OffsetInBytes();
ASSERT(offset_in_bytes > 0); // Field is finalized and points after header.

if (IsUnboxedStore() && compiler->is_optimizing()) {
XmmRegister value = locs()->in(1).fpu_reg();
Expand Down
1 change: 1 addition & 0 deletions runtime/vm/compiler/backend/il_x64.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2171,6 +2171,7 @@ void StoreInstanceFieldInstr::EmitNativeCode(FlowGraphCompiler* compiler) {

const Register instance_reg = locs()->in(0).reg();
const intptr_t offset_in_bytes = OffsetInBytes();
ASSERT(offset_in_bytes > 0); // Field is finalized and points after header.

if (IsUnboxedStore() && compiler->is_optimizing()) {
XmmRegister value = locs()->in(1).fpu_reg();
Expand Down
7 changes: 7 additions & 0 deletions runtime/vm/kernel_loader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1575,6 +1575,13 @@ void KernelLoader::FinishClassLoading(const Class& klass,
TokenPosition::kNoSource, TokenPosition::kNoSource);
fields_.Add(&deleted_enum_sentinel);
}

// Due to ReadVMAnnotations(), the klass may have been loaded at this point
// (loading the class while evaluating annotations).
if (klass.is_loaded()) {
return;
}

klass.SetFields(Array::Handle(Z, MakeFieldsArray()));
}

Expand Down

0 comments on commit 6312030

Please sign in to comment.