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

Unified Diff: test/cctest/test-macro-assembler-arm.cc

Issue 2028633002: Provide a tagged allocation top pointer. Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: WIP: adding a few tests. Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/cctest/heap/test-heap.cc ('k') | test/cctest/test-macro-assembler-ia32.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-macro-assembler-arm.cc
diff --git a/test/cctest/test-macro-assembler-arm.cc b/test/cctest/test-macro-assembler-arm.cc
index 24ab60e972e1b7718c4d12abd23504f3bc38ed6a..0d05102a83c8068d42728bd7c4ff4e66ea017f5a 100644
--- a/test/cctest/test-macro-assembler-arm.cc
+++ b/test/cctest/test-macro-assembler-arm.cc
@@ -29,6 +29,7 @@
#include "src/v8.h"
#include "test/cctest/cctest.h"
+#include "test/cctest/heap/heap-utils.h"
#include "src/macro-assembler.h"
@@ -226,4 +227,112 @@ TEST(LoadAndStoreWithRepresentation) {
CHECK(!CALL_GENERATED_CODE(isolate, f, 0, 0, 0, 0, 0));
}
+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);
+ __ bx(lr);
+
+ CodeDesc desc;
+ masm->GetCode(&desc);
+}
+
+TEST(AllocateMacrosNoGCRequired) {
+ typedef intptr_t (*F0)();
+
+ // Allocate an executable page of memory.
+ 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, r0, r1, r2, &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, r0, r1, r2, &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;
+ __ mov(r3, Operand(kPointerSize));
+ __ Allocate(r3, r0, r1, r2, &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;
+ __ mov(r3, Operand(kDoubleSize));
+ __ Allocate(r3, r0, r1, r2, &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 __
« no previous file with comments | « test/cctest/heap/test-heap.cc ('k') | test/cctest/test-macro-assembler-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698