OLD | NEW |
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 12 matching lines...) Expand all Loading... |
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
28 #include <stdlib.h> | 28 #include <stdlib.h> |
29 #include <iostream> // NOLINT(readability/streams) | 29 #include <iostream> // NOLINT(readability/streams) |
30 | 30 |
31 #include "src/v8.h" | 31 #include "src/v8.h" |
32 #include "test/cctest/cctest.h" | 32 #include "test/cctest/cctest.h" |
| 33 #include "test/cctest/heap/heap-utils.h" |
33 | 34 |
34 #include "src/base/utils/random-number-generator.h" | 35 #include "src/base/utils/random-number-generator.h" |
35 #include "src/macro-assembler.h" | 36 #include "src/macro-assembler.h" |
36 #include "src/mips64/macro-assembler-mips64.h" | 37 #include "src/mips64/macro-assembler-mips64.h" |
37 #include "src/mips64/simulator-mips64.h" | 38 #include "src/mips64/simulator-mips64.h" |
38 | 39 |
39 | 40 |
40 using namespace v8::internal; | 41 using namespace v8::internal; |
41 | 42 |
42 typedef void* (*F)(int64_t x, int64_t y, int p2, int p3, int p4); | 43 typedef void* (*F)(int64_t x, int64_t y, int p2, int p3, int p4); |
(...skipping 1695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1738 [](MacroAssembler* masm, int32_t in_offset, | 1739 [](MacroAssembler* masm, int32_t in_offset, |
1739 int32_t out_offset) { | 1740 int32_t out_offset) { |
1740 __ Uldc1(f0, MemOperand(a0, in_offset), t0); | 1741 __ Uldc1(f0, MemOperand(a0, in_offset), t0); |
1741 __ Usdc1(f0, MemOperand(a0, out_offset), t0); | 1742 __ Usdc1(f0, MemOperand(a0, out_offset), t0); |
1742 })); | 1743 })); |
1743 } | 1744 } |
1744 } | 1745 } |
1745 } | 1746 } |
1746 } | 1747 } |
1747 | 1748 |
| 1749 template <typename Fun> |
| 1750 void AssembleFunction(Isolate* isolate, size_t actual_size, byte* buffer, |
| 1751 Fun f) { |
| 1752 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size), |
| 1753 v8::internal::CodeObjectRequired::kYes); |
| 1754 MacroAssembler* masm = &assembler; |
| 1755 f(masm); |
| 1756 __ jr(ra); |
| 1757 |
| 1758 CodeDesc desc; |
| 1759 masm->GetCode(&desc); |
| 1760 } |
| 1761 |
| 1762 TEST(AllocateMacrosNoGCRequired) { |
| 1763 typedef intptr_t (*F0)(); |
| 1764 // Allocate an executable page of memory. |
| 1765 CcTest::InitializeVM(); |
| 1766 size_t actual_size; |
| 1767 byte* buffer = static_cast<byte*>(v8::base::OS::Allocate( |
| 1768 Assembler::kMinimalBufferSize, &actual_size, true)); |
| 1769 CHECK(buffer); |
| 1770 Isolate* isolate = CcTest::i_isolate(); |
| 1771 HandleScope handles(isolate); |
| 1772 |
| 1773 AllocationFlags const kNoAllocationFlags = |
| 1774 static_cast<AllocationFlags>(NO_ALLOCATION_FLAGS); |
| 1775 |
| 1776 #define CHECK_TAGGED(result) CHECK_EQ(result& kHeapObjectTag, 1); |
| 1777 |
| 1778 heap::GcAndSweep(isolate->heap(), AllocationSpace::NEW_SPACE); |
| 1779 { |
| 1780 AssembleFunction(isolate, actual_size, buffer, [](MacroAssembler* masm) { |
| 1781 Label gc_required, success; |
| 1782 __ Allocate(kPointerSize, v0, t0, t1, &gc_required, kNoAllocationFlags); |
| 1783 __ jmp(&success); |
| 1784 __ bind(&gc_required); |
| 1785 __ Abort(kNoReason); |
| 1786 __ bind(&success); |
| 1787 }); |
| 1788 F0 f = FUNCTION_CAST<F0>(buffer); |
| 1789 intptr_t test_result = reinterpret_cast<intptr_t>( |
| 1790 CALL_GENERATED_CODE(isolate, f, 0, 0, 0, 0, 0)); |
| 1791 CHECK_TAGGED(test_result); |
| 1792 } |
| 1793 |
| 1794 { |
| 1795 AssembleFunction(isolate, actual_size, buffer, [](MacroAssembler* masm) { |
| 1796 Label gc_required, success; |
| 1797 __ li(a0, Operand(kPointerSize)); |
| 1798 __ Allocate(a0, v0, t0, t1, &gc_required, kNoAllocationFlags); |
| 1799 __ jmp(&success); |
| 1800 __ bind(&gc_required); |
| 1801 __ Abort(kNoReason); |
| 1802 __ bind(&success); |
| 1803 }); |
| 1804 F0 f = FUNCTION_CAST<F0>(buffer); |
| 1805 intptr_t test_result = reinterpret_cast<intptr_t>( |
| 1806 CALL_GENERATED_CODE(isolate, f, 0, 0, 0, 0, 0)); |
| 1807 CHECK_TAGGED(test_result); |
| 1808 } |
| 1809 |
| 1810 #undef CHECK_TAGGED |
| 1811 } |
| 1812 |
1748 #undef __ | 1813 #undef __ |
OLD | NEW |