Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 7d90df4

Browse files
committed
[Kernel, VM runtime] Hook up bool checks in strong mode (fixes #32336).
Update kernel status file. Change-Id: I08b153d431c15870e0251e7dd760213c795579c9 Reviewed-on: https://dart-review.googlesource.com/48707 Reviewed-by: Siva Annamalai <asiva@google.com>
1 parent 4da5228 commit 7d90df4

File tree

12 files changed

+31
-32
lines changed

12 files changed

+31
-32
lines changed

pkg/front_end/testcases/strong.status

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ inference/mixin_inference_outwards_3: TypeCheckError
106106
inference/mixin_inference_outwards_4: TypeCheckError
107107
inference/mixin_inference_unification_1: TypeCheckError
108108
inference/mixin_inference_unification_2: TypeCheckError
109+
inference/override_equals: RuntimeError
109110
inference/unresolved_super: TypeCheckError
110111
inference/unsafe_block_closure_inference_function_call_explicit_dynamic_param_via_expr1: Fail # Issue #25824
111112
inference/unsafe_block_closure_inference_function_call_explicit_dynamic_param_via_expr2: Fail # Issue #25824

runtime/vm/compiler/backend/il_arm.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -437,14 +437,15 @@ static void EmitAssertBoolean(Register reg,
437437
// Call the runtime if the object is not bool::true or bool::false.
438438
ASSERT(locs->always_calls());
439439
Label done;
440+
Isolate* isolate = Isolate::Current();
440441

441-
if (Isolate::Current()->type_checks()) {
442+
if (isolate->type_checks() || isolate->strong()) {
442443
__ CompareObject(reg, Bool::True());
443444
__ b(&done, EQ);
444445
__ CompareObject(reg, Bool::False());
445446
__ b(&done, EQ);
446447
} else {
447-
ASSERT(Isolate::Current()->asserts());
448+
ASSERT(isolate->asserts());
448449
__ CompareObject(reg, Object::null_instance());
449450
__ b(&done, NE);
450451
}

runtime/vm/compiler/backend/il_arm64.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -435,14 +435,15 @@ static void EmitAssertBoolean(Register reg,
435435
// Call the runtime if the object is not bool::true or bool::false.
436436
ASSERT(locs->always_calls());
437437
Label done;
438+
Isolate* isolate = Isolate::Current();
438439

439-
if (Isolate::Current()->type_checks()) {
440+
if (isolate->type_checks() || isolate->strong()) {
440441
__ CompareObject(reg, Bool::True());
441442
__ b(&done, EQ);
442443
__ CompareObject(reg, Bool::False());
443444
__ b(&done, EQ);
444445
} else {
445-
ASSERT(Isolate::Current()->asserts());
446+
ASSERT(isolate->asserts());
446447
__ CompareObject(reg, Object::null_instance());
447448
__ b(&done, NE);
448449
}

runtime/vm/compiler/backend/il_dbc.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,8 @@ EMIT_NATIVE_CODE(AssertBoolean,
195195
if (compiler->is_optimizing()) {
196196
__ Push(locs()->in(0).reg());
197197
}
198-
__ AssertBoolean(Isolate::Current()->type_checks() ? 1 : 0);
198+
Isolate* isolate = Isolate::Current();
199+
__ AssertBoolean((isolate->type_checks() || isolate->strong()) ? 1 : 0);
199200
compiler->AddCurrentDescriptor(RawPcDescriptors::kOther, deopt_id(),
200201
token_pos());
201202
compiler->RecordAfterCall(this, FlowGraphCompiler::kHasResult);

runtime/vm/compiler/backend/il_ia32.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,14 +310,15 @@ static void EmitAssertBoolean(Register reg,
310310
// Call the runtime if the object is not bool::true or bool::false.
311311
ASSERT(locs->always_calls());
312312
Label done;
313+
Isolate* isolate = Isolate::Current();
313314

314-
if (Isolate::Current()->type_checks()) {
315+
if (isolate->type_checks() || isolate->strong()) {
315316
__ CompareObject(reg, Bool::True());
316317
__ j(EQUAL, &done, Assembler::kNearJump);
317318
__ CompareObject(reg, Bool::False());
318319
__ j(EQUAL, &done, Assembler::kNearJump);
319320
} else {
320-
ASSERT(Isolate::Current()->asserts());
321+
ASSERT(isolate->asserts());
321322
__ CompareObject(reg, Object::null_instance());
322323
__ j(NOT_EQUAL, &done, Assembler::kNearJump);
323324
}

runtime/vm/compiler/backend/il_x64.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -403,14 +403,15 @@ static void EmitAssertBoolean(Register reg,
403403
// Call the runtime if the object is not bool::true or bool::false.
404404
ASSERT(locs->always_calls());
405405
Label done;
406+
Isolate* isolate = Isolate::Current();
406407

407-
if (Isolate::Current()->type_checks()) {
408+
if (isolate->type_checks() || isolate->strong()) {
408409
__ CompareObject(reg, Bool::True());
409410
__ j(EQUAL, &done, Assembler::kNearJump);
410411
__ CompareObject(reg, Bool::False());
411412
__ j(EQUAL, &done, Assembler::kNearJump);
412413
} else {
413-
ASSERT(Isolate::Current()->asserts());
414+
ASSERT(isolate->asserts());
414415
__ CompareObject(reg, Object::null_instance());
415416
__ j(NOT_EQUAL, &done, Assembler::kNearJump);
416417
}

runtime/vm/compiler/frontend/flow_graph_builder.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -945,7 +945,7 @@ BlockEntryInstr* TestGraphVisitor::CreateFalseSuccessor() const {
945945

946946
void TestGraphVisitor::ReturnValue(Value* value) {
947947
Isolate* isolate = Isolate::Current();
948-
if (isolate->type_checks() || isolate->asserts()) {
948+
if (isolate->strong() || isolate->type_checks() || isolate->asserts()) {
949949
value = Bind(new (Z) AssertBooleanInstr(condition_token_pos(), value,
950950
owner()->GetNextDeoptId()));
951951
}
@@ -1290,7 +1290,7 @@ void EffectGraphVisitor::VisitBinaryOpNode(BinaryOpNode* node) {
12901290
node->left()->Visit(&for_left);
12911291
EffectGraphVisitor empty(owner());
12921292
Isolate* isolate = Isolate::Current();
1293-
if (isolate->type_checks() || isolate->asserts()) {
1293+
if (isolate->strong() || isolate->type_checks() || isolate->asserts()) {
12941294
ValueGraphVisitor for_right(owner());
12951295
node->right()->Visit(&for_right);
12961296
Value* right_value = for_right.value();
@@ -1354,7 +1354,7 @@ void ValueGraphVisitor::VisitBinaryOpNode(BinaryOpNode* node) {
13541354
node->right()->Visit(&for_right);
13551355
Value* right_value = for_right.value();
13561356
Isolate* isolate = Isolate::Current();
1357-
if (isolate->type_checks() || isolate->asserts()) {
1357+
if (isolate->strong() || isolate->type_checks() || isolate->asserts()) {
13581358
right_value = for_right.Bind(new (Z) AssertBooleanInstr(
13591359
node->right()->token_pos(), right_value, owner()->GetNextDeoptId()));
13601360
}
@@ -1626,7 +1626,7 @@ void EffectGraphVisitor::VisitComparisonNode(ComparisonNode* node) {
16261626
owner()->ic_data_array(), owner()->GetNextDeoptId());
16271627
if (node->kind() == Token::kNE) {
16281628
Isolate* isolate = Isolate::Current();
1629-
if (isolate->type_checks() || isolate->asserts()) {
1629+
if (isolate->strong() || isolate->type_checks() || isolate->asserts()) {
16301630
Value* value = Bind(result);
16311631
result = new (Z) AssertBooleanInstr(node->token_pos(), value,
16321632
owner()->GetNextDeoptId());
@@ -1670,7 +1670,7 @@ void EffectGraphVisitor::VisitUnaryOpNode(UnaryOpNode* node) {
16701670
Append(for_value);
16711671
Value* value = for_value.value();
16721672
Isolate* isolate = Isolate::Current();
1673-
if (isolate->type_checks() || isolate->asserts()) {
1673+
if (isolate->strong() || isolate->type_checks() || isolate->asserts()) {
16741674
value = Bind(new (Z) AssertBooleanInstr(
16751675
node->operand()->token_pos(), value, owner()->GetNextDeoptId()));
16761676
}

runtime/vm/compiler/frontend/kernel_binary_flowgraph.cc

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2010,7 +2010,8 @@ void StreamingScopeBuilder::VisitFunctionType(bool simple) {
20102010
TypeParameterHelper helper(builder_);
20112011
helper.ReadUntilExcludingAndSetJustRead(TypeParameterHelper::kBound);
20122012
VisitDartType(); // read bound.
2013-
helper.ReadUntilExcludingAndSetJustRead(TypeParameterHelper::kDefaultType);
2013+
helper.ReadUntilExcludingAndSetJustRead(
2014+
TypeParameterHelper::kDefaultType);
20142015
if (builder_->ReadTag() == kSomething) {
20152016
VisitDartType(); // read default type.
20162017
}
@@ -6490,8 +6491,8 @@ Fragment StreamingFlowGraphBuilder::BuildImplicitClosureCreation(
64906491
return flow_graph_builder_->BuildImplicitClosureCreation(target);
64916492
}
64926493

6493-
Fragment StreamingFlowGraphBuilder::CheckBooleanInCheckedMode() {
6494-
return flow_graph_builder_->CheckBooleanInCheckedMode();
6494+
Fragment StreamingFlowGraphBuilder::CheckBoolean() {
6495+
return flow_graph_builder_->CheckBoolean();
64956496
}
64966497

64976498
Fragment StreamingFlowGraphBuilder::CheckAssignableInCheckedMode(
@@ -6550,7 +6551,7 @@ Fragment StreamingFlowGraphBuilder::TranslateCondition(bool* negate) {
65506551
SkipBytes(1); // Skip Not tag, thus go directly to the inner expression.
65516552
}
65526553
Fragment instructions = BuildExpression(); // read expression.
6553-
instructions += CheckBooleanInCheckedMode();
6554+
instructions += CheckBoolean();
65546555
return instructions;
65556556
}
65566557

@@ -7785,7 +7786,7 @@ Fragment StreamingFlowGraphBuilder::BuildNot(TokenPosition* position) {
77857786
if (position != NULL) *position = TokenPosition::kNoSource;
77867787

77877788
Fragment instructions = BuildExpression(); // read expression.
7788-
instructions += CheckBooleanInCheckedMode();
7789+
instructions += CheckBoolean();
77897790
instructions += BooleanNegate();
77907791
return instructions;
77917792
}
@@ -8569,7 +8570,7 @@ Fragment StreamingFlowGraphBuilder::BuildAssertStatement() {
85698570
instructions += BuildExpression(); // read condition.
85708571
instructions += PushArgument();
85718572
instructions += EvaluateAssertion();
8572-
instructions += CheckBooleanInCheckedMode();
8573+
instructions += CheckBoolean();
85738574
instructions += Constant(Bool::True());
85748575
instructions += BranchIfEqual(&then, &otherwise, false);
85758576

runtime/vm/compiler/frontend/kernel_binary_flowgraph.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1316,7 +1316,7 @@ class StreamingFlowGraphBuilder {
13161316
JoinEntryInstr* BuildJoinEntry(intptr_t try_index);
13171317
Fragment Goto(JoinEntryInstr* destination);
13181318
Fragment BuildImplicitClosureCreation(const Function& target);
1319-
Fragment CheckBooleanInCheckedMode();
1319+
Fragment CheckBoolean();
13201320
Fragment CheckAssignableInCheckedMode(const AbstractType& dst_type,
13211321
const String& dst_name);
13221322
Fragment CheckArgumentType(LocalVariable* variable, const AbstractType& type);

runtime/vm/compiler/frontend/kernel_to_il.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2223,9 +2223,9 @@ Fragment FlowGraphBuilder::EvaluateAssertion() {
22232223
ICData::kStatic);
22242224
}
22252225

2226-
Fragment FlowGraphBuilder::CheckBooleanInCheckedMode() {
2226+
Fragment FlowGraphBuilder::CheckBoolean() {
22272227
Fragment instructions;
2228-
if (I->type_checks()) {
2228+
if (I->strong() || I->type_checks() || I->asserts()) {
22292229
LocalVariable* top_of_stack = MakeTemporary();
22302230
instructions += LoadLocal(top_of_stack);
22312231
instructions += AssertBool();

0 commit comments

Comments
 (0)