Skip to content

Commit f7078b3

Browse files
alexmarkovcommit-bot@chromium.org
authored andcommitted
[vm/compiler] Fix Handle passed to AllocateObject instruction while generating constructor tear-off
All handles passed to IL instructions should be ZoneHandles. Recently added code for generating constructor tear-offs has been passing Handle instead of ZoneHandle by mistake. This change fixes the bug and adds assertions to AllocateObjectInstr so it would check handle type earlier and on all platforms. TEST=co19/LanguageFeatures/Constructor-tear-offs in debug/ia32 mode Issue #46231 Change-Id: I99e6889e59bf40f4788a7f3c6d37dad89aa91ab0 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208686 Reviewed-by: Martin Kustermann <[email protected]> Commit-Queue: Alexander Markov <[email protected]>
1 parent 59069f3 commit f7078b3

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

runtime/vm/compiler/backend/il.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6171,6 +6171,8 @@ class AllocateObjectInstr : public AllocationInstr {
61716171
: AllocationInstr(source, deopt_id),
61726172
cls_(cls),
61736173
type_arguments_(type_arguments) {
6174+
ASSERT(cls.IsZoneHandle());
6175+
ASSERT(!cls.IsNull());
61746176
ASSERT((cls.NumTypeArguments() > 0) == (type_arguments != nullptr));
61756177
if (type_arguments != nullptr) {
61766178
SetInputAt(kTypeArgumentsPos, type_arguments);

runtime/vm/compiler/backend/redundancy_elimination_test.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ static void TestAliasingViaRedefinition(
219219
const Library& lib =
220220
Library::Handle(LoadTestScript(script_chars, NoopNativeLookup));
221221

222-
const Class& cls = Class::Handle(
222+
const Class& cls = Class::ZoneHandle(
223223
lib.LookupLocalClass(String::Handle(Symbols::New(thread, "K"))));
224224
const Error& err = Error::Handle(cls.EnsureIsFinalized(thread));
225225
EXPECT(err.IsNull());
@@ -383,7 +383,7 @@ static void TestAliasingViaStore(
383383
const Library& lib =
384384
Library::Handle(LoadTestScript(script_chars, NoopNativeLookup));
385385

386-
const Class& cls = Class::Handle(
386+
const Class& cls = Class::ZoneHandle(
387387
lib.LookupLocalClass(String::Handle(Symbols::New(thread, "K"))));
388388
const Error& err = Error::Handle(cls.EnsureIsFinalized(thread));
389389
EXPECT(err.IsNull());

runtime/vm/compiler/frontend/kernel_to_il.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3450,7 +3450,7 @@ FlowGraph* FlowGraphBuilder::BuildGraphOfImplicitClosureFunction(
34503450

34513451
// Push receiver.
34523452
if (target.IsGenerativeConstructor()) {
3453-
const Class& cls = Class::Handle(Z, target.Owner());
3453+
const Class& cls = Class::ZoneHandle(Z, target.Owner());
34543454
if (cls.NumTypeArguments() > 0) {
34553455
if (!function.IsGeneric()) {
34563456
Type& cls_type = Type::Handle(Z, cls.DeclarationType());

0 commit comments

Comments
 (0)