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

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: Address comments. 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
« no previous file with comments | « src/arm64/assembler-arm64.cc ('k') | test/cctest/test-disasm-arm64.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 CHECK_EQ(expected, __ GetConstantPoolEntriesSizeForTesting())
247 #else 247 #else
248 #define CHECK_LITERAL_POOL_SIZE(expected) ((void)0) 248 #define CHECK_CONSTANT_POOL_SIZE(expected) ((void)0)
249 #endif 249 #endif
250 250
251 251
252 TEST(stack_ops) { 252 TEST(stack_ops) {
253 INIT_V8(); 253 INIT_V8();
254 SETUP(); 254 SETUP();
255 255
256 START(); 256 START();
257 // save csp. 257 // save csp.
258 __ Mov(x29, csp); 258 __ Mov(x29, csp);
(...skipping 6423 matching lines...) Expand 10 before | Expand all | Expand 10 after
6682 CHECK_EQUAL_64(0x00000001, x3); 6682 CHECK_EQUAL_64(0x00000001, x3);
6683 CHECK_EQUAL_64(0x0100000000000000L, dst[4]); 6683 CHECK_EQUAL_64(0x0100000000000000L, dst[4]);
6684 CHECK_EQUAL_64(src_base, x17); 6684 CHECK_EQUAL_64(src_base, x17);
6685 CHECK_EQUAL_64(dst_base, x18); 6685 CHECK_EQUAL_64(dst_base, x18);
6686 CHECK_EQUAL_64(src_base + 16, x19); 6686 CHECK_EQUAL_64(src_base + 16, x19);
6687 CHECK_EQUAL_64(dst_base + 32, x20); 6687 CHECK_EQUAL_64(dst_base + 32, x20);
6688 6688
6689 TEARDOWN(); 6689 TEARDOWN();
6690 } 6690 }
6691 6691
6692 TEST(ldr_pcrel_large_offset) {
6693 INIT_V8();
6694 SETUP_SIZE(1 * MB);
6692 6695
6693 #if 0 // TODO(all) enable. 6696 START();
6694 // TODO(rodolph): Adapt w16 Literal tests for RelocInfo. 6697
6698 __ Ldr(x1, Immediate(0x1234567890abcdefUL));
6699
6700 {
6701 v8::internal::PatchingAssembler::BlockPoolsScope scope(&masm);
6702 int start = __ pc_offset();
6703 while (__ pc_offset() - start < 600 * KB) {
6704 __ Nop();
6705 }
6706 }
6707
6708 __ Ldr(x2, Immediate(0x1234567890abcdefUL));
6709
6710 END();
6711
6712 RUN();
6713
6714 CHECK_EQUAL_64(0x1234567890abcdefUL, x1);
6715 CHECK_EQUAL_64(0x1234567890abcdefUL, x2);
6716
6717 TEARDOWN();
6718 }
6719
6695 TEST(ldr_literal) { 6720 TEST(ldr_literal) {
6696 INIT_V8(); 6721 INIT_V8();
6697 SETUP(); 6722 SETUP();
6698 6723
6699 START(); 6724 START();
6700 __ Ldr(x2, 0x1234567890abcdefUL); 6725 __ Ldr(x2, Immediate(0x1234567890abcdefUL));
6701 __ Ldr(w3, 0xfedcba09);
6702 __ Ldr(d13, 1.234); 6726 __ Ldr(d13, 1.234);
6703 __ Ldr(s25, 2.5);
6704 END(); 6727 END();
6705 6728
6706 RUN(); 6729 RUN();
6707 6730
6708 CHECK_EQUAL_64(0x1234567890abcdefUL, x2); 6731 CHECK_EQUAL_64(0x1234567890abcdefUL, x2);
6709 CHECK_EQUAL_64(0xfedcba09, x3);
6710 CHECK_EQUAL_FP64(1.234, d13); 6732 CHECK_EQUAL_FP64(1.234, d13);
6711 CHECK_EQUAL_FP32(2.5, s25);
6712 6733
6713 TEARDOWN(); 6734 TEARDOWN();
6714 } 6735 }
6715 6736
6737 #ifdef DEBUG
6738 // These tests rely on functions available in debug mode.
6739 enum LiteralPoolEmitOption { NoJumpRequired, JumpRequired };
6716 6740
6717 static void LdrLiteralRangeHelper(ptrdiff_t range_, 6741 static void LdrLiteralRangeHelper(int range_, LiteralPoolEmitOption option,
6718 LiteralPoolEmitOption option,
6719 bool expect_dump) { 6742 bool expect_dump) {
6720 CHECK(range_ > 0); 6743 CHECK_GT(range_, 0);
6721 SETUP_SIZE(range_ + 1024); 6744 SETUP_SIZE(range_ + 1024);
6722 6745
6723 Label label_1, label_2; 6746 Label label_1, label_2;
6724 6747
6725 size_t range = static_cast<size_t>(range_); 6748 size_t range = static_cast<size_t>(range_);
6726 size_t code_size = 0; 6749 size_t code_size = 0;
6727 size_t pool_guard_size; 6750 size_t pool_guard_size;
6728 6751
6729 if (option == NoJumpRequired) { 6752 if (option == NoJumpRequired) {
6730 // Space for an explicit branch. 6753 // Space for an explicit branch.
6731 pool_guard_size = sizeof(Instr); 6754 pool_guard_size = kInstructionSize;
6732 } else { 6755 } else {
6733 pool_guard_size = 0; 6756 pool_guard_size = 0;
6734 } 6757 }
6735 6758
6736 START(); 6759 START();
6737 // Force a pool dump so the pool starts off empty. 6760 // Force a pool dump so the pool starts off empty.
6738 __ EmitLiteralPool(JumpRequired); 6761 __ CheckConstPool(true, true);
6739 CHECK_LITERAL_POOL_SIZE(0); 6762 CHECK_CONSTANT_POOL_SIZE(0);
6740 6763
6741 __ Ldr(x0, 0x1234567890abcdefUL); 6764 __ Ldr(x0, Immediate(0x1234567890abcdefUL));
6742 __ Ldr(w1, 0xfedcba09);
6743 __ Ldr(d0, 1.234); 6765 __ Ldr(d0, 1.234);
6744 __ Ldr(s1, 2.5); 6766 CHECK_CONSTANT_POOL_SIZE(16);
6745 CHECK_LITERAL_POOL_SIZE(4);
6746 6767
6747 code_size += 4 * sizeof(Instr); 6768 code_size += 2 * kInstructionSize;
6748 6769
6749 // Check that the requested range (allowing space for a branch over the pool) 6770 // Check that the requested range (allowing space for a branch over the pool)
6750 // can be handled by this test. 6771 // can be handled by this test.
6751 CHECK((code_size + pool_guard_size) <= range); 6772 CHECK_LE(code_size + pool_guard_size, range);
6752 6773
6753 // Emit NOPs up to 'range', leaving space for the pool guard. 6774 // Emit NOPs up to 'range', leaving space for the pool guard.
6754 while ((code_size + pool_guard_size) < range) { 6775 while ((code_size + pool_guard_size + kInstructionSize) < range) {
6755 __ Nop(); 6776 __ Nop();
6756 code_size += sizeof(Instr); 6777 code_size += kInstructionSize;
6757 } 6778 }
6758 6779
6759 // Emit the guard sequence before the literal pool. 6780 // Emit the guard sequence before the literal pool.
6760 if (option == NoJumpRequired) { 6781 if (option == NoJumpRequired) {
6761 __ B(&label_1); 6782 __ B(&label_1);
6762 code_size += sizeof(Instr); 6783 code_size += kInstructionSize;
6763 } 6784 }
6764 6785
6765 CHECK(code_size == range); 6786 // The next instruction will trigger pool emission when expect_dump is true.
6766 CHECK_LITERAL_POOL_SIZE(4); 6787 CHECK_EQ(code_size, range - kInstructionSize);
6788 CHECK_CONSTANT_POOL_SIZE(16);
6767 6789
6768 // Possibly generate a literal pool. 6790 // Possibly generate a literal pool.
6769 __ CheckLiteralPool(option); 6791 __ Nop();
6792
6770 __ Bind(&label_1); 6793 __ Bind(&label_1);
6771 if (expect_dump) { 6794 if (expect_dump) {
6772 CHECK_LITERAL_POOL_SIZE(0); 6795 CHECK_CONSTANT_POOL_SIZE(0);
6773 } else { 6796 } else {
6774 CHECK_LITERAL_POOL_SIZE(4); 6797 CHECK_CONSTANT_POOL_SIZE(16);
6775 } 6798 }
6776 6799
6777 // Force a pool flush to check that a second pool functions correctly. 6800 // Force a pool flush to check that a second pool functions correctly.
6778 __ EmitLiteralPool(JumpRequired); 6801 __ CheckConstPool(true, true);
6779 CHECK_LITERAL_POOL_SIZE(0); 6802 CHECK_CONSTANT_POOL_SIZE(0);
6780 6803
6781 // These loads should be after the pool (and will require a new one). 6804 // These loads should be after the pool (and will require a new one).
6782 __ Ldr(x4, 0x34567890abcdef12UL); 6805 __ Ldr(x4, Immediate(0x34567890abcdef12UL));
6783 __ Ldr(w5, 0xdcba09fe);
6784 __ Ldr(d4, 123.4); 6806 __ Ldr(d4, 123.4);
6785 __ Ldr(s5, 250.0); 6807 CHECK_CONSTANT_POOL_SIZE(16);
6786 CHECK_LITERAL_POOL_SIZE(4);
6787 END(); 6808 END();
6788 6809
6789 RUN(); 6810 RUN();
6790 6811
6791 // Check that the literals loaded correctly. 6812 // Check that the literals loaded correctly.
6792 CHECK_EQUAL_64(0x1234567890abcdefUL, x0); 6813 CHECK_EQUAL_64(0x1234567890abcdefUL, x0);
6793 CHECK_EQUAL_64(0xfedcba09, x1);
6794 CHECK_EQUAL_FP64(1.234, d0); 6814 CHECK_EQUAL_FP64(1.234, d0);
6795 CHECK_EQUAL_FP32(2.5, s1);
6796 CHECK_EQUAL_64(0x34567890abcdef12UL, x4); 6815 CHECK_EQUAL_64(0x34567890abcdef12UL, x4);
6797 CHECK_EQUAL_64(0xdcba09fe, x5);
6798 CHECK_EQUAL_FP64(123.4, d4); 6816 CHECK_EQUAL_FP64(123.4, d4);
6799 CHECK_EQUAL_FP32(250.0, s5);
6800 6817
6801 TEARDOWN(); 6818 TEARDOWN();
6802 } 6819 }
6803 6820
6804
6805 TEST(ldr_literal_range_1) { 6821 TEST(ldr_literal_range_1) {
6806 INIT_V8(); 6822 INIT_V8();
6807 LdrLiteralRangeHelper(kRecommendedLiteralPoolRange, 6823 LdrLiteralRangeHelper(MacroAssembler::GetApproxMaxDistToConstPoolForTesting(),
6808 NoJumpRequired, 6824 NoJumpRequired, true);
6809 true);
6810 } 6825 }
6811 6826
6812 6827
6813 TEST(ldr_literal_range_2) { 6828 TEST(ldr_literal_range_2) {
6814 INIT_V8(); 6829 INIT_V8();
6815 LdrLiteralRangeHelper(kRecommendedLiteralPoolRange-sizeof(Instr), 6830 LdrLiteralRangeHelper(
6816 NoJumpRequired, 6831 MacroAssembler::GetApproxMaxDistToConstPoolForTesting() -
6817 false); 6832 kInstructionSize,
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::GetCheckConstPoolIntervalForTesting(),
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::GetCheckConstPoolIntervalForTesting() - 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
« no previous file with comments | « src/arm64/assembler-arm64.cc ('k') | test/cctest/test-disasm-arm64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698