From de310a0c7b6507d6ea1313cdc1d7a018254d4a50 Mon Sep 17 00:00:00 2001 From: Ryan Macnak Date: Mon, 12 Dec 2022 23:23:53 +0000 Subject: [PATCH] [vm, compiler] Fix address encoding limit when loading type arguments. TEST=ci Bug: https://github.com/dart-lang/sdk/issues/50671 Change-Id: I3a5ab9492d74fa770efd8e4c7cf90002a3793b9a Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/275081 Commit-Queue: Ryan Macnak Reviewed-by: Alexander Markov --- .../compiler/backend/flow_graph_compiler.cc | 8 +- .../medium_offset_type_parameter_test.dart | 560 ++++++++++++++++++ 2 files changed, 563 insertions(+), 5 deletions(-) create mode 100644 tests/language/scaling/medium_offset_type_parameter_test.dart diff --git a/runtime/vm/compiler/backend/flow_graph_compiler.cc b/runtime/vm/compiler/backend/flow_graph_compiler.cc index c85ffd73d0c..b7f48735155 100644 --- a/runtime/vm/compiler/backend/flow_graph_compiler.cc +++ b/runtime/vm/compiler/backend/flow_graph_compiler.cc @@ -3248,11 +3248,9 @@ void FlowGraphCompiler::GenerateCallerChecksForAssertAssignable( __ BranchIf(EQUAL, done); // Put the instantiated type parameter into the scratch register, so its // TTS can be called by the caller. - __ LoadCompressedField( - TypeTestABI::kScratchReg, - compiler::FieldAddress(kTypeArgumentsReg, - compiler::target::TypeArguments::type_at_offset( - type_param.index()))); + __ LoadCompressedFieldFromOffset( + TypeTestABI::kScratchReg, kTypeArgumentsReg, + compiler::target::TypeArguments::type_at_offset(type_param.index())); return output_dst_type(); } diff --git a/tests/language/scaling/medium_offset_type_parameter_test.dart b/tests/language/scaling/medium_offset_type_parameter_test.dart new file mode 100644 index 00000000000..13a66c7f26c --- /dev/null +++ b/tests/language/scaling/medium_offset_type_parameter_test.dart @@ -0,0 +1,560 @@ +// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +// VMOptions=--optimization-counter-threshold=100 --no-use-osr --no-background-compilation + +class C< + T0, + T1, + T2, + T3, + T4, + T5, + T6, + T7, + T8, + T9, + T10, + T11, + T12, + T13, + T14, + T15, + T16, + T17, + T18, + T19, + T20, + T21, + T22, + T23, + T24, + T25, + T26, + T27, + T28, + T29, + T30, + T31, + T32, + T33, + T34, + T35, + T36, + T37, + T38, + T39, + T40, + T41, + T42, + T43, + T44, + T45, + T46, + T47, + T48, + T49, + T50, + T51, + T52, + T53, + T54, + T55, + T56, + T57, + T58, + T59, + T60, + T61, + T62, + T63, + T64, + T65, + T66, + T67, + T68, + T69, + T70, + T71, + T72, + T73, + T74, + T75, + T76, + T77, + T78, + T79, + T80, + T81, + T82, + T83, + T84, + T85, + T86, + T87, + T88, + T89, + T90, + T91, + T92, + T93, + T94, + T95, + T96, + T97, + T98, + T99, + T100, + T101, + T102, + T103, + T104, + T105, + T106, + T107, + T108, + T109, + T110, + T111, + T112, + T113, + T114, + T115, + T116, + T117, + T118, + T119, + T120, + T121, + T122, + T123, + T124, + T125, + T126, + T127, + T128, + T129, + T130, + T131, + T132, + T133, + T134, + T135, + T136, + T137, + T138, + T139, + T140, + T141, + T142, + T143, + T144, + T145, + T146, + T147, + T148, + T149, + T150, + T151, + T152, + T153, + T154, + T155, + T156, + T157, + T158, + T159, + T160, + T161, + T162, + T163, + T164, + T165, + T166, + T167, + T168, + T169, + T170, + T171, + T172, + T173, + T174, + T175, + T176, + T177, + T178, + T179, + T180, + T181, + T182, + T183, + T184, + T185, + T186, + T187, + T188, + T189, + T190, + T191, + T192, + T193, + T194, + T195, + T196, + T197, + T198, + T199, + T200, + T201, + T202, + T203, + T204, + T205, + T206, + T207, + T208, + T209, + T210, + T211, + T212, + T213, + T214, + T215, + T216, + T217, + T218, + T219, + T220, + T221, + T222, + T223, + T224, + T225, + T226, + T227, + T228, + T229, + T230, + T231, + T232, + T233, + T234, + T235, + T236, + T237, + T238, + T239, + T240, + T241, + T242, + T243, + T244, + T245, + T246, + T247, + T248, + T249, + T250, + T251, + T252, + T253, + T254, + T255> { + @pragma("vm:never-inline") + static create() { + return new C< + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + double, + T>(); + } + + @pragma("vm:never-inline") + @pragma("vm:entry-point") // Stop TFA + @pragma("dart2js:noInline") + dynamic checkIs(dynamic x) => x is T255; + + @pragma("vm:never-inline") + @pragma("vm:entry-point") // Stop TFA + @pragma("dart2js:noInline") + dynamic checkAs(dynamic x) => x as T255; + + @pragma("vm:never-inline") + @pragma("vm:entry-point") // Stop TFA + @pragma("dart2js:noInline") + dynamic checkInstantiate() => new G>(); +} + +class G {} + +main() { + for (var i = 0; i < 101; i++) { + var c1 = C.create(); + if (c1.checkIs(42) != true) throw "Wrong is"; + if (c1.checkAs(42) != 42) throw "Wrong as"; + if (c1.checkInstantiate() is! G>) throw "Wrong instantiate"; + + var c2 = C.create(); + if (c2.checkIs(42.0) != true) throw "Wrong is"; + if (c2.checkAs(42.0) != 42.0) throw "Wrong as"; + if (c2.checkInstantiate() is! G>) throw "Wrong instantiate"; + + var c3 = C.create(); + if (c3.checkIs("42") != true) throw "Wrong is"; + if (c3.checkAs("42") != "42") throw "Wrong as"; + if (c3.checkInstantiate() is! G>) throw "Wrong instantiate"; + } +}