Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(154)

Side by Side Diff: test/cctest/test-assembler-arm64.cc

Issue 2922983002: [arm64] Fix assertion in IsImmLLiteral and enable literal pool tests. (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 235
236 #define CHECK_EQUAL_FP64(expected, result) \ 236 #define CHECK_EQUAL_FP64(expected, result) \
237 CHECK(EqualFP64(expected, &core, result)) 237 CHECK(EqualFP64(expected, &core, result))
238 238
239 // Expected values for 128-bit comparisons are passed as two 64-bit values, 239 // Expected values for 128-bit comparisons are passed as two 64-bit values,
240 // where expected_h (high) is <127:64> and expected_l (low) is <63:0>. 240 // where expected_h (high) is <127:64> and expected_l (low) is <63:0>.
241 #define CHECK_EQUAL_128(expected_h, expected_l, result) \ 241 #define CHECK_EQUAL_128(expected_h, expected_l, result) \
242 CHECK(Equal128(expected_h, expected_l, &core, result)) 242 CHECK(Equal128(expected_h, expected_l, &core, result))
243 243
244 #ifdef DEBUG 244 #ifdef DEBUG
245 #define CHECK_LITERAL_POOL_SIZE(expected) \ 245 #define CHECK_CONSTANT_POOL_SIZE(expected) \
246 CHECK((expected) == (__ LiteralPoolSize())) 246 printf("constant pool size is: %d\n", __ GetConstantPoolEntriesSize()); \
Jarin 2017/06/13 14:21:55 Remove the printf?
georgia.kouveli 2017/06/14 09:46:09 Done.
247 CHECK_EQ(expected, __ GetConstantPoolEntriesSize())
247 #else 248 #else
248 #define CHECK_LITERAL_POOL_SIZE(expected) ((void)0) 249 #define CHECK_CONSTANT_POOL_SIZE(expected) ((void)0)
249 #endif 250 #endif
250 251
251 252
252 TEST(stack_ops) { 253 TEST(stack_ops) {
253 INIT_V8(); 254 INIT_V8();
254 SETUP(); 255 SETUP();
255 256
256 START(); 257 START();
257 // save csp. 258 // save csp.
258 __ Mov(x29, csp); 259 __ Mov(x29, csp);
(...skipping 6423 matching lines...) Expand 10 before | Expand all | Expand 10 after
6682 CHECK_EQUAL_64(0x00000001, x3); 6683 CHECK_EQUAL_64(0x00000001, x3);
6683 CHECK_EQUAL_64(0x0100000000000000L, dst[4]); 6684 CHECK_EQUAL_64(0x0100000000000000L, dst[4]);
6684 CHECK_EQUAL_64(src_base, x17); 6685 CHECK_EQUAL_64(src_base, x17);
6685 CHECK_EQUAL_64(dst_base, x18); 6686 CHECK_EQUAL_64(dst_base, x18);
6686 CHECK_EQUAL_64(src_base + 16, x19); 6687 CHECK_EQUAL_64(src_base + 16, x19);
6687 CHECK_EQUAL_64(dst_base + 32, x20); 6688 CHECK_EQUAL_64(dst_base + 32, x20);
6688 6689
6689 TEARDOWN(); 6690 TEARDOWN();
6690 } 6691 }
6691 6692
6693 TEST(ldr_pcrel_large_offset) {
6694 INIT_V8();
6695 SETUP_SIZE(1 * MB);
6692 6696
6693 #if 0 // TODO(all) enable. 6697 START();
6694 // TODO(rodolph): Adapt w16 Literal tests for RelocInfo. 6698
6699 __ Ldr(x1, Immediate(0x1234567890abcdefUL));
6700
6701 {
6702 v8::internal::PatchingAssembler::BlockPoolsScope scope(&masm);
6703 int start = __ pc_offset();
6704 while (__ pc_offset() - start < 600 * KB) {
6705 __ Nop();
6706 }
6707 }
6708
6709 __ Ldr(x2, Immediate(0x1234567890abcdefUL));
6710
6711 END();
6712
6713 RUN();
6714
6715 CHECK_EQUAL_64(0x1234567890abcdefUL, x1);
6716 CHECK_EQUAL_64(0x1234567890abcdefUL, x2);
6717
6718 TEARDOWN();
6719 }
6720
6695 TEST(ldr_literal) { 6721 TEST(ldr_literal) {
6696 INIT_V8(); 6722 INIT_V8();
6697 SETUP(); 6723 SETUP();
6698 6724
6699 START(); 6725 START();
6700 __ Ldr(x2, 0x1234567890abcdefUL); 6726 __ Ldr(x2, Immediate(0x1234567890abcdefUL));
6701 __ Ldr(w3, 0xfedcba09);
6702 __ Ldr(d13, 1.234); 6727 __ Ldr(d13, 1.234);
6703 __ Ldr(s25, 2.5);
6704 END(); 6728 END();
6705 6729
6706 RUN(); 6730 RUN();
6707 6731
6708 CHECK_EQUAL_64(0x1234567890abcdefUL, x2); 6732 CHECK_EQUAL_64(0x1234567890abcdefUL, x2);
6709 CHECK_EQUAL_64(0xfedcba09, x3);
6710 CHECK_EQUAL_FP64(1.234, d13); 6733 CHECK_EQUAL_FP64(1.234, d13);
6711 CHECK_EQUAL_FP32(2.5, s25);
6712 6734
6713 TEARDOWN(); 6735 TEARDOWN();
6714 } 6736 }
6715 6737
6738 #ifdef DEBUG
6739 // These tests rely on functions available in debug mode.
6740 enum LiteralPoolEmitOption { NoJumpRequired, JumpRequired };
6716 6741
6717 static void LdrLiteralRangeHelper(ptrdiff_t range_, 6742 static void LdrLiteralRangeHelper(int range_, LiteralPoolEmitOption option,
6718 LiteralPoolEmitOption option,
6719 bool expect_dump) { 6743 bool expect_dump) {
6720 CHECK(range_ > 0); 6744 CHECK_GT(range_, 0);
6721 SETUP_SIZE(range_ + 1024); 6745 SETUP_SIZE(range_ + 1024);
6722 6746
6723 Label label_1, label_2; 6747 Label label_1, label_2;
6724 6748
6725 size_t range = static_cast<size_t>(range_); 6749 size_t range = static_cast<size_t>(range_);
6726 size_t code_size = 0; 6750 size_t code_size = 0;
6727 size_t pool_guard_size; 6751 size_t pool_guard_size;
6728 6752
6729 if (option == NoJumpRequired) { 6753 if (option == NoJumpRequired) {
6730 // Space for an explicit branch. 6754 // Space for an explicit branch.
6731 pool_guard_size = sizeof(Instr); 6755 pool_guard_size = kInstructionSize;
6732 } else { 6756 } else {
6733 pool_guard_size = 0; 6757 pool_guard_size = 0;
6734 } 6758 }
6735 6759
6736 START(); 6760 START();
6737 // Force a pool dump so the pool starts off empty. 6761 // Force a pool dump so the pool starts off empty.
6738 __ EmitLiteralPool(JumpRequired); 6762 __ CheckConstPool(true, true);
6739 CHECK_LITERAL_POOL_SIZE(0); 6763 CHECK_CONSTANT_POOL_SIZE(0);
6740 6764
6741 __ Ldr(x0, 0x1234567890abcdefUL); 6765 __ Ldr(x0, Immediate(0x1234567890abcdefUL));
6742 __ Ldr(w1, 0xfedcba09);
6743 __ Ldr(d0, 1.234); 6766 __ Ldr(d0, 1.234);
6744 __ Ldr(s1, 2.5); 6767 CHECK_CONSTANT_POOL_SIZE(16);
6745 CHECK_LITERAL_POOL_SIZE(4);
6746 6768
6747 code_size += 4 * sizeof(Instr); 6769 code_size += 2 * kInstructionSize;
6748 6770
6749 // Check that the requested range (allowing space for a branch over the pool) 6771 // Check that the requested range (allowing space for a branch over the pool)
6750 // can be handled by this test. 6772 // can be handled by this test.
6751 CHECK((code_size + pool_guard_size) <= range); 6773 CHECK_LE(code_size + pool_guard_size, range);
6752 6774
6753 // Emit NOPs up to 'range', leaving space for the pool guard. 6775 // Emit NOPs up to 'range', leaving space for the pool guard.
6754 while ((code_size + pool_guard_size) < range) { 6776 while ((code_size + pool_guard_size + kInstructionSize) < range) {
6755 __ Nop(); 6777 __ Nop();
6756 code_size += sizeof(Instr); 6778 code_size += kInstructionSize;
6757 } 6779 }
6758 6780
6759 // Emit the guard sequence before the literal pool. 6781 // Emit the guard sequence before the literal pool.
6760 if (option == NoJumpRequired) { 6782 if (option == NoJumpRequired) {
6761 __ B(&label_1); 6783 __ B(&label_1);
6762 code_size += sizeof(Instr); 6784 code_size += kInstructionSize;
6763 } 6785 }
6764 6786
6765 CHECK(code_size == range); 6787 // The next instruction will trigger pool emission when expect_dump is true.
6766 CHECK_LITERAL_POOL_SIZE(4); 6788 CHECK_EQ(code_size, range - kInstructionSize);
6789 CHECK_CONSTANT_POOL_SIZE(16);
6767 6790
6768 // Possibly generate a literal pool. 6791 // Possibly generate a literal pool.
6769 __ CheckLiteralPool(option); 6792 __ Nop();
6793
6770 __ Bind(&label_1); 6794 __ Bind(&label_1);
6771 if (expect_dump) { 6795 if (expect_dump) {
6772 CHECK_LITERAL_POOL_SIZE(0); 6796 CHECK_CONSTANT_POOL_SIZE(0);
6773 } else { 6797 } else {
6774 CHECK_LITERAL_POOL_SIZE(4); 6798 CHECK_CONSTANT_POOL_SIZE(16);
6775 } 6799 }
6776 6800
6777 // Force a pool flush to check that a second pool functions correctly. 6801 // Force a pool flush to check that a second pool functions correctly.
6778 __ EmitLiteralPool(JumpRequired); 6802 __ CheckConstPool(true, true);
6779 CHECK_LITERAL_POOL_SIZE(0); 6803 CHECK_CONSTANT_POOL_SIZE(0);
6780 6804
6781 // These loads should be after the pool (and will require a new one). 6805 // These loads should be after the pool (and will require a new one).
6782 __ Ldr(x4, 0x34567890abcdef12UL); 6806 __ Ldr(x4, Immediate(0x34567890abcdef12UL));
6783 __ Ldr(w5, 0xdcba09fe);
6784 __ Ldr(d4, 123.4); 6807 __ Ldr(d4, 123.4);
6785 __ Ldr(s5, 250.0); 6808 CHECK_CONSTANT_POOL_SIZE(16);
6786 CHECK_LITERAL_POOL_SIZE(4);
6787 END(); 6809 END();
6788 6810
6789 RUN(); 6811 RUN();
6790 6812
6791 // Check that the literals loaded correctly. 6813 // Check that the literals loaded correctly.
6792 CHECK_EQUAL_64(0x1234567890abcdefUL, x0); 6814 CHECK_EQUAL_64(0x1234567890abcdefUL, x0);
6793 CHECK_EQUAL_64(0xfedcba09, x1);
6794 CHECK_EQUAL_FP64(1.234, d0); 6815 CHECK_EQUAL_FP64(1.234, d0);
6795 CHECK_EQUAL_FP32(2.5, s1);
6796 CHECK_EQUAL_64(0x34567890abcdef12UL, x4); 6816 CHECK_EQUAL_64(0x34567890abcdef12UL, x4);
6797 CHECK_EQUAL_64(0xdcba09fe, x5);
6798 CHECK_EQUAL_FP64(123.4, d4); 6817 CHECK_EQUAL_FP64(123.4, d4);
6799 CHECK_EQUAL_FP32(250.0, s5);
6800 6818
6801 TEARDOWN(); 6819 TEARDOWN();
6802 } 6820 }
6803 6821
6804
6805 TEST(ldr_literal_range_1) { 6822 TEST(ldr_literal_range_1) {
6806 INIT_V8(); 6823 INIT_V8();
6807 LdrLiteralRangeHelper(kRecommendedLiteralPoolRange, 6824 LdrLiteralRangeHelper(MacroAssembler::GetApproxMaxDistToConstPool(),
6808 NoJumpRequired, 6825 NoJumpRequired, true);
6809 true);
6810 } 6826 }
6811 6827
6812 6828
6813 TEST(ldr_literal_range_2) { 6829 TEST(ldr_literal_range_2) {
6814 INIT_V8(); 6830 INIT_V8();
6815 LdrLiteralRangeHelper(kRecommendedLiteralPoolRange-sizeof(Instr), 6831 LdrLiteralRangeHelper(
6816 NoJumpRequired, 6832 MacroAssembler::GetApproxMaxDistToConstPool() - kInstructionSize,
6817 false); 6833 NoJumpRequired, false);
6818 } 6834 }
6819 6835
6820 6836
6821 TEST(ldr_literal_range_3) { 6837 TEST(ldr_literal_range_3) {
6822 INIT_V8(); 6838 INIT_V8();
6823 LdrLiteralRangeHelper(2 * kRecommendedLiteralPoolRange, 6839 LdrLiteralRangeHelper(MacroAssembler::GetCheckConstPoolInterval(),
6824 JumpRequired, 6840 JumpRequired, false);
6825 true);
6826 } 6841 }
6827 6842
6828 6843
6829 TEST(ldr_literal_range_4) { 6844 TEST(ldr_literal_range_4) {
6830 INIT_V8(); 6845 INIT_V8();
6831 LdrLiteralRangeHelper(2 * kRecommendedLiteralPoolRange-sizeof(Instr), 6846 LdrLiteralRangeHelper(
6832 JumpRequired, 6847 MacroAssembler::GetCheckConstPoolInterval() - kInstructionSize,
6833 false); 6848 JumpRequired, false);
6834 }
6835
6836
6837 TEST(ldr_literal_range_5) {
6838 INIT_V8();
6839 LdrLiteralRangeHelper(kLiteralPoolCheckInterval,
6840 JumpRequired,
6841 false);
6842 }
6843
6844
6845 TEST(ldr_literal_range_6) {
6846 INIT_V8();
6847 LdrLiteralRangeHelper(kLiteralPoolCheckInterval-sizeof(Instr),
6848 JumpRequired,
6849 false);
6850 } 6849 }
6851 #endif 6850 #endif
6852 6851
6853 TEST(add_sub_imm) { 6852 TEST(add_sub_imm) {
6854 INIT_V8(); 6853 INIT_V8();
6855 SETUP(); 6854 SETUP();
6856 6855
6857 START(); 6856 START();
6858 __ Mov(x0, 0x0); 6857 __ Mov(x0, 0x0);
6859 __ Mov(x1, 0x1111); 6858 __ Mov(x1, 0x1111);
(...skipping 8576 matching lines...) Expand 10 before | Expand all | Expand 10 after
15436 __ Mov(x0, 1); 15435 __ Mov(x0, 1);
15437 15436
15438 END(); 15437 END();
15439 15438
15440 RUN(); 15439 RUN();
15441 15440
15442 CHECK_EQUAL_64(0x1, x0); 15441 CHECK_EQUAL_64(0x1, x0);
15443 15442
15444 TEARDOWN(); 15443 TEARDOWN();
15445 } 15444 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698