Skip to content

Commit dd2d040

Browse files
alexmarkovcommit-bot@chromium.org
authored andcommitted
[vm] Cleanup flags which disable argument type checks and strong mode types
The following options are removed: --use_strong_mode_types --experimental_unsafe_mode_use_at_your_own_risk The following flags and predicates are removed: Dart_IsolateFlags::unsafe_trust_strong_mode_types Isolate::argument_type_checks() Isolate::can_use_strong_mode_types() Isolate::should_emit_strong_mode_checks() Also, everything depending on these flags is cleaned up. Change-Id: I9328009ad5a42ea2173842386d612c465e3ebec1 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/147325 Reviewed-by: Martin Kustermann <[email protected]> Commit-Queue: Alexander Markov <[email protected]>
1 parent 485ad3b commit dd2d040

28 files changed

+135
-427
lines changed

runtime/include/dart_api.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ typedef struct {
518518
* for each part.
519519
*/
520520

521-
#define DART_FLAGS_CURRENT_VERSION (0x0000000b)
521+
#define DART_FLAGS_CURRENT_VERSION (0x0000000c)
522522

523523
typedef struct {
524524
int32_t version;
@@ -528,7 +528,6 @@ typedef struct {
528528
bool obfuscate;
529529
Dart_QualifiedFunctionName* entry_points;
530530
bool load_vmservice_library;
531-
bool unsafe_trust_strong_mode_types;
532531
bool copy_parent_code;
533532
} Dart_IsolateFlags;
534533

runtime/vm/compiler/aot/aot_call_specializer.cc

Lines changed: 1 addition & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,6 @@ bool AotCallSpecializer::IsSupportedIntOperandForStaticDoubleOp(
294294
Value* AotCallSpecializer::PrepareStaticOpInput(Value* input,
295295
intptr_t cid,
296296
Instruction* call) {
297-
ASSERT(I->can_use_strong_mode_types());
298297
ASSERT((cid == kDoubleCid) || (cid == kMintCid));
299298

300299
if (input->Type()->is_nullable()) {
@@ -368,18 +367,13 @@ static void RefineUseTypes(Definition* instr) {
368367

369368
bool AotCallSpecializer::TryOptimizeInstanceCallUsingStaticTypes(
370369
InstanceCallInstr* instr) {
371-
ASSERT(I->can_use_strong_mode_types());
372-
373370
const Token::Kind op_kind = instr->token_kind();
374-
375371
return TryOptimizeIntegerOperation(instr, op_kind) ||
376372
TryOptimizeDoubleOperation(instr, op_kind);
377373
}
378374

379375
bool AotCallSpecializer::TryOptimizeStaticCallUsingStaticTypes(
380376
StaticCallInstr* instr) {
381-
ASSERT(I->can_use_strong_mode_types());
382-
383377
const String& name = String::Handle(Z, instr->function().name());
384378
const Token::Kind op_kind = MethodTokenRecognizer::RecognizeTokenKind(name);
385379

@@ -472,8 +466,6 @@ bool AotCallSpecializer::TryOptimizeIntegerOperation(TemplateDartCall<0>* instr,
472466
return false;
473467
}
474468

475-
ASSERT(I->can_use_strong_mode_types());
476-
477469
Definition* replacement = NULL;
478470
if (instr->ArgumentCount() == 2) {
479471
Value* left_value = instr->ArgumentValueAt(0);
@@ -801,43 +793,8 @@ void AotCallSpecializer::VisitInstanceCall(InstanceCallInstr* instr) {
801793

802794
const CallTargets& targets = instr->Targets();
803795
const intptr_t receiver_idx = instr->FirstArgIndex();
804-
if (I->can_use_strong_mode_types()) {
805-
// In AOT strong mode, we avoid deopting speculation.
806-
// TODO(ajcbik): replace this with actual analysis phase
807-
// that determines if checks are removed later.
808-
} else if (speculative_policy_->IsAllowedForInlining(instr->deopt_id()) &&
809-
!targets.is_empty()) {
810-
if ((op_kind == Token::kINDEX) && TryReplaceWithIndexedOp(instr)) {
811-
return;
812-
}
813-
if ((op_kind == Token::kASSIGN_INDEX) && TryReplaceWithIndexedOp(instr)) {
814-
return;
815-
}
816-
if ((op_kind == Token::kEQ) && TryReplaceWithEqualityOp(instr, op_kind)) {
817-
return;
818-
}
819-
820-
if (Token::IsRelationalOperator(op_kind) &&
821-
TryReplaceWithRelationalOp(instr, op_kind)) {
822-
return;
823-
}
824-
825-
if (Token::IsBinaryOperator(op_kind) &&
826-
TryReplaceWithBinaryOp(instr, op_kind)) {
827-
return;
828-
}
829-
if (Token::IsUnaryOperator(op_kind) &&
830-
TryReplaceWithUnaryOp(instr, op_kind)) {
831-
return;
832-
}
833-
834-
if (TryInlineInstanceMethod(instr)) {
835-
return;
836-
}
837-
}
838796

839-
if (I->can_use_strong_mode_types() &&
840-
TryOptimizeInstanceCallUsingStaticTypes(instr)) {
797+
if (TryOptimizeInstanceCallUsingStaticTypes(instr)) {
841798
return;
842799
}
843800

runtime/vm/compiler/backend/flow_graph.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -424,8 +424,8 @@ FlowGraph::ToCheck FlowGraph::CheckForInstanceCall(
424424
if (function().IsDynamicFunction() && IsReceiver(receiver->definition())) {
425425
// Call receiver is callee receiver: calling "this.g()" in f().
426426
receiver_class = function().Owner();
427-
} else if (isolate()->can_use_strong_mode_types()) {
428-
// In strong mode, get the receiver's compile type. Note that
427+
} else {
428+
// Get the receiver's compile type. Note that
429429
// we allow nullable types, which may result in just generating
430430
// a null check rather than the more elaborate class check
431431
CompileType* type = receiver->Type();
@@ -1381,7 +1381,7 @@ void FlowGraph::RenameRecursive(
13811381
captured_parameters_->Add(index);
13821382
}
13831383

1384-
if ((phi != NULL) && isolate()->can_use_strong_mode_types()) {
1384+
if (phi != nullptr) {
13851385
// Assign type to Phi if it doesn't have a type yet.
13861386
// For a Phi to appear in the local variable it either was placed
13871387
// there as incoming value by renaming or it was stored there by

runtime/vm/compiler/backend/flow_graph_compiler.cc

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1309,26 +1309,8 @@ bool FlowGraphCompiler::TryIntrinsifyHelper() {
13091309
}
13101310
return false;
13111311
}
1312-
case FunctionLayout::kImplicitSetter: {
1313-
if (!isolate()->argument_type_checks()) {
1314-
Field& field = Field::Handle(function().accessor_field());
1315-
ASSERT(!field.IsNull());
1316-
#if defined(DEBUG)
1317-
// HACK: Clone the field to ignore assertion in Field::guarded_cid().
1318-
// The same reasons as above apply, but we only check if it's dynamic.
1319-
field = field.CloneFromOriginal();
1320-
#endif
1321-
1322-
if (field.is_instance() && field.guarded_cid() == kDynamicCid) {
1323-
SpecialStatsBegin(CombinedCodeStatistics::kTagIntrinsics);
1324-
GenerateSetterIntrinsic(compiler::target::Field::OffsetOf(field));
1325-
SpecialStatsEnd(CombinedCodeStatistics::kTagIntrinsics);
1326-
return true;
1327-
}
1328-
return false;
1329-
}
1312+
case FunctionLayout::kImplicitSetter:
13301313
break;
1331-
}
13321314
#if !defined(TARGET_ARCH_IA32)
13331315
case FunctionLayout::kMethodExtractor: {
13341316
auto& extracted_method = Function::ZoneHandle(

runtime/vm/compiler/backend/flow_graph_compiler.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1094,7 +1094,6 @@ class FlowGraphCompiler : public ValueObject {
10941094
intptr_t type_arguments_field_offset);
10951095

10961096
void GenerateGetterIntrinsic(intptr_t offset);
1097-
void GenerateSetterIntrinsic(intptr_t offset);
10981097

10991098
// Perform a greedy local register allocation. Consider all registers free.
11001099
void AllocateRegistersLocally(Instruction* instr);

runtime/vm/compiler/backend/flow_graph_compiler_arm.cc

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -871,20 +871,6 @@ void FlowGraphCompiler::GenerateGetterIntrinsic(intptr_t offset) {
871871
__ Ret();
872872
}
873873

874-
void FlowGraphCompiler::GenerateSetterIntrinsic(intptr_t offset) {
875-
// LR: return address.
876-
// SP+1: receiver.
877-
// SP+0: value.
878-
// Sequence node has one store node and one return NULL node.
879-
__ Comment("Intrinsic Setter");
880-
__ ldr(R0,
881-
compiler::Address(SP, 1 * compiler::target::kWordSize)); // Receiver.
882-
__ ldr(R1, compiler::Address(SP, 0 * compiler::target::kWordSize)); // Value.
883-
__ StoreIntoObjectOffset(R0, offset, R1);
884-
__ LoadObject(R0, Object::null_object());
885-
__ Ret();
886-
}
887-
888874
void FlowGraphCompiler::EmitFrameEntry() {
889875
const Function& function = parsed_function().function();
890876
if (CanOptimizeFunction() && function.IsOptimizable() &&

runtime/vm/compiler/backend/flow_graph_compiler_arm64.cc

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -832,19 +832,6 @@ void FlowGraphCompiler::GenerateGetterIntrinsic(intptr_t offset) {
832832
__ ret();
833833
}
834834

835-
void FlowGraphCompiler::GenerateSetterIntrinsic(intptr_t offset) {
836-
// LR: return address.
837-
// SP+1: receiver.
838-
// SP+0: value.
839-
// Sequence node has one store node and one return NULL node.
840-
__ Comment("Intrinsic Setter");
841-
__ LoadFromOffset(R0, SP, 1 * kWordSize); // Receiver.
842-
__ LoadFromOffset(R1, SP, 0 * kWordSize); // Value.
843-
__ StoreIntoObjectOffset(R0, offset, R1);
844-
__ LoadObject(R0, Object::null_object());
845-
__ ret();
846-
}
847-
848835
void FlowGraphCompiler::EmitFrameEntry() {
849836
const Function& function = parsed_function().function();
850837
if (CanOptimizeFunction() && function.IsOptimizable() &&

runtime/vm/compiler/backend/flow_graph_compiler_ia32.cc

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -752,21 +752,6 @@ void FlowGraphCompiler::GenerateGetterIntrinsic(intptr_t offset) {
752752
__ ret();
753753
}
754754

755-
void FlowGraphCompiler::GenerateSetterIntrinsic(intptr_t offset) {
756-
// TOS: return address.
757-
// +1 : value
758-
// +2 : receiver.
759-
// Sequence node has one store node and one return NULL node.
760-
__ Comment("Intrinsic Setter");
761-
__ movl(EAX, compiler::Address(ESP, 2 * kWordSize)); // Receiver.
762-
__ movl(EBX, compiler::Address(ESP, 1 * kWordSize)); // Value.
763-
__ StoreIntoObject(EAX, compiler::FieldAddress(EAX, offset), EBX);
764-
const compiler::Immediate& raw_null =
765-
compiler::Immediate(static_cast<intptr_t>(Object::null()));
766-
__ movl(EAX, raw_null);
767-
__ ret();
768-
}
769-
770755
// NOTE: If the entry code shape changes, ReturnAddressLocator in profiler.cc
771756
// needs to be updated to match.
772757
void FlowGraphCompiler::EmitFrameEntry() {

runtime/vm/compiler/backend/flow_graph_compiler_x64.cc

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -837,19 +837,6 @@ void FlowGraphCompiler::GenerateGetterIntrinsic(intptr_t offset) {
837837
__ ret();
838838
}
839839

840-
void FlowGraphCompiler::GenerateSetterIntrinsic(intptr_t offset) {
841-
// TOS: return address.
842-
// +1 : value
843-
// +2 : receiver.
844-
// Sequence node has one store node and one return NULL node.
845-
__ Comment("Intrinsic Setter");
846-
__ movq(RAX, compiler::Address(RSP, 2 * kWordSize)); // Receiver.
847-
__ movq(RBX, compiler::Address(RSP, 1 * kWordSize)); // Value.
848-
__ StoreIntoObject(RAX, compiler::FieldAddress(RAX, offset), RBX);
849-
__ LoadObject(RAX, Object::null_object());
850-
__ ret();
851-
}
852-
853840
// NOTE: If the entry code shape changes, ReturnAddressLocator in profiler.cc
854841
// needs to be updated to match.
855842
void FlowGraphCompiler::EmitFrameEntry() {

runtime/vm/compiler/backend/il.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2337,8 +2337,7 @@ Definition* CheckedSmiComparisonInstr::Canonicalize(FlowGraph* flow_graph) {
23372337

23382338
if ((left_type->ToCid() == kSmiCid) && (right_type->ToCid() == kSmiCid)) {
23392339
op_cid = kSmiCid;
2340-
} else if (Isolate::Current()->can_use_strong_mode_types() &&
2341-
FlowGraphCompiler::SupportsUnboxedInt64() &&
2340+
} else if (FlowGraphCompiler::SupportsUnboxedInt64() &&
23422341
// TODO(dartbug.com/30480): handle nullable types here
23432342
left_type->IsNullableInt() && !left_type->is_nullable() &&
23442343
right_type->IsNullableInt() && !right_type->is_nullable()) {

0 commit comments

Comments
 (0)