| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 20 matching lines...) Expand all Loading... |
| 31 | 31 |
| 32 #include "debug.h" | 32 #include "debug.h" |
| 33 #include "disasm.h" | 33 #include "disasm.h" |
| 34 #include "disassembler.h" | 34 #include "disassembler.h" |
| 35 #include "macro-assembler.h" | 35 #include "macro-assembler.h" |
| 36 #include "serialize.h" | 36 #include "serialize.h" |
| 37 #include "cctest.h" | 37 #include "cctest.h" |
| 38 | 38 |
| 39 using namespace v8::internal; | 39 using namespace v8::internal; |
| 40 | 40 |
| 41 static v8::Persistent<v8::Context> env; | |
| 42 | |
| 43 static void InitializeVM() { | |
| 44 if (env.IsEmpty()) { | |
| 45 env = v8::Context::New(); | |
| 46 } | |
| 47 } | |
| 48 | |
| 49 | 41 |
| 50 #define __ assm. | 42 #define __ assm. |
| 51 | 43 |
| 52 | 44 |
| 53 static void DummyStaticFunction(Object* result) { | 45 static void DummyStaticFunction(Object* result) { |
| 54 } | 46 } |
| 55 | 47 |
| 56 | 48 |
| 57 TEST(DisasmX64) { | 49 TEST(DisasmX64) { |
| 58 InitializeVM(); | 50 CcTest::InitializeVM(); |
| 59 v8::HandleScope scope; | 51 v8::HandleScope scope; |
| 60 v8::internal::byte buffer[2048]; | 52 v8::internal::byte buffer[2048]; |
| 61 Assembler assm(Isolate::Current(), buffer, sizeof buffer); | 53 Assembler assm(Isolate::Current(), buffer, sizeof buffer); |
| 62 DummyStaticFunction(NULL); // just bloody use it (DELETE; debugging) | 54 DummyStaticFunction(NULL); // just bloody use it (DELETE; debugging) |
| 63 | 55 |
| 64 // Short immediate instructions | 56 // Short immediate instructions |
| 65 __ addq(rax, Immediate(12345678)); | 57 __ addq(rax, Immediate(12345678)); |
| 66 __ or_(rax, Immediate(12345678)); | 58 __ or_(rax, Immediate(12345678)); |
| 67 __ subq(rax, Immediate(12345678)); | 59 __ subq(rax, Immediate(12345678)); |
| 68 __ xor_(rax, Immediate(12345678)); | 60 __ xor_(rax, Immediate(12345678)); |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 CHECK(code->IsCode()); | 413 CHECK(code->IsCode()); |
| 422 #ifdef OBJECT_PRINT | 414 #ifdef OBJECT_PRINT |
| 423 Code::cast(code)->Print(); | 415 Code::cast(code)->Print(); |
| 424 byte* begin = Code::cast(code)->instruction_start(); | 416 byte* begin = Code::cast(code)->instruction_start(); |
| 425 byte* end = begin + Code::cast(code)->instruction_size(); | 417 byte* end = begin + Code::cast(code)->instruction_size(); |
| 426 disasm::Disassembler::Disassemble(stdout, begin, end); | 418 disasm::Disassembler::Disassemble(stdout, begin, end); |
| 427 #endif | 419 #endif |
| 428 } | 420 } |
| 429 | 421 |
| 430 #undef __ | 422 #undef __ |
| OLD | NEW |