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

Side by Side Diff: test/cctest/test-assembler-x64.cc

Issue 2807031: [Isolates] RegExpStack and memory allocation limits (statics #6) (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/isolates/
Patch Set: -> is different than . Created 10 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « test/cctest/test-alloc.cc ('k') | test/cctest/test-platform-linux.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 static const v8::internal::Register arg2 = rdx; 73 static const v8::internal::Register arg2 = rdx;
74 #else 74 #else
75 static const v8::internal::Register arg1 = rdi; 75 static const v8::internal::Register arg1 = rdi;
76 static const v8::internal::Register arg2 = rsi; 76 static const v8::internal::Register arg2 = rsi;
77 #endif 77 #endif
78 78
79 #define __ assm. 79 #define __ assm.
80 80
81 81
82 TEST(AssemblerX64ReturnOperation) { 82 TEST(AssemblerX64ReturnOperation) {
83 OS::Setup();
83 // Allocate an executable page of memory. 84 // Allocate an executable page of memory.
84 size_t actual_size; 85 size_t actual_size;
85 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, 86 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize,
86 &actual_size, 87 &actual_size,
87 true)); 88 true));
88 CHECK(buffer); 89 CHECK(buffer);
89 Assembler assm(buffer, static_cast<int>(actual_size)); 90 Assembler assm(buffer, static_cast<int>(actual_size));
90 91
91 // Assemble a simple function that copies argument 2 and returns it. 92 // Assemble a simple function that copies argument 2 and returns it.
92 __ movq(rax, arg2); 93 __ movq(rax, arg2);
93 __ nop(); 94 __ nop();
94 __ ret(0); 95 __ ret(0);
95 96
96 CodeDesc desc; 97 CodeDesc desc;
97 assm.GetCode(&desc); 98 assm.GetCode(&desc);
98 // Call the function from C++. 99 // Call the function from C++.
99 int result = FUNCTION_CAST<F2>(buffer)(3, 2); 100 int result = FUNCTION_CAST<F2>(buffer)(3, 2);
100 CHECK_EQ(2, result); 101 CHECK_EQ(2, result);
101 } 102 }
102 103
103 TEST(AssemblerX64StackOperations) { 104 TEST(AssemblerX64StackOperations) {
105 OS::Setup();
104 // Allocate an executable page of memory. 106 // Allocate an executable page of memory.
105 size_t actual_size; 107 size_t actual_size;
106 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, 108 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize,
107 &actual_size, 109 &actual_size,
108 true)); 110 true));
109 CHECK(buffer); 111 CHECK(buffer);
110 Assembler assm(buffer, static_cast<int>(actual_size)); 112 Assembler assm(buffer, static_cast<int>(actual_size));
111 113
112 // Assemble a simple function that copies argument 2 and returns it. 114 // Assemble a simple function that copies argument 2 and returns it.
113 // We compile without stack frame pointers, so the gdb debugger shows 115 // We compile without stack frame pointers, so the gdb debugger shows
(...skipping 11 matching lines...) Expand all
125 __ ret(0); 127 __ ret(0);
126 128
127 CodeDesc desc; 129 CodeDesc desc;
128 assm.GetCode(&desc); 130 assm.GetCode(&desc);
129 // Call the function from C++. 131 // Call the function from C++.
130 int result = FUNCTION_CAST<F2>(buffer)(3, 2); 132 int result = FUNCTION_CAST<F2>(buffer)(3, 2);
131 CHECK_EQ(2, result); 133 CHECK_EQ(2, result);
132 } 134 }
133 135
134 TEST(AssemblerX64ArithmeticOperations) { 136 TEST(AssemblerX64ArithmeticOperations) {
137 OS::Setup();
135 // Allocate an executable page of memory. 138 // Allocate an executable page of memory.
136 size_t actual_size; 139 size_t actual_size;
137 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, 140 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize,
138 &actual_size, 141 &actual_size,
139 true)); 142 true));
140 CHECK(buffer); 143 CHECK(buffer);
141 Assembler assm(buffer, static_cast<int>(actual_size)); 144 Assembler assm(buffer, static_cast<int>(actual_size));
142 145
143 // Assemble a simple function that adds arguments returning the sum. 146 // Assemble a simple function that adds arguments returning the sum.
144 __ movq(rax, arg2); 147 __ movq(rax, arg2);
145 __ addq(rax, arg1); 148 __ addq(rax, arg1);
146 __ ret(0); 149 __ ret(0);
147 150
148 CodeDesc desc; 151 CodeDesc desc;
149 assm.GetCode(&desc); 152 assm.GetCode(&desc);
150 // Call the function from C++. 153 // Call the function from C++.
151 int result = FUNCTION_CAST<F2>(buffer)(3, 2); 154 int result = FUNCTION_CAST<F2>(buffer)(3, 2);
152 CHECK_EQ(5, result); 155 CHECK_EQ(5, result);
153 } 156 }
154 157
155 TEST(AssemblerX64ImulOperation) { 158 TEST(AssemblerX64ImulOperation) {
159 OS::Setup();
156 // Allocate an executable page of memory. 160 // Allocate an executable page of memory.
157 size_t actual_size; 161 size_t actual_size;
158 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, 162 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize,
159 &actual_size, 163 &actual_size,
160 true)); 164 true));
161 CHECK(buffer); 165 CHECK(buffer);
162 Assembler assm(buffer, static_cast<int>(actual_size)); 166 Assembler assm(buffer, static_cast<int>(actual_size));
163 167
164 // Assemble a simple function that multiplies arguments returning the high 168 // Assemble a simple function that multiplies arguments returning the high
165 // word. 169 // word.
166 __ movq(rax, arg2); 170 __ movq(rax, arg2);
167 __ imul(arg1); 171 __ imul(arg1);
168 __ movq(rax, rdx); 172 __ movq(rax, rdx);
169 __ ret(0); 173 __ ret(0);
170 174
171 CodeDesc desc; 175 CodeDesc desc;
172 assm.GetCode(&desc); 176 assm.GetCode(&desc);
173 // Call the function from C++. 177 // Call the function from C++.
174 int result = FUNCTION_CAST<F2>(buffer)(3, 2); 178 int result = FUNCTION_CAST<F2>(buffer)(3, 2);
175 CHECK_EQ(0, result); 179 CHECK_EQ(0, result);
176 result = FUNCTION_CAST<F2>(buffer)(0x100000000l, 0x100000000l); 180 result = FUNCTION_CAST<F2>(buffer)(0x100000000l, 0x100000000l);
177 CHECK_EQ(1, result); 181 CHECK_EQ(1, result);
178 result = FUNCTION_CAST<F2>(buffer)(-0x100000000l, 0x100000000l); 182 result = FUNCTION_CAST<F2>(buffer)(-0x100000000l, 0x100000000l);
179 CHECK_EQ(-1, result); 183 CHECK_EQ(-1, result);
180 } 184 }
181 185
182 TEST(AssemblerX64MemoryOperands) { 186 TEST(AssemblerX64MemoryOperands) {
187 OS::Setup();
183 // Allocate an executable page of memory. 188 // Allocate an executable page of memory.
184 size_t actual_size; 189 size_t actual_size;
185 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, 190 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize,
186 &actual_size, 191 &actual_size,
187 true)); 192 true));
188 CHECK(buffer); 193 CHECK(buffer);
189 Assembler assm(buffer, static_cast<int>(actual_size)); 194 Assembler assm(buffer, static_cast<int>(actual_size));
190 195
191 // Assemble a simple function that copies argument 2 and returns it. 196 // Assemble a simple function that copies argument 2 and returns it.
192 __ push(rbp); 197 __ push(rbp);
(...skipping 13 matching lines...) Expand all
206 __ ret(0); 211 __ ret(0);
207 212
208 CodeDesc desc; 213 CodeDesc desc;
209 assm.GetCode(&desc); 214 assm.GetCode(&desc);
210 // Call the function from C++. 215 // Call the function from C++.
211 int result = FUNCTION_CAST<F2>(buffer)(3, 2); 216 int result = FUNCTION_CAST<F2>(buffer)(3, 2);
212 CHECK_EQ(3, result); 217 CHECK_EQ(3, result);
213 } 218 }
214 219
215 TEST(AssemblerX64ControlFlow) { 220 TEST(AssemblerX64ControlFlow) {
221 OS::Setup();
216 // Allocate an executable page of memory. 222 // Allocate an executable page of memory.
217 size_t actual_size; 223 size_t actual_size;
218 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, 224 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize,
219 &actual_size, 225 &actual_size,
220 true)); 226 true));
221 CHECK(buffer); 227 CHECK(buffer);
222 Assembler assm(buffer, static_cast<int>(actual_size)); 228 Assembler assm(buffer, static_cast<int>(actual_size));
223 229
224 // Assemble a simple function that copies argument 1 and returns it. 230 // Assemble a simple function that copies argument 1 and returns it.
225 __ push(rbp); 231 __ push(rbp);
226 232
227 __ movq(rbp, rsp); 233 __ movq(rbp, rsp);
228 __ movq(rax, arg1); 234 __ movq(rax, arg1);
229 Label target; 235 Label target;
230 __ jmp(&target); 236 __ jmp(&target);
231 __ movq(rax, arg2); 237 __ movq(rax, arg2);
232 __ bind(&target); 238 __ bind(&target);
233 __ pop(rbp); 239 __ pop(rbp);
234 __ ret(0); 240 __ ret(0);
235 241
236 CodeDesc desc; 242 CodeDesc desc;
237 assm.GetCode(&desc); 243 assm.GetCode(&desc);
238 // Call the function from C++. 244 // Call the function from C++.
239 int result = FUNCTION_CAST<F2>(buffer)(3, 2); 245 int result = FUNCTION_CAST<F2>(buffer)(3, 2);
240 CHECK_EQ(3, result); 246 CHECK_EQ(3, result);
241 } 247 }
242 248
243 TEST(AssemblerX64LoopImmediates) { 249 TEST(AssemblerX64LoopImmediates) {
250 OS::Setup();
244 // Allocate an executable page of memory. 251 // Allocate an executable page of memory.
245 size_t actual_size; 252 size_t actual_size;
246 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, 253 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize,
247 &actual_size, 254 &actual_size,
248 true)); 255 true));
249 CHECK(buffer); 256 CHECK(buffer);
250 Assembler assm(buffer, static_cast<int>(actual_size)); 257 Assembler assm(buffer, static_cast<int>(actual_size));
251 // Assemble two loops using rax as counter, and verify the ending counts. 258 // Assemble two loops using rax as counter, and verify the ending counts.
252 Label Fail; 259 Label Fail;
253 __ movq(rax, Immediate(-3)); 260 __ movq(rax, Immediate(-3));
(...skipping 29 matching lines...) Expand all
283 __ ret(0); 290 __ ret(0);
284 291
285 CodeDesc desc; 292 CodeDesc desc;
286 assm.GetCode(&desc); 293 assm.GetCode(&desc);
287 // Call the function from C++. 294 // Call the function from C++.
288 int result = FUNCTION_CAST<F0>(buffer)(); 295 int result = FUNCTION_CAST<F0>(buffer)();
289 CHECK_EQ(1, result); 296 CHECK_EQ(1, result);
290 } 297 }
291 298
292 #undef __ 299 #undef __
OLDNEW
« no previous file with comments | « test/cctest/test-alloc.cc ('k') | test/cctest/test-platform-linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698