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).depends_on_register(rax)); |
| 304 CHECK(!Operand(rax, offset).depends_on_register(r8)); |
| 305 CHECK(!Operand(rax, offset).depends_on_register(rcx)); |
| 306 |
| 307 CHECK(Operand(rax, rax, times_1, offset).depends_on_register(rax)); |
| 308 CHECK(!Operand(rax, rax, times_1, offset).depends_on_register(r8)); |
| 309 CHECK(!Operand(rax, rax, times_1, offset).depends_on_register(rcx)); |
| 310 |
| 311 CHECK(Operand(rax, rcx, times_1, offset).depends_on_register(rax)); |
| 312 CHECK(Operand(rax, rcx, times_1, offset).depends_on_register(rcx)); |
| 313 CHECK(!Operand(rax, rcx, times_1, offset).depends_on_register(r8)); |
| 314 CHECK(!Operand(rax, rcx, times_1, offset).depends_on_register(r9)); |
| 315 CHECK(!Operand(rax, rcx, times_1, offset).depends_on_register(rdx)); |
| 316 CHECK(!Operand(rax, rcx, times_1, offset).depends_on_register(rsp)); |
| 317 |
| 318 CHECK(Operand(rsp, offset).depends_on_register(rsp)); |
| 319 CHECK(!Operand(rsp, offset).depends_on_register(rax)); |
| 320 CHECK(!Operand(rsp, offset).depends_on_register(r12)); |
| 321 |
| 322 CHECK(Operand(rbp, offset).depends_on_register(rbp)); |
| 323 CHECK(!Operand(rbp, offset).depends_on_register(rax)); |
| 324 CHECK(!Operand(rbp, offset).depends_on_register(r13)); |
| 325 |
| 326 CHECK(Operand(rbp, rax, times_1, offset).depends_on_register(rbp)); |
| 327 CHECK(Operand(rbp, rax, times_1, offset).depends_on_register(rax)); |
| 328 CHECK(!Operand(rbp, rax, times_1, offset).depends_on_register(rcx)); |
| 329 CHECK(!Operand(rbp, rax, times_1, offset).depends_on_register(r13)); |
| 330 CHECK(!Operand(rbp, rax, times_1, offset).depends_on_register(r8)); |
| 331 CHECK(!Operand(rbp, rax, times_1, offset).depends_on_register(rsp)); |
| 332 |
| 333 CHECK(Operand(rsp, rbp, times_1, offset).depends_on_register(rsp)); |
| 334 CHECK(Operand(rsp, rbp, times_1, offset).depends_on_register(rbp)); |
| 335 CHECK(!Operand(rsp, rbp, times_1, offset).depends_on_register(rax)); |
| 336 CHECK(!Operand(rsp, rbp, times_1, offset).depends_on_register(r12)); |
| 337 CHECK(!Operand(rsp, rbp, times_1, offset).depends_on_register(r13)); |
| 338 } |
| 339 } |
| 340 |
292 #undef __ | 341 #undef __ |
OLD | NEW |