Skip to content

Commit e299963

Browse files
alexmarkovcommit-bot@chromium.org
authored andcommitted
[VM] Fix out of range immediates on ARM/ARM64
Code generation is changed to handle correctly values of * ArgumentsDescriptor::TypeArgsLenField::mask_in_place() * ArgumentsDescriptor::PositionalCountField::mask_in_place() which cannot be represented as immediates on ARM/ARM64. Closes #31559 Change-Id: I94bb470bf95dcdde48dca56e7128d00b95a974da Reviewed-on: https://dart-review.googlesource.com/27081 Commit-Queue: Vyacheslav Egorov <[email protected]> Reviewed-by: Vyacheslav Egorov <[email protected]>
1 parent 30f154c commit e299963

File tree

2 files changed

+30
-30
lines changed

2 files changed

+30
-30
lines changed

runtime/vm/compiler/backend/flow_graph_compiler_arm.cc

+15-15
Original file line numberDiff line numberDiff line change
@@ -712,9 +712,9 @@ void FlowGraphCompiler::CheckTypeArgsLen(bool expect_type_args,
712712
// If expect_type_args, a non-zero length must match the declaration length.
713713
__ ldr(R6, FieldAddress(R4, ArgumentsDescriptor::type_args_len_offset()));
714714
if (isolate()->strong()) {
715-
__ and_(R6, R6,
716-
Operand(Smi::RawValue(
717-
ArgumentsDescriptor::TypeArgsLenField::mask_in_place())));
715+
__ AndImmediate(
716+
R6, R6,
717+
Smi::RawValue(ArgumentsDescriptor::TypeArgsLenField::mask_in_place()));
718718
}
719719
__ CompareImmediate(R6, Smi::RawValue(0));
720720
if (expect_type_args) {
@@ -751,9 +751,10 @@ void FlowGraphCompiler::CopyParameters(bool expect_type_args,
751751
__ ldr(R6, FieldAddress(R4, ArgumentsDescriptor::positional_count_offset()));
752752

753753
if (isolate()->strong()) {
754-
__ and_(R6, R6,
755-
Operand(Smi::RawValue(
756-
ArgumentsDescriptor::PositionalCountField::mask_in_place())));
754+
__ AndImmediate(
755+
R6, R6,
756+
Smi::RawValue(
757+
ArgumentsDescriptor::PositionalCountField::mask_in_place()));
757758
}
758759

759760
// Check that min_num_pos_args <= num_pos_args.
@@ -843,10 +844,10 @@ void FlowGraphCompiler::CopyParameters(bool expect_type_args,
843844
// fp[kParamEndSlotFromFp + num_args - arg_pos].
844845
__ ldr(R9, Address(R8, ArgumentsDescriptor::position_offset()));
845846
if (isolate()->strong()) {
846-
__ and_(
847+
__ AndImmediate(
847848
R9, R9,
848-
Operand(Smi::RawValue(
849-
ArgumentsDescriptor::PositionalCountField::mask_in_place())));
849+
Smi::RawValue(
850+
ArgumentsDescriptor::PositionalCountField::mask_in_place()));
850851
}
851852
// R9 is arg_pos as Smi.
852853
// Point to next named entry.
@@ -884,9 +885,8 @@ void FlowGraphCompiler::CopyParameters(bool expect_type_args,
884885
FieldAddress(R4, ArgumentsDescriptor::positional_count_offset()));
885886
__ SmiUntag(R6);
886887
if (isolate()->strong()) {
887-
__ and_(
888-
R6, R6,
889-
Operand(ArgumentsDescriptor::PositionalCountField::mask_in_place()));
888+
__ AndImmediate(
889+
R6, R6, ArgumentsDescriptor::PositionalCountField::mask_in_place());
890890
}
891891
for (int i = 0; i < num_opt_pos_params; i++) {
892892
Label next_parameter;
@@ -1062,10 +1062,10 @@ void FlowGraphCompiler::CompileGraph() {
10621062
__ ldr(R1,
10631063
FieldAddress(R4, ArgumentsDescriptor::positional_count_offset()));
10641064
if (isolate()->strong()) {
1065-
__ and_(
1065+
__ AndImmediate(
10661066
R1, R1,
1067-
Operand(Smi::RawValue(
1068-
ArgumentsDescriptor::PositionalCountField::mask_in_place())));
1067+
Smi::RawValue(
1068+
ArgumentsDescriptor::PositionalCountField::mask_in_place()));
10691069
}
10701070
__ cmp(R0, Operand(R1));
10711071
__ b(&correct_num_arguments, EQ);

runtime/vm/compiler/backend/flow_graph_compiler_arm64.cc

+15-15
Original file line numberDiff line numberDiff line change
@@ -689,9 +689,9 @@ void FlowGraphCompiler::CheckTypeArgsLen(bool expect_type_args,
689689
// If expect_type_args, a non-zero length must match the declaration length.
690690
__ LoadFieldFromOffset(R8, R4, ArgumentsDescriptor::type_args_len_offset());
691691
if (isolate()->strong()) {
692-
__ and_(R8, R8,
693-
Operand(Smi::RawValue(
694-
ArgumentsDescriptor::TypeArgsLenField::mask_in_place())));
692+
__ AndImmediate(
693+
R8, R8,
694+
Smi::RawValue(ArgumentsDescriptor::TypeArgsLenField::mask_in_place()));
695695
}
696696
__ CompareImmediate(R8, Smi::RawValue(0));
697697
if (expect_type_args) {
@@ -730,9 +730,10 @@ void FlowGraphCompiler::CopyParameters(bool expect_type_args,
730730
ArgumentsDescriptor::positional_count_offset());
731731

732732
if (isolate()->strong()) {
733-
__ and_(R8, R8,
734-
Operand(Smi::RawValue(
735-
ArgumentsDescriptor::PositionalCountField::mask_in_place())));
733+
__ AndImmediate(
734+
R8, R8,
735+
Smi::RawValue(
736+
ArgumentsDescriptor::PositionalCountField::mask_in_place()));
736737
}
737738

738739
// Check that min_num_pos_args <= num_pos_args.
@@ -822,10 +823,10 @@ void FlowGraphCompiler::CopyParameters(bool expect_type_args,
822823
// fp[kParamEndSlotFromFp + num_args - arg_pos].
823824
__ LoadFromOffset(R5, R6, ArgumentsDescriptor::position_offset());
824825
if (isolate()->strong()) {
825-
__ and_(
826+
__ AndImmediate(
826827
R5, R5,
827-
Operand(Smi::RawValue(
828-
ArgumentsDescriptor::PositionalCountField::mask_in_place())));
828+
Smi::RawValue(
829+
ArgumentsDescriptor::PositionalCountField::mask_in_place()));
829830
}
830831
// R5 is arg_pos as Smi.
831832
// Point to next named entry.
@@ -863,9 +864,8 @@ void FlowGraphCompiler::CopyParameters(bool expect_type_args,
863864
ArgumentsDescriptor::positional_count_offset());
864865
__ SmiUntag(R8);
865866
if (isolate()->strong()) {
866-
__ and_(
867-
R8, R8,
868-
Operand(ArgumentsDescriptor::PositionalCountField::mask_in_place()));
867+
__ AndImmediate(
868+
R8, R8, ArgumentsDescriptor::PositionalCountField::mask_in_place());
869869
}
870870
for (int i = 0; i < num_opt_pos_params; i++) {
871871
Label next_parameter;
@@ -1046,10 +1046,10 @@ void FlowGraphCompiler::CompileGraph() {
10461046
__ LoadFieldFromOffset(R1, R4,
10471047
ArgumentsDescriptor::positional_count_offset());
10481048
if (isolate()->strong()) {
1049-
__ and_(
1049+
__ AndImmediate(
10501050
R1, R1,
1051-
Operand(Smi::RawValue(
1052-
ArgumentsDescriptor::PositionalCountField::mask_in_place())));
1051+
Smi::RawValue(
1052+
ArgumentsDescriptor::PositionalCountField::mask_in_place()));
10531053
}
10541054
__ CompareRegisters(R0, R1);
10551055
__ b(&correct_num_arguments, EQ);

0 commit comments

Comments
 (0)