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

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

Issue 598703003: convert disassembler to use OStream (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « src/objects.cc ('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 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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 v8::internal::byte buffer[256]; 163 v8::internal::byte buffer[256];
164 Assembler assm(isolate, buffer, sizeof buffer); 164 Assembler assm(isolate, buffer, sizeof buffer);
165 165
166 __ cvttss2si(eax, Operand(esp, 4)); 166 __ cvttss2si(eax, Operand(esp, 4));
167 __ ret(0); 167 __ ret(0);
168 168
169 CodeDesc desc; 169 CodeDesc desc;
170 assm.GetCode(&desc); 170 assm.GetCode(&desc);
171 Handle<Code> code = isolate->factory()->NewCode( 171 Handle<Code> code = isolate->factory()->NewCode(
172 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); 172 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
173 // don't print the code - our disassembler can't handle cvttss2si 173 #ifdef OBJECT_PRINT
174 // instead print bytes 174 OFStream os(stdout);
175 Disassembler::Dump(stdout, 175 code->Print(os);
176 code->instruction_start(), 176 #endif
177 code->instruction_start() + code->instruction_size());
178 F3 f = FUNCTION_CAST<F3>(code->entry()); 177 F3 f = FUNCTION_CAST<F3>(code->entry());
179 int res = f(static_cast<float>(-3.1415)); 178 int res = f(static_cast<float>(-3.1415));
180 ::printf("f() = %d\n", res); 179 ::printf("f() = %d\n", res);
181 CHECK_EQ(-3, res); 180 CHECK_EQ(-3, res);
182 } 181 }
183 182
184 183
185 typedef int (*F4)(double x); 184 typedef int (*F4)(double x);
186 185
187 TEST(AssemblerIa324) { 186 TEST(AssemblerIa324) {
188 CcTest::InitializeVM(); 187 CcTest::InitializeVM();
189 188
190 Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate()); 189 Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate());
191 HandleScope scope(isolate); 190 HandleScope scope(isolate);
192 191
193 v8::internal::byte buffer[256]; 192 v8::internal::byte buffer[256];
194 Assembler assm(isolate, buffer, sizeof buffer); 193 Assembler assm(isolate, buffer, sizeof buffer);
195 194
196 __ cvttsd2si(eax, Operand(esp, 4)); 195 __ cvttsd2si(eax, Operand(esp, 4));
197 __ ret(0); 196 __ ret(0);
198 197
199 CodeDesc desc; 198 CodeDesc desc;
200 assm.GetCode(&desc); 199 assm.GetCode(&desc);
201 Handle<Code> code = isolate->factory()->NewCode( 200 Handle<Code> code = isolate->factory()->NewCode(
202 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); 201 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
203 // don't print the code - our disassembler can't handle cvttsd2si 202 #ifdef OBJECT_PRINT
204 // instead print bytes 203 OFStream os(stdout);
205 Disassembler::Dump(stdout, 204 code->Print(os);
206 code->instruction_start(), 205 #endif
207 code->instruction_start() + code->instruction_size());
208 F4 f = FUNCTION_CAST<F4>(code->entry()); 206 F4 f = FUNCTION_CAST<F4>(code->entry());
209 int res = f(2.718281828); 207 int res = f(2.718281828);
210 ::printf("f() = %d\n", res); 208 ::printf("f() = %d\n", res);
211 CHECK_EQ(2, res); 209 CHECK_EQ(2, res);
212 } 210 }
213 211
214 212
215 static int baz = 42; 213 static int baz = 42;
216 TEST(AssemblerIa325) { 214 TEST(AssemblerIa325) {
217 CcTest::InitializeVM(); 215 CcTest::InitializeVM();
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 __ sub(esp, Immediate(8)); 252 __ sub(esp, Immediate(8));
255 __ movsd(Operand(esp, 0), xmm0); 253 __ movsd(Operand(esp, 0), xmm0);
256 __ fld_d(Operand(esp, 0)); 254 __ fld_d(Operand(esp, 0));
257 __ add(esp, Immediate(8)); 255 __ add(esp, Immediate(8));
258 __ ret(0); 256 __ ret(0);
259 257
260 CodeDesc desc; 258 CodeDesc desc;
261 assm.GetCode(&desc); 259 assm.GetCode(&desc);
262 Handle<Code> code = isolate->factory()->NewCode( 260 Handle<Code> code = isolate->factory()->NewCode(
263 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); 261 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
264 #ifdef DEBUG 262 #ifdef OBJECT_PRINT
265 ::printf("\n---\n"); 263 OFStream os(stdout);
266 // don't print the code - our disassembler can't handle SSE instructions 264 code->Print(os);
267 // instead print bytes
268 Disassembler::Dump(stdout,
269 code->instruction_start(),
270 code->instruction_start() + code->instruction_size());
271 #endif 265 #endif
272 F5 f = FUNCTION_CAST<F5>(code->entry()); 266 F5 f = FUNCTION_CAST<F5>(code->entry());
273 double res = f(2.2, 1.1); 267 double res = f(2.2, 1.1);
274 ::printf("f() = %f\n", res); 268 ::printf("f() = %f\n", res);
275 CHECK(2.29 < res && res < 2.31); 269 CHECK(2.29 < res && res < 2.31);
276 } 270 }
277 271
278 272
279 typedef double (*F6)(int x); 273 typedef double (*F6)(int x);
280 274
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 OFStream os(stdout); 583 OFStream os(stdout);
590 code->Print(os); 584 code->Print(os);
591 #endif 585 #endif
592 586
593 F8 f = FUNCTION_CAST<F8>(code->entry()); 587 F8 f = FUNCTION_CAST<F8>(code->entry());
594 CHECK_EQ(2, f(1.0, 2.0)); 588 CHECK_EQ(2, f(1.0, 2.0));
595 } 589 }
596 590
597 591
598 #undef __ 592 #undef __
OLDNEW
« no previous file with comments | « src/objects.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698