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

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

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

Powered by Google App Engine
This is Rietveld 408576698