OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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/dart.h" | 5 #include "vm/dart.h" |
6 | 6 |
7 #include "vm/code_observers.h" | 7 #include "vm/code_observers.h" |
8 #include "vm/cpu.h" | 8 #include "vm/cpu.h" |
9 #include "vm/dart_api_state.h" | 9 #include "vm/dart_api_state.h" |
10 #include "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 | 73 |
74 private: | 74 private: |
75 VMHandles handles_; | 75 VMHandles handles_; |
76 LocalHandles api_handles_; | 76 LocalHandles api_handles_; |
77 | 77 |
78 friend class Dart; | 78 friend class Dart; |
79 DISALLOW_COPY_AND_ASSIGN(ReadOnlyHandles); | 79 DISALLOW_COPY_AND_ASSIGN(ReadOnlyHandles); |
80 }; | 80 }; |
81 | 81 |
82 | 82 |
| 83 static void CheckOffsets() { |
| 84 #define CHECK_OFFSET(expr, offset) \ |
| 85 if ((expr) != (offset)) { \ |
| 86 FATAL2("%s == %" Pd, #expr, (expr)); \ |
| 87 } \ |
| 88 |
| 89 #if defined(TARGET_ARCH_ARM) |
| 90 // These offsets are embedded in precompiled instructions. We need simarm |
| 91 // (compiler) and arm (runtime) to agree. |
| 92 CHECK_OFFSET(Heap::TopOffset(Heap::kNew), 8); |
| 93 CHECK_OFFSET(Isolate::heap_offset(), 8); |
| 94 CHECK_OFFSET(Thread::stack_limit_offset(), 4); |
| 95 CHECK_OFFSET(Thread::object_null_offset(), 36); |
| 96 #endif |
| 97 #if defined(TARGET_ARCH_MIPS) |
| 98 // These offsets are embedded in precompiled instructions. We need simmips |
| 99 // (compiler) and mips (runtime) to agree. |
| 100 CHECK_OFFSET(Heap::TopOffset(Heap::kNew), 8); |
| 101 CHECK_OFFSET(Isolate::heap_offset(), 8); |
| 102 CHECK_OFFSET(Thread::stack_limit_offset(), 4); |
| 103 CHECK_OFFSET(Thread::object_null_offset(), 36); |
| 104 #endif |
| 105 #if defined(TARGET_ARCH_ARM64) |
| 106 // These offsets are embedded in precompiled instructions. We need simarm64 |
| 107 // (compiler) and arm64 (runtime) to agree. |
| 108 CHECK_OFFSET(Heap::TopOffset(Heap::kNew), 8); |
| 109 CHECK_OFFSET(Isolate::heap_offset(), 16); |
| 110 CHECK_OFFSET(Thread::stack_limit_offset(), 8); |
| 111 CHECK_OFFSET(Thread::object_null_offset(), 72); |
| 112 #endif |
| 113 #undef CHECK_OFFSET |
| 114 } |
| 115 |
| 116 |
83 const char* Dart::InitOnce(const uint8_t* vm_isolate_snapshot, | 117 const char* Dart::InitOnce(const uint8_t* vm_isolate_snapshot, |
84 const uint8_t* instructions_snapshot, | 118 const uint8_t* instructions_snapshot, |
85 const uint8_t* data_snapshot, | 119 const uint8_t* data_snapshot, |
86 Dart_IsolateCreateCallback create, | 120 Dart_IsolateCreateCallback create, |
87 Dart_IsolateShutdownCallback shutdown, | 121 Dart_IsolateShutdownCallback shutdown, |
88 Dart_ThreadExitCallback thread_exit, | 122 Dart_ThreadExitCallback thread_exit, |
89 Dart_FileOpenCallback file_open, | 123 Dart_FileOpenCallback file_open, |
90 Dart_FileReadCallback file_read, | 124 Dart_FileReadCallback file_read, |
91 Dart_FileWriteCallback file_write, | 125 Dart_FileWriteCallback file_write, |
92 Dart_FileCloseCallback file_close, | 126 Dart_FileCloseCallback file_close, |
93 Dart_EntropySource entropy_source, | 127 Dart_EntropySource entropy_source, |
94 Dart_GetVMServiceAssetsArchive get_service_assets) { | 128 Dart_GetVMServiceAssetsArchive get_service_assets) { |
| 129 CheckOffsets(); |
95 // TODO(iposva): Fix race condition here. | 130 // TODO(iposva): Fix race condition here. |
96 if (vm_isolate_ != NULL || !Flags::Initialized()) { | 131 if (vm_isolate_ != NULL || !Flags::Initialized()) { |
97 return "VM already initialized or flags not initialized."; | 132 return "VM already initialized or flags not initialized."; |
98 } | 133 } |
99 set_thread_exit_callback(thread_exit); | 134 set_thread_exit_callback(thread_exit); |
100 SetFileCallbacks(file_open, file_read, file_write, file_close); | 135 SetFileCallbacks(file_open, file_read, file_write, file_close); |
101 set_entropy_source_callback(entropy_source); | 136 set_entropy_source_callback(entropy_source); |
102 OS::InitOnce(); | 137 OS::InitOnce(); |
103 VirtualMemory::InitOnce(); | 138 VirtualMemory::InitOnce(); |
104 OSThread::InitOnce(); | 139 OSThread::InitOnce(); |
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
584 return predefined_handles_->handles_.IsValidScopedHandle(address); | 619 return predefined_handles_->handles_.IsValidScopedHandle(address); |
585 } | 620 } |
586 | 621 |
587 | 622 |
588 bool Dart::IsReadOnlyApiHandle(Dart_Handle handle) { | 623 bool Dart::IsReadOnlyApiHandle(Dart_Handle handle) { |
589 ASSERT(predefined_handles_ != NULL); | 624 ASSERT(predefined_handles_ != NULL); |
590 return predefined_handles_->api_handles_.IsValidHandle(handle); | 625 return predefined_handles_->api_handles_.IsValidHandle(handle); |
591 } | 626 } |
592 | 627 |
593 } // namespace dart | 628 } // namespace dart |
OLD | NEW |