Skip to content

Commit e7403c1

Browse files
a-sivacommit-bot@chromium.org
authored andcommitted
Revert "[vm] Aggressive write-barrier elimination."
This reverts commit e5a2271. Reason for revert: We are seeing some crashes on the bot see https://ci.chromium.org/p/dart/builders/ci.sandbox/vm-kernel-linux-debug-x64/8684 Original change's description: > [vm] Aggressive write-barrier elimination. > > Flutter Gallery code size total: > -0.88% on ARM64 > -0.98% on ARM > > Fixes #39164. > > Change-Id: I8e65b1209ef1150bb73f3474506ebc97d7ab3685 > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/132003 > Reviewed-by: Ryan Macnak <[email protected]> > Commit-Queue: Samir Jindel <[email protected]> [email protected],[email protected],[email protected] Change-Id: Ia93b43a423ee982aea550eb9fc24d34509db3dce No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/135421 Reviewed-by: Siva Annamalai <[email protected]> Commit-Queue: Siva Annamalai <[email protected]>
1 parent 7575235 commit e7403c1

18 files changed

+30
-490
lines changed

runtime/vm/bit_vector.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,6 @@ class BitVector : public ZoneAllocated {
7070
data_[i / kBitsPerWord] &= ~(static_cast<uword>(1) << (i % kBitsPerWord));
7171
}
7272

73-
void Set(intptr_t i, bool value) { value ? Add(i) : Remove(i); }
74-
7573
bool Equals(const BitVector& other) const;
7674

7775
// Add all elements that are in the bitvector from.
@@ -94,14 +92,6 @@ class BitVector : public ZoneAllocated {
9492
return (block & (static_cast<uword>(1) << (i % kBitsPerWord))) != 0;
9593
}
9694

