| 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 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 | 321 |
| 322 CodeDesc desc; | 322 CodeDesc desc; |
| 323 assm.GetCode(&desc); | 323 assm.GetCode(&desc); |
| 324 // Call the function from C++. | 324 // Call the function from C++. |
| 325 uint64_t left = V8_2PART_UINT64_C(0x10000000, 20000000); | 325 uint64_t left = V8_2PART_UINT64_C(0x10000000, 20000000); |
| 326 uint64_t right = V8_2PART_UINT64_C(0x30000000, 00000000); | 326 uint64_t right = V8_2PART_UINT64_C(0x30000000, 00000000); |
| 327 uint64_t result = FUNCTION_CAST<F4>(buffer)(&left, &right); | 327 uint64_t result = FUNCTION_CAST<F4>(buffer)(&left, &right); |
| 328 CHECK_EQ(1u, result); | 328 CHECK_EQ(1u, result); |
| 329 } | 329 } |
| 330 | 330 |
| 331 TEST(AssemblerX64TestwOperations) { |
| 332 typedef uint16_t (*F)(uint16_t * x); |
| 333 CcTest::InitializeVM(); |
| 334 // Allocate an executable page of memory. |
| 335 size_t actual_size; |
| 336 byte* buffer = static_cast<byte*>(v8::base::OS::Allocate( |
| 337 Assembler::kMinimalBufferSize, &actual_size, true)); |
| 338 CHECK(buffer); |
| 339 Assembler assm(CcTest::i_isolate(), buffer, static_cast<int>(actual_size)); |
| 340 |
| 341 // Set rax with the ZF flag of the testl instruction. |
| 342 Label done; |
| 343 __ movq(rax, Immediate(1)); |
| 344 __ testw(Operand(arg1, 0), Immediate(0xf0f0)); |
| 345 __ j(not_zero, &done, Label::kNear); |
| 346 __ movq(rax, Immediate(0)); |
| 347 __ bind(&done); |
| 348 __ ret(0); |
| 349 |
| 350 CodeDesc desc; |
| 351 assm.GetCode(&desc); |
| 352 // Call the function from C++. |
| 353 uint16_t operand = 0x8000; |
| 354 uint16_t result = FUNCTION_CAST<F>(buffer)(&operand); |
| 355 CHECK_EQ(1u, result); |
| 356 } |
| 331 | 357 |
| 332 TEST(AssemblerX64XorlOperations) { | 358 TEST(AssemblerX64XorlOperations) { |
| 333 CcTest::InitializeVM(); | 359 CcTest::InitializeVM(); |
| 334 // Allocate an executable page of memory. | 360 // Allocate an executable page of memory. |
| 335 size_t actual_size; | 361 size_t actual_size; |
| 336 byte* buffer = static_cast<byte*>(v8::base::OS::Allocate( | 362 byte* buffer = static_cast<byte*>(v8::base::OS::Allocate( |
| 337 Assembler::kMinimalBufferSize, &actual_size, true)); | 363 Assembler::kMinimalBufferSize, &actual_size, true)); |
| 338 CHECK(buffer); | 364 CHECK(buffer); |
| 339 Assembler assm(CcTest::i_isolate(), buffer, static_cast<int>(actual_size)); | 365 Assembler assm(CcTest::i_isolate(), buffer, static_cast<int>(actual_size)); |
| 340 | 366 |
| (...skipping 1923 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2264 | 2290 |
| 2265 F1 f = FUNCTION_CAST<F1>(code->entry()); | 2291 F1 f = FUNCTION_CAST<F1>(code->entry()); |
| 2266 for (int i = 0; i < kNumCases; ++i) { | 2292 for (int i = 0; i < kNumCases; ++i) { |
| 2267 int res = f(i); | 2293 int res = f(i); |
| 2268 PrintF("f(%d) = %d\n", i, res); | 2294 PrintF("f(%d) = %d\n", i, res); |
| 2269 CHECK_EQ(values[i], res); | 2295 CHECK_EQ(values[i], res); |
| 2270 } | 2296 } |
| 2271 } | 2297 } |
| 2272 | 2298 |
| 2273 #undef __ | 2299 #undef __ |
| OLD | NEW |