| 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/snapshot.h" | 5 #include "vm/snapshot.h" |
| 6 | 6 |
| 7 #include "platform/assert.h" | 7 #include "platform/assert.h" |
| 8 #include "vm/bootstrap.h" | 8 #include "vm/bootstrap.h" |
| 9 #include "vm/class_finalizer.h" | 9 #include "vm/class_finalizer.h" |
| 10 #include "vm/dart.h" | 10 #include "vm/dart.h" |
| (...skipping 878 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 889 ASSERT(Utils::IsAligned(beginning, sizeof(uword))); | 889 ASSERT(Utils::IsAligned(beginning, sizeof(uword))); |
| 890 ASSERT(Utils::IsAligned(entry, sizeof(uword))); | 890 ASSERT(Utils::IsAligned(entry, sizeof(uword))); |
| 891 ASSERT(Utils::IsAligned(end, sizeof(uword))); | 891 ASSERT(Utils::IsAligned(end, sizeof(uword))); |
| 892 | 892 |
| 893 WriteByteSequence(entry, end); | 893 WriteByteSequence(entry, end); |
| 894 } | 894 } |
| 895 } | 895 } |
| 896 | 896 |
| 897 FrameUnwindEpilogue(); | 897 FrameUnwindEpilogue(); |
| 898 | 898 |
| 899 #if defined(HOST_OS_LINUX) | 899 #if defined(TARGET_OS_LINUX) || defined(TARGET_OS_ANDROID) || \ |
| 900 defined(TARGET_OS_FUCHSIA) |
| 900 assembly_stream_.Print(".section .rodata\n"); | 901 assembly_stream_.Print(".section .rodata\n"); |
| 901 #elif defined(HOST_OS_MACOS) | 902 #elif defined(TARGET_OS_MACOS) || defined(TARGET_OS_MACOS_IOS) |
| 902 assembly_stream_.Print(".const\n"); | 903 assembly_stream_.Print(".const\n"); |
| 903 #else | 904 #else |
| 904 // Unsupported platform. | 905 UNIMPLEMENTED(); |
| 905 UNREACHABLE(); | |
| 906 #endif | 906 #endif |
| 907 | 907 |
| 908 const char* data_symbol = | 908 const char* data_symbol = |
| 909 vm ? "_kDartVmSnapshotData" : "_kDartIsolateSnapshotData"; | 909 vm ? "_kDartVmSnapshotData" : "_kDartIsolateSnapshotData"; |
| 910 assembly_stream_.Print(".globl %s\n", data_symbol); | 910 assembly_stream_.Print(".globl %s\n", data_symbol); |
| 911 assembly_stream_.Print(".balign %" Pd ", 0\n", | 911 assembly_stream_.Print(".balign %" Pd ", 0\n", |
| 912 OS::kMaxPreferredCodeAlignment); | 912 OS::kMaxPreferredCodeAlignment); |
| 913 assembly_stream_.Print("%s:\n", data_symbol); | 913 assembly_stream_.Print("%s:\n", data_symbol); |
| 914 uword buffer = reinterpret_cast<uword>(clustered_stream->buffer()); | 914 uword buffer = reinterpret_cast<uword>(clustered_stream->buffer()); |
| 915 intptr_t length = clustered_stream->bytes_written(); | 915 intptr_t length = clustered_stream->bytes_written(); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 947 // Should be ".cfi_value_offset sp, 16", but requires gcc newer than late | 947 // Should be ".cfi_value_offset sp, 16", but requires gcc newer than late |
| 948 // 2016 and not supported by Android's libunwind. | 948 // 2016 and not supported by Android's libunwind. |
| 949 // DW_CFA_expression 0x10 | 949 // DW_CFA_expression 0x10 |
| 950 // uleb128 register (x31) 31 | 950 // uleb128 register (x31) 31 |
| 951 // uleb128 size of operation 2 | 951 // uleb128 size of operation 2 |
| 952 // DW_OP_plus_uconst 0x23 | 952 // DW_OP_plus_uconst 0x23 |
| 953 // uleb128 addend 16 | 953 // uleb128 addend 16 |
| 954 assembly_stream_.Print(".cfi_escape 0x10, 31, 2, 0x23, 16\n"); | 954 assembly_stream_.Print(".cfi_escape 0x10, 31, 2, 0x23, 16\n"); |
| 955 | 955 |
| 956 #elif defined(TARGET_ARCH_ARM) | 956 #elif defined(TARGET_ARCH_ARM) |
| 957 #if defined(TARGET_ABI_EABI) | 957 #if defined(TARGET_OS_MACOS) || defined(TARGET_OS_MACOS_IOS) |
| 958 COMPILE_ASSERT(FP == R7); |
| 959 assembly_stream_.Print(".cfi_def_cfa r7, 0\n"); // CFA is fp+j0 |
| 960 assembly_stream_.Print(".cfi_offset r7, 0\n"); // saved fp is *(CFA+0) |
| 961 #else |
| 958 COMPILE_ASSERT(FP == R11); | 962 COMPILE_ASSERT(FP == R11); |
| 959 assembly_stream_.Print(".cfi_def_cfa r11, 0\n"); // CFA is fp+0 | 963 assembly_stream_.Print(".cfi_def_cfa r11, 0\n"); // CFA is fp+0 |
| 960 assembly_stream_.Print(".cfi_offset r11, 0\n"); // saved fp is *(CFA+0) | 964 assembly_stream_.Print(".cfi_offset r11, 0\n"); // saved fp is *(CFA+0) |
| 961 #elif defined(TARGET_ABI_IOS) | |
| 962 COMPILE_ASSERT(FP == R7); | |
| 963 assembly_stream_.Print(".cfi_def_cfa r7, 0\n"); // CFA is fp+0 | |
| 964 assembly_stream_.Print(".cfi_offset r7, 0\n"); // saved fp is *(CFA+0) | |
| 965 #endif | 965 #endif |
| 966 assembly_stream_.Print(".cfi_offset lr, 4\n"); // saved pc is *(CFA+4) | 966 assembly_stream_.Print(".cfi_offset lr, 4\n"); // saved pc is *(CFA+4) |
| 967 // saved sp is CFA+8 | 967 // saved sp is CFA+8 |
| 968 // Should be ".cfi_value_offset sp, 8", but requires gcc newer than late | 968 // Should be ".cfi_value_offset sp, 8", but requires gcc newer than late |
| 969 // 2016 and not supported by Android's libunwind. | 969 // 2016 and not supported by Android's libunwind. |
| 970 // DW_CFA_expression 0x10 | 970 // DW_CFA_expression 0x10 |
| 971 // uleb128 register (sp) 13 | 971 // uleb128 register (sp) 13 |
| 972 // uleb128 size of operation 2 | 972 // uleb128 size of operation 2 |
| 973 // DW_OP_plus_uconst 0x23 | 973 // DW_OP_plus_uconst 0x23 |
| 974 // uleb128 addend 8 | 974 // uleb128 addend 8 |
| 975 assembly_stream_.Print(".cfi_escape 0x10, 13, 2, 0x23, 8\n"); | 975 assembly_stream_.Print(".cfi_escape 0x10, 13, 2, 0x23, 8\n"); |
| 976 | 976 |
| 977 // libunwind on ARM may use .ARM.exidx instead of .debug_frame | 977 // libunwind on ARM may use .ARM.exidx instead of .debug_frame |
| 978 #if defined(TARGET_ABI_EABI) | 978 #if defined(TARGET_OS_MACOS) || defined(TARGET_OS_MACOS_IOS) |
| 979 COMPILE_ASSERT(FP == R7); |
| 980 assembly_stream_.Print(".fnstart\n"); |
| 981 assembly_stream_.Print(".save {r7, lr}\n"); |
| 982 assembly_stream_.Print(".setfp r7, sp, #0\n"); |
| 983 #else |
| 979 COMPILE_ASSERT(FP == R11); | 984 COMPILE_ASSERT(FP == R11); |
| 980 assembly_stream_.Print(".fnstart\n"); | 985 assembly_stream_.Print(".fnstart\n"); |
| 981 assembly_stream_.Print(".save {r11, lr}\n"); | 986 assembly_stream_.Print(".save {r11, lr}\n"); |
| 982 assembly_stream_.Print(".setfp r11, sp, #0\n"); | 987 assembly_stream_.Print(".setfp r11, sp, #0\n"); |
| 983 #elif defined(TARGET_ABI_IOS) | |
| 984 COMPILE_ASSERT(FP == R7); | |
| 985 assembly_stream_.Print(".fnstart\n"); | |
| 986 assembly_stream_.Print(".save {r7, lr}\n"); | |
| 987 assembly_stream_.Print(".setfp r7, sp, #0\n"); | |
| 988 #endif | 988 #endif |
| 989 | 989 |
| 990 #elif defined(TARGET_ARCH_MIPS) | 990 #elif defined(TARGET_ARCH_MIPS) |
| 991 COMPILE_ASSERT(FP == R30); | 991 COMPILE_ASSERT(FP == R30); |
| 992 COMPILE_ASSERT(RA == R31); | 992 COMPILE_ASSERT(RA == R31); |
| 993 assembly_stream_.Print(".cfi_def_cfa r30, 0\n"); // CFA is fp+0 | 993 assembly_stream_.Print(".cfi_def_cfa r30, 0\n"); // CFA is fp+0 |
| 994 assembly_stream_.Print(".cfi_offset r30, 0\n"); // saved fp is *(CFA+0) | 994 assembly_stream_.Print(".cfi_offset r30, 0\n"); // saved fp is *(CFA+0) |
| 995 assembly_stream_.Print(".cfi_offset r31, 4\n"); // saved pc is *(CFA+4) | 995 assembly_stream_.Print(".cfi_offset r31, 4\n"); // saved pc is *(CFA+4) |
| 996 // saved sp is CFA+16 | 996 // saved sp is CFA+16 |
| 997 // Should be ".cfi_value_offset sp, 8", but requires gcc newer than late | 997 // Should be ".cfi_value_offset sp, 8", but requires gcc newer than late |
| (...skipping 1048 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2046 *buffer_len_ = BytesWritten(); | 2046 *buffer_len_ = BytesWritten(); |
| 2047 } | 2047 } |
| 2048 } else { | 2048 } else { |
| 2049 FreeBuffer(); | 2049 FreeBuffer(); |
| 2050 ThrowException(exception_type(), exception_msg()); | 2050 ThrowException(exception_type(), exception_msg()); |
| 2051 } | 2051 } |
| 2052 } | 2052 } |
| 2053 | 2053 |
| 2054 | 2054 |
| 2055 } // namespace dart | 2055 } // namespace dart |
| OLD | NEW |