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

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

Issue 1965823002: Initial isolate reload support (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 7 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
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/service.h" 5 #include "vm/service.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/globals.h" 9 #include "platform/globals.h"
10 10
(...skipping 1435 matching lines...) Expand 10 before | Expand all | Expand 10 after
1446 if ((id < 0) || (id >= libs.Length())) { 1446 if ((id < 0) || (id >= libs.Length())) {
1447 return Object::sentinel().raw(); 1447 return Object::sentinel().raw();
1448 } 1448 }
1449 Library& lib = Library::Handle(); 1449 Library& lib = Library::Handle();
1450 lib ^= libs.At(id); 1450 lib ^= libs.At(id);
1451 ASSERT(!lib.IsNull()); 1451 ASSERT(!lib.IsNull());
1452 if (num_parts == 2) { 1452 if (num_parts == 2) {
1453 return lib.raw(); 1453 return lib.raw();
1454 } 1454 }
1455 if (strcmp(parts[2], "scripts") == 0) { 1455 if (strcmp(parts[2], "scripts") == 0) {
1456 // Script ids look like "libraries/35/scripts/library%2Furl.dart" 1456 // Script ids look like "libraries/35/scripts/library%2Furl.dart/12345"
1457 if (num_parts != 4) { 1457 if (num_parts != 5) {
1458 return Object::sentinel().raw(); 1458 return Object::sentinel().raw();
1459 } 1459 }
1460 const String& id = String::Handle(String::New(parts[3])); 1460 const String& id = String::Handle(String::New(parts[3]));
1461 ASSERT(!id.IsNull()); 1461 ASSERT(!id.IsNull());
1462 // The id is the url of the script % encoded, decode it. 1462 // The id is the url of the script % encoded, decode it.
1463 const String& requested_url = String::Handle(String::DecodeIRI(id)); 1463 const String& requested_url = String::Handle(String::DecodeIRI(id));
1464
1465 // Each script id is tagged with a load time.
1466 int64_t timestamp;
1467 if (!GetInteger64Id(parts[4], &timestamp, 16) || (timestamp < 0)) {
1468 return Object::sentinel().raw();
1469 }
1470
1464 Script& script = Script::Handle(); 1471 Script& script = Script::Handle();
1465 String& script_url = String::Handle(); 1472 String& script_url = String::Handle();
1466 const Array& loaded_scripts = Array::Handle(lib.LoadedScripts()); 1473 const Array& loaded_scripts = Array::Handle(lib.LoadedScripts());
1467 ASSERT(!loaded_scripts.IsNull()); 1474 ASSERT(!loaded_scripts.IsNull());
1468 intptr_t i; 1475 intptr_t i;
1469 for (i = 0; i < loaded_scripts.Length(); i++) { 1476 for (i = 0; i < loaded_scripts.Length(); i++) {
1470 script ^= loaded_scripts.At(i); 1477 script ^= loaded_scripts.At(i);
1471 ASSERT(!script.IsNull()); 1478 ASSERT(!script.IsNull());
1472 script_url ^= script.url(); 1479 script_url ^= script.url();
1473 if (script_url.Equals(requested_url)) { 1480 if (script_url.Equals(requested_url) &&
1481 (timestamp == script.load_timestamp())) {
1474 return script.raw(); 1482 return script.raw();
1475 } 1483 }
1476 } 1484 }
1477 } 1485 }
1478 1486
1479 // Not found. 1487 // Not found.
1480 return Object::sentinel().raw(); 1488 return Object::sentinel().raw();
1481 } 1489 }
1482 1490
1483 static RawObject* LookupHeapObjectClasses(Thread* thread, 1491 static RawObject* LookupHeapObjectClasses(Thread* thread,
(...skipping 885 matching lines...) Expand 10 before | Expand all | Expand 10 after
2369 } 2377 }
2370 SourceReport report(report_set, compile_mode); 2378 SourceReport report(report_set, compile_mode);
2371 report.PrintJSON(js, 2379 report.PrintJSON(js,
2372 script, 2380 script,
2373 TokenPosition(start_pos), 2381 TokenPosition(start_pos),
2374 TokenPosition(end_pos)); 2382 TokenPosition(end_pos));
2375 return true; 2383 return true;
2376 } 2384 }
2377 2385
2378 2386
2387 static const MethodParameter* reload_sources_params[] = {
2388 RUNNABLE_ISOLATE_PARAMETER,
2389 NULL,
2390 };
2391
2392
2393 static bool ReloadSources(Thread* thread, JSONStream* js) {
2394 Isolate* isolate = thread->isolate();
2395 if (!isolate->compilation_allowed()) {
2396 js->PrintError(kFeatureDisabled,
2397 "Cannot reload source when running a precompiled program.");
2398 return true;
2399 }
2400 if (Dart::snapshot_kind() == Snapshot::kAppWithJIT) {
2401 js->PrintError(kFeatureDisabled,
2402 "Cannot reload source when running an app snapshot.");
2403 return true;
2404 }
2405 Dart_LibraryTagHandler handler = isolate->library_tag_handler();
2406 if (handler == NULL) {
2407 js->PrintError(kFeatureDisabled,
2408 "A library tag handler must be installed.");
2409 return true;
2410 }
2411 if (isolate->IsReloading()) {
2412 js->PrintError(kIsolateIsReloading,
2413 "This isolate is being reloaded.");
2414 return true;
2415 }
2416 DebuggerStackTrace* stack = isolate->debugger()->StackTrace();
2417 ASSERT(isolate->CanReload());
2418
2419 if (stack->Length() > 0) {
2420 // TODO(turnidge): We need to support this case.
2421 js->PrintError(kFeatureDisabled,
2422 "Source can only be reloaded when stack is empty.");
2423 return true;
2424 } else {
2425 isolate->ReloadSources();
2426 }
2427
2428 PrintSuccess(js);
2429 return true;
2430 }
2431
2432
2379 static bool AddBreakpointCommon(Thread* thread, 2433 static bool AddBreakpointCommon(Thread* thread,
2380 JSONStream* js, 2434 JSONStream* js,
2381 const String& script_uri) { 2435 const String& script_uri) {
2382 if (!thread->isolate()->compilation_allowed()) { 2436 if (!thread->isolate()->compilation_allowed()) {
2383 js->PrintError(kFeatureDisabled, 2437 js->PrintError(kFeatureDisabled,
2384 "Cannot use breakpoints when running a precompiled program."); 2438 "Cannot use breakpoints when running a precompiled program.");
2385 return true; 2439 return true;
2386 } 2440 }
2387 const char* line_param = js->LookupParam("line"); 2441 const char* line_param = js->LookupParam("line");
2388 intptr_t line = UIntParameter::Parse(line_param); 2442 intptr_t line = UIntParameter::Parse(line_param);
(...skipping 1554 matching lines...) Expand 10 before | Expand all | Expand 10 after
3943 { "_getVMTimeline", GetVMTimeline, 3997 { "_getVMTimeline", GetVMTimeline,
3944 get_vm_timeline_params }, 3998 get_vm_timeline_params },
3945 { "_getVMTimelineFlags", GetVMTimelineFlags, 3999 { "_getVMTimelineFlags", GetVMTimelineFlags,
3946 get_vm_timeline_flags_params }, 4000 get_vm_timeline_flags_params },
3947 { "pause", Pause, 4001 { "pause", Pause,
3948 pause_params }, 4002 pause_params },
3949 { "removeBreakpoint", RemoveBreakpoint, 4003 { "removeBreakpoint", RemoveBreakpoint,
3950 remove_breakpoint_params }, 4004 remove_breakpoint_params },
3951 { "_restartVM", RestartVM, 4005 { "_restartVM", RestartVM,
3952 restart_vm_params }, 4006 restart_vm_params },
4007 { "_reloadSources", ReloadSources,
4008 reload_sources_params },
3953 { "resume", Resume, 4009 { "resume", Resume,
3954 resume_params }, 4010 resume_params },
3955 { "_requestHeapSnapshot", RequestHeapSnapshot, 4011 { "_requestHeapSnapshot", RequestHeapSnapshot,
3956 request_heap_snapshot_params }, 4012 request_heap_snapshot_params },
3957 { "setExceptionPauseMode", SetExceptionPauseMode, 4013 { "setExceptionPauseMode", SetExceptionPauseMode,
3958 set_exception_pause_mode_params }, 4014 set_exception_pause_mode_params },
3959 { "_setFlag", SetFlag, 4015 { "_setFlag", SetFlag,
3960 set_flags_params }, 4016 set_flags_params },
3961 { "setLibraryDebuggable", SetLibraryDebuggable, 4017 { "setLibraryDebuggable", SetLibraryDebuggable,
3962 set_library_debuggable_params }, 4018 set_library_debuggable_params },
(...skipping 16 matching lines...) Expand all
3979 if (strcmp(method_name, method.name) == 0) { 4035 if (strcmp(method_name, method.name) == 0) {
3980 return &method; 4036 return &method;
3981 } 4037 }
3982 } 4038 }
3983 return NULL; 4039 return NULL;
3984 } 4040 }
3985 4041
3986 #endif // !PRODUCT 4042 #endif // !PRODUCT
3987 4043
3988 } // namespace dart 4044 } // namespace dart
OLDNEW
« runtime/vm/object.cc ('K') | « runtime/vm/scavenger.cc ('k') | runtime/vm/service_event.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698