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

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

Issue 6685088: Merge isolates to bleeding_edge. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 9 years, 9 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-assembler-arm.cc ('k') | test/cctest/test-assembler-x64.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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 62
63 v8::internal::byte buffer[256]; 63 v8::internal::byte buffer[256];
64 Assembler assm(buffer, sizeof buffer); 64 Assembler assm(buffer, sizeof buffer);
65 65
66 __ mov(eax, Operand(esp, 4)); 66 __ mov(eax, Operand(esp, 4));
67 __ add(eax, Operand(esp, 8)); 67 __ add(eax, Operand(esp, 8));
68 __ ret(0); 68 __ ret(0);
69 69
70 CodeDesc desc; 70 CodeDesc desc;
71 assm.GetCode(&desc); 71 assm.GetCode(&desc);
72 Object* code = Heap::CreateCode(desc, 72 Object* code = HEAP->CreateCode(
73 Code::ComputeFlags(Code::STUB), 73 desc,
74 Handle<Object>(Heap::undefined_value()))-> 74 Code::ComputeFlags(Code::STUB),
75 ToObjectChecked(); 75 Handle<Object>(HEAP->undefined_value()))->ToObjectChecked();
76 CHECK(code->IsCode()); 76 CHECK(code->IsCode());
77 #ifdef OBJECT_PRINT 77 #ifdef OBJECT_PRINT
78 Code::cast(code)->Print(); 78 Code::cast(code)->Print();
79 #endif 79 #endif
80 F2 f = FUNCTION_CAST<F2>(Code::cast(code)->entry()); 80 F2 f = FUNCTION_CAST<F2>(Code::cast(code)->entry());
81 int res = f(3, 4); 81 int res = f(3, 4);
82 ::printf("f() = %d\n", res); 82 ::printf("f() = %d\n", res);
83 CHECK_EQ(7, res); 83 CHECK_EQ(7, res);
84 } 84 }
85 85
(...skipping 14 matching lines...) Expand all
100 __ add(eax, Operand(edx)); 100 __ add(eax, Operand(edx));
101 __ sub(Operand(edx), Immediate(1)); 101 __ sub(Operand(edx), Immediate(1));
102 102
103 __ bind(&C); 103 __ bind(&C);
104 __ test(edx, Operand(edx)); 104 __ test(edx, Operand(edx));
105 __ j(not_zero, &L, taken); 105 __ j(not_zero, &L, taken);
106 __ ret(0); 106 __ ret(0);
107 107
108 CodeDesc desc; 108 CodeDesc desc;
109 assm.GetCode(&desc); 109 assm.GetCode(&desc);
110 Object* code = Heap::CreateCode(desc, 110 Object* code = HEAP->CreateCode(
111 Code::ComputeFlags(Code::STUB), 111 desc,
112 Handle<Object>(Heap::undefined_value()))-> 112 Code::ComputeFlags(Code::STUB),
113 ToObjectChecked(); 113 Handle<Object>(HEAP->undefined_value()))->ToObjectChecked();
114 CHECK(code->IsCode()); 114 CHECK(code->IsCode());
115 #ifdef OBJECT_PRINT 115 #ifdef OBJECT_PRINT
116 Code::cast(code)->Print(); 116 Code::cast(code)->Print();
117 #endif 117 #endif
118 F1 f = FUNCTION_CAST<F1>(Code::cast(code)->entry()); 118 F1 f = FUNCTION_CAST<F1>(Code::cast(code)->entry());
119 int res = f(100); 119 int res = f(100);
120 ::printf("f() = %d\n", res); 120 ::printf("f() = %d\n", res);
121 CHECK_EQ(5050, res); 121 CHECK_EQ(5050, res);
122 } 122 }
123 123
(...skipping 13 matching lines...) Expand all
137 __ bind(&L); 137 __ bind(&L);
138 __ imul(eax, Operand(edx)); 138 __ imul(eax, Operand(edx));
139 __ sub(Operand(edx), Immediate(1)); 139 __ sub(Operand(edx), Immediate(1));
140 140
141 __ bind(&C); 141 __ bind(&C);
142 __ test(edx, Operand(edx)); 142 __ test(edx, Operand(edx));
143 __ j(not_zero, &L, taken); 143 __ j(not_zero, &L, taken);
144 __ ret(0); 144 __ ret(0);
145 145
146 // some relocated stuff here, not executed 146 // some relocated stuff here, not executed
147 __ mov(eax, Factory::true_value()); 147 __ mov(eax, FACTORY->true_value());
148 __ jmp(NULL, RelocInfo::RUNTIME_ENTRY); 148 __ jmp(NULL, RelocInfo::RUNTIME_ENTRY);
149 149
150 CodeDesc desc; 150 CodeDesc desc;
151 assm.GetCode(&desc); 151 assm.GetCode(&desc);
152 Object* code = Heap::CreateCode( 152 Object* code = HEAP->CreateCode(
153 desc, 153 desc,
154 Code::ComputeFlags(Code::STUB), 154 Code::ComputeFlags(Code::STUB),
155 Handle<Object>(Heap::undefined_value()))->ToObjectChecked(); 155 Handle<Object>(HEAP->undefined_value()))->ToObjectChecked();
156
157 CHECK(code->IsCode()); 156 CHECK(code->IsCode());
158 #ifdef OBJECT_PRINT 157 #ifdef OBJECT_PRINT
159 Code::cast(code)->Print(); 158 Code::cast(code)->Print();
160 #endif 159 #endif
161 F1 f = FUNCTION_CAST<F1>(Code::cast(code)->entry()); 160 F1 f = FUNCTION_CAST<F1>(Code::cast(code)->entry());
162 int res = f(10); 161 int res = f(10);
163 ::printf("f() = %d\n", res); 162 ::printf("f() = %d\n", res);
164 CHECK_EQ(3628800, res); 163 CHECK_EQ(3628800, res);
165 } 164 }
166 165
167 166
168 typedef int (*F3)(float x); 167 typedef int (*F3)(float x);
169 168
170 TEST(AssemblerIa323) { 169 TEST(AssemblerIa323) {
171 if (!CpuFeatures::IsSupported(SSE2)) return; 170 if (!Isolate::Current()->cpu_features()->IsSupported(SSE2)) return;
172 171
173 InitializeVM(); 172 InitializeVM();
174 v8::HandleScope scope; 173 v8::HandleScope scope;
175 174
176 v8::internal::byte buffer[256]; 175 v8::internal::byte buffer[256];
177 Assembler assm(buffer, sizeof buffer); 176 Assembler assm(buffer, sizeof buffer);
178 177
179 CHECK(CpuFeatures::IsSupported(SSE2)); 178 CHECK(Isolate::Current()->cpu_features()->IsSupported(SSE2));
180 { CpuFeatures::Scope fscope(SSE2); 179 { CpuFeatures::Scope fscope(SSE2);
181 __ cvttss2si(eax, Operand(esp, 4)); 180 __ cvttss2si(eax, Operand(esp, 4));
182 __ ret(0); 181 __ ret(0);
183 } 182 }
184 183
185 CodeDesc desc; 184 CodeDesc desc;
186 assm.GetCode(&desc); 185 assm.GetCode(&desc);
187 Code* code = Code::cast(Heap::CreateCode( 186 Code* code = Code::cast(HEAP->CreateCode(
188 desc, 187 desc,
189 Code::ComputeFlags(Code::STUB), 188 Code::ComputeFlags(Code::STUB),
190 Handle<Object>(Heap::undefined_value()))->ToObjectChecked()); 189 Handle<Object>(HEAP->undefined_value()))->ToObjectChecked());
191 // don't print the code - our disassembler can't handle cvttss2si 190 // don't print the code - our disassembler can't handle cvttss2si
192 // instead print bytes 191 // instead print bytes
193 Disassembler::Dump(stdout, 192 Disassembler::Dump(stdout,
194 code->instruction_start(), 193 code->instruction_start(),
195 code->instruction_start() + code->instruction_size()); 194 code->instruction_start() + code->instruction_size());
196 F3 f = FUNCTION_CAST<F3>(code->entry()); 195 F3 f = FUNCTION_CAST<F3>(code->entry());
197 int res = f(static_cast<float>(-3.1415)); 196 int res = f(static_cast<float>(-3.1415));
198 ::printf("f() = %d\n", res); 197 ::printf("f() = %d\n", res);
199 CHECK_EQ(-3, res); 198 CHECK_EQ(-3, res);
200 } 199 }
201 200
202 201
203 typedef int (*F4)(double x); 202 typedef int (*F4)(double x);
204 203
205 TEST(AssemblerIa324) { 204 TEST(AssemblerIa324) {
206 if (!CpuFeatures::IsSupported(SSE2)) return; 205 if (!Isolate::Current()->cpu_features()->IsSupported(SSE2)) return;
207 206
208 InitializeVM(); 207 InitializeVM();
209 v8::HandleScope scope; 208 v8::HandleScope scope;
210 209
211 v8::internal::byte buffer[256]; 210 v8::internal::byte buffer[256];
212 Assembler assm(buffer, sizeof buffer); 211 Assembler assm(buffer, sizeof buffer);
213 212
214 CHECK(CpuFeatures::IsSupported(SSE2)); 213 CHECK(Isolate::Current()->cpu_features()->IsSupported(SSE2));
215 CpuFeatures::Scope fscope(SSE2); 214 CpuFeatures::Scope fscope(SSE2);
216 __ cvttsd2si(eax, Operand(esp, 4)); 215 __ cvttsd2si(eax, Operand(esp, 4));
217 __ ret(0); 216 __ ret(0);
218 217
219 CodeDesc desc; 218 CodeDesc desc;
220 assm.GetCode(&desc); 219 assm.GetCode(&desc);
221 Code* code = Code::cast(Heap::CreateCode( 220 Code* code = Code::cast(HEAP->CreateCode(
222 desc, 221 desc,
223 Code::ComputeFlags(Code::STUB), 222 Code::ComputeFlags(Code::STUB),
224 Handle<Object>(Heap::undefined_value()))->ToObjectChecked()); 223 Handle<Object>(HEAP->undefined_value()))->ToObjectChecked());
225 // don't print the code - our disassembler can't handle cvttsd2si 224 // don't print the code - our disassembler can't handle cvttsd2si
226 // instead print bytes 225 // instead print bytes
227 Disassembler::Dump(stdout, 226 Disassembler::Dump(stdout,
228 code->instruction_start(), 227 code->instruction_start(),
229 code->instruction_start() + code->instruction_size()); 228 code->instruction_start() + code->instruction_size());
230 F4 f = FUNCTION_CAST<F4>(code->entry()); 229 F4 f = FUNCTION_CAST<F4>(code->entry());
231 int res = f(2.718281828); 230 int res = f(2.718281828);
232 ::printf("f() = %d\n", res); 231 ::printf("f() = %d\n", res);
233 CHECK_EQ(2, res); 232 CHECK_EQ(2, res);
234 } 233 }
235 234
236 235
237 static int baz = 42; 236 static int baz = 42;
238 TEST(AssemblerIa325) { 237 TEST(AssemblerIa325) {
239 InitializeVM(); 238 InitializeVM();
240 v8::HandleScope scope; 239 v8::HandleScope scope;
241 240
242 v8::internal::byte buffer[256]; 241 v8::internal::byte buffer[256];
243 Assembler assm(buffer, sizeof buffer); 242 Assembler assm(buffer, sizeof buffer);
244 243
245 __ mov(eax, Operand(reinterpret_cast<intptr_t>(&baz), RelocInfo::NONE)); 244 __ mov(eax, Operand(reinterpret_cast<intptr_t>(&baz), RelocInfo::NONE));
246 __ ret(0); 245 __ ret(0);
247 246
248 CodeDesc desc; 247 CodeDesc desc;
249 assm.GetCode(&desc); 248 assm.GetCode(&desc);
250 Code* code = Code::cast(Heap::CreateCode( 249 Code* code = Code::cast(HEAP->CreateCode(
251 desc, 250 desc,
252 Code::ComputeFlags(Code::STUB), 251 Code::ComputeFlags(Code::STUB),
253 Handle<Object>(Heap::undefined_value()))->ToObjectChecked()); 252 Handle<Object>(HEAP->undefined_value()))->ToObjectChecked());
254 F0 f = FUNCTION_CAST<F0>(code->entry()); 253 F0 f = FUNCTION_CAST<F0>(code->entry());
255 int res = f(); 254 int res = f();
256 CHECK_EQ(42, res); 255 CHECK_EQ(42, res);
257 } 256 }
258 257
259 258
260 typedef double (*F5)(double x, double y); 259 typedef double (*F5)(double x, double y);
261 260
262 TEST(AssemblerIa326) { 261 TEST(AssemblerIa326) {
263 if (!CpuFeatures::IsSupported(SSE2)) return; 262 if (!Isolate::Current()->cpu_features()->IsSupported(SSE2)) return;
264 263
265 InitializeVM(); 264 InitializeVM();
266 v8::HandleScope scope; 265 v8::HandleScope scope;
267 CHECK(CpuFeatures::IsSupported(SSE2)); 266 CHECK(Isolate::Current()->cpu_features()->IsSupported(SSE2));
268 CpuFeatures::Scope fscope(SSE2); 267 CpuFeatures::Scope fscope(SSE2);
269 v8::internal::byte buffer[256]; 268 v8::internal::byte buffer[256];
270 Assembler assm(buffer, sizeof buffer); 269 Assembler assm(buffer, sizeof buffer);
271 270
272 __ movdbl(xmm0, Operand(esp, 1 * kPointerSize)); 271 __ movdbl(xmm0, Operand(esp, 1 * kPointerSize));
273 __ movdbl(xmm1, Operand(esp, 3 * kPointerSize)); 272 __ movdbl(xmm1, Operand(esp, 3 * kPointerSize));
274 __ addsd(xmm0, xmm1); 273 __ addsd(xmm0, xmm1);
275 __ mulsd(xmm0, xmm1); 274 __ mulsd(xmm0, xmm1);
276 __ subsd(xmm0, xmm1); 275 __ subsd(xmm0, xmm1);
277 __ divsd(xmm0, xmm1); 276 __ divsd(xmm0, xmm1);
278 // Copy xmm0 to st(0) using eight bytes of stack. 277 // Copy xmm0 to st(0) using eight bytes of stack.
279 __ sub(Operand(esp), Immediate(8)); 278 __ sub(Operand(esp), Immediate(8));
280 __ movdbl(Operand(esp, 0), xmm0); 279 __ movdbl(Operand(esp, 0), xmm0);
281 __ fld_d(Operand(esp, 0)); 280 __ fld_d(Operand(esp, 0));
282 __ add(Operand(esp), Immediate(8)); 281 __ add(Operand(esp), Immediate(8));
283 __ ret(0); 282 __ ret(0);
284 283
285 CodeDesc desc; 284 CodeDesc desc;
286 assm.GetCode(&desc); 285 assm.GetCode(&desc);
287 Code* code = Code::cast(Heap::CreateCode( 286 Code* code = Code::cast(HEAP->CreateCode(
288 desc, 287 desc,
289 Code::ComputeFlags(Code::STUB), 288 Code::ComputeFlags(Code::STUB),
290 Handle<Object>(Heap::undefined_value()))->ToObjectChecked()); 289 Handle<Object>(HEAP->undefined_value()))->ToObjectChecked());
291 #ifdef DEBUG 290 #ifdef DEBUG
292 ::printf("\n---\n"); 291 ::printf("\n---\n");
293 // don't print the code - our disassembler can't handle SSE instructions 292 // don't print the code - our disassembler can't handle SSE instructions
294 // instead print bytes 293 // instead print bytes
295 Disassembler::Dump(stdout, 294 Disassembler::Dump(stdout,
296 code->instruction_start(), 295 code->instruction_start(),
297 code->instruction_start() + code->instruction_size()); 296 code->instruction_start() + code->instruction_size());
298 #endif 297 #endif
299 F5 f = FUNCTION_CAST<F5>(code->entry()); 298 F5 f = FUNCTION_CAST<F5>(code->entry());
300 double res = f(2.2, 1.1); 299 double res = f(2.2, 1.1);
301 ::printf("f() = %f\n", res); 300 ::printf("f() = %f\n", res);
302 CHECK(2.29 < res && res < 2.31); 301 CHECK(2.29 < res && res < 2.31);
303 } 302 }
304 303
305 304
306 typedef double (*F6)(int x); 305 typedef double (*F6)(int x);
307 306
308 TEST(AssemblerIa328) { 307 TEST(AssemblerIa328) {
309 if (!CpuFeatures::IsSupported(SSE2)) return; 308 if (!Isolate::Current()->cpu_features()->IsSupported(SSE2)) return;
310 309
311 InitializeVM(); 310 InitializeVM();
312 v8::HandleScope scope; 311 v8::HandleScope scope;
313 CHECK(CpuFeatures::IsSupported(SSE2)); 312 CHECK(Isolate::Current()->cpu_features()->IsSupported(SSE2));
314 CpuFeatures::Scope fscope(SSE2); 313 CpuFeatures::Scope fscope(SSE2);
315 v8::internal::byte buffer[256]; 314 v8::internal::byte buffer[256];
316 Assembler assm(buffer, sizeof buffer); 315 Assembler assm(buffer, sizeof buffer);
317 __ mov(eax, Operand(esp, 4)); 316 __ mov(eax, Operand(esp, 4));
318 __ cvtsi2sd(xmm0, Operand(eax)); 317 __ cvtsi2sd(xmm0, Operand(eax));
319 // Copy xmm0 to st(0) using eight bytes of stack. 318 // Copy xmm0 to st(0) using eight bytes of stack.
320 __ sub(Operand(esp), Immediate(8)); 319 __ sub(Operand(esp), Immediate(8));
321 __ movdbl(Operand(esp, 0), xmm0); 320 __ movdbl(Operand(esp, 0), xmm0);
322 __ fld_d(Operand(esp, 0)); 321 __ fld_d(Operand(esp, 0));
323 __ add(Operand(esp), Immediate(8)); 322 __ add(Operand(esp), Immediate(8));
324 __ ret(0); 323 __ ret(0);
325 CodeDesc desc; 324 CodeDesc desc;
326 assm.GetCode(&desc); 325 assm.GetCode(&desc);
327 Code* code = Code::cast(Heap::CreateCode( 326 Code* code = Code::cast(HEAP->CreateCode(
328 desc, 327 desc,
329 Code::ComputeFlags(Code::STUB), 328 Code::ComputeFlags(Code::STUB),
330 Handle<Object>(Heap::undefined_value()))->ToObjectChecked()); 329 Handle<Object>(HEAP->undefined_value()))->ToObjectChecked());
331 CHECK(code->IsCode()); 330 CHECK(code->IsCode());
332 #ifdef OBJECT_PRINT 331 #ifdef OBJECT_PRINT
333 Code::cast(code)->Print(); 332 Code::cast(code)->Print();
334 #endif 333 #endif
335 F6 f = FUNCTION_CAST<F6>(Code::cast(code)->entry()); 334 F6 f = FUNCTION_CAST<F6>(Code::cast(code)->entry());
336 double res = f(12); 335 double res = f(12);
337 336
338 ::printf("f() = %f\n", res); 337 ::printf("f() = %f\n", res);
339 CHECK(11.99 < res && res < 12.001); 338 CHECK(11.99 < res && res < 12.001);
340 } 339 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 __ mov(eax, kLess); 371 __ mov(eax, kLess);
373 __ ret(0); 372 __ ret(0);
374 373
375 __ bind(&nan_l); 374 __ bind(&nan_l);
376 __ mov(eax, kNaN); 375 __ mov(eax, kNaN);
377 __ ret(0); 376 __ ret(0);
378 377
379 378
380 CodeDesc desc; 379 CodeDesc desc;
381 assm.GetCode(&desc); 380 assm.GetCode(&desc);
382 Code* code = Code::cast(Heap::CreateCode( 381 Code* code = Code::cast(HEAP->CreateCode(
383 desc, 382 desc,
384 Code::ComputeFlags(Code::STUB), 383 Code::ComputeFlags(Code::STUB),
385 Handle<Object>(Heap::undefined_value()))->ToObjectChecked()); 384 Handle<Object>(HEAP->undefined_value()))->ToObjectChecked());
386 CHECK(code->IsCode()); 385 CHECK(code->IsCode());
387 #ifdef OBJECT_PRINT 386 #ifdef OBJECT_PRINT
388 Code::cast(code)->Print(); 387 Code::cast(code)->Print();
389 #endif 388 #endif
390 389
391 F7 f = FUNCTION_CAST<F7>(Code::cast(code)->entry()); 390 F7 f = FUNCTION_CAST<F7>(Code::cast(code)->entry());
392 CHECK_EQ(kLess, f(1.1, 2.2)); 391 CHECK_EQ(kLess, f(1.1, 2.2));
393 CHECK_EQ(kEqual, f(2.2, 2.2)); 392 CHECK_EQ(kEqual, f(2.2, 2.2));
394 CHECK_EQ(kGreater, f(3.3, 2.2)); 393 CHECK_EQ(kGreater, f(3.3, 2.2));
395 CHECK_EQ(kNaN, f(OS::nan_value(), 1.1)); 394 CHECK_EQ(kNaN, f(OS::nan_value(), 1.1));
396 } 395 }
397 396
398 #undef __ 397 #undef __
OLDNEW
« no previous file with comments | « test/cctest/test-assembler-arm.cc ('k') | test/cctest/test-assembler-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698