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

Side by Side Diff: test/cctest/test-macro-assembler-arm.cc

Issue 2434753003: [cleanup] Delete MacroAssembler::CopyBytes, it is dead code (Closed)
Patch Set: update .golden files Created 4 years, 2 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 24 matching lines...) Expand all
35 #include "src/arm/macro-assembler-arm.h" 35 #include "src/arm/macro-assembler-arm.h"
36 #include "src/arm/simulator-arm.h" 36 #include "src/arm/simulator-arm.h"
37 37
38 38
39 using namespace v8::internal; 39 using namespace v8::internal;
40 40
41 typedef void* (*F)(int x, int y, int p2, int p3, int p4); 41 typedef void* (*F)(int x, int y, int p2, int p3, int p4);
42 42
43 #define __ masm-> 43 #define __ masm->
44 44
45
46 static byte to_non_zero(int n) {
47 return static_cast<unsigned>(n) % 255 + 1;
48 }
49
50
51 static bool all_zeroes(const byte* beg, const byte* end) {
52 CHECK(beg);
53 CHECK(beg <= end);
54 while (beg < end) {
55 if (*beg++ != 0)
56 return false;
57 }
58 return true;
59 }
60
61
62 TEST(CopyBytes) {
63 CcTest::InitializeVM();
64 Isolate* isolate = CcTest::i_isolate();
65 HandleScope handles(isolate);
66
67 const int data_size = 1 * KB;
68 size_t act_size;
69
70 // Allocate two blocks to copy data between.
71 byte* src_buffer =
72 static_cast<byte*>(v8::base::OS::Allocate(data_size, &act_size, 0));
73 CHECK(src_buffer);
74 CHECK(act_size >= static_cast<size_t>(data_size));
75 byte* dest_buffer =
76 static_cast<byte*>(v8::base::OS::Allocate(data_size, &act_size, 0));
77 CHECK(dest_buffer);
78 CHECK(act_size >= static_cast<size_t>(data_size));
79
80 // Storage for R0 and R1.
81 byte* r0_;
82 byte* r1_;
83
84 MacroAssembler assembler(isolate, NULL, 0,
85 v8::internal::CodeObjectRequired::kYes);
86 MacroAssembler* masm = &assembler;
87
88 // Code to be generated: The stuff in CopyBytes followed by a store of R0 and
89 // R1, respectively.
90 __ CopyBytes(r0, r1, r2, r3);
91 __ mov(r2, Operand(reinterpret_cast<int>(&r0_)));
92 __ mov(r3, Operand(reinterpret_cast<int>(&r1_)));
93 __ str(r0, MemOperand(r2));
94 __ str(r1, MemOperand(r3));
95 __ bx(lr);
96
97 CodeDesc desc;
98 masm->GetCode(&desc);
99 Handle<Code> code = isolate->factory()->NewCode(
100 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
101
102 F f = FUNCTION_CAST<F>(code->entry());
103
104 // Initialise source data with non-zero bytes.
105 for (int i = 0; i < data_size; i++) {
106 src_buffer[i] = to_non_zero(i);
107 }
108
109 const int fuzz = 11;
110
111 for (int size = 0; size < 600; size++) {
112 for (const byte* src = src_buffer; src < src_buffer + fuzz; src++) {
113 for (byte* dest = dest_buffer; dest < dest_buffer + fuzz; dest++) {
114 memset(dest_buffer, 0, data_size);
115 CHECK(dest + size < dest_buffer + data_size);
116 (void)CALL_GENERATED_CODE(isolate, f, reinterpret_cast<int>(src),
117 reinterpret_cast<int>(dest), size, 0, 0);
118 // R0 and R1 should point at the first byte after the copied data.
119 CHECK_EQ(src + size, r0_);
120 CHECK_EQ(dest + size, r1_);
121 // Check that we haven't written outside the target area.
122 CHECK(all_zeroes(dest_buffer, dest));
123 CHECK(all_zeroes(dest + size, dest_buffer + data_size));
124 // Check the target area.
125 CHECK_EQ(0, memcmp(src, dest, size));
126 }
127 }
128 }
129
130 // Check that the source data hasn't been clobbered.
131 for (int i = 0; i < data_size; i++) {
132 CHECK(src_buffer[i] == to_non_zero(i));
133 }
134 }
135
136
137 typedef int (*F5)(void*, void*, void*, void*, void*); 45 typedef int (*F5)(void*, void*, void*, void*, void*);
138 46
139 47
140 TEST(LoadAndStoreWithRepresentation) { 48 TEST(LoadAndStoreWithRepresentation) {
141 // Allocate an executable page of memory. 49 // Allocate an executable page of memory.
142 size_t actual_size; 50 size_t actual_size;
143 byte* buffer = static_cast<byte*>(v8::base::OS::Allocate( 51 byte* buffer = static_cast<byte*>(v8::base::OS::Allocate(
144 Assembler::kMinimalBufferSize, &actual_size, true)); 52 Assembler::kMinimalBufferSize, &actual_size, true));
145 CHECK(buffer); 53 CHECK(buffer);
146 Isolate* isolate = CcTest::i_isolate(); 54 Isolate* isolate = CcTest::i_isolate();
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 masm->GetCode(&desc); 128 masm->GetCode(&desc);
221 Handle<Code> code = isolate->factory()->NewCode( 129 Handle<Code> code = isolate->factory()->NewCode(
222 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); 130 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
223 131
224 // Call the function from C++. 132 // Call the function from C++.
225 F5 f = FUNCTION_CAST<F5>(code->entry()); 133 F5 f = FUNCTION_CAST<F5>(code->entry());
226 CHECK(!CALL_GENERATED_CODE(isolate, f, 0, 0, 0, 0, 0)); 134 CHECK(!CALL_GENERATED_CODE(isolate, f, 0, 0, 0, 0, 0));
227 } 135 }
228 136
229 #undef __ 137 #undef __
OLDNEW
« no previous file with comments | « test/cctest/interpreter/bytecode_expectations/Modules.golden ('k') | test/cctest/test-macro-assembler-mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698