97-
bool SubsetOf(const BitVector& other) {
98-
ASSERT(length_ == other.length_);
99-
for (intptr_t i = 0; i < data_length_; ++i) {
100-
if ((data_[i] & other.data_[i]) != data_[i]) return false;
101-
}
102-
return true;
103-
}
104-
10595
void Clear() {
10696
for (intptr_t i = 0; i < data_length_; i++) {
10797
data_[i] = 0;

runtime/vm/compiler/backend/flow_graph_compiler.cc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -611,9 +611,7 @@ void FlowGraphCompiler::VisitBlocks() {
611611
EmitInstructionPrologue(instr);
612612
ASSERT(pending_deoptimization_env_ == NULL);
613613
pending_deoptimization_env_ = instr->env();
614-
DEBUG_ONLY(current_instruction_ = instr);
615614
instr->EmitNativeCode(this);
616-
DEBUG_ONLY(current_instruction_ = nullptr);
617615
pending_deoptimization_env_ = NULL;
618616
if (IsPeephole(instr)) {
619617
ASSERT(top_of_stack_ == nullptr);
@@ -700,9 +698,7 @@ void FlowGraphCompiler::GenerateDeferredCode() {
700698
slow_path->instruction()->tag());
701699
SpecialStatsBegin(stats_tag);
702700
BeginCodeSourceRange();
703-
DEBUG_ONLY(current_instruction_ = slow_path->instruction());
704701
slow_path->GenerateCode(this);
705-
DEBUG_ONLY(current_instruction_ = nullptr);
706702
EndCodeSourceRange(slow_path->instruction()->token_pos());
707703
SpecialStatsEnd(stats_tag);
708704
}

runtime/vm/compiler/backend/flow_graph_compiler.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,15 +1118,6 @@ class FlowGraphCompiler : public ValueObject {
11181118
// is amenable to a peephole optimization.
11191119
bool IsPeephole(Instruction* instr) const;
11201120

1121-
#ifdef DEBUG
1122-
bool CanCallDart() const {
1123-
return current_instruction_ == nullptr ||
1124-
current_instruction_->CanCallDart();
1125-
}
1126-
#else
1127-
bool CanCallDart() const { return true; }
1128-
#endif
1129-
11301121
// This struct contains either function or code, the other one being NULL.
11311122
class StaticCallsStruct : public ZoneAllocated {
11321123
public:
@@ -1219,10 +1210,6 @@ class FlowGraphCompiler : public ValueObject {
12191210
ZoneGrowableArray<const ICData*>* deopt_id_to_ic_data_;
12201211
Array& edge_counters_array_;
12211212

1222-
// Instruction current running EmitNativeCode(). Useful for asserts.
1223-
// Does not include Phis and BlockEntrys.
1224-
DEBUG_ONLY(Instruction* current_instruction_ = nullptr);
1225-
12261213
DISALLOW_COPY_AND_ASSIGN(FlowGraphCompiler);
12271214
};
12281215

runtime/vm/compiler/backend/flow_graph_compiler_arm.cc

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -997,7 +997,6 @@ void FlowGraphCompiler::GenerateDartCall(intptr_t deopt_id,
997997
RawPcDescriptors::Kind kind,
998998
LocationSummary* locs,
999999
Code::EntryKind entry_kind) {
1000-
ASSERT(CanCallDart());
10011000
__ BranchLinkPatchable(stub, entry_kind);
10021001
EmitCallsiteMetadata(token_pos, deopt_id, kind, locs);
10031002
}
@@ -1008,7 +1007,6 @@ void FlowGraphCompiler::GenerateStaticDartCall(intptr_t deopt_id,
10081007
LocationSummary* locs,
10091008
const Function& target,
10101009
Code::EntryKind entry_kind) {
1011-
ASSERT(CanCallDart());
10121010
if (FLAG_precompiled_mode && FLAG_use_bare_instructions) {
10131011
__ GenerateUnRelocatedPcRelativeCall();
10141012
AddPcRelativeCallTarget(target, entry_kind);
@@ -1088,7 +1086,6 @@ void FlowGraphCompiler::EmitInstanceCallJIT(const Code& stub,
10881086
TokenPosition token_pos,
10891087
LocationSummary* locs,
10901088
Code::EntryKind entry_kind) {
1091-
ASSERT(CanCallDart());
10921089
ASSERT(entry_kind == Code::EntryKind::kNormal ||
10931090
entry_kind == Code::EntryKind::kUnchecked);
10941091
ASSERT(Array::Handle(zone(), ic_data.arguments_descriptor()).Length() > 0);
@@ -1114,7 +1111,6 @@ void FlowGraphCompiler::EmitMegamorphicInstanceCall(
11141111
LocationSummary* locs,
11151112
intptr_t try_index,
11161113
intptr_t slow_path_argument_count) {
1117-
ASSERT(CanCallDart());
11181114
ASSERT(!arguments_descriptor.IsNull() && (arguments_descriptor.Length() > 0));
11191115
const ArgumentsDescriptor args_desc(arguments_descriptor);
11201116
const MegamorphicCache& cache = MegamorphicCache::ZoneHandle(
@@ -1162,7 +1158,6 @@ void FlowGraphCompiler::EmitInstanceCallAOT(const ICData& ic_data,
11621158
LocationSummary* locs,
11631159
Code::EntryKind entry_kind,
11641160
bool receiver_can_be_smi) {
1165-
ASSERT(CanCallDart());
11661161
ASSERT(entry_kind == Code::EntryKind::kNormal ||
11671162
entry_kind == Code::EntryKind::kUnchecked);
11681163
ASSERT(ic_data.NumArgsTested() == 1);

runtime/vm/compiler/backend/flow_graph_compiler_arm64.cc

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -968,7 +968,6 @@ void FlowGraphCompiler::GenerateDartCall(intptr_t deopt_id,
968968
RawPcDescriptors::Kind kind,
969969
LocationSummary* locs,
970970
Code::EntryKind entry_kind) {
971-
ASSERT(CanCallDart());
972971
__ BranchLinkPatchable(stub, entry_kind);
973972
EmitCallsiteMetadata(token_pos, deopt_id, kind, locs);
974973
}
@@ -979,7 +978,6 @@ void FlowGraphCompiler::GenerateStaticDartCall(intptr_t deopt_id,
979978
LocationSummary* locs,
980979
const Function& target,
981980
Code::EntryKind entry_kind) {
982-
ASSERT(CanCallDart());
983981
if (FLAG_precompiled_mode && FLAG_use_bare_instructions) {
984982
__ GenerateUnRelocatedPcRelativeCall();
985983
AddPcRelativeCallTarget(target, entry_kind);
@@ -1049,7 +1047,6 @@ void FlowGraphCompiler::EmitInstanceCallJIT(const Code& stub,
10491047
TokenPosition token_pos,
10501048
LocationSummary* locs,
10511049
Code::EntryKind entry_kind) {
1052-
ASSERT(CanCallDart());
10531050
ASSERT(entry_kind == Code::EntryKind::kNormal ||
10541051
entry_kind == Code::EntryKind::kUnchecked);
10551052
ASSERT(Array::Handle(zone(), ic_data.arguments_descriptor()).Length() > 0);
@@ -1081,7 +1078,6 @@ void FlowGraphCompiler::EmitMegamorphicInstanceCall(
10811078
LocationSummary* locs,
10821079
intptr_t try_index,
10831080
intptr_t slow_path_argument_count) {
1084-
ASSERT(CanCallDart());
10851081
ASSERT(!arguments_descriptor.IsNull() && (arguments_descriptor.Length() > 0));
10861082
const ArgumentsDescriptor args_desc(arguments_descriptor);
10871083
const MegamorphicCache& cache = MegamorphicCache::ZoneHandle(
@@ -1126,7 +1122,6 @@ void FlowGraphCompiler::EmitInstanceCallAOT(const ICData& ic_data,
11261122
LocationSummary* locs,
11271123
Code::EntryKind entry_kind,
11281124
bool receiver_can_be_smi) {
1129-
ASSERT(CanCallDart());
11301125
ASSERT(ic_data.NumArgsTested() == 1);
11311126
const Code& initial_stub = StubCode::UnlinkedCall();
11321127
const char* switchable_call_mode = "smiable";

runtime/vm/compiler/backend/flow_graph_compiler_ia32.cc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -863,7 +863,6 @@ void FlowGraphCompiler::GenerateDartCall(intptr_t deopt_id,
863863
RawPcDescriptors::Kind kind,
864864
LocationSummary* locs,
865865
Code::EntryKind entry_kind) {
866-
ASSERT(CanCallDart());
867866
__ Call(stub, /*moveable_target=*/false, entry_kind);
868867
EmitCallsiteMetadata(token_pos, deopt_id, kind, locs);
869868
}
@@ -874,7 +873,6 @@ void FlowGraphCompiler::GenerateStaticDartCall(intptr_t deopt_id,
874873
LocationSummary* locs,
875874
const Function& target,
876875
Code::EntryKind entry_kind) {
877-
ASSERT(CanCallDart());
878876
const auto& stub = StubCode::CallStaticFunction();
879877
__ Call(stub, /*movable_target=*/true, entry_kind);
880878
EmitCallsiteMetadata(token_pos, deopt_id, kind, locs);
@@ -946,7 +944,6 @@ void FlowGraphCompiler::EmitInstanceCallJIT(const Code& stub,
946944
TokenPosition token_pos,
947945
LocationSummary* locs,
948946
Code::EntryKind entry_kind) {
949-
ASSERT(CanCallDart());
950947
ASSERT(entry_kind == Code::EntryKind::kNormal ||
951948
entry_kind == Code::EntryKind::kUnchecked);
952949
ASSERT(Array::Handle(ic_data.arguments_descriptor()).Length() > 0);
@@ -972,7 +969,6 @@ void FlowGraphCompiler::EmitMegamorphicInstanceCall(
972969
LocationSummary* locs,
973970
intptr_t try_index,
974971
intptr_t slow_path_argument_count) {
975-
ASSERT(CanCallDart());
976972
ASSERT(!arguments_descriptor.IsNull() && (arguments_descriptor.Length() > 0));
977973
const ArgumentsDescriptor args_desc(arguments_descriptor);
978974
const MegamorphicCache& cache = MegamorphicCache::ZoneHandle(

runtime/vm/compiler/backend/flow_graph_compiler_x64.cc

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -982,7 +982,6 @@ void FlowGraphCompiler::GenerateDartCall(intptr_t deopt_id,
982982
RawPcDescriptors::Kind kind,
983983
LocationSummary* locs,
984984
Code::EntryKind entry_kind) {
985-
ASSERT(CanCallDart());
986985
__ CallPatchable(stub, entry_kind);
987986
EmitCallsiteMetadata(token_pos, deopt_id, kind, locs);
988987
}
@@ -993,7 +992,6 @@ void FlowGraphCompiler::GenerateStaticDartCall(intptr_t deopt_id,
993992
LocationSummary* locs,
994993
const Function& target,
995994
Code::EntryKind entry_kind) {
996-
ASSERT(CanCallDart());
997995
ASSERT(is_optimizing());
998996
if (FLAG_precompiled_mode && FLAG_use_bare_instructions) {
999997
__ GenerateUnRelocatedPcRelativeCall();
@@ -1077,7 +1075,6 @@ void FlowGraphCompiler::EmitInstanceCallJIT(const Code& stub,
10771075
TokenPosition token_pos,
10781076
LocationSummary* locs,
10791077
Code::EntryKind entry_kind) {
1080-
ASSERT(CanCallDart());
10811078
ASSERT(entry_kind == Code::EntryKind::kNormal ||
10821079
entry_kind == Code::EntryKind::kUnchecked);
10831080
ASSERT(Array::Handle(zone(), ic_data.arguments_descriptor()).Length() > 0);
@@ -1103,7 +1100,6 @@ void FlowGraphCompiler::EmitMegamorphicInstanceCall(
11031100
LocationSummary* locs,
11041101
intptr_t try_index,
11051102
intptr_t slow_path_argument_count) {
1106-
ASSERT(CanCallDart());
11071103
ASSERT(!arguments_descriptor.IsNull() && (arguments_descriptor.Length() > 0));
11081104
const ArgumentsDescriptor args_desc(arguments_descriptor);
11091105
const MegamorphicCache& cache = MegamorphicCache::ZoneHandle(
@@ -1145,7 +1141,6 @@ void FlowGraphCompiler::EmitInstanceCallAOT(const ICData& ic_data,
11451141
LocationSummary* locs,
11461142
Code::EntryKind entry_kind,
11471143
bool receiver_can_be_smi) {
1148-
ASSERT(CanCallDart());
11491144
ASSERT(entry_kind == Code::EntryKind::kNormal ||
11501145
entry_kind == Code::EntryKind::kUnchecked);
11511146
ASSERT(ic_data.NumArgsTested() == 1);

runtime/vm/compiler/backend/il.h

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1031,15 +1031,6 @@ class Instruction : public ZoneAllocated {
10311031
// See StoreInstanceFieldInstr::HasUnknownSideEffects() for rationale.
10321032
virtual bool HasUnknownSideEffects() const = 0;
10331033

1034-
// Whether this instruction can call Dart code without going through
1035-
// the runtime.
1036-
//
1037-
// Must be true for any instruction which can call Dart code without
1038-
// first creating an exit frame to transition into the runtime.
1039-
//
1040-
// See also WriteBarrierElimination and Thread::RememberLiveTemporaries().
1041-
virtual bool CanCallDart() const { return false; }
1042-
10431034
virtual bool CanTriggerGC() const;
10441035

10451036
// Get the block entry for this instruction.
@@ -3152,8 +3143,6 @@ class BranchInstr : public Instruction {
31523143
return comparison()->HasUnknownSideEffects();
31533144
}
31543145

3155-
virtual bool CanCallDart() const { return comparison()->CanCallDart(); }
3156-
31573146
ComparisonInstr* comparison() const { return comparison_; }
31583147
void SetComparison(ComparisonInstr* comp);
31593148

@@ -3720,7 +3709,6 @@ class ClosureCallInstr : public TemplateDartCall<1> {
37203709
virtual bool ComputeCanDeoptimize() const { return !FLAG_precompiled_mode; }
37213710

37223711
virtual bool HasUnknownSideEffects() const { return true; }
3723-
virtual bool CanCallDart() const { return true; }
37243712

37253713
Code::EntryKind entry_kind() const { return entry_kind_; }
37263714

@@ -3796,7 +3784,6 @@ class InstanceCallBaseInstr : public TemplateDartCall<0> {
37963784
}
37973785

37983786
virtual bool HasUnknownSideEffects() const { return true; }
3799-
virtual bool CanCallDart() const { return true; }
38003787

38013788
void SetResultType(Zone* zone, CompileType new_type) {
38023789
result_type_ = new (zone) CompileType(new_type);
@@ -4348,7 +4335,6 @@ class IfThenElseInstr : public Definition {
43484335
virtual bool HasUnknownSideEffects() const {
43494336
return comparison()->HasUnknownSideEffects();
43504337
}
4351-
virtual bool CanCallDart() const { return comparison()->CanCallDart(); }
43524338

43534339
virtual bool AttributesEqual(Instruction* other) const {
43544340
IfThenElseInstr* other_if_then_else = other->AsIfThenElse();
@@ -4477,7 +4463,6 @@ class StaticCallInstr : public TemplateDartCall<0> {
44774463
}
44784464

44794465
virtual bool HasUnknownSideEffects() const { return true; }
4480-
virtual bool CanCallDart() const { return true; }
44814466

44824467
// Initialize result type of this call instruction if target is a recognized
44834468
// method or has pragma annotation.
@@ -4736,9 +4721,6 @@ class NativeCallInstr : public TemplateDartCall<0> {
47364721

47374722
virtual bool HasUnknownSideEffects() const { return true; }
47384723

4739-
// Always creates an exit frame before more Dart code can be called.
4740-
virtual bool CanCallDart() const { return false; }
4741-
47424724
void SetupNative();
47434725

47444726
PRINT_OPERANDS_TO_SUPPORT
@@ -4798,9 +4780,6 @@ class FfiCallInstr : public Definition {
47984780

47994781
virtual bool HasUnknownSideEffects() const { return true; }
48004782

4801-
// Always creates an exit frame before more Dart code can be called.
4802-
virtual bool CanCallDart() const { return false; }
4803-
48044783
virtual Representation RequiredInputRepresentation(intptr_t idx) const;
48054784
virtual Representation representation() const;
48064785

@@ -5350,7 +5329,6 @@ class StringInterpolateInstr : public TemplateDefinition<1, Throws> {
53505329
virtual CompileType ComputeType() const;
53515330
// Issues a static call to Dart code which calls toString on objects.
53525331
virtual bool HasUnknownSideEffects() const { return true; }
5353-
virtual bool CanCallDart() const { return true; }
53545332
virtual bool ComputeCanDeoptimize() const { return !FLAG_precompiled_mode; }
53555333

53565334
const Function& CallFunction() const;
@@ -7028,7 +7006,6 @@ class CheckedSmiOpInstr : public TemplateDefinition<2, Throws> {
70287006
virtual bool RecomputeType();
70297007

70307008
virtual bool HasUnknownSideEffects() const { return true; }
7031-
virtual bool CanCallDart() const { return true; }
70327009

70337010
virtual Definition* Canonicalize(FlowGraph* flow_graph);
70347011

@@ -7073,7 +7050,6 @@ class CheckedSmiComparisonInstr : public TemplateComparison<2, Throws> {
70737050
bool is_negated() const { return is_negated_; }
70747051

70757052
virtual bool HasUnknownSideEffects() const { return true; }
7076-
virtual bool CanCallDart() const { return true; }
70777053

70787054
PRINT_OPERANDS_TO_SUPPORT
70797055

runtime/vm/compiler/compiler_pass.cc

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#include "vm/compiler/backend/redundancy_elimination.h"
2020
#include "vm/compiler/backend/type_propagator.h"
2121
#include "vm/compiler/call_specializer.h"
22-
#include "vm/compiler/write_barrier_elimination.h"
2322
#if defined(DART_PRECOMPILER)
2423
#include "vm/compiler/aot/aot_call_specializer.h"
2524
#include "vm/compiler/aot/precompiler.h"
@@ -530,6 +529,36 @@ COMPILER_PASS(ReorderBlocks, {
530529
}
531530
});
532531

532+
static void WriteBarrierElimination(FlowGraph* flow_graph) {
533+
for (BlockIterator block_it = flow_graph->reverse_postorder_iterator();
534+
!block_it.Done(); block_it.Advance()) {
535+
BlockEntryInstr* block = block_it.Current();
536+
Definition* last_allocated = nullptr;
537+
for (ForwardInstructionIterator it(block); !it.Done(); it.Advance()) {
538+
Instruction* current = it.Current();
539+
if (!current->CanTriggerGC()) {
540+
if (StoreInstanceFieldInstr* instr = current->AsStoreInstanceField()) {
541+
if (instr->instance()->definition() == last_allocated) {
542+
instr->set_emit_store_barrier(kNoStoreBarrier);
543+
}
544+
continue;
545+
}
546+
}
547+
548+
if (AllocationInstr* alloc = current->AsAllocation()) {
549+
if (alloc->WillAllocateNewOrRemembered()) {
550+
last_allocated = alloc;
551+
continue;
552+
}
553+
}
554+
555+
if (current->CanTriggerGC()) {
556+
last_allocated = nullptr;
557+
}
558+
}
559+
}
560+
}
561+
533562
COMPILER_PASS(WriteBarrierElimination,
534563
{ WriteBarrierElimination(flow_graph); });
535564

runtime/vm/compiler/compiler_sources.gni

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,6 @@ compiler_sources = [
165165
"stub_code_compiler_arm64.cc",
166166
"stub_code_compiler_ia32.cc",
167167
"stub_code_compiler_x64.cc",
168-
"write_barrier_elimination.cc",
169-
"write_barrier_elimination.h",
170168
]
171169

172170
compiler_sources_tests = [

0 commit comments

Comments
 (0)