| 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 static const v8::internal::Register arg1 = rcx; | 81 static const v8::internal::Register arg1 = rcx; |
| 82 static const v8::internal::Register arg2 = rdx; | 82 static const v8::internal::Register arg2 = rdx; |
| 83 #else | 83 #else |
| 84 static const v8::internal::Register arg1 = rdi; | 84 static const v8::internal::Register arg1 = rdi; |
| 85 static const v8::internal::Register arg2 = rsi; | 85 static const v8::internal::Register arg2 = rsi; |
| 86 #endif | 86 #endif |
| 87 | 87 |
| 88 #define __ assm. | 88 #define __ assm. |
| 89 | 89 |
| 90 | 90 |
| 91 static v8::Persistent<v8::Context> env; | |
| 92 | |
| 93 | |
| 94 static void InitializeVM() { | |
| 95 if (env.IsEmpty()) { | |
| 96 env = v8::Context::New(); | |
| 97 } | |
| 98 } | |
| 99 | |
| 100 | |
| 101 TEST(AssemblerX64ReturnOperation) { | 91 TEST(AssemblerX64ReturnOperation) { |
| 102 OS::SetUp(); | 92 OS::SetUp(); |
| 103 // Allocate an executable page of memory. | 93 // Allocate an executable page of memory. |
| 104 size_t actual_size; | 94 size_t actual_size; |
| 105 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, | 95 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, |
| 106 &actual_size, | 96 &actual_size, |
| 107 true)); | 97 true)); |
| 108 CHECK(buffer); | 98 CHECK(buffer); |
| 109 Assembler assm(Isolate::Current(), buffer, static_cast<int>(actual_size)); | 99 Assembler assm(Isolate::Current(), buffer, static_cast<int>(actual_size)); |
| 110 | 100 |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 CHECK(Operand(rsp, rbp, times_1, offset).AddressUsesRegister(rbp)); | 344 CHECK(Operand(rsp, rbp, times_1, offset).AddressUsesRegister(rbp)); |
| 355 CHECK(!Operand(rsp, rbp, times_1, offset).AddressUsesRegister(rax)); | 345 CHECK(!Operand(rsp, rbp, times_1, offset).AddressUsesRegister(rax)); |
| 356 CHECK(!Operand(rsp, rbp, times_1, offset).AddressUsesRegister(r15)); | 346 CHECK(!Operand(rsp, rbp, times_1, offset).AddressUsesRegister(r15)); |
| 357 CHECK(!Operand(rsp, rbp, times_1, offset).AddressUsesRegister(r13)); | 347 CHECK(!Operand(rsp, rbp, times_1, offset).AddressUsesRegister(r13)); |
| 358 } | 348 } |
| 359 } | 349 } |
| 360 | 350 |
| 361 | 351 |
| 362 TEST(AssemblerX64LabelChaining) { | 352 TEST(AssemblerX64LabelChaining) { |
| 363 // Test chaining of label usages within instructions (issue 1644). | 353 // Test chaining of label usages within instructions (issue 1644). |
| 364 InitializeVM(); | 354 CcTest::InitializeVM(); |
| 365 v8::HandleScope scope(env->GetIsolate()); | 355 v8::HandleScope scope(CcTest::isolate()); |
| 366 Assembler assm(Isolate::Current(), NULL, 0); | 356 Assembler assm(Isolate::Current(), NULL, 0); |
| 367 | 357 |
| 368 Label target; | 358 Label target; |
| 369 __ j(equal, &target); | 359 __ j(equal, &target); |
| 370 __ j(not_equal, &target); | 360 __ j(not_equal, &target); |
| 371 __ bind(&target); | 361 __ bind(&target); |
| 372 __ nop(); | 362 __ nop(); |
| 373 } | 363 } |
| 374 | 364 |
| 375 | 365 |
| 376 TEST(AssemblerMultiByteNop) { | 366 TEST(AssemblerMultiByteNop) { |
| 377 InitializeVM(); | 367 CcTest::InitializeVM(); |
| 378 v8::HandleScope scope(env->GetIsolate()); | 368 v8::HandleScope scope(CcTest::isolate()); |
| 379 v8::internal::byte buffer[1024]; | 369 v8::internal::byte buffer[1024]; |
| 380 Isolate* isolate = Isolate::Current(); | 370 Isolate* isolate = Isolate::Current(); |
| 381 Assembler assm(isolate, buffer, sizeof(buffer)); | 371 Assembler assm(isolate, buffer, sizeof(buffer)); |
| 382 __ push(rbx); | 372 __ push(rbx); |
| 383 __ push(rcx); | 373 __ push(rcx); |
| 384 __ push(rdx); | 374 __ push(rdx); |
| 385 __ push(rdi); | 375 __ push(rdi); |
| 386 __ push(rsi); | 376 __ push(rsi); |
| 387 __ movq(rax, Immediate(1)); | 377 __ movq(rax, Immediate(1)); |
| 388 __ movq(rbx, Immediate(2)); | 378 __ movq(rbx, Immediate(2)); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 435 | 425 |
| 436 F0 f = FUNCTION_CAST<F0>(code->entry()); | 426 F0 f = FUNCTION_CAST<F0>(code->entry()); |
| 437 int res = f(); | 427 int res = f(); |
| 438 CHECK_EQ(42, res); | 428 CHECK_EQ(42, res); |
| 439 } | 429 } |
| 440 | 430 |
| 441 | 431 |
| 442 | 432 |
| 443 | 433 |
| 444 #undef __ | 434 #undef __ |
| OLD | NEW |