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

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

Issue 590123002: Revert "Per isolate package root." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « runtime/include/dart_api.h ('k') | runtime/lib/isolate_patch.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) 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 "platform/assert.h" 5 #include "platform/assert.h"
6 #include "vm/bootstrap_natives.h" 6 #include "vm/bootstrap_natives.h"
7 #include "vm/class_finalizer.h" 7 #include "vm/class_finalizer.h"
8 #include "vm/dart.h" 8 #include "vm/dart.h"
9 #include "vm/dart_api_impl.h" 9 #include "vm/dart_api_impl.h"
10 #include "vm/dart_entry.h" 10 #include "vm/dart_entry.h"
11 #include "vm/exceptions.h" 11 #include "vm/exceptions.h"
12 #include "vm/lockers.h" 12 #include "vm/lockers.h"
13 #include "vm/longjump.h" 13 #include "vm/longjump.h"
14 #include "vm/message_handler.h" 14 #include "vm/message_handler.h"
15 #include "vm/object.h" 15 #include "vm/object.h"
16 #include "vm/object_store.h" 16 #include "vm/object_store.h"
17 #include "vm/port.h" 17 #include "vm/port.h"
18 #include "vm/resolver.h" 18 #include "vm/resolver.h"
19 #include "vm/snapshot.h" 19 #include "vm/snapshot.h"
20 #include "vm/symbols.h" 20 #include "vm/symbols.h"
21 #include "vm/unicode.h"
22 21
23 namespace dart { 22 namespace dart {
24 23
25 static uint8_t* allocator(uint8_t* ptr, intptr_t old_size, intptr_t new_size) { 24 static uint8_t* allocator(uint8_t* ptr, intptr_t old_size, intptr_t new_size) {
26 void* new_ptr = realloc(reinterpret_cast<void*>(ptr), new_size); 25 void* new_ptr = realloc(reinterpret_cast<void*>(ptr), new_size);
27 return reinterpret_cast<uint8_t*>(new_ptr); 26 return reinterpret_cast<uint8_t*>(new_ptr);
28 } 27 }
29 28
30 29
31 DEFINE_NATIVE_ENTRY(CapabilityImpl_factory, 1) { 30 DEFINE_NATIVE_ENTRY(CapabilityImpl_factory, 1) {
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 if (callback == NULL) { 146 if (callback == NULL) {
148 *error = strdup("Null callback specified for isolate creation\n"); 147 *error = strdup("Null callback specified for isolate creation\n");
149 Isolate::SetCurrent(parent_isolate); 148 Isolate::SetCurrent(parent_isolate);
150 return false; 149 return false;
151 } 150 }
152 151
153 void* init_data = parent_isolate->init_callback_data(); 152 void* init_data = parent_isolate->init_callback_data();
154 Isolate* child_isolate = reinterpret_cast<Isolate*>( 153 Isolate* child_isolate = reinterpret_cast<Isolate*>(
155 (callback)(state->script_url(), 154 (callback)(state->script_url(),
156 state->function_name(), 155 state->function_name(),
157 state->package_root(),
158 init_data, 156 init_data,
159 error)); 157 error));
160 if (child_isolate == NULL) { 158 if (child_isolate == NULL) {
161 Isolate::SetCurrent(parent_isolate); 159 Isolate::SetCurrent(parent_isolate);
162 return false; 160 return false;
163 } 161 }
164 state->set_isolate(reinterpret_cast<Isolate*>(child_isolate)); 162 state->set_isolate(reinterpret_cast<Isolate*>(child_isolate));
165 163
166 Isolate::SetCurrent(parent_isolate); 164 Isolate::SetCurrent(parent_isolate);
167 return true; 165 return true;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 return Spawn(isolate, new IsolateSpawnState(port.Id(), func, message)); 209 return Spawn(isolate, new IsolateSpawnState(port.Id(), func, message));
212 } 210 }
213 } 211 }
214 const String& msg = String::Handle(String::New( 212 const String& msg = String::Handle(String::New(
215 "Isolate.spawn expects to be passed a static or top-level function")); 213 "Isolate.spawn expects to be passed a static or top-level function"));
216 Exceptions::ThrowArgumentError(msg); 214 Exceptions::ThrowArgumentError(msg);
217 return Object::null(); 215 return Object::null();
218 } 216 }
219 217
220 218
221 DEFINE_NATIVE_ENTRY(Isolate_spawnUri, 5) { 219 DEFINE_NATIVE_ENTRY(Isolate_spawnUri, 4) {
222 GET_NON_NULL_NATIVE_ARGUMENT(SendPort, port, arguments->NativeArgAt(0)); 220 GET_NON_NULL_NATIVE_ARGUMENT(SendPort, port, arguments->NativeArgAt(0));
223 GET_NON_NULL_NATIVE_ARGUMENT(String, uri, arguments->NativeArgAt(1)); 221 GET_NON_NULL_NATIVE_ARGUMENT(String, uri, arguments->NativeArgAt(1));
224 GET_NON_NULL_NATIVE_ARGUMENT(Instance, args, arguments->NativeArgAt(2)); 222 GET_NON_NULL_NATIVE_ARGUMENT(Instance, args, arguments->NativeArgAt(2));
225 GET_NON_NULL_NATIVE_ARGUMENT(Instance, message, arguments->NativeArgAt(3)); 223 GET_NON_NULL_NATIVE_ARGUMENT(Instance, message, arguments->NativeArgAt(3));
226 GET_NATIVE_ARGUMENT(String, package_root, arguments->NativeArgAt(4));
227 224
228 // Canonicalize the uri with respect to the current isolate. 225 // Canonicalize the uri with respect to the current isolate.
229 char* error = NULL; 226 char* error = NULL;
230 char* canonical_uri = NULL; 227 char* canonical_uri = NULL;
231 const Library& root_lib = 228 const Library& root_lib =
232 Library::Handle(arguments->isolate()->object_store()->root_library()); 229 Library::Handle(arguments->isolate()->object_store()->root_library());
233 if (!CanonicalizeUri(arguments->isolate(), root_lib, uri, 230 if (!CanonicalizeUri(arguments->isolate(), root_lib, uri,
234 &canonical_uri, &error)) { 231 &canonical_uri, &error)) {
235 const String& msg = String::Handle(String::New(error)); 232 const String& msg = String::Handle(String::New(error));
236 ThrowIsolateSpawnException(msg); 233 ThrowIsolateSpawnException(msg);
237 } 234 }
238 235
239 char* utf8_package_root = NULL; 236 return Spawn(isolate, new IsolateSpawnState(port.Id(), canonical_uri,
240 if (!package_root.IsNull()) { 237 args, message));
241 const intptr_t len = Utf8::Length(package_root);
242 Zone* zone = isolate->current_zone();
243 utf8_package_root = zone->Alloc<char>(len + 1);
244 package_root.ToUTF8(reinterpret_cast<uint8_t*>(utf8_package_root), len);
245 utf8_package_root[len] = '\0';
246 }
247
248 return Spawn(isolate, new IsolateSpawnState(
249 port.Id(), canonical_uri, utf8_package_root, args, message));
250 } 238 }
251 239
252 240
253 DEFINE_NATIVE_ENTRY(Isolate_sendOOB, 2) { 241 DEFINE_NATIVE_ENTRY(Isolate_sendOOB, 2) {
254 GET_NON_NULL_NATIVE_ARGUMENT(SendPort, port, arguments->NativeArgAt(0)); 242 GET_NON_NULL_NATIVE_ARGUMENT(SendPort, port, arguments->NativeArgAt(0));
255 GET_NON_NULL_NATIVE_ARGUMENT(Array, msg, arguments->NativeArgAt(1)); 243 GET_NON_NULL_NATIVE_ARGUMENT(Array, msg, arguments->NativeArgAt(1));
256 244
257 // Make sure to route this request to the isolate library OOB mesage handler. 245 // Make sure to route this request to the isolate library OOB mesage handler.
258 msg.SetAt(0, Smi::Handle(Smi::New(Message::kIsolateLibOOBMsg))); 246 msg.SetAt(0, Smi::Handle(Smi::New(Message::kIsolateLibOOBMsg)));
259 247
260 uint8_t* data = NULL; 248 uint8_t* data = NULL;
261 MessageWriter writer(&data, &allocator); 249 MessageWriter writer(&data, &allocator);
262 writer.WriteMessage(msg); 250 writer.WriteMessage(msg);
263 251
264 PortMap::PostMessage(new Message(port.Id(), 252 PortMap::PostMessage(new Message(port.Id(),
265 data, writer.BytesWritten(), 253 data, writer.BytesWritten(),
266 Message::kOOBPriority)); 254 Message::kOOBPriority));
267 return Object::null(); 255 return Object::null();
268 } 256 }
269 257
270 } // namespace dart 258 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/include/dart_api.h ('k') | runtime/lib/isolate_patch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698