Skip to content

Commit 5df6c55

Browse files
mkustermanncommit-bot@chromium.org
authored andcommitted
[VM] Improve AssertAssignable/InstanceOf by having a fast case for non-generic, instantiated types
When the type to test against is instantiated and has no type arguments there is a high probability that we receive instances of that class or subclasses at runtime. This CL therefore extends the fast-path of AssertAssignable/InstanceOf by checking whether the instance class id is within the cid ranges that directly/indirectly implement/extend the type to test against. Currently we have an almost depth-first preorder numbering of class ids in AOT, but there are exceptions. So each class can have a number of cid-ranges as subclasses / classes which implement it's interface. This seems to improve performance of dart-aot-v2 * flutter stock build by 15+% * DeltaBlueClosures by 10+% and reduces code size on * flutter gallery by -3% Issue dart-lang#31798 Change-Id: I07dd91589cc3fcd8c5952bdba339e2e2a459e08e Reviewed-on: https://dart-review.googlesource.com/35620 Commit-Queue: Martin Kustermann <[email protected]> Reviewed-by: Régis Crelier <[email protected]> Reviewed-by: Vyacheslav Egorov <[email protected]>
1 parent 8c4e1b0 commit 5df6c55

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

assembler_ia32.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,10 @@ class Assembler : public ValueObject {
643643
void AddImmediate(Register reg, const Immediate& imm);
644644
void SubImmediate(Register reg, const Immediate& imm);
645645

646+
void CompareImmediate(Register reg, int32_t immediate) {
647+
cmpl(reg, Immediate(immediate));
648+
}
649+
646650
void Drop(intptr_t stack_elements);
647651

648652
void LoadIsolate(Register dst);

assembler_x64.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,9 @@ class Assembler : public ValueObject {
582582

583583
void CompareImmediate(Register reg, const Immediate& imm);
584584
void CompareImmediate(const Address& address, const Immediate& imm);
585+
void CompareImmediate(Register reg, int32_t immediate) {
586+
return CompareImmediate(reg, Immediate(immediate));
587+
}
585588

586589
void testl(Register reg, const Immediate& imm) { testq(reg, imm); }
587590
void testb(const Address& address, const Immediate& imm);

0 commit comments

Comments
 (0)