OLD | NEW |
1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 using v8::internal::r9; | 72 using v8::internal::r9; |
73 using v8::internal::rax; | 73 using v8::internal::rax; |
74 using v8::internal::rbp; | 74 using v8::internal::rbp; |
75 using v8::internal::rbx; | 75 using v8::internal::rbx; |
76 using v8::internal::rcx; | 76 using v8::internal::rcx; |
77 using v8::internal::rdi; | 77 using v8::internal::rdi; |
78 using v8::internal::rdx; | 78 using v8::internal::rdx; |
79 using v8::internal::rsi; | 79 using v8::internal::rsi; |
80 using v8::internal::rsp; | 80 using v8::internal::rsp; |
81 using v8::internal::times_pointer_size; | 81 using v8::internal::times_pointer_size; |
| 82 using v8::internal::Address; |
82 | 83 |
83 // Test the x64 assembler by compiling some simple functions into | 84 // Test the x64 assembler by compiling some simple functions into |
84 // a buffer and executing them. These tests do not initialize the | 85 // a buffer and executing them. These tests do not initialize the |
85 // V8 library, create a context, or use any V8 objects. | 86 // V8 library, create a context, or use any V8 objects. |
86 // The AMD64 calling convention is used, with the first five arguments | 87 // The AMD64 calling convention is used, with the first five arguments |
87 // in RSI, RDI, RDX, RCX, R8, and R9, and floating point arguments in | 88 // in RSI, RDI, RDX, RCX, R8, and R9, and floating point arguments in |
88 // the XMM registers. The return value is in RAX. | 89 // the XMM registers. The return value is in RAX. |
89 // This calling convention is used on Linux, with GCC, and on Mac OS, | 90 // This calling convention is used on Linux, with GCC, and on Mac OS, |
90 // with GCC. A different convention is used on 64-bit windows. | 91 // with GCC. A different convention is used on 64-bit windows. |
91 | 92 |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 | 396 |
396 void TestI64PlusConstantToSmi(MacroAssembler* masm, | 397 void TestI64PlusConstantToSmi(MacroAssembler* masm, |
397 Label* exit, | 398 Label* exit, |
398 int id, | 399 int id, |
399 int64_t x, | 400 int64_t x, |
400 int y) { | 401 int y) { |
401 int64_t result = x + y; | 402 int64_t result = x + y; |
402 ASSERT(Smi::IsValid(result)); | 403 ASSERT(Smi::IsValid(result)); |
403 __ movl(rax, Immediate(id)); | 404 __ movl(rax, Immediate(id)); |
404 __ Move(r8, Smi::FromInt(static_cast<int>(result))); | 405 __ Move(r8, Smi::FromInt(static_cast<int>(result))); |
405 __ movq(rcx, x, RelocInfo::NONE64); | 406 __ movq(rcx, x); |
406 __ movq(r11, rcx); | 407 __ movq(r11, rcx); |
407 __ Integer64PlusConstantToSmi(rdx, rcx, y); | 408 __ Integer64PlusConstantToSmi(rdx, rcx, y); |
408 __ cmpq(rdx, r8); | 409 __ cmpq(rdx, r8); |
409 __ j(not_equal, exit); | 410 __ j(not_equal, exit); |
410 | 411 |
411 __ incq(rax); | 412 __ incq(rax); |
412 __ cmpq(r11, rcx); | 413 __ cmpq(r11, rcx); |
413 __ j(not_equal, exit); | 414 __ j(not_equal, exit); |
414 | 415 |
415 __ incq(rax); | 416 __ incq(rax); |
(...skipping 1899 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2315 __ push(Immediate(0x108)); | 2316 __ push(Immediate(0x108)); |
2316 __ push(Immediate(0x109)); // <-- rsp | 2317 __ push(Immediate(0x109)); // <-- rsp |
2317 // rbp = rsp[9] | 2318 // rbp = rsp[9] |
2318 // r15 = rsp[3] | 2319 // r15 = rsp[3] |
2319 // rbx = rsp[5] | 2320 // rbx = rsp[5] |
2320 // r13 = rsp[7] | 2321 // r13 = rsp[7] |
2321 __ lea(r14, Operand(rsp, 3 * kPointerSize)); | 2322 __ lea(r14, Operand(rsp, 3 * kPointerSize)); |
2322 __ lea(r13, Operand(rbp, -3 * kPointerSize)); | 2323 __ lea(r13, Operand(rbp, -3 * kPointerSize)); |
2323 __ lea(rbx, Operand(rbp, -5 * kPointerSize)); | 2324 __ lea(rbx, Operand(rbp, -5 * kPointerSize)); |
2324 __ movl(rcx, Immediate(2)); | 2325 __ movl(rcx, Immediate(2)); |
2325 __ movq(r8, reinterpret_cast<uintptr_t>(&data[128]), RelocInfo::NONE64); | 2326 __ movq(r8, reinterpret_cast<Address>(&data[128]), RelocInfo::NONE64); |
2326 __ movl(rax, Immediate(1)); | 2327 __ movl(rax, Immediate(1)); |
2327 | 2328 |
2328 Operand sp0 = Operand(rsp, 0); | 2329 Operand sp0 = Operand(rsp, 0); |
2329 | 2330 |
2330 // Test 1. | 2331 // Test 1. |
2331 __ movl(rdx, sp0); // Sanity check. | 2332 __ movl(rdx, sp0); // Sanity check. |
2332 __ cmpl(rdx, Immediate(0x109)); | 2333 __ cmpl(rdx, Immediate(0x109)); |
2333 __ j(not_equal, &exit); | 2334 __ j(not_equal, &exit); |
2334 __ incq(rax); | 2335 __ incq(rax); |
2335 | 2336 |
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2739 | 2740 |
2740 CodeDesc desc; | 2741 CodeDesc desc; |
2741 masm->GetCode(&desc); | 2742 masm->GetCode(&desc); |
2742 // Call the function from C++. | 2743 // Call the function from C++. |
2743 int result = FUNCTION_CAST<F0>(buffer)(); | 2744 int result = FUNCTION_CAST<F0>(buffer)(); |
2744 CHECK_EQ(0, result); | 2745 CHECK_EQ(0, result); |
2745 } | 2746 } |
2746 | 2747 |
2747 | 2748 |
2748 #undef __ | 2749 #undef __ |
OLD | NEW |