Skip to content

Commit fe572ec

Browse files
mkustermanncommit-bot@chromium.org
authored andcommitted
[VM] Introduction of type testing stubs - Part 1
This CL: * Adds a field to [RawAbstractType] which will always hold a pointer to the entrypoint of a type testing stub * Makes this new field be initialized to a default stub whenever a instances are created (e.g. via Type::New(), snapshot reader, ...) * Makes the clustered snapshotter write a reference to the corresponding [RawInstructions] object when writing the field and do the reverse when reading it. * Makes us call the type testing stub for performing assert-assignable checks. To reduce unnecessary loads on callsites, we store the entrypoint of the type testing stubs directly in the type objects. This means that the caller of type testing stubs can simply branch there without populating a code object first. This also means that the type testing stubs themselves have no access to a pool and we therefore also don't hold on to the [Code] object, only the [Instruction] object is necessary. The type testing stubs do not setup a frame themselves and also have no safepoint. In the case when the type testing stubs could not determine a positive answer they will tail-call a general-purpose stub. The general-purpose stub sets up a stub frame, tries to consult a [SubtypeTestCache] and bails out to runtime if this was unsuccessful. This CL is just the the first, for ease of reviewing. The actual type-specialized type testing stubs will be generated in later CLs. Issue dart-lang#31798 Change-Id: I174a11b3b812799f399a60af799144c2ba3c26ec Reviewed-on: https://dart-review.googlesource.com/44787 Reviewed-by: Vyacheslav Egorov <[email protected]> Reviewed-by: Régis Crelier <[email protected]>
1 parent ec105c9 commit fe572ec

File tree

4 files changed

+18
-1
lines changed

4 files changed

+18
-1
lines changed

assembler_arm.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,13 @@ class Assembler : public ValueObject {
353353
void Bind(Label* label);
354354
void Jump(Label* label) { b(label); }
355355

356+
void LoadField(Register dst, FieldAddress address) { ldr(dst, address); }
357+
358+
void CompareWithFieldValue(Register value, FieldAddress address) {
359+
ldr(TMP, address);
360+
cmp(value, Operand(TMP));
361+
}
362+
356363
// Misc. functionality
357364
intptr_t CodeSize() const { return buffer_.Size(); }
358365
intptr_t prologue_offset() const { return prologue_offset_; }

assembler_arm64.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,8 @@ class Assembler : public ValueObject {
438438
void Bind(Label* label);
439439
void Jump(Label* label) { b(label); }
440440

441+
void LoadField(Register dst, FieldAddress address) { ldr(dst, address); }
442+
441443
// Misc. functionality
442444
intptr_t CodeSize() const { return buffer_.Size(); }
443445
intptr_t prologue_offset() const { return prologue_offset_; }
@@ -1506,6 +1508,7 @@ class Assembler : public ValueObject {
15061508

15071509
void EnterFrame(intptr_t frame_size);
15081510
void LeaveFrame();
1511+
void Ret() { ret(LR); }
15091512

15101513
void CheckCodePointer();
15111514
void RestoreCodePointer();

assembler_x64.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -651,6 +651,7 @@ class Assembler : public ValueObject {
651651
}
652652

653653
// Methods for High-level operations and implemented on all architectures.
654+
void Ret() { ret(); }
654655
void CompareRegisters(Register a, Register b);
655656
void BranchIf(Condition condition, Label* label) { j(condition, label); }
656657

@@ -799,6 +800,12 @@ class Assembler : public ValueObject {
799800
void Bind(Label* label);
800801
void Jump(Label* label) { jmp(label); }
801802

803+
void LoadField(Register dst, FieldAddress address) { movq(dst, address); }
804+
805+
void CompareWithFieldValue(Register value, FieldAddress address) {
806+
cmpq(value, address);
807+
}
808+
802809
void Comment(const char* format, ...) PRINTF_ATTRIBUTE(2, 3);
803810
static bool EmittingComments();
804811

assembler_x64_test.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3226,7 +3226,7 @@ ASSEMBLER_TEST_RUN(PackedDoubleNegate, test) {
32263226
EXPECT_FLOAT_EQ(-1.0, res, 0.000001f);
32273227
EXPECT_DISASSEMBLY_NOT_WINDOWS_ENDS_WITH(
32283228
"movups xmm10,[rax]\n"
3229-
"movq r11,[thr+0xf8]\n"
3229+
"movq r11,[thr+0x...]\n"
32303230
"xorpd xmm10,[r11]\n"
32313231
"movaps xmm0,xmm10\n"
32323232
"pop thr\n"

0 commit comments

Comments
 (0)