OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 | 53 |
54 v8::internal::byte buffer[256]; | 54 v8::internal::byte buffer[256]; |
55 Assembler assm(isolate, buffer, sizeof buffer); | 55 Assembler assm(isolate, buffer, sizeof buffer); |
56 | 56 |
57 __ mov(eax, Operand(esp, 4)); | 57 __ mov(eax, Operand(esp, 4)); |
58 __ add(eax, Operand(esp, 8)); | 58 __ add(eax, Operand(esp, 8)); |
59 __ ret(0); | 59 __ ret(0); |
60 | 60 |
61 CodeDesc desc; | 61 CodeDesc desc; |
62 assm.GetCode(&desc); | 62 assm.GetCode(&desc); |
63 Object* code = isolate->heap()->CreateCode( | 63 Handle<Code> code = isolate->factory()->NewCode( |
64 desc, | 64 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
65 Code::ComputeFlags(Code::STUB), | |
66 Handle<Code>())->ToObjectChecked(); | |
67 CHECK(code->IsCode()); | |
68 #ifdef OBJECT_PRINT | 65 #ifdef OBJECT_PRINT |
69 Code::cast(code)->Print(); | 66 code->Print(); |
70 #endif | 67 #endif |
71 F2 f = FUNCTION_CAST<F2>(Code::cast(code)->entry()); | 68 F2 f = FUNCTION_CAST<F2>(code->entry()); |
72 int res = f(3, 4); | 69 int res = f(3, 4); |
73 ::printf("f() = %d\n", res); | 70 ::printf("f() = %d\n", res); |
74 CHECK_EQ(7, res); | 71 CHECK_EQ(7, res); |
75 } | 72 } |
76 | 73 |
77 | 74 |
78 TEST(AssemblerIa321) { | 75 TEST(AssemblerIa321) { |
79 CcTest::InitializeVM(); | 76 CcTest::InitializeVM(); |
80 Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate()); | 77 Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate()); |
81 HandleScope scope(isolate); | 78 HandleScope scope(isolate); |
(...skipping 10 matching lines...) Expand all Loading... |
92 __ add(eax, edx); | 89 __ add(eax, edx); |
93 __ sub(edx, Immediate(1)); | 90 __ sub(edx, Immediate(1)); |
94 | 91 |
95 __ bind(&C); | 92 __ bind(&C); |
96 __ test(edx, edx); | 93 __ test(edx, edx); |
97 __ j(not_zero, &L); | 94 __ j(not_zero, &L); |
98 __ ret(0); | 95 __ ret(0); |
99 | 96 |
100 CodeDesc desc; | 97 CodeDesc desc; |
101 assm.GetCode(&desc); | 98 assm.GetCode(&desc); |
102 Object* code = isolate->heap()->CreateCode( | 99 Handle<Code> code = isolate->factory()->NewCode( |
103 desc, | 100 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
104 Code::ComputeFlags(Code::STUB), | |
105 Handle<Code>())->ToObjectChecked(); | |
106 CHECK(code->IsCode()); | |
107 #ifdef OBJECT_PRINT | 101 #ifdef OBJECT_PRINT |
108 Code::cast(code)->Print(); | 102 code->Print(); |
109 #endif | 103 #endif |
110 F1 f = FUNCTION_CAST<F1>(Code::cast(code)->entry()); | 104 F1 f = FUNCTION_CAST<F1>(code->entry()); |
111 int res = f(100); | 105 int res = f(100); |
112 ::printf("f() = %d\n", res); | 106 ::printf("f() = %d\n", res); |
113 CHECK_EQ(5050, res); | 107 CHECK_EQ(5050, res); |
114 } | 108 } |
115 | 109 |
116 | 110 |
117 TEST(AssemblerIa322) { | 111 TEST(AssemblerIa322) { |
118 CcTest::InitializeVM(); | 112 CcTest::InitializeVM(); |
119 Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate()); | 113 Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate()); |
120 HandleScope scope(isolate); | 114 HandleScope scope(isolate); |
(...skipping 14 matching lines...) Expand all Loading... |
135 __ test(edx, edx); | 129 __ test(edx, edx); |
136 __ j(not_zero, &L); | 130 __ j(not_zero, &L); |
137 __ ret(0); | 131 __ ret(0); |
138 | 132 |
139 // some relocated stuff here, not executed | 133 // some relocated stuff here, not executed |
140 __ mov(eax, isolate->factory()->true_value()); | 134 __ mov(eax, isolate->factory()->true_value()); |
141 __ jmp(NULL, RelocInfo::RUNTIME_ENTRY); | 135 __ jmp(NULL, RelocInfo::RUNTIME_ENTRY); |
142 | 136 |
143 CodeDesc desc; | 137 CodeDesc desc; |
144 assm.GetCode(&desc); | 138 assm.GetCode(&desc); |
145 Object* code = isolate->heap()->CreateCode( | 139 Handle<Code> code = isolate->factory()->NewCode( |
146 desc, | 140 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
147 Code::ComputeFlags(Code::STUB), | |
148 Handle<Code>())->ToObjectChecked(); | |
149 CHECK(code->IsCode()); | |
150 #ifdef OBJECT_PRINT | 141 #ifdef OBJECT_PRINT |
151 Code::cast(code)->Print(); | 142 code->Print(); |
152 #endif | 143 #endif |
153 F1 f = FUNCTION_CAST<F1>(Code::cast(code)->entry()); | 144 F1 f = FUNCTION_CAST<F1>(code->entry()); |
154 int res = f(10); | 145 int res = f(10); |
155 ::printf("f() = %d\n", res); | 146 ::printf("f() = %d\n", res); |
156 CHECK_EQ(3628800, res); | 147 CHECK_EQ(3628800, res); |
157 } | 148 } |
158 | 149 |
159 | 150 |
160 typedef int (*F3)(float x); | 151 typedef int (*F3)(float x); |
161 | 152 |
162 TEST(AssemblerIa323) { | 153 TEST(AssemblerIa323) { |
163 CcTest::InitializeVM(); | 154 CcTest::InitializeVM(); |
164 if (!CpuFeatures::IsSupported(SSE2)) return; | 155 if (!CpuFeatures::IsSupported(SSE2)) return; |
165 | 156 |
166 Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate()); | 157 Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate()); |
167 HandleScope scope(isolate); | 158 HandleScope scope(isolate); |
168 | 159 |
169 v8::internal::byte buffer[256]; | 160 v8::internal::byte buffer[256]; |
170 Assembler assm(isolate, buffer, sizeof buffer); | 161 Assembler assm(isolate, buffer, sizeof buffer); |
171 | 162 |
172 CHECK(CpuFeatures::IsSupported(SSE2)); | 163 CHECK(CpuFeatures::IsSupported(SSE2)); |
173 { CpuFeatureScope fscope(&assm, SSE2); | 164 { CpuFeatureScope fscope(&assm, SSE2); |
174 __ cvttss2si(eax, Operand(esp, 4)); | 165 __ cvttss2si(eax, Operand(esp, 4)); |
175 __ ret(0); | 166 __ ret(0); |
176 } | 167 } |
177 | 168 |
178 CodeDesc desc; | 169 CodeDesc desc; |
179 assm.GetCode(&desc); | 170 assm.GetCode(&desc); |
180 Code* code = Code::cast(isolate->heap()->CreateCode( | 171 Handle<Code> code = isolate->factory()->NewCode( |
181 desc, | 172 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
182 Code::ComputeFlags(Code::STUB), | |
183 Handle<Code>())->ToObjectChecked()); | |
184 // don't print the code - our disassembler can't handle cvttss2si | 173 // don't print the code - our disassembler can't handle cvttss2si |
185 // instead print bytes | 174 // instead print bytes |
186 Disassembler::Dump(stdout, | 175 Disassembler::Dump(stdout, |
187 code->instruction_start(), | 176 code->instruction_start(), |
188 code->instruction_start() + code->instruction_size()); | 177 code->instruction_start() + code->instruction_size()); |
189 F3 f = FUNCTION_CAST<F3>(code->entry()); | 178 F3 f = FUNCTION_CAST<F3>(code->entry()); |
190 int res = f(static_cast<float>(-3.1415)); | 179 int res = f(static_cast<float>(-3.1415)); |
191 ::printf("f() = %d\n", res); | 180 ::printf("f() = %d\n", res); |
192 CHECK_EQ(-3, res); | 181 CHECK_EQ(-3, res); |
193 } | 182 } |
(...skipping 11 matching lines...) Expand all Loading... |
205 v8::internal::byte buffer[256]; | 194 v8::internal::byte buffer[256]; |
206 Assembler assm(isolate, buffer, sizeof buffer); | 195 Assembler assm(isolate, buffer, sizeof buffer); |
207 | 196 |
208 CHECK(CpuFeatures::IsSupported(SSE2)); | 197 CHECK(CpuFeatures::IsSupported(SSE2)); |
209 CpuFeatureScope fscope(&assm, SSE2); | 198 CpuFeatureScope fscope(&assm, SSE2); |
210 __ cvttsd2si(eax, Operand(esp, 4)); | 199 __ cvttsd2si(eax, Operand(esp, 4)); |
211 __ ret(0); | 200 __ ret(0); |
212 | 201 |
213 CodeDesc desc; | 202 CodeDesc desc; |
214 assm.GetCode(&desc); | 203 assm.GetCode(&desc); |
215 Code* code = Code::cast(isolate->heap()->CreateCode( | 204 Handle<Code> code = isolate->factory()->NewCode( |
216 desc, | 205 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
217 Code::ComputeFlags(Code::STUB), | |
218 Handle<Code>())->ToObjectChecked()); | |
219 // don't print the code - our disassembler can't handle cvttsd2si | 206 // don't print the code - our disassembler can't handle cvttsd2si |
220 // instead print bytes | 207 // instead print bytes |
221 Disassembler::Dump(stdout, | 208 Disassembler::Dump(stdout, |
222 code->instruction_start(), | 209 code->instruction_start(), |
223 code->instruction_start() + code->instruction_size()); | 210 code->instruction_start() + code->instruction_size()); |
224 F4 f = FUNCTION_CAST<F4>(code->entry()); | 211 F4 f = FUNCTION_CAST<F4>(code->entry()); |
225 int res = f(2.718281828); | 212 int res = f(2.718281828); |
226 ::printf("f() = %d\n", res); | 213 ::printf("f() = %d\n", res); |
227 CHECK_EQ(2, res); | 214 CHECK_EQ(2, res); |
228 } | 215 } |
229 | 216 |
230 | 217 |
231 static int baz = 42; | 218 static int baz = 42; |
232 TEST(AssemblerIa325) { | 219 TEST(AssemblerIa325) { |
233 CcTest::InitializeVM(); | 220 CcTest::InitializeVM(); |
234 Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate()); | 221 Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate()); |
235 HandleScope scope(isolate); | 222 HandleScope scope(isolate); |
236 | 223 |
237 v8::internal::byte buffer[256]; | 224 v8::internal::byte buffer[256]; |
238 Assembler assm(isolate, buffer, sizeof buffer); | 225 Assembler assm(isolate, buffer, sizeof buffer); |
239 | 226 |
240 __ mov(eax, Operand(reinterpret_cast<intptr_t>(&baz), RelocInfo::NONE32)); | 227 __ mov(eax, Operand(reinterpret_cast<intptr_t>(&baz), RelocInfo::NONE32)); |
241 __ ret(0); | 228 __ ret(0); |
242 | 229 |
243 CodeDesc desc; | 230 CodeDesc desc; |
244 assm.GetCode(&desc); | 231 assm.GetCode(&desc); |
245 Code* code = Code::cast(isolate->heap()->CreateCode( | 232 Handle<Code> code = isolate->factory()->NewCode( |
246 desc, | 233 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
247 Code::ComputeFlags(Code::STUB), | |
248 Handle<Code>())->ToObjectChecked()); | |
249 F0 f = FUNCTION_CAST<F0>(code->entry()); | 234 F0 f = FUNCTION_CAST<F0>(code->entry()); |
250 int res = f(); | 235 int res = f(); |
251 CHECK_EQ(42, res); | 236 CHECK_EQ(42, res); |
252 } | 237 } |
253 | 238 |
254 | 239 |
255 typedef double (*F5)(double x, double y); | 240 typedef double (*F5)(double x, double y); |
256 | 241 |
257 TEST(AssemblerIa326) { | 242 TEST(AssemblerIa326) { |
258 CcTest::InitializeVM(); | 243 CcTest::InitializeVM(); |
(...skipping 13 matching lines...) Expand all Loading... |
272 __ divsd(xmm0, xmm1); | 257 __ divsd(xmm0, xmm1); |
273 // Copy xmm0 to st(0) using eight bytes of stack. | 258 // Copy xmm0 to st(0) using eight bytes of stack. |
274 __ sub(esp, Immediate(8)); | 259 __ sub(esp, Immediate(8)); |
275 __ movsd(Operand(esp, 0), xmm0); | 260 __ movsd(Operand(esp, 0), xmm0); |
276 __ fld_d(Operand(esp, 0)); | 261 __ fld_d(Operand(esp, 0)); |
277 __ add(esp, Immediate(8)); | 262 __ add(esp, Immediate(8)); |
278 __ ret(0); | 263 __ ret(0); |
279 | 264 |
280 CodeDesc desc; | 265 CodeDesc desc; |
281 assm.GetCode(&desc); | 266 assm.GetCode(&desc); |
282 Code* code = Code::cast(isolate->heap()->CreateCode( | 267 Handle<Code> code = isolate->factory()->NewCode( |
283 desc, | 268 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
284 Code::ComputeFlags(Code::STUB), | |
285 Handle<Code>())->ToObjectChecked()); | |
286 #ifdef DEBUG | 269 #ifdef DEBUG |
287 ::printf("\n---\n"); | 270 ::printf("\n---\n"); |
288 // don't print the code - our disassembler can't handle SSE instructions | 271 // don't print the code - our disassembler can't handle SSE instructions |
289 // instead print bytes | 272 // instead print bytes |
290 Disassembler::Dump(stdout, | 273 Disassembler::Dump(stdout, |
291 code->instruction_start(), | 274 code->instruction_start(), |
292 code->instruction_start() + code->instruction_size()); | 275 code->instruction_start() + code->instruction_size()); |
293 #endif | 276 #endif |
294 F5 f = FUNCTION_CAST<F5>(code->entry()); | 277 F5 f = FUNCTION_CAST<F5>(code->entry()); |
295 double res = f(2.2, 1.1); | 278 double res = f(2.2, 1.1); |
(...skipping 16 matching lines...) Expand all Loading... |
312 __ mov(eax, Operand(esp, 4)); | 295 __ mov(eax, Operand(esp, 4)); |
313 __ cvtsi2sd(xmm0, eax); | 296 __ cvtsi2sd(xmm0, eax); |
314 // Copy xmm0 to st(0) using eight bytes of stack. | 297 // Copy xmm0 to st(0) using eight bytes of stack. |
315 __ sub(esp, Immediate(8)); | 298 __ sub(esp, Immediate(8)); |
316 __ movsd(Operand(esp, 0), xmm0); | 299 __ movsd(Operand(esp, 0), xmm0); |
317 __ fld_d(Operand(esp, 0)); | 300 __ fld_d(Operand(esp, 0)); |
318 __ add(esp, Immediate(8)); | 301 __ add(esp, Immediate(8)); |
319 __ ret(0); | 302 __ ret(0); |
320 CodeDesc desc; | 303 CodeDesc desc; |
321 assm.GetCode(&desc); | 304 assm.GetCode(&desc); |
322 Code* code = Code::cast(isolate->heap()->CreateCode( | 305 Handle<Code> code = isolate->factory()->NewCode( |
323 desc, | 306 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
324 Code::ComputeFlags(Code::STUB), | |
325 Handle<Code>())->ToObjectChecked()); | |
326 CHECK(code->IsCode()); | |
327 #ifdef OBJECT_PRINT | 307 #ifdef OBJECT_PRINT |
328 Code::cast(code)->Print(); | 308 code->Print(); |
329 #endif | 309 #endif |
330 F6 f = FUNCTION_CAST<F6>(Code::cast(code)->entry()); | 310 F6 f = FUNCTION_CAST<F6>(code->entry()); |
331 double res = f(12); | 311 double res = f(12); |
332 | 312 |
333 ::printf("f() = %f\n", res); | 313 ::printf("f() = %f\n", res); |
334 CHECK(11.99 < res && res < 12.001); | 314 CHECK(11.99 < res && res < 12.001); |
335 } | 315 } |
336 | 316 |
337 | 317 |
338 typedef int (*F7)(double x, double y); | 318 typedef int (*F7)(double x, double y); |
339 | 319 |
340 TEST(AssemblerIa329) { | 320 TEST(AssemblerIa329) { |
(...skipping 27 matching lines...) Expand all Loading... |
368 __ mov(eax, kLess); | 348 __ mov(eax, kLess); |
369 __ ret(0); | 349 __ ret(0); |
370 | 350 |
371 __ bind(&nan_l); | 351 __ bind(&nan_l); |
372 __ mov(eax, kNaN); | 352 __ mov(eax, kNaN); |
373 __ ret(0); | 353 __ ret(0); |
374 | 354 |
375 | 355 |
376 CodeDesc desc; | 356 CodeDesc desc; |
377 assm.GetCode(&desc); | 357 assm.GetCode(&desc); |
378 Code* code = Code::cast(isolate->heap()->CreateCode( | 358 Handle<Code> code = isolate->factory()->NewCode( |
379 desc, | 359 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
380 Code::ComputeFlags(Code::STUB), | |
381 Handle<Code>())->ToObjectChecked()); | |
382 CHECK(code->IsCode()); | |
383 #ifdef OBJECT_PRINT | 360 #ifdef OBJECT_PRINT |
384 Code::cast(code)->Print(); | 361 code->Print(); |
385 #endif | 362 #endif |
386 | 363 |
387 F7 f = FUNCTION_CAST<F7>(Code::cast(code)->entry()); | 364 F7 f = FUNCTION_CAST<F7>(code->entry()); |
388 CHECK_EQ(kLess, f(1.1, 2.2)); | 365 CHECK_EQ(kLess, f(1.1, 2.2)); |
389 CHECK_EQ(kEqual, f(2.2, 2.2)); | 366 CHECK_EQ(kEqual, f(2.2, 2.2)); |
390 CHECK_EQ(kGreater, f(3.3, 2.2)); | 367 CHECK_EQ(kGreater, f(3.3, 2.2)); |
391 CHECK_EQ(kNaN, f(OS::nan_value(), 1.1)); | 368 CHECK_EQ(kNaN, f(OS::nan_value(), 1.1)); |
392 } | 369 } |
393 | 370 |
394 | 371 |
395 TEST(AssemblerIa3210) { | 372 TEST(AssemblerIa3210) { |
396 // Test chaining of label usages within instructions (issue 1644). | 373 // Test chaining of label usages within instructions (issue 1644). |
397 CcTest::InitializeVM(); | 374 CcTest::InitializeVM(); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
454 __ mov(eax, 13); | 431 __ mov(eax, 13); |
455 __ pop(esi); | 432 __ pop(esi); |
456 __ pop(edi); | 433 __ pop(edi); |
457 __ pop(edx); | 434 __ pop(edx); |
458 __ pop(ecx); | 435 __ pop(ecx); |
459 __ pop(ebx); | 436 __ pop(ebx); |
460 __ ret(0); | 437 __ ret(0); |
461 | 438 |
462 CodeDesc desc; | 439 CodeDesc desc; |
463 assm.GetCode(&desc); | 440 assm.GetCode(&desc); |
464 Code* code = Code::cast(isolate->heap()->CreateCode( | 441 Handle<Code> code = isolate->factory()->NewCode( |
465 desc, | 442 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
466 Code::ComputeFlags(Code::STUB), | |
467 Handle<Code>())->ToObjectChecked()); | |
468 CHECK(code->IsCode()); | 443 CHECK(code->IsCode()); |
469 | 444 |
470 F0 f = FUNCTION_CAST<F0>(code->entry()); | 445 F0 f = FUNCTION_CAST<F0>(code->entry()); |
471 int res = f(); | 446 int res = f(); |
472 CHECK_EQ(42, res); | 447 CHECK_EQ(42, res); |
473 } | 448 } |
474 | 449 |
475 | 450 |
476 #ifdef __GNUC__ | 451 #ifdef __GNUC__ |
477 #define ELEMENT_COUNT 4 | 452 #define ELEMENT_COUNT 4 |
(...skipping 29 matching lines...) Expand all Loading... |
507 // Remove unused data from the stack. | 482 // Remove unused data from the stack. |
508 __ add(esp, Immediate(ELEMENT_COUNT * sizeof(int32_t))); | 483 __ add(esp, Immediate(ELEMENT_COUNT * sizeof(int32_t))); |
509 // Restore return address. | 484 // Restore return address. |
510 __ push(ecx); | 485 __ push(ecx); |
511 | 486 |
512 __ ret(0); | 487 __ ret(0); |
513 | 488 |
514 CodeDesc desc; | 489 CodeDesc desc; |
515 assm.GetCode(&desc); | 490 assm.GetCode(&desc); |
516 | 491 |
517 Object* code = isolate->heap()->CreateCode( | 492 Handle<Code> code = isolate->factory()->NewCode( |
518 desc, | 493 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
519 Code::ComputeFlags(Code::STUB), | |
520 Handle<Code>())->ToObjectChecked(); | |
521 CHECK(code->IsCode()); | |
522 | 494 |
523 F0 f = FUNCTION_CAST<F0>(Code::cast(code)->entry()); | 495 F0 f = FUNCTION_CAST<F0>(code->entry()); |
524 int res = f(); | 496 int res = f(); |
525 args.GetReturnValue().Set(v8::Integer::New(CcTest::isolate(), res)); | 497 args.GetReturnValue().Set(v8::Integer::New(CcTest::isolate(), res)); |
526 } | 498 } |
527 | 499 |
528 | 500 |
529 TEST(StackAlignmentForSSE2) { | 501 TEST(StackAlignmentForSSE2) { |
530 CcTest::InitializeVM(); | 502 CcTest::InitializeVM(); |
531 if (!CpuFeatures::IsSupported(SSE2)) return; | 503 if (!CpuFeatures::IsSupported(SSE2)) return; |
532 | 504 |
533 CHECK_EQ(0, OS::ActivationFrameAlignment() % 16); | 505 CHECK_EQ(0, OS::ActivationFrameAlignment() % 16); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
577 MacroAssembler assm(isolate, buffer, sizeof buffer); | 549 MacroAssembler assm(isolate, buffer, sizeof buffer); |
578 { CpuFeatureScope fscope2(&assm, SSE2); | 550 { CpuFeatureScope fscope2(&assm, SSE2); |
579 CpuFeatureScope fscope41(&assm, SSE4_1); | 551 CpuFeatureScope fscope41(&assm, SSE4_1); |
580 __ movsd(xmm1, Operand(esp, 4)); | 552 __ movsd(xmm1, Operand(esp, 4)); |
581 __ extractps(eax, xmm1, 0x1); | 553 __ extractps(eax, xmm1, 0x1); |
582 __ ret(0); | 554 __ ret(0); |
583 } | 555 } |
584 | 556 |
585 CodeDesc desc; | 557 CodeDesc desc; |
586 assm.GetCode(&desc); | 558 assm.GetCode(&desc); |
587 Code* code = Code::cast(isolate->heap()->CreateCode( | 559 Handle<Code> code = isolate->factory()->NewCode( |
588 desc, | 560 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
589 Code::ComputeFlags(Code::STUB), | |
590 Handle<Code>())->ToObjectChecked()); | |
591 CHECK(code->IsCode()); | |
592 #ifdef OBJECT_PRINT | 561 #ifdef OBJECT_PRINT |
593 Code::cast(code)->Print(); | 562 code->Print(); |
594 #endif | 563 #endif |
595 | 564 |
596 F4 f = FUNCTION_CAST<F4>(Code::cast(code)->entry()); | 565 F4 f = FUNCTION_CAST<F4>(code->entry()); |
597 uint64_t value1 = V8_2PART_UINT64_C(0x12345678, 87654321); | 566 uint64_t value1 = V8_2PART_UINT64_C(0x12345678, 87654321); |
598 CHECK_EQ(0x12345678, f(uint64_to_double(value1))); | 567 CHECK_EQ(0x12345678, f(uint64_to_double(value1))); |
599 uint64_t value2 = V8_2PART_UINT64_C(0x87654321, 12345678); | 568 uint64_t value2 = V8_2PART_UINT64_C(0x87654321, 12345678); |
600 CHECK_EQ(0x87654321, f(uint64_to_double(value2))); | 569 CHECK_EQ(0x87654321, f(uint64_to_double(value2))); |
601 } | 570 } |
602 | 571 |
603 | 572 |
604 typedef int (*F8)(float x, float y); | 573 typedef int (*F8)(float x, float y); |
605 TEST(AssemblerIa32SSE) { | 574 TEST(AssemblerIa32SSE) { |
606 CcTest::InitializeVM(); | 575 CcTest::InitializeVM(); |
(...skipping 13 matching lines...) Expand all Loading... |
620 __ addps(xmm2, xmm0); | 589 __ addps(xmm2, xmm0); |
621 __ mulps(xmm2, xmm1); | 590 __ mulps(xmm2, xmm1); |
622 __ subps(xmm2, xmm0); | 591 __ subps(xmm2, xmm0); |
623 __ divps(xmm2, xmm1); | 592 __ divps(xmm2, xmm1); |
624 __ cvttss2si(eax, xmm2); | 593 __ cvttss2si(eax, xmm2); |
625 __ ret(0); | 594 __ ret(0); |
626 } | 595 } |
627 | 596 |
628 CodeDesc desc; | 597 CodeDesc desc; |
629 assm.GetCode(&desc); | 598 assm.GetCode(&desc); |
630 Code* code = Code::cast(isolate->heap()->CreateCode( | 599 Handle<Code> code = isolate->factory()->NewCode( |
631 desc, | 600 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
632 Code::ComputeFlags(Code::STUB), | |
633 Handle<Code>())->ToObjectChecked()); | |
634 CHECK(code->IsCode()); | |
635 #ifdef OBJECT_PRINT | 601 #ifdef OBJECT_PRINT |
636 Code::cast(code)->Print(); | 602 code->Print(); |
637 #endif | 603 #endif |
638 | 604 |
639 F8 f = FUNCTION_CAST<F8>(Code::cast(code)->entry()); | 605 F8 f = FUNCTION_CAST<F8>(code->entry()); |
640 CHECK_EQ(2, f(1.0, 2.0)); | 606 CHECK_EQ(2, f(1.0, 2.0)); |
641 } | 607 } |
642 | 608 |
643 | 609 |
644 #undef __ | 610 #undef __ |
OLD | NEW |