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

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

Issue 24266007: MIPS: Fixed a bug in CopyBytes() and new test cases for MIPS macro assembler. (Closed) Base URL: https://github.com/v8/v8.git@gbl
Patch Set: fix comments. Created 7 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
« no previous file with comments | « test/cctest/cctest.gyp ('k') | no next file » | 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 11 matching lines...) Expand all
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
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 29
30 #include "v8.h" 30 #include "v8.h"
31 #include "macro-assembler.h" 31 #include "macro-assembler.h"
32 #include "arm/macro-assembler-arm.h" 32 #include "mips/macro-assembler-mips.h"
33 #include "arm/simulator-arm.h" 33 #include "mips/simulator-mips.h"
34 #include "cctest.h" 34 #include "cctest.h"
35 35
36 36
37 using namespace v8::internal; 37 using namespace v8::internal;
38 38
39 typedef void* (*F)(int x, int y, int p2, int p3, int p4); 39 typedef void* (*F)(int x, int y, int p2, int p3, int p4);
40 40
41 #define __ masm-> 41 #define __ masm->
42 42
43 43
(...skipping 22 matching lines...) Expand all
66 size_t act_size; 66 size_t act_size;
67 67
68 // Allocate two blocks to copy data between. 68 // Allocate two blocks to copy data between.
69 byte* src_buffer = static_cast<byte*>(OS::Allocate(data_size, &act_size, 0)); 69 byte* src_buffer = static_cast<byte*>(OS::Allocate(data_size, &act_size, 0));
70 CHECK(src_buffer); 70 CHECK(src_buffer);
71 CHECK(act_size >= static_cast<size_t>(data_size)); 71 CHECK(act_size >= static_cast<size_t>(data_size));
72 byte* dest_buffer = static_cast<byte*>(OS::Allocate(data_size, &act_size, 0)); 72 byte* dest_buffer = static_cast<byte*>(OS::Allocate(data_size, &act_size, 0));
73 CHECK(dest_buffer); 73 CHECK(dest_buffer);
74 CHECK(act_size >= static_cast<size_t>(data_size)); 74 CHECK(act_size >= static_cast<size_t>(data_size));
75 75
76 // Storage for R0 and R1. 76 // Storage for a0 and a1.
77 byte* r0_; 77 byte* a0_;
78 byte* r1_; 78 byte* a1_;
79 79
80 MacroAssembler assembler(isolate, NULL, 0); 80 MacroAssembler assembler(isolate, NULL, 0);
81 MacroAssembler* masm = &assembler; 81 MacroAssembler* masm = &assembler;
82 82
83 // Code to be generated: The stuff in CopyBytes followed by a store of R0 and 83 // Code to be generated: The stuff in CopyBytes followed by a store of a0 and
84 // R1, respectively. 84 // a1, respectively.
85 __ CopyBytes(r0, r1, r2, r3); 85 __ CopyBytes(a0, a1, a2, a3);
86 __ mov(r2, Operand(reinterpret_cast<int>(&r0_))); 86 __ li(a2, Operand(reinterpret_cast<int>(&a0_)));
87 __ mov(r3, Operand(reinterpret_cast<int>(&r1_))); 87 __ li(a3, Operand(reinterpret_cast<int>(&a1_)));
88 __ str(r0, MemOperand(r2)); 88 __ sw(a0, MemOperand(a2));
89 __ str(r1, MemOperand(r3)); 89 __ jr(ra);
90 __ bx(lr); 90 __ sw(a1, MemOperand(a3));
91 91
92 CodeDesc desc; 92 CodeDesc desc;
93 masm->GetCode(&desc); 93 masm->GetCode(&desc);
94 Object* code = isolate->heap()->CreateCode( 94 Object* code = isolate->heap()->CreateCode(
95 desc, 95 desc,
96 Code::ComputeFlags(Code::STUB), 96 Code::ComputeFlags(Code::STUB),
97 Handle<Code>())->ToObjectChecked(); 97 Handle<Code>())->ToObjectChecked();
98 CHECK(code->IsCode()); 98 CHECK(code->IsCode());
99 99
100 F f = FUNCTION_CAST<F>(Code::cast(code)->entry()); 100 ::F f = FUNCTION_CAST< ::F>(Code::cast(code)->entry());
101 101
102 // Initialise source data with non-zero bytes. 102 // Initialise source data with non-zero bytes.
103 for (int i = 0; i < data_size; i++) { 103 for (int i = 0; i < data_size; i++) {
104 src_buffer[i] = to_non_zero(i); 104 src_buffer[i] = to_non_zero(i);
105 } 105 }
106 106
107 const int fuzz = 11; 107 const int fuzz = 11;
108 108
109 for (int size = 0; size < 600; size++) { 109 for (int size = 0; size < 600; size++) {
110 for (const byte* src = src_buffer; src < src_buffer + fuzz; src++) { 110 for (const byte* src = src_buffer; src < src_buffer + fuzz; src++) {
111 for (byte* dest = dest_buffer; dest < dest_buffer + fuzz; dest++) { 111 for (byte* dest = dest_buffer; dest < dest_buffer + fuzz; dest++) {
112 memset(dest_buffer, 0, data_size); 112 memset(dest_buffer, 0, data_size);
113 CHECK(dest + size < dest_buffer + data_size); 113 CHECK(dest + size < dest_buffer + data_size);
114 (void) CALL_GENERATED_CODE(f, reinterpret_cast<int>(src), 114 (void) CALL_GENERATED_CODE(f, reinterpret_cast<int>(src),
115 reinterpret_cast<int>(dest), size, 0, 0); 115 reinterpret_cast<int>(dest), size, 0, 0);
116 // R0 and R1 should point at the first byte after the copied data. 116 // a0 and a1 should point at the first byte after the copied data.
117 CHECK_EQ(src + size, r0_); 117 CHECK_EQ(src + size, a0_);
118 CHECK_EQ(dest + size, r1_); 118 CHECK_EQ(dest + size, a1_);
119 // Check that we haven't written outside the target area. 119 // Check that we haven't written outside the target area.
120 CHECK(all_zeroes(dest_buffer, dest)); 120 CHECK(all_zeroes(dest_buffer, dest));
121 CHECK(all_zeroes(dest + size, dest_buffer + data_size)); 121 CHECK(all_zeroes(dest + size, dest_buffer + data_size));
122 // Check the target area. 122 // Check the target area.
123 CHECK_EQ(0, memcmp(src, dest, size)); 123 CHECK_EQ(0, memcmp(src, dest, size));
124 } 124 }
125 } 125 }
126 } 126 }
127 127
128 // Check that the source data hasn't been clobbered. 128 // Check that the source data hasn't been clobbered.
129 for (int i = 0; i < data_size; i++) { 129 for (int i = 0; i < data_size; i++) {
130 CHECK(src_buffer[i] == to_non_zero(i)); 130 CHECK(src_buffer[i] == to_non_zero(i));
131 } 131 }
132 } 132 }
133 133
134 134
135 135
136 #undef __ 136 #undef __
OLDNEW
« no previous file with comments | « test/cctest/cctest.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698