[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 https://github.com/dart-lang/sdk/issues/31559

Change-Id: I94bb470bf95dcdde48dca56e7128d00b95a974da
Reviewed-on: https://dart-review.googlesource.com/27081
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
This commit is contained in:
Alexander Markov 2017-12-07 05:17:51 +00:00 committed by commit-bot@chromium.org
parent 30f154c8ea
commit e299963a3c
2 changed files with 30 additions and 30 deletions

View file

@ -712,9 +712,9 @@ void FlowGraphCompiler::CheckTypeArgsLen(bool expect_type_args,
// If expect_type_args, a non-zero length must match the declaration length.
__ ldr(R6, FieldAddress(R4, ArgumentsDescriptor::type_args_len_offset()));
if (isolate()->strong()) {
__ and_(R6, R6,
Operand(Smi::RawValue(
ArgumentsDescriptor::TypeArgsLenField::mask_in_place())));
__ AndImmediate(
R6, R6,
Smi::RawValue(ArgumentsDescriptor::TypeArgsLenField::mask_in_place()));
}
__ CompareImmediate(R6, Smi::RawValue(0));
if (expect_type_args) {
@ -751,9 +751,10 @@ void FlowGraphCompiler::CopyParameters(bool expect_type_args,
__ ldr(R6, FieldAddress(R4, ArgumentsDescriptor::positional_count_offset()));
if (isolate()->strong()) {
__ and_(R6, R6,
Operand(Smi::RawValue(
ArgumentsDescriptor::PositionalCountField::mask_in_place())));
__ AndImmediate(
R6, R6,
Smi::RawValue(
ArgumentsDescriptor::PositionalCountField::mask_in_place()));
}
// Check that min_num_pos_args <= num_pos_args.
@ -843,10 +844,10 @@ void FlowGraphCompiler::CopyParameters(bool expect_type_args,
// fp[kParamEndSlotFromFp + num_args - arg_pos].
__ ldr(R9, Address(R8, ArgumentsDescriptor::position_offset()));
if (isolate()->strong()) {
__ and_(
__ AndImmediate(
R9, R9,
Operand(Smi::RawValue(
ArgumentsDescriptor::PositionalCountField::mask_in_place())));
Smi::RawValue(
ArgumentsDescriptor::PositionalCountField::mask_in_place()));
}
// R9 is arg_pos as Smi.
// Point to next named entry.
@ -884,9 +885,8 @@ void FlowGraphCompiler::CopyParameters(bool expect_type_args,
FieldAddress(R4, ArgumentsDescriptor::positional_count_offset()));
__ SmiUntag(R6);
if (isolate()->strong()) {
__ and_(
R6, R6,
Operand(ArgumentsDescriptor::PositionalCountField::mask_in_place()));
__ AndImmediate(
R6, R6, ArgumentsDescriptor::PositionalCountField::mask_in_place());
}
for (int i = 0; i < num_opt_pos_params; i++) {
Label next_parameter;
@ -1062,10 +1062,10 @@ void FlowGraphCompiler::CompileGraph() {
__ ldr(R1,
FieldAddress(R4, ArgumentsDescriptor::positional_count_offset()));
if (isolate()->strong()) {
__ and_(
__ AndImmediate(
R1, R1,
Operand(Smi::RawValue(
ArgumentsDescriptor::PositionalCountField::mask_in_place())));
Smi::RawValue(
ArgumentsDescriptor::PositionalCountField::mask_in_place()));
}
__ cmp(R0, Operand(R1));
__ b(&correct_num_arguments, EQ);

View file

@ -689,9 +689,9 @@ void FlowGraphCompiler::CheckTypeArgsLen(bool expect_type_args,
// If expect_type_args, a non-zero length must match the declaration length.
__ LoadFieldFromOffset(R8, R4, ArgumentsDescriptor::type_args_len_offset());
if (isolate()->strong()) {
__ and_(R8, R8,
Operand(Smi::RawValue(
ArgumentsDescriptor::TypeArgsLenField::mask_in_place())));
__ AndImmediate(
R8, R8,
Smi::RawValue(ArgumentsDescriptor::TypeArgsLenField::mask_in_place()));
}
__ CompareImmediate(R8, Smi::RawValue(0));
if (expect_type_args) {
@ -730,9 +730,10 @@ void FlowGraphCompiler::CopyParameters(bool expect_type_args,
ArgumentsDescriptor::positional_count_offset());
if (isolate()->strong()) {
__ and_(R8, R8,
Operand(Smi::RawValue(
ArgumentsDescriptor::PositionalCountField::mask_in_place())));
__ AndImmediate(
R8, R8,
Smi::RawValue(
ArgumentsDescriptor::PositionalCountField::mask_in_place()));
}
// Check that min_num_pos_args <= num_pos_args.
@ -822,10 +823,10 @@ void FlowGraphCompiler::CopyParameters(bool expect_type_args,
// fp[kParamEndSlotFromFp + num_args - arg_pos].
__ LoadFromOffset(R5, R6, ArgumentsDescriptor::position_offset());
if (isolate()->strong()) {
__ and_(
__ AndImmediate(
R5, R5,
Operand(Smi::RawValue(
ArgumentsDescriptor::PositionalCountField::mask_in_place())));
Smi::RawValue(
ArgumentsDescriptor::PositionalCountField::mask_in_place()));
}
// R5 is arg_pos as Smi.
// Point to next named entry.
@ -863,9 +864,8 @@ void FlowGraphCompiler::CopyParameters(bool expect_type_args,
ArgumentsDescriptor::positional_count_offset());
__ SmiUntag(R8);
if (isolate()->strong()) {
__ and_(
R8, R8,
Operand(ArgumentsDescriptor::PositionalCountField::mask_in_place()));
__ AndImmediate(
R8, R8, ArgumentsDescriptor::PositionalCountField::mask_in_place());
}
for (int i = 0; i < num_opt_pos_params; i++) {
Label next_parameter;
@ -1046,10 +1046,10 @@ void FlowGraphCompiler::CompileGraph() {
__ LoadFieldFromOffset(R1, R4,
ArgumentsDescriptor::positional_count_offset());
if (isolate()->strong()) {
__ and_(
__ AndImmediate(
R1, R1,
Operand(Smi::RawValue(
ArgumentsDescriptor::PositionalCountField::mask_in_place())));
Smi::RawValue(
ArgumentsDescriptor::PositionalCountField::mask_in_place()));
}
__ CompareRegisters(R0, R1);
__ b(&correct_num_arguments, EQ);