| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/globals.h" | 5 #include "vm/globals.h" |
| 6 #if defined(TARGET_OS_LINUX) | 6 #if defined(TARGET_OS_LINUX) |
| 7 | 7 |
| 8 #include "vm/os.h" | 8 #include "vm/os.h" |
| 9 | 9 |
| 10 #include <errno.h> // NOLINT | 10 #include <errno.h> // NOLINT |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 return; | 52 return; |
| 53 } | 53 } |
| 54 const char* filename = "v8.log.ll"; | 54 const char* filename = "v8.log.ll"; |
| 55 log_file_ = (*file_open)(filename, true); | 55 log_file_ = (*file_open)(filename, true); |
| 56 #if defined(TARGET_ARCH_IA32) | 56 #if defined(TARGET_ARCH_IA32) |
| 57 const char arch[] = "ia32"; | 57 const char arch[] = "ia32"; |
| 58 #elif defined(TARGET_ARCH_X64) | 58 #elif defined(TARGET_ARCH_X64) |
| 59 const char arch[] = "x64"; | 59 const char arch[] = "x64"; |
| 60 #elif defined(TARGET_ARCH_ARM) | 60 #elif defined(TARGET_ARCH_ARM) |
| 61 const char arch[] = "arm"; | 61 const char arch[] = "arm"; |
| 62 #elif defined(TARGET_ARCH_ARM64) |
| 63 const char arch[] = "arm64"; |
| 62 #elif defined(TARGET_ARCH_MIPS) | 64 #elif defined(TARGET_ARCH_MIPS) |
| 63 const char arch[] = "mips"; | 65 const char arch[] = "mips"; |
| 64 #else | 66 #else |
| 65 #error Unknown architecture. | 67 #error Unknown architecture. |
| 66 #endif | 68 #endif |
| 67 LowLevelLogWriteBytes(arch, sizeof(arch)); | 69 LowLevelLogWriteBytes(arch, sizeof(arch)); |
| 68 } | 70 } |
| 69 | 71 |
| 70 ~LowLevelProfileCodeObserver() { | 72 ~LowLevelProfileCodeObserver() { |
| 71 Dart_FileCloseCallback file_close = Isolate::file_close_callback(); | 73 Dart_FileCloseCallback file_close = Isolate::file_close_callback(); |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 bool optimized) { | 350 bool optimized) { |
| 349 WriteCodeLoad(name, base, prologue_offset, size, optimized); | 351 WriteCodeLoad(name, base, prologue_offset, size, optimized); |
| 350 } | 352 } |
| 351 | 353 |
| 352 private: | 354 private: |
| 353 static const uint32_t kJitHeaderMagic = 0x4F74496A; | 355 static const uint32_t kJitHeaderMagic = 0x4F74496A; |
| 354 static const uint32_t kJitHeaderVersion = 0x2; | 356 static const uint32_t kJitHeaderVersion = 0x2; |
| 355 static const uint32_t kElfMachIA32 = 3; | 357 static const uint32_t kElfMachIA32 = 3; |
| 356 static const uint32_t kElfMachX64 = 62; | 358 static const uint32_t kElfMachX64 = 62; |
| 357 static const uint32_t kElfMachARM = 40; | 359 static const uint32_t kElfMachARM = 40; |
| 360 // TODO(zra): Find the right ARM64 constant. |
| 361 static const uint32_t kElfMachARM64 = 40; |
| 358 static const uint32_t kElfMachMIPS = 10; | 362 static const uint32_t kElfMachMIPS = 10; |
| 359 static const int kInvalidClockId = -1; | 363 static const int kInvalidClockId = -1; |
| 360 | 364 |
| 361 struct jitheader { | 365 struct jitheader { |
| 362 uint32_t magic; | 366 uint32_t magic; |
| 363 uint32_t version; | 367 uint32_t version; |
| 364 uint32_t total_size; | 368 uint32_t total_size; |
| 365 uint32_t elf_mach; | 369 uint32_t elf_mach; |
| 366 uint32_t pad1; | 370 uint32_t pad1; |
| 367 uint32_t pid; | 371 uint32_t pid; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 398 return buffer; | 402 return buffer; |
| 399 } | 403 } |
| 400 | 404 |
| 401 uint32_t GetElfMach() { | 405 uint32_t GetElfMach() { |
| 402 #if defined(TARGET_ARCH_IA32) | 406 #if defined(TARGET_ARCH_IA32) |
| 403 return kElfMachIA32; | 407 return kElfMachIA32; |
| 404 #elif defined(TARGET_ARCH_X64) | 408 #elif defined(TARGET_ARCH_X64) |
| 405 return kElfMachX64; | 409 return kElfMachX64; |
| 406 #elif defined(TARGET_ARCH_ARM) | 410 #elif defined(TARGET_ARCH_ARM) |
| 407 return kElfMachARM; | 411 return kElfMachARM; |
| 412 #elif defined(TARGET_ARCH_ARM64) |
| 413 return kElfMachARM64; |
| 408 #elif defined(TARGET_ARCH_MIPS) | 414 #elif defined(TARGET_ARCH_MIPS) |
| 409 return kElfMachMIPS; | 415 return kElfMachMIPS; |
| 410 #else | 416 #else |
| 411 #error Unknown architecture. | 417 #error Unknown architecture. |
| 412 #endif | 418 #endif |
| 413 } | 419 } |
| 414 | 420 |
| 415 pid_t gettid() { | 421 pid_t gettid() { |
| 416 // libc doesn't wrap the Linux-specific gettid system call. | 422 // libc doesn't wrap the Linux-specific gettid system call. |
| 417 // Note that this thread id is not the same as the posix thread id. | 423 // Note that this thread id is not the same as the posix thread id. |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 563 | 569 |
| 564 | 570 |
| 565 void OS::AlignedFree(void* ptr) { | 571 void OS::AlignedFree(void* ptr) { |
| 566 free(ptr); | 572 free(ptr); |
| 567 } | 573 } |
| 568 | 574 |
| 569 | 575 |
| 570 // TODO(5411554): May need to hoist these architecture dependent code | 576 // TODO(5411554): May need to hoist these architecture dependent code |
| 571 // into a architecture specific file e.g: os_ia32_linux.cc | 577 // into a architecture specific file e.g: os_ia32_linux.cc |
| 572 word OS::ActivationFrameAlignment() { | 578 word OS::ActivationFrameAlignment() { |
| 573 #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64) | 579 #if defined(TARGET_ARCH_IA32) || \ |
| 580 defined(TARGET_ARCH_X64) || \ |
| 581 defined(TARGET_ARCH_ARM64) |
| 574 const int kMinimumAlignment = 16; | 582 const int kMinimumAlignment = 16; |
| 575 #elif defined(TARGET_ARCH_ARM) || defined(TARGET_ARCH_MIPS) | 583 #elif defined(TARGET_ARCH_ARM) || defined(TARGET_ARCH_MIPS) |
| 576 const int kMinimumAlignment = 8; | 584 const int kMinimumAlignment = 8; |
| 577 #else | 585 #else |
| 578 #error Unsupported architecture. | 586 #error Unsupported architecture. |
| 579 #endif | 587 #endif |
| 580 word alignment = kMinimumAlignment; | 588 word alignment = kMinimumAlignment; |
| 581 // TODO(5411554): Allow overriding default stack alignment for | 589 // TODO(5411554): Allow overriding default stack alignment for |
| 582 // testing purposes. | 590 // testing purposes. |
| 583 // Flags::DebugIsInt("stackalign", &alignment); | 591 // Flags::DebugIsInt("stackalign", &alignment); |
| 584 ASSERT(Utils::IsPowerOfTwo(alignment)); | 592 ASSERT(Utils::IsPowerOfTwo(alignment)); |
| 585 ASSERT(alignment >= kMinimumAlignment); | 593 ASSERT(alignment >= kMinimumAlignment); |
| 586 return alignment; | 594 return alignment; |
| 587 } | 595 } |
| 588 | 596 |
| 589 | 597 |
| 590 word OS::PreferredCodeAlignment() { | 598 word OS::PreferredCodeAlignment() { |
| 591 #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64) | 599 #if defined(TARGET_ARCH_IA32) || \ |
| 600 defined(TARGET_ARCH_X64) || \ |
| 601 defined(TARGET_ARCH_ARM64) |
| 592 const int kMinimumAlignment = 32; | 602 const int kMinimumAlignment = 32; |
| 593 #elif defined(TARGET_ARCH_ARM) || defined(TARGET_ARCH_MIPS) | 603 #elif defined(TARGET_ARCH_ARM) || defined(TARGET_ARCH_MIPS) |
| 594 const int kMinimumAlignment = 16; | 604 const int kMinimumAlignment = 16; |
| 595 #else | 605 #else |
| 596 #error Unsupported architecture. | 606 #error Unsupported architecture. |
| 597 #endif | 607 #endif |
| 598 word alignment = kMinimumAlignment; | 608 word alignment = kMinimumAlignment; |
| 599 // TODO(5411554): Allow overriding default code alignment for | 609 // TODO(5411554): Allow overriding default code alignment for |
| 600 // testing purposes. | 610 // testing purposes. |
| 601 // Flags::DebugIsInt("codealign", &alignment); | 611 // Flags::DebugIsInt("codealign", &alignment); |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 769 } | 779 } |
| 770 | 780 |
| 771 | 781 |
| 772 void OS::Exit(int code) { | 782 void OS::Exit(int code) { |
| 773 exit(code); | 783 exit(code); |
| 774 } | 784 } |
| 775 | 785 |
| 776 } // namespace dart | 786 } // namespace dart |
| 777 | 787 |
| 778 #endif // defined(TARGET_OS_LINUX) | 788 #endif // defined(TARGET_OS_LINUX) |
| OLD | NEW |