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

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

Issue 363323003: More OStreamsUse OStreams more often. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebased and polished. Created 6 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-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 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 Handle<Code> code = isolate->factory()->NewCode( 63 Handle<Code> code = isolate->factory()->NewCode(
64 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); 64 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
65 #ifdef OBJECT_PRINT 65 #ifdef OBJECT_PRINT
66 code->Print(); 66 OFStream os(stdout);
67 code->Print(os);
67 #endif 68 #endif
68 F2 f = FUNCTION_CAST<F2>(code->entry()); 69 F2 f = FUNCTION_CAST<F2>(code->entry());
69 int res = f(3, 4); 70 int res = f(3, 4);
70 ::printf("f() = %d\n", res); 71 ::printf("f() = %d\n", res);
71 CHECK_EQ(7, res); 72 CHECK_EQ(7, res);
72 } 73 }
73 74
74 75
75 TEST(AssemblerIa321) { 76 TEST(AssemblerIa321) {
76 CcTest::InitializeVM(); 77 CcTest::InitializeVM();
(...skipping 15 matching lines...) Expand all
92 __ bind(&C); 93 __ bind(&C);
93 __ test(edx, edx); 94 __ test(edx, edx);
94 __ j(not_zero, &L); 95 __ j(not_zero, &L);
95 __ ret(0); 96 __ ret(0);
96 97
97 CodeDesc desc; 98 CodeDesc desc;
98 assm.GetCode(&desc); 99 assm.GetCode(&desc);
99 Handle<Code> code = isolate->factory()->NewCode( 100 Handle<Code> code = isolate->factory()->NewCode(
100 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); 101 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
101 #ifdef OBJECT_PRINT 102 #ifdef OBJECT_PRINT
102 code->Print(); 103 OFStream os(stdout);
104 code->Print(os);
103 #endif 105 #endif
104 F1 f = FUNCTION_CAST<F1>(code->entry()); 106 F1 f = FUNCTION_CAST<F1>(code->entry());
105 int res = f(100); 107 int res = f(100);
106 ::printf("f() = %d\n", res); 108 ::printf("f() = %d\n", res);
107 CHECK_EQ(5050, res); 109 CHECK_EQ(5050, res);
108 } 110 }
109 111
110 112
111 TEST(AssemblerIa322) { 113 TEST(AssemblerIa322) {
112 CcTest::InitializeVM(); 114 CcTest::InitializeVM();
(...skipping 19 matching lines...) Expand all
132 134
133 // some relocated stuff here, not executed 135 // some relocated stuff here, not executed
134 __ mov(eax, isolate->factory()->true_value()); 136 __ mov(eax, isolate->factory()->true_value());
135 __ jmp(NULL, RelocInfo::RUNTIME_ENTRY); 137 __ jmp(NULL, RelocInfo::RUNTIME_ENTRY);
136 138
137 CodeDesc desc; 139 CodeDesc desc;
138 assm.GetCode(&desc); 140 assm.GetCode(&desc);
139 Handle<Code> code = isolate->factory()->NewCode( 141 Handle<Code> code = isolate->factory()->NewCode(
140 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); 142 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
141 #ifdef OBJECT_PRINT 143 #ifdef OBJECT_PRINT
142 code->Print(); 144 OFStream os(stdout);
145 code->Print(os);
143 #endif 146 #endif
144 F1 f = FUNCTION_CAST<F1>(code->entry()); 147 F1 f = FUNCTION_CAST<F1>(code->entry());
145 int res = f(10); 148 int res = f(10);
146 ::printf("f() = %d\n", res); 149 ::printf("f() = %d\n", res);
147 CHECK_EQ(3628800, res); 150 CHECK_EQ(3628800, res);
148 } 151 }
149 152
150 153
151 typedef int (*F3)(float x); 154 typedef int (*F3)(float x);
152 155
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 __ sub(esp, Immediate(8)); 290 __ sub(esp, Immediate(8));
288 __ movsd(Operand(esp, 0), xmm0); 291 __ movsd(Operand(esp, 0), xmm0);
289 __ fld_d(Operand(esp, 0)); 292 __ fld_d(Operand(esp, 0));
290 __ add(esp, Immediate(8)); 293 __ add(esp, Immediate(8));
291 __ ret(0); 294 __ ret(0);
292 CodeDesc desc; 295 CodeDesc desc;
293 assm.GetCode(&desc); 296 assm.GetCode(&desc);
294 Handle<Code> code = isolate->factory()->NewCode( 297 Handle<Code> code = isolate->factory()->NewCode(
295 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); 298 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
296 #ifdef OBJECT_PRINT 299 #ifdef OBJECT_PRINT
297 code->Print(); 300 OFStream os(stdout);
301 code->Print(os);
298 #endif 302 #endif
299 F6 f = FUNCTION_CAST<F6>(code->entry()); 303 F6 f = FUNCTION_CAST<F6>(code->entry());
300 double res = f(12); 304 double res = f(12);
301 305
302 ::printf("f() = %f\n", res); 306 ::printf("f() = %f\n", res);
303 CHECK(11.99 < res && res < 12.001); 307 CHECK(11.99 < res && res < 12.001);
304 } 308 }
305 309
306 310
307 typedef int (*F7)(double x, double y); 311 typedef int (*F7)(double x, double y);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 __ bind(&nan_l); 344 __ bind(&nan_l);
341 __ mov(eax, kNaN); 345 __ mov(eax, kNaN);
342 __ ret(0); 346 __ ret(0);
343 347
344 348
345 CodeDesc desc; 349 CodeDesc desc;
346 assm.GetCode(&desc); 350 assm.GetCode(&desc);
347 Handle<Code> code = isolate->factory()->NewCode( 351 Handle<Code> code = isolate->factory()->NewCode(
348 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); 352 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
349 #ifdef OBJECT_PRINT 353 #ifdef OBJECT_PRINT
350 code->Print(); 354 OFStream os(stdout);
355 code->Print(os);
351 #endif 356 #endif
352 357
353 F7 f = FUNCTION_CAST<F7>(code->entry()); 358 F7 f = FUNCTION_CAST<F7>(code->entry());
354 CHECK_EQ(kLess, f(1.1, 2.2)); 359 CHECK_EQ(kLess, f(1.1, 2.2));
355 CHECK_EQ(kEqual, f(2.2, 2.2)); 360 CHECK_EQ(kEqual, f(2.2, 2.2));
356 CHECK_EQ(kGreater, f(3.3, 2.2)); 361 CHECK_EQ(kGreater, f(3.3, 2.2));
357 CHECK_EQ(kNaN, f(v8::base::OS::nan_value(), 1.1)); 362 CHECK_EQ(kNaN, f(v8::base::OS::nan_value(), 1.1));
358 } 363 }
359 364
360 365
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 __ movsd(xmm1, Operand(esp, 4)); 539 __ movsd(xmm1, Operand(esp, 4));
535 __ extractps(eax, xmm1, 0x1); 540 __ extractps(eax, xmm1, 0x1);
536 __ ret(0); 541 __ ret(0);
537 } 542 }
538 543
539 CodeDesc desc; 544 CodeDesc desc;
540 assm.GetCode(&desc); 545 assm.GetCode(&desc);
541 Handle<Code> code = isolate->factory()->NewCode( 546 Handle<Code> code = isolate->factory()->NewCode(
542 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); 547 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
543 #ifdef OBJECT_PRINT 548 #ifdef OBJECT_PRINT
544 code->Print(); 549 OFStream os(stdout);
550 code->Print(os);
545 #endif 551 #endif
546 552
547 F4 f = FUNCTION_CAST<F4>(code->entry()); 553 F4 f = FUNCTION_CAST<F4>(code->entry());
548 uint64_t value1 = V8_2PART_UINT64_C(0x12345678, 87654321); 554 uint64_t value1 = V8_2PART_UINT64_C(0x12345678, 87654321);
549 CHECK_EQ(0x12345678, f(uint64_to_double(value1))); 555 CHECK_EQ(0x12345678, f(uint64_to_double(value1)));
550 uint64_t value2 = V8_2PART_UINT64_C(0x87654321, 12345678); 556 uint64_t value2 = V8_2PART_UINT64_C(0x87654321, 12345678);
551 CHECK_EQ(0x87654321, f(uint64_to_double(value2))); 557 CHECK_EQ(0x87654321, f(uint64_to_double(value2)));
552 } 558 }
553 559
554 560
(...skipping 17 matching lines...) Expand all
572 __ divps(xmm2, xmm1); 578 __ divps(xmm2, xmm1);
573 __ cvttss2si(eax, xmm2); 579 __ cvttss2si(eax, xmm2);
574 __ ret(0); 580 __ ret(0);
575 } 581 }
576 582
577 CodeDesc desc; 583 CodeDesc desc;
578 assm.GetCode(&desc); 584 assm.GetCode(&desc);
579 Handle<Code> code = isolate->factory()->NewCode( 585 Handle<Code> code = isolate->factory()->NewCode(
580 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); 586 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
581 #ifdef OBJECT_PRINT 587 #ifdef OBJECT_PRINT
582 code->Print(); 588 OFStream os(stdout);
589 code->Print(os);
583 #endif 590 #endif
584 591
585 F8 f = FUNCTION_CAST<F8>(code->entry()); 592 F8 f = FUNCTION_CAST<F8>(code->entry());
586 CHECK_EQ(2, f(1.0, 2.0)); 593 CHECK_EQ(2, f(1.0, 2.0));
587 } 594 }
588 595
589 596
590 #undef __ 597 #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