Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(101)

Side by Side Diff: runtime/vm/isolate.cc

Issue 1244733002: - Implement VM parts of https://codereview.chromium.org/1240743003/ (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Update isolate.status file as expected. Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/vm/isolate.h ('k') | tests/isolate/error_at_spawn_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "platform/assert.h" 8 #include "platform/assert.h"
9 #include "platform/json.h" 9 #include "platform/json.h"
10 #include "vm/code_observers.h" 10 #include "vm/code_observers.h"
(...skipping 1214 matching lines...) Expand 10 before | Expand all | Expand 10 after
1225 IsolateSpawnState* state = NULL; 1225 IsolateSpawnState* state = NULL;
1226 { 1226 {
1227 // TODO(turnidge): Is this locking required here at all anymore? 1227 // TODO(turnidge): Is this locking required here at all anymore?
1228 MutexLocker ml(isolate->mutex()); 1228 MutexLocker ml(isolate->mutex());
1229 state = isolate->spawn_state(); 1229 state = isolate->spawn_state();
1230 } 1230 }
1231 { 1231 {
1232 StartIsolateScope start_scope(isolate); 1232 StartIsolateScope start_scope(isolate);
1233 StackZone zone(isolate); 1233 StackZone zone(isolate);
1234 HandleScope handle_scope(isolate); 1234 HandleScope handle_scope(isolate);
1235
1236 // If particular values were requested for this newly spawned isolate, then
1237 // they are set here before the isolate starts executing user code.
1238 isolate->SetErrorsFatal(state->errors_are_fatal());
1239 if (state->on_exit_port() != ILLEGAL_PORT) {
1240 const SendPort& listener =
1241 SendPort::Handle(SendPort::New(state->on_exit_port()));
1242 isolate->AddExitListener(listener, Instance::null_instance());
1243 }
1244 if (state->on_error_port() != ILLEGAL_PORT) {
1245 const SendPort& listener =
1246 SendPort::Handle(SendPort::New(state->on_error_port()));
1247 isolate->AddErrorListener(listener);
1248 }
1249
1250 // Switch back to spawning isolate.
1251
1252
1235 if (!ClassFinalizer::ProcessPendingClasses()) { 1253 if (!ClassFinalizer::ProcessPendingClasses()) {
1236 // Error is in sticky error already. 1254 // Error is in sticky error already.
1237 return false; 1255 return false;
1238 } 1256 }
1239 1257
1240 Object& result = Object::Handle(); 1258 Object& result = Object::Handle();
1241 result = state->ResolveFunction(); 1259 result = state->ResolveFunction();
1242 bool is_spawn_uri = state->is_spawn_uri(); 1260 bool is_spawn_uri = state->is_spawn_uri();
1243 if (result.IsError()) { 1261 if (result.IsError()) {
1244 StoreError(isolate, result); 1262 StoreError(isolate, result);
(...skipping 700 matching lines...) Expand 10 before | Expand all | Expand 10 after
1945 ASSERT(!obj.IsError()); 1963 ASSERT(!obj.IsError());
1946 Instance& instance = Instance::Handle(isolate); 1964 Instance& instance = Instance::Handle(isolate);
1947 instance ^= obj.raw(); // Can't use Instance::Cast because may be null. 1965 instance ^= obj.raw(); // Can't use Instance::Cast because may be null.
1948 return instance.raw(); 1966 return instance.raw();
1949 } 1967 }
1950 1968
1951 1969
1952 IsolateSpawnState::IsolateSpawnState(Dart_Port parent_port, 1970 IsolateSpawnState::IsolateSpawnState(Dart_Port parent_port,
1953 const Function& func, 1971 const Function& func,
1954 const Instance& message, 1972 const Instance& message,
1955 bool paused) 1973 bool paused,
1974 bool errors_are_fatal,
1975 Dart_Port on_exit_port,
1976 Dart_Port on_error_port)
1956 : isolate_(NULL), 1977 : isolate_(NULL),
1957 parent_port_(parent_port), 1978 parent_port_(parent_port),
1979 on_exit_port_(on_exit_port),
1980 on_error_port_(on_error_port),
1958 script_url_(NULL), 1981 script_url_(NULL),
1959 package_root_(NULL), 1982 package_root_(NULL),
1960 library_url_(NULL), 1983 library_url_(NULL),
1961 class_name_(NULL), 1984 class_name_(NULL),
1962 function_name_(NULL), 1985 function_name_(NULL),
1963 serialized_args_(NULL), 1986 serialized_args_(NULL),
1964 serialized_args_len_(0), 1987 serialized_args_len_(0),
1965 serialized_message_(NULL), 1988 serialized_message_(NULL),
1966 serialized_message_len_(0), 1989 serialized_message_len_(0),
1967 isolate_flags_(), 1990 isolate_flags_(),
1968 paused_(paused) { 1991 paused_(paused),
1992 errors_are_fatal_(errors_are_fatal) {
1969 script_url_ = NULL; 1993 script_url_ = NULL;
1970 const Class& cls = Class::Handle(func.Owner()); 1994 const Class& cls = Class::Handle(func.Owner());
1971 const Library& lib = Library::Handle(cls.library()); 1995 const Library& lib = Library::Handle(cls.library());
1972 const String& lib_url = String::Handle(lib.url()); 1996 const String& lib_url = String::Handle(lib.url());
1973 library_url_ = strdup(lib_url.ToCString()); 1997 library_url_ = strdup(lib_url.ToCString());
1974 1998
1975 const String& func_name = String::Handle(func.name()); 1999 const String& func_name = String::Handle(func.name());
1976 function_name_ = strdup(func_name.ToCString()); 2000 function_name_ = strdup(func_name.ToCString());
1977 if (!cls.IsTopLevel()) { 2001 if (!cls.IsTopLevel()) {
1978 const String& class_name = String::Handle(cls.Name()); 2002 const String& class_name = String::Handle(cls.Name());
1979 class_name_ = strdup(class_name.ToCString()); 2003 class_name_ = strdup(class_name.ToCString());
1980 } 2004 }
1981 bool can_send_any_object = true; 2005 bool can_send_any_object = true;
1982 SerializeObject(message, 2006 SerializeObject(message,
1983 &serialized_message_, 2007 &serialized_message_,
1984 &serialized_message_len_, 2008 &serialized_message_len_,
1985 can_send_any_object); 2009 can_send_any_object);
1986 // Inherit flags from spawning isolate. 2010 // Inherit flags from spawning isolate.
1987 isolate_flags()->CopyFrom(Isolate::Current()->flags()); 2011 isolate_flags()->CopyFrom(Isolate::Current()->flags());
1988 } 2012 }
1989 2013
1990 2014
1991 IsolateSpawnState::IsolateSpawnState(Dart_Port parent_port, 2015 IsolateSpawnState::IsolateSpawnState(Dart_Port parent_port,
1992 const char* script_url, 2016 const char* script_url,
1993 const char* package_root, 2017 const char* package_root,
1994 const Instance& args, 2018 const Instance& args,
1995 const Instance& message, 2019 const Instance& message,
1996 bool paused) 2020 bool paused,
2021 bool errors_are_fatal,
2022 Dart_Port on_exit_port,
2023 Dart_Port on_error_port)
1997 : isolate_(NULL), 2024 : isolate_(NULL),
1998 parent_port_(parent_port), 2025 parent_port_(parent_port),
2026 on_exit_port_(on_exit_port),
2027 on_error_port_(on_error_port),
1999 package_root_(NULL), 2028 package_root_(NULL),
2000 library_url_(NULL), 2029 library_url_(NULL),
2001 class_name_(NULL), 2030 class_name_(NULL),
2002 function_name_(NULL), 2031 function_name_(NULL),
2003 serialized_args_(NULL), 2032 serialized_args_(NULL),
2004 serialized_args_len_(0), 2033 serialized_args_len_(0),
2005 serialized_message_(NULL), 2034 serialized_message_(NULL),
2006 serialized_message_len_(0), 2035 serialized_message_len_(0),
2007 isolate_flags_(), 2036 isolate_flags_(),
2008 paused_(paused) { 2037 paused_(paused),
2038 errors_are_fatal_(errors_are_fatal) {
2009 script_url_ = strdup(script_url); 2039 script_url_ = strdup(script_url);
2010 if (package_root != NULL) { 2040 if (package_root != NULL) {
2011 package_root_ = strdup(package_root); 2041 package_root_ = strdup(package_root);
2012 } 2042 }
2013 library_url_ = NULL; 2043 library_url_ = NULL;
2014 function_name_ = strdup("main"); 2044 function_name_ = strdup("main");
2015 bool can_send_any_object = false; 2045 bool can_send_any_object = false;
2016 SerializeObject(args, 2046 SerializeObject(args,
2017 &serialized_args_, 2047 &serialized_args_,
2018 &serialized_args_len_, 2048 &serialized_args_len_,
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
2117 serialized_message_, serialized_message_len_); 2147 serialized_message_, serialized_message_len_);
2118 } 2148 }
2119 2149
2120 2150
2121 void IsolateSpawnState::Cleanup() { 2151 void IsolateSpawnState::Cleanup() {
2122 SwitchIsolateScope switch_scope(I); 2152 SwitchIsolateScope switch_scope(I);
2123 Dart::ShutdownIsolate(); 2153 Dart::ShutdownIsolate();
2124 } 2154 }
2125 2155
2126 } // namespace dart 2156 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/isolate.h ('k') | tests/isolate/error_at_spawn_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698