Index: test/cctest/test-macro-assembler-mips.cc |
diff --git a/test/cctest/test-macro-assembler-mips.cc b/test/cctest/test-macro-assembler-mips.cc |
index 5408061c3c9c1172459b5e78dbaac32bf18848c0..4aeeab0275a6a02c7f33e3961986b02e3dfc2f36 100644 |
--- a/test/cctest/test-macro-assembler-mips.cc |
+++ b/test/cctest/test-macro-assembler-mips.cc |
@@ -34,7 +34,7 @@ |
#include "src/mips/simulator-mips.h" |
#include "src/v8.h" |
#include "test/cctest/cctest.h" |
- |
+#include "test/cctest/heap/heap-utils.h" |
using namespace v8::internal; |
@@ -413,12 +413,12 @@ static const std::vector<int32_t> cvt_trunc_int32_test_values() { |
for (std::vector<ctype>::iterator var = var##_vec.begin(); \ |
var != var##_vec.end(); ++var) |
-#define FOR_INPUTS2(ctype, itype, var, var2, test_vector) \ |
+#define FOR_INPUTS2(ctype, itype, var, vat1, test_vector) \ |
std::vector<ctype> var##_vec = test_vector(); \ |
std::vector<ctype>::iterator var; \ |
- std::vector<ctype>::reverse_iterator var2; \ |
- for (var = var##_vec.begin(), var2 = var##_vec.rbegin(); \ |
- var != var##_vec.end(); ++var, ++var2) |
+ std::vector<ctype>::reverse_iterator vat1; \ |
+ for (var = var##_vec.begin(), vat1 = var##_vec.rbegin(); \ |
+ var != var##_vec.end(); ++var, ++vat1) |
#define FOR_ENUM_INPUTS(var, type, test_vector) \ |
FOR_INPUTS(enum type, type, var, test_vector) |
@@ -428,8 +428,8 @@ static const std::vector<int32_t> cvt_trunc_int32_test_values() { |
FOR_INPUTS(uint32_t, uint32, var, test_vector) |
#define FOR_INT32_INPUTS(var, test_vector) \ |
FOR_INPUTS(int32_t, int32, var, test_vector) |
-#define FOR_INT32_INPUTS2(var, var2, test_vector) \ |
- FOR_INPUTS2(int32_t, int32, var, var2, test_vector) |
+#define FOR_INT32_INPUTS2(var, vat1, test_vector) \ |
+ FOR_INPUTS2(int32_t, int32, var, vat1, test_vector) |
#define FOR_UINT64_INPUTS(var, test_vector) \ |
FOR_INPUTS(uint64_t, uint32, var, test_vector) |
@@ -1168,4 +1168,112 @@ TEST(Uldc1) { |
} |
} |
+template <typename Fun> |
+void AssembleFunction(Isolate* isolate, size_t actual_size, byte* buffer, |
+ Fun f) { |
+ MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size), |
+ v8::internal::CodeObjectRequired::kYes); |
+ MacroAssembler* masm = &assembler; |
+ f(masm); |
+ __ jr(ra); |
+ |
+ CodeDesc desc; |
+ masm->GetCode(&desc); |
+} |
+ |
+TEST(AllocateMacrosNoGCRequired) { |
+ typedef intptr_t (*F0)(); |
+ // Allocate an executable page of memory. |
+ CcTest::InitializeVM(); |
+ size_t actual_size; |
+ byte* buffer = static_cast<byte*>(v8::base::OS::Allocate( |
+ Assembler::kMinimalBufferSize, &actual_size, true)); |
+ CHECK(buffer); |
+ Isolate* isolate = CcTest::i_isolate(); |
+ HandleScope handles(isolate); |
+ |
+ AllocationFlags const kDoubleAligned = |
+ static_cast<AllocationFlags>(DOUBLE_ALIGNMENT); |
+ AllocationFlags const kNoAllocationFlags = |
+ static_cast<AllocationFlags>(NO_ALLOCATION_FLAGS); |
+ |
+#define CHECK_TAGGED(result) CHECK_EQ(result& kHeapObjectTag, 1); |
+#define CHECK_DOUBLE_ALIGNED(result) \ |
+ do { \ |
+ CHECK_TAGGED((result)); \ |
+ CHECK_EQ((result)&kDoubleAlignmentMaskTagged, 0); \ |
+ /* Check that the filler was written in the correct place */ \ |
+ CHECK_EQ(*reinterpret_cast<v8::internal::Map***>( \ |
+ (result) - (kHeapObjectTag + kPointerSize)), \ |
+ isolate->factory()->one_pointer_filler_map().location()); \ |
+ } while (false) |
+ |
+ heap::GcAndSweep(isolate->heap(), AllocationSpace::NEW_SPACE); |
+ { |
+ AssembleFunction(isolate, actual_size, buffer, [](MacroAssembler* masm) { |
+ Label gc_required, success; |
+ __ Allocate(kPointerSize, v0, t0, t1, &gc_required, kNoAllocationFlags); |
+ __ jmp(&success); |
+ __ bind(&gc_required); |
+ __ Abort(kNoReason); |
+ __ bind(&success); |
+ }); |
+ F0 f = FUNCTION_CAST<F0>(buffer); |
+ intptr_t test_result = reinterpret_cast<intptr_t>( |
+ CALL_GENERATED_CODE(isolate, f, 0, 0, 0, 0, 0)); |
+ CHECK_TAGGED(test_result); |
+ } |
+ |
+ { |
+ AssembleFunction(isolate, actual_size, buffer, [](MacroAssembler* masm) { |
+ Label gc_required, success; |
+ __ Allocate(kDoubleSize, v0, t0, t1, &gc_required, kDoubleAligned); |
+ __ jmp(&success); |
+ __ bind(&gc_required); |
+ __ Abort(kNoReason); |
+ __ bind(&success); |
+ }); |
+ heap::MakeSureNewSpaceTopIsNotDoubleAligned(isolate->heap()); |
+ F0 f = FUNCTION_CAST<F0>(buffer); |
+ intptr_t test_result = reinterpret_cast<intptr_t>( |
+ CALL_GENERATED_CODE(isolate, f, 0, 0, 0, 0, 0)); |
+ CHECK_DOUBLE_ALIGNED(test_result); |
+ } |
+ { |
+ AssembleFunction(isolate, actual_size, buffer, [](MacroAssembler* masm) { |
+ Label gc_required, success; |
+ __ li(a0, Operand(kPointerSize)); |
+ __ Allocate(a0, v0, t0, t1, &gc_required, kNoAllocationFlags); |
+ __ jmp(&success); |
+ __ bind(&gc_required); |
+ __ Abort(kNoReason); |
+ __ bind(&success); |
+ }); |
+ F0 f = FUNCTION_CAST<F0>(buffer); |
+ intptr_t test_result = reinterpret_cast<intptr_t>( |
+ CALL_GENERATED_CODE(isolate, f, 0, 0, 0, 0, 0)); |
+ CHECK_TAGGED(test_result); |
+ } |
+ |
+ { |
+ AssembleFunction(isolate, actual_size, buffer, [](MacroAssembler* masm) { |
+ Label gc_required, success; |
+ __ li(a0, Operand(kDoubleSize)); |
+ __ Allocate(a0, v0, t0, t1, &gc_required, kDoubleAligned); |
+ __ jmp(&success); |
+ __ bind(&gc_required); |
+ __ Abort(kNoReason); |
+ __ bind(&success); |
+ }); |
+ heap::MakeSureNewSpaceTopIsNotDoubleAligned(isolate->heap()); |
+ F0 f = FUNCTION_CAST<F0>(buffer); |
+ intptr_t test_result = reinterpret_cast<intptr_t>( |
+ CALL_GENERATED_CODE(isolate, f, 0, 0, 0, 0, 0)); |
+ CHECK_DOUBLE_ALIGNED(test_result); |
+ } |
+ |
+#undef CHECK_TAGGED |
+#undef CHECK_DOUBLE_ALIGNED |
+} |
+ |
#undef __ |