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/isolate.h" | 5 #include "vm/isolate.h" |
6 | 6 |
7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
8 #include "include/dart_native_api.h" | 8 #include "include/dart_native_api.h" |
9 #include "platform/assert.h" | 9 #include "platform/assert.h" |
10 #include "platform/json.h" | 10 #include "platform/json.h" |
(...skipping 876 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
887 // Setup the isolate message handler. | 887 // Setup the isolate message handler. |
888 MessageHandler* handler = new IsolateMessageHandler(result); | 888 MessageHandler* handler = new IsolateMessageHandler(result); |
889 ASSERT(handler != NULL); | 889 ASSERT(handler != NULL); |
890 result->set_message_handler(handler); | 890 result->set_message_handler(handler); |
891 | 891 |
892 // Setup the Dart API state. | 892 // Setup the Dart API state. |
893 ApiState* state = new ApiState(); | 893 ApiState* state = new ApiState(); |
894 ASSERT(state != NULL); | 894 ASSERT(state != NULL); |
895 result->set_api_state(state); | 895 result->set_api_state(state); |
896 | 896 |
897 // Initialize stack limit (wait until later for the VM isolate, since the | |
898 // needed GetStackPointer stub has not yet been generated in that case). | |
899 if (!is_vm_isolate) { | |
900 result->InitializeStackLimit(); | |
901 } | |
902 result->set_main_port(PortMap::CreatePort(result->message_handler())); | 897 result->set_main_port(PortMap::CreatePort(result->message_handler())); |
903 #if defined(DEBUG) | 898 #if defined(DEBUG) |
904 // Verify that we are never reusing a live origin id. | 899 // Verify that we are never reusing a live origin id. |
905 VerifyOriginId id_verifier(result->main_port()); | 900 VerifyOriginId id_verifier(result->main_port()); |
906 Isolate::VisitIsolates(&id_verifier); | 901 Isolate::VisitIsolates(&id_verifier); |
907 #endif | 902 #endif |
908 result->set_origin_id(result->main_port()); | 903 result->set_origin_id(result->main_port()); |
909 result->set_pause_capability(result->random()->NextUInt64()); | 904 result->set_pause_capability(result->random()->NextUInt64()); |
910 result->set_terminate_capability(result->random()->NextUInt64()); | 905 result->set_terminate_capability(result->random()->NextUInt64()); |
911 | 906 |
(...skipping 19 matching lines...) Expand all Loading... |
931 result->LowLevelShutdown(); | 926 result->LowLevelShutdown(); |
932 Thread::ExitIsolate(); | 927 Thread::ExitIsolate(); |
933 delete result; | 928 delete result; |
934 return NULL; | 929 return NULL; |
935 } | 930 } |
936 | 931 |
937 return result; | 932 return result; |
938 } | 933 } |
939 | 934 |
940 | 935 |
941 void Isolate::InitializeStackLimit() { | |
942 SetStackLimitFromStackBase(Isolate::GetCurrentStackPointer()); | |
943 } | |
944 | |
945 | |
946 /* static */ | 936 /* static */ |
947 uword Isolate::GetCurrentStackPointer() { | 937 uword Isolate::GetCurrentStackPointer() { |
948 // Since AddressSanitizer's detect_stack_use_after_return instruments the | 938 // Since AddressSanitizer's detect_stack_use_after_return instruments the |
949 // C++ code to give out fake stack addresses, we call a stub in that case. | 939 // C++ code to give out fake stack addresses, we call a stub in that case. |
950 uword (*func)() = reinterpret_cast<uword (*)()>( | 940 uword (*func)() = reinterpret_cast<uword (*)()>( |
951 StubCode::GetStackPointer_entry()->EntryPoint()); | 941 StubCode::GetStackPointer_entry()->EntryPoint()); |
952 // But for performance (and to support simulators), we normally use a local. | 942 // But for performance (and to support simulators), we normally use a local. |
953 #if defined(__has_feature) | 943 #if defined(__has_feature) |
954 #if __has_feature(address_sanitizer) | 944 #if __has_feature(address_sanitizer) |
955 uword current_sp = func(); | 945 uword current_sp = func(); |
(...skipping 1654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2610 } | 2600 } |
2611 | 2601 |
2612 | 2602 |
2613 RawInstance* IsolateSpawnState::BuildMessage(Thread* thread) { | 2603 RawInstance* IsolateSpawnState::BuildMessage(Thread* thread) { |
2614 return DeserializeObject(thread, | 2604 return DeserializeObject(thread, |
2615 serialized_message_, serialized_message_len_); | 2605 serialized_message_, serialized_message_len_); |
2616 } | 2606 } |
2617 | 2607 |
2618 | 2608 |
2619 } // namespace dart | 2609 } // namespace dart |
OLD | NEW |