| 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 30 matching lines...) Expand all Loading... |
| 41 using v8::internal::Operand; | 41 using v8::internal::Operand; |
| 42 using v8::internal::Immediate; | 42 using v8::internal::Immediate; |
| 43 using v8::internal::Label; | 43 using v8::internal::Label; |
| 44 using v8::internal::rax; | 44 using v8::internal::rax; |
| 45 using v8::internal::rsi; | 45 using v8::internal::rsi; |
| 46 using v8::internal::rdi; | 46 using v8::internal::rdi; |
| 47 using v8::internal::rcx; | 47 using v8::internal::rcx; |
| 48 using v8::internal::rdx; | 48 using v8::internal::rdx; |
| 49 using v8::internal::rbp; | 49 using v8::internal::rbp; |
| 50 using v8::internal::rsp; | 50 using v8::internal::rsp; |
| 51 using v8::internal::r8; |
| 52 using v8::internal::r9; |
| 53 using v8::internal::r12; |
| 54 using v8::internal::r13; |
| 55 using v8::internal::times_1; |
| 56 |
| 51 using v8::internal::FUNCTION_CAST; | 57 using v8::internal::FUNCTION_CAST; |
| 52 using v8::internal::CodeDesc; | 58 using v8::internal::CodeDesc; |
| 53 using v8::internal::less_equal; | 59 using v8::internal::less_equal; |
| 54 using v8::internal::not_equal; | 60 using v8::internal::not_equal; |
| 55 using v8::internal::greater; | 61 using v8::internal::greater; |
| 56 | 62 |
| 57 // Test the x64 assembler by compiling some simple functions into | 63 // Test the x64 assembler by compiling some simple functions into |
| 58 // a buffer and executing them. These tests do not initialize the | 64 // a buffer and executing them. These tests do not initialize the |
| 59 // V8 library, create a context, or use any V8 objects. | 65 // V8 library, create a context, or use any V8 objects. |
| 60 // The AMD64 calling convention is used, with the first six arguments | 66 // The AMD64 calling convention is used, with the first six arguments |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 __ movq(rax, Immediate(0)); | 288 __ movq(rax, Immediate(0)); |
| 283 __ ret(0); | 289 __ ret(0); |
| 284 | 290 |
| 285 CodeDesc desc; | 291 CodeDesc desc; |
| 286 assm.GetCode(&desc); | 292 assm.GetCode(&desc); |
| 287 // Call the function from C++. | 293 // Call the function from C++. |
| 288 int result = FUNCTION_CAST<F0>(buffer)(); | 294 int result = FUNCTION_CAST<F0>(buffer)(); |
| 289 CHECK_EQ(1, result); | 295 CHECK_EQ(1, result); |
| 290 } | 296 } |
| 291 | 297 |
| 298 |
| 299 TEST(OperandRegisterDependency) { |
| 300 int offsets[4] = {0, 1, 0xfed, 0xbeefcad}; |
| 301 for (int i = 0; i < 4; i++) { |
| 302 int offset = offsets[i]; |
| 303 CHECK(Operand(rax, offset).AddressUsesRegister(rax)); |
| 304 CHECK(!Operand(rax, offset).AddressUsesRegister(r8)); |
| 305 CHECK(!Operand(rax, offset).AddressUsesRegister(rcx)); |
| 306 |
| 307 CHECK(Operand(rax, rax, times_1, offset).AddressUsesRegister(rax)); |
| 308 CHECK(!Operand(rax, rax, times_1, offset).AddressUsesRegister(r8)); |
| 309 CHECK(!Operand(rax, rax, times_1, offset).AddressUsesRegister(rcx)); |
| 310 |
| 311 CHECK(Operand(rax, rcx, times_1, offset).AddressUsesRegister(rax)); |
| 312 CHECK(Operand(rax, rcx, times_1, offset).AddressUsesRegister(rcx)); |
| 313 CHECK(!Operand(rax, rcx, times_1, offset).AddressUsesRegister(r8)); |
| 314 CHECK(!Operand(rax, rcx, times_1, offset).AddressUsesRegister(r9)); |
| 315 CHECK(!Operand(rax, rcx, times_1, offset).AddressUsesRegister(rdx)); |
| 316 CHECK(!Operand(rax, rcx, times_1, offset).AddressUsesRegister(rsp)); |
| 317 |
| 318 CHECK(Operand(rsp, offset).AddressUsesRegister(rsp)); |
| 319 CHECK(!Operand(rsp, offset).AddressUsesRegister(rax)); |
| 320 CHECK(!Operand(rsp, offset).AddressUsesRegister(r12)); |
| 321 |
| 322 CHECK(Operand(rbp, offset).AddressUsesRegister(rbp)); |
| 323 CHECK(!Operand(rbp, offset).AddressUsesRegister(rax)); |
| 324 CHECK(!Operand(rbp, offset).AddressUsesRegister(r13)); |
| 325 |
| 326 CHECK(Operand(rbp, rax, times_1, offset).AddressUsesRegister(rbp)); |
| 327 CHECK(Operand(rbp, rax, times_1, offset).AddressUsesRegister(rax)); |
| 328 CHECK(!Operand(rbp, rax, times_1, offset).AddressUsesRegister(rcx)); |
| 329 CHECK(!Operand(rbp, rax, times_1, offset).AddressUsesRegister(r13)); |
| 330 CHECK(!Operand(rbp, rax, times_1, offset).AddressUsesRegister(r8)); |
| 331 CHECK(!Operand(rbp, rax, times_1, offset).AddressUsesRegister(rsp)); |
| 332 |
| 333 CHECK(Operand(rsp, rbp, times_1, offset).AddressUsesRegister(rsp)); |
| 334 CHECK(Operand(rsp, rbp, times_1, offset).AddressUsesRegister(rbp)); |
| 335 CHECK(!Operand(rsp, rbp, times_1, offset).AddressUsesRegister(rax)); |
| 336 CHECK(!Operand(rsp, rbp, times_1, offset).AddressUsesRegister(r12)); |
| 337 CHECK(!Operand(rsp, rbp, times_1, offset).AddressUsesRegister(r13)); |
| 338 } |
| 339 } |
| 340 |
| 292 #undef __ | 341 #undef __ |
| OLD | NEW |