OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 | 52 |
53 Assembler assm(isolate, NULL, 0); | 53 Assembler assm(isolate, NULL, 0); |
54 | 54 |
55 __ lhi(r1, Operand(3)); // test 4-byte instr | 55 __ lhi(r1, Operand(3)); // test 4-byte instr |
56 __ llilf(r2, Operand(4)); // test 6-byte instr | 56 __ llilf(r2, Operand(4)); // test 6-byte instr |
57 __ lgr(r2, r2); // test 2-byte opcode | 57 __ lgr(r2, r2); // test 2-byte opcode |
58 __ ar(r2, r1); // test 2-byte instr | 58 __ ar(r2, r1); // test 2-byte instr |
59 __ b(r14); | 59 __ b(r14); |
60 | 60 |
61 CodeDesc desc; | 61 CodeDesc desc; |
62 assm.GetCode(&desc); | 62 assm.GetCode(isolate, &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 DEBUG | 65 #ifdef DEBUG |
66 code->Print(); | 66 code->Print(); |
67 #endif | 67 #endif |
68 F2 f = FUNCTION_CAST<F2>(code->entry()); | 68 F2 f = FUNCTION_CAST<F2>(code->entry()); |
69 intptr_t res = reinterpret_cast<intptr_t>( | 69 intptr_t res = reinterpret_cast<intptr_t>( |
70 CALL_GENERATED_CODE(isolate, f, 3, 4, 0, 0, 0)); | 70 CALL_GENERATED_CODE(isolate, f, 3, 4, 0, 0, 0)); |
71 ::printf("f() = %" V8PRIxPTR "\n", res); | 71 ::printf("f() = %" V8PRIxPTR "\n", res); |
72 CHECK_EQ(7, static_cast<int>(res)); | 72 CHECK_EQ(7, static_cast<int>(res)); |
(...skipping 19 matching lines...) Expand all Loading... |
92 __ bind(&L); | 92 __ bind(&L); |
93 __ ar(r2, r3); | 93 __ ar(r2, r3); |
94 __ ahi(r3, Operand(-1 & 0xFFFF)); | 94 __ ahi(r3, Operand(-1 & 0xFFFF)); |
95 | 95 |
96 __ bind(&C); | 96 __ bind(&C); |
97 __ cfi(r3, Operand(0, kRelocInfo_NONEPTR)); | 97 __ cfi(r3, Operand(0, kRelocInfo_NONEPTR)); |
98 __ bne(&L); | 98 __ bne(&L); |
99 __ b(r14); | 99 __ b(r14); |
100 | 100 |
101 CodeDesc desc; | 101 CodeDesc desc; |
102 assm.GetCode(&desc); | 102 assm.GetCode(isolate, &desc); |
103 Handle<Code> code = isolate->factory()->NewCode( | 103 Handle<Code> code = isolate->factory()->NewCode( |
104 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | 104 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
105 #ifdef DEBUG | 105 #ifdef DEBUG |
106 code->Print(); | 106 code->Print(); |
107 #endif | 107 #endif |
108 F1 f = FUNCTION_CAST<F1>(code->entry()); | 108 F1 f = FUNCTION_CAST<F1>(code->entry()); |
109 intptr_t res = reinterpret_cast<intptr_t>( | 109 intptr_t res = reinterpret_cast<intptr_t>( |
110 CALL_GENERATED_CODE(isolate, f, 100, 0, 0, 0, 0)); | 110 CALL_GENERATED_CODE(isolate, f, 100, 0, 0, 0, 0)); |
111 ::printf("f() = %" V8PRIxPTR "\n", res); | 111 ::printf("f() = %" V8PRIxPTR "\n", res); |
112 CHECK_EQ(5050, static_cast<int>(res)); | 112 CHECK_EQ(5050, static_cast<int>(res)); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 // some relocated stuff here, not executed | 144 // some relocated stuff here, not executed |
145 __ RecordComment("dead code, just testing relocations"); | 145 __ RecordComment("dead code, just testing relocations"); |
146 __ iilf(r0, Operand(isolate->factory()->true_value())); | 146 __ iilf(r0, Operand(isolate->factory()->true_value())); |
147 __ RecordComment("dead code, just testing immediate operands"); | 147 __ RecordComment("dead code, just testing immediate operands"); |
148 __ iilf(r0, Operand(-1)); | 148 __ iilf(r0, Operand(-1)); |
149 __ iilf(r0, Operand(0xFF000000)); | 149 __ iilf(r0, Operand(0xFF000000)); |
150 __ iilf(r0, Operand(0xF0F0F0F0)); | 150 __ iilf(r0, Operand(0xF0F0F0F0)); |
151 __ iilf(r0, Operand(0xFFF0FFFF)); | 151 __ iilf(r0, Operand(0xFFF0FFFF)); |
152 | 152 |
153 CodeDesc desc; | 153 CodeDesc desc; |
154 assm.GetCode(&desc); | 154 assm.GetCode(isolate, &desc); |
155 Handle<Code> code = isolate->factory()->NewCode( | 155 Handle<Code> code = isolate->factory()->NewCode( |
156 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | 156 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
157 #ifdef DEBUG | 157 #ifdef DEBUG |
158 code->Print(); | 158 code->Print(); |
159 #endif | 159 #endif |
160 F1 f = FUNCTION_CAST<F1>(code->entry()); | 160 F1 f = FUNCTION_CAST<F1>(code->entry()); |
161 intptr_t res = reinterpret_cast<intptr_t>( | 161 intptr_t res = reinterpret_cast<intptr_t>( |
162 CALL_GENERATED_CODE(isolate, f, 10, 0, 0, 0, 0)); | 162 CALL_GENERATED_CODE(isolate, f, 10, 0, 0, 0, 0)); |
163 ::printf("f() = %" V8PRIxPTR "\n", res); | 163 ::printf("f() = %" V8PRIxPTR "\n", res); |
164 CHECK_EQ(3628800, static_cast<int>(res)); | 164 CHECK_EQ(3628800, static_cast<int>(res)); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 __ iihf(r13, Operand(-123456789)); | 200 __ iihf(r13, Operand(-123456789)); |
201 __ mvc(MemOperand(r0, 123), MemOperand(r4, 567), 89); | 201 __ mvc(MemOperand(r0, 123), MemOperand(r4, 567), 89); |
202 __ sll(r13, Operand(10)); | 202 __ sll(r13, Operand(10)); |
203 | 203 |
204 v8::internal::byte* bufPos = assm.buffer_pos(); | 204 v8::internal::byte* bufPos = assm.buffer_pos(); |
205 ::printf("buffer position = %p", static_cast<void*>(bufPos)); | 205 ::printf("buffer position = %p", static_cast<void*>(bufPos)); |
206 ::fflush(stdout); | 206 ::fflush(stdout); |
207 // OS::DebugBreak(); | 207 // OS::DebugBreak(); |
208 | 208 |
209 CodeDesc desc; | 209 CodeDesc desc; |
210 assm.GetCode(&desc); | 210 assm.GetCode(isolate, &desc); |
211 Handle<Code> code = isolate->factory()->NewCode( | 211 Handle<Code> code = isolate->factory()->NewCode( |
212 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | 212 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
213 #ifdef DEBUG | 213 #ifdef DEBUG |
214 code->Print(); | 214 code->Print(); |
215 #endif | 215 #endif |
216 USE(code); | 216 USE(code); |
217 ::exit(0); | 217 ::exit(0); |
218 } | 218 } |
219 | 219 |
220 #if 0 | 220 #if 0 |
(...skipping 20 matching lines...) Expand all Loading... |
241 | 241 |
242 __ bind(&L4); | 242 __ bind(&L4); |
243 __ lr(r2, r3); | 243 __ lr(r2, r3); |
244 __ sr(r2, r4); | 244 __ sr(r2, r4); |
245 | 245 |
246 __ bind(&L3); | 246 __ bind(&L3); |
247 __ lgfr(r2, r3); | 247 __ lgfr(r2, r3); |
248 __ b(r14); | 248 __ b(r14); |
249 | 249 |
250 CodeDesc desc; | 250 CodeDesc desc; |
251 assm.GetCode(&desc); | 251 assm.GetCode(isolate, &desc); |
252 Handle<Code> code = isolate->factory()->NewCode( | 252 Handle<Code> code = isolate->factory()->NewCode( |
253 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | 253 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
254 #ifdef DEBUG | 254 #ifdef DEBUG |
255 code->Print(); | 255 code->Print(); |
256 #endif | 256 #endif |
257 F2 f = FUNCTION_CAST<F2>(code->entry()); | 257 F2 f = FUNCTION_CAST<F2>(code->entry()); |
258 intptr_t res = reinterpret_cast<intptr_t>( | 258 intptr_t res = reinterpret_cast<intptr_t>( |
259 CALL_GENERATED_CODE(isolate, f, 3, 4, 3, 0, 0)); | 259 CALL_GENERATED_CODE(isolate, f, 3, 4, 3, 0, 0)); |
260 ::printf("f() = %" V8PRIdPTR "\n", res); | 260 ::printf("f() = %" V8PRIdPTR "\n", res); |
261 CHECK_EQ(4, static_cast<int>(res)); | 261 CHECK_EQ(4, static_cast<int>(res)); |
262 } | 262 } |
263 | 263 |
264 | 264 |
265 // Test ExtractBitRange | 265 // Test ExtractBitRange |
266 TEST(5) { | 266 TEST(5) { |
267 CcTest::InitializeVM(); | 267 CcTest::InitializeVM(); |
268 Isolate* isolate = CcTest::i_isolate(); | 268 Isolate* isolate = CcTest::i_isolate(); |
269 HandleScope scope(isolate); | 269 HandleScope scope(isolate); |
270 | 270 |
271 MacroAssembler assm(isolate, NULL, 0); | 271 MacroAssembler assm(isolate, NULL, 0); |
272 | 272 |
273 __ mov(r2, Operand(0x12345678)); | 273 __ mov(r2, Operand(0x12345678)); |
274 __ ExtractBitRange(r3, r2, 3, 2); | 274 __ ExtractBitRange(r3, r2, 3, 2); |
275 __ lgfr(r2, r3); | 275 __ lgfr(r2, r3); |
276 __ b(r14); | 276 __ b(r14); |
277 | 277 |
278 CodeDesc desc; | 278 CodeDesc desc; |
279 assm.GetCode(&desc); | 279 assm.GetCode(isolate, &desc); |
280 Handle<Code> code = isolate->factory()->NewCode( | 280 Handle<Code> code = isolate->factory()->NewCode( |
281 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | 281 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
282 #ifdef DEBUG | 282 #ifdef DEBUG |
283 code->Print(); | 283 code->Print(); |
284 #endif | 284 #endif |
285 F2 f = FUNCTION_CAST<F2>(code->entry()); | 285 F2 f = FUNCTION_CAST<F2>(code->entry()); |
286 intptr_t res = | 286 intptr_t res = |
287 reinterpret_cast<intptr_t>(CALL_GENERATED_CODE(isolate, f, 3, 4, 3, 0, 0)); | 287 reinterpret_cast<intptr_t>(CALL_GENERATED_CODE(isolate, f, 3, 4, 3, 0, 0)); |
288 ::printf("f() = %" V8PRIdPTR "\n", res); | 288 ::printf("f() = %" V8PRIdPTR "\n", res); |
289 CHECK_EQ(2, static_cast<int>(res)); | 289 CHECK_EQ(2, static_cast<int>(res)); |
(...skipping 13 matching lines...) Expand all Loading... |
303 __ mov(r2, Operand(0x12345678)); | 303 __ mov(r2, Operand(0x12345678)); |
304 __ JumpIfSmi(r2, &yes); | 304 __ JumpIfSmi(r2, &yes); |
305 __ beq(&yes); | 305 __ beq(&yes); |
306 __ Load(r2, Operand::Zero()); | 306 __ Load(r2, Operand::Zero()); |
307 __ b(r14); | 307 __ b(r14); |
308 __ bind(&yes); | 308 __ bind(&yes); |
309 __ Load(r2, Operand(1)); | 309 __ Load(r2, Operand(1)); |
310 __ b(r14); | 310 __ b(r14); |
311 | 311 |
312 CodeDesc desc; | 312 CodeDesc desc; |
313 assm.GetCode(&desc); | 313 assm.GetCode(isolate, &desc); |
314 Handle<Code> code = isolate->factory()->NewCode( | 314 Handle<Code> code = isolate->factory()->NewCode( |
315 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | 315 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
316 #ifdef DEBUG | 316 #ifdef DEBUG |
317 code->Print(); | 317 code->Print(); |
318 #endif | 318 #endif |
319 F2 f = FUNCTION_CAST<F2>(code->entry()); | 319 F2 f = FUNCTION_CAST<F2>(code->entry()); |
320 intptr_t res = | 320 intptr_t res = |
321 reinterpret_cast<intptr_t>(CALL_GENERATED_CODE(isolate, f, 3, 4, 3, 0, 0)); | 321 reinterpret_cast<intptr_t>(CALL_GENERATED_CODE(isolate, f, 3, 4, 3, 0, 0)); |
322 ::printf("f() = %" V8PRIdPTR "\n", res); | 322 ::printf("f() = %" V8PRIdPTR "\n", res); |
323 CHECK_EQ(1, static_cast<int>(res)); | 323 CHECK_EQ(1, static_cast<int>(res)); |
(...skipping 11 matching lines...) Expand all Loading... |
335 Label yes; | 335 Label yes; |
336 | 336 |
337 __ mov(r3, Operand(0x1234)); | 337 __ mov(r3, Operand(0x1234)); |
338 __ cdfbr(d1, r3); | 338 __ cdfbr(d1, r3); |
339 __ ldr(d2, d1); | 339 __ ldr(d2, d1); |
340 __ adbr(d1, d2); | 340 __ adbr(d1, d2); |
341 __ cfdbr(Condition(0), r2, d1); | 341 __ cfdbr(Condition(0), r2, d1); |
342 __ b(r14); | 342 __ b(r14); |
343 | 343 |
344 CodeDesc desc; | 344 CodeDesc desc; |
345 assm.GetCode(&desc); | 345 assm.GetCode(isolate, &desc); |
346 Handle<Code> code = isolate->factory()->NewCode( | 346 Handle<Code> code = isolate->factory()->NewCode( |
347 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | 347 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
348 #ifdef DEBUG | 348 #ifdef DEBUG |
349 code->Print(); | 349 code->Print(); |
350 #endif | 350 #endif |
351 F2 f = FUNCTION_CAST<F2>(code->entry()); | 351 F2 f = FUNCTION_CAST<F2>(code->entry()); |
352 intptr_t res = | 352 intptr_t res = |
353 reinterpret_cast<intptr_t>(CALL_GENERATED_CODE(isolate, f, 3, 4, 3, 0, 0)); | 353 reinterpret_cast<intptr_t>(CALL_GENERATED_CODE(isolate, f, 3, 4, 3, 0, 0)); |
354 ::printf("f() = %" V8PRIdPTR "\n", res); | 354 ::printf("f() = %" V8PRIdPTR "\n", res); |
355 CHECK_EQ(0x2468, static_cast<int>(res)); | 355 CHECK_EQ(0x2468, static_cast<int>(res)); |
(...skipping 10 matching lines...) Expand all Loading... |
366 | 366 |
367 // Zero upper bits of r3/r4 | 367 // Zero upper bits of r3/r4 |
368 __ llihf(r3, Operand::Zero()); | 368 __ llihf(r3, Operand::Zero()); |
369 __ llihf(r4, Operand::Zero()); | 369 __ llihf(r4, Operand::Zero()); |
370 __ mov(r3, Operand(0x0002)); | 370 __ mov(r3, Operand(0x0002)); |
371 __ mov(r4, Operand(0x0002)); | 371 __ mov(r4, Operand(0x0002)); |
372 __ dsgr(r2, r4); | 372 __ dsgr(r2, r4); |
373 __ b(r14); | 373 __ b(r14); |
374 | 374 |
375 CodeDesc desc; | 375 CodeDesc desc; |
376 assm.GetCode(&desc); | 376 assm.GetCode(isolate, &desc); |
377 Handle<Code> code = isolate->factory()->NewCode( | 377 Handle<Code> code = isolate->factory()->NewCode( |
378 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | 378 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
379 #ifdef DEBUG | 379 #ifdef DEBUG |
380 code->Print(); | 380 code->Print(); |
381 #endif | 381 #endif |
382 F1 f = FUNCTION_CAST<F1>(code->entry()); | 382 F1 f = FUNCTION_CAST<F1>(code->entry()); |
383 intptr_t res = | 383 intptr_t res = |
384 reinterpret_cast<intptr_t>(CALL_GENERATED_CODE(isolate, f, 100, 0, | 384 reinterpret_cast<intptr_t>(CALL_GENERATED_CODE(isolate, f, 100, 0, |
385 0, 0, 0)); | 385 0, 0, 0)); |
386 ::printf("f() = %" V8PRIdPTR "\n", res); | 386 ::printf("f() = %" V8PRIdPTR "\n", res); |
387 CHECK_EQ(0, static_cast<int>(res)); | 387 CHECK_EQ(0, static_cast<int>(res)); |
388 } | 388 } |
389 | 389 |
390 | 390 |
391 // Test LZDR | 391 // Test LZDR |
392 TEST(9) { | 392 TEST(9) { |
393 CcTest::InitializeVM(); | 393 CcTest::InitializeVM(); |
394 Isolate* isolate = CcTest::i_isolate(); | 394 Isolate* isolate = CcTest::i_isolate(); |
395 HandleScope scope(isolate); | 395 HandleScope scope(isolate); |
396 | 396 |
397 MacroAssembler assm(isolate, NULL, 0); | 397 MacroAssembler assm(isolate, NULL, 0); |
398 | 398 |
399 __ lzdr(d4); | 399 __ lzdr(d4); |
400 __ b(r14); | 400 __ b(r14); |
401 | 401 |
402 CodeDesc desc; | 402 CodeDesc desc; |
403 assm.GetCode(&desc); | 403 assm.GetCode(isolate, &desc); |
404 Handle<Code> code = isolate->factory()->NewCode( | 404 Handle<Code> code = isolate->factory()->NewCode( |
405 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | 405 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
406 #ifdef DEBUG | 406 #ifdef DEBUG |
407 code->Print(); | 407 code->Print(); |
408 #endif | 408 #endif |
409 F1 f = FUNCTION_CAST<F1>(code->entry()); | 409 F1 f = FUNCTION_CAST<F1>(code->entry()); |
410 intptr_t res = | 410 intptr_t res = |
411 reinterpret_cast<intptr_t>(CALL_GENERATED_CODE(isolate, f, 0, 0, 0, 0, 0)); | 411 reinterpret_cast<intptr_t>(CALL_GENERATED_CODE(isolate, f, 0, 0, 0, 0, 0)); |
412 ::printf("f() = %" V8PRIdPTR "\n", res); | 412 ::printf("f() = %" V8PRIdPTR "\n", res); |
413 } | 413 } |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
478 | 478 |
479 __ bind(&ok); | 479 __ bind(&ok); |
480 __ lgfi(r2, Operand::Zero()); | 480 __ lgfi(r2, Operand::Zero()); |
481 __ b(r14); // test done. | 481 __ b(r14); // test done. |
482 | 482 |
483 __ bind(&failed); | 483 __ bind(&failed); |
484 __ lgfi(r2, Operand(1)); | 484 __ lgfi(r2, Operand(1)); |
485 __ b(r14); | 485 __ b(r14); |
486 | 486 |
487 CodeDesc desc; | 487 CodeDesc desc; |
488 assm.GetCode(&desc); | 488 assm.GetCode(isolate, &desc); |
489 Handle<Code> code = isolate->factory()->NewCode( | 489 Handle<Code> code = isolate->factory()->NewCode( |
490 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | 490 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
491 #ifdef DEBUG | 491 #ifdef DEBUG |
492 code->Print(); | 492 code->Print(); |
493 #endif | 493 #endif |
494 F2 f = FUNCTION_CAST<F2>(code->entry()); | 494 F2 f = FUNCTION_CAST<F2>(code->entry()); |
495 intptr_t res = reinterpret_cast<intptr_t>( | 495 intptr_t res = reinterpret_cast<intptr_t>( |
496 CALL_GENERATED_CODE(isolate, f, 3, 4, 0, 0, 0)); | 496 CALL_GENERATED_CODE(isolate, f, 3, 4, 0, 0, 0)); |
497 ::printf("f() = %" V8PRIxPTR "\n", res); | 497 ::printf("f() = %" V8PRIxPTR "\n", res); |
498 CHECK_EQ(0, static_cast<int>(res)); | 498 CHECK_EQ(0, static_cast<int>(res)); |
499 } | 499 } |
500 | 500 |
501 #undef __ | 501 #undef __ |
OLD | NEW |