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/service.h" | 5 #include "vm/service.h" |
6 | 6 |
7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
8 #include "platform/globals.h" | 8 #include "platform/globals.h" |
9 | 9 |
10 #include "vm/compiler.h" | 10 #include "vm/compiler.h" |
(...skipping 1443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1454 return true; | 1454 return true; |
1455 } | 1455 } |
1456 | 1456 |
1457 static bool HandleCoverage(Isolate* isolate, JSONStream* js) { | 1457 static bool HandleCoverage(Isolate* isolate, JSONStream* js) { |
1458 CodeCoverage::PrintToJSONStream(isolate, js); | 1458 CodeCoverage::PrintToJSONStream(isolate, js); |
1459 return true; | 1459 return true; |
1460 } | 1460 } |
1461 | 1461 |
1462 | 1462 |
1463 static bool HandleAllocationProfile(Isolate* isolate, JSONStream* js) { | 1463 static bool HandleAllocationProfile(Isolate* isolate, JSONStream* js) { |
1464 if (js->num_arguments() == 2) { | 1464 bool should_reset_accumulator = false; |
1465 const char* sub_command = js->GetArgument(1); | 1465 bool should_collect = false; |
1466 if (!strcmp(sub_command, "reset")) { | |
1467 isolate->class_table()->ResetAllocationAccumulators(); | |
1468 isolate->class_table()->AllocationProfilePrintToJSONStream(js); | |
1469 return true; | |
1470 } else if (!strcmp(sub_command, "fullgc")) { | |
1471 isolate->heap()->CollectAllGarbage(); | |
1472 isolate->class_table()->AllocationProfilePrintToJSONStream(js); | |
1473 return true; | |
1474 } else { | |
1475 PrintError(js, "Unrecognized subcommand '%s'", sub_command); | |
1476 return true; | |
1477 } | |
1478 } | |
1479 if (js->num_arguments() != 1) { | 1466 if (js->num_arguments() != 1) { |
1480 PrintError(js, "Command too long"); | 1467 PrintError(js, "Command too long"); |
1481 return true; | 1468 return true; |
1482 } | 1469 } |
| 1470 if (js->HasOption("reset")) { |
| 1471 if (js->OptionIs("reset", "true")) { |
| 1472 should_reset_accumulator = true; |
| 1473 } else { |
| 1474 PrintError(js, "Unrecognized reset option '%s'", |
| 1475 js->LookupOption("reset")); |
| 1476 return true; |
| 1477 } |
| 1478 } |
| 1479 if (js->HasOption("gc")) { |
| 1480 if (js->OptionIs("gc", "full")) { |
| 1481 should_collect = true; |
| 1482 } else { |
| 1483 PrintError(js, "Unrecognized gc option '%s'", js->LookupOption("gc")); |
| 1484 return true; |
| 1485 } |
| 1486 } |
| 1487 if (should_reset_accumulator) { |
| 1488 isolate->class_table()->ResetAllocationAccumulators(); |
| 1489 } |
| 1490 if (should_collect) { |
| 1491 isolate->heap()->CollectAllGarbage(); |
| 1492 } |
1483 isolate->class_table()->AllocationProfilePrintToJSONStream(js); | 1493 isolate->class_table()->AllocationProfilePrintToJSONStream(js); |
1484 return true; | 1494 return true; |
1485 } | 1495 } |
1486 | 1496 |
1487 | 1497 |
1488 static bool HandleResume(Isolate* isolate, JSONStream* js) { | 1498 static bool HandleResume(Isolate* isolate, JSONStream* js) { |
1489 if (isolate->message_handler()->pause_on_start()) { | 1499 if (isolate->message_handler()->pause_on_start()) { |
1490 isolate->message_handler()->set_pause_on_start(false); | 1500 isolate->message_handler()->set_pause_on_start(false); |
1491 JSONObject jsobj(js); | 1501 JSONObject jsobj(js); |
1492 jsobj.AddProperty("type", "Success"); | 1502 jsobj.AddProperty("type", "Success"); |
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1886 while (current != NULL) { | 1896 while (current != NULL) { |
1887 if (strcmp(name, current->name()) == 0) { | 1897 if (strcmp(name, current->name()) == 0) { |
1888 return current; | 1898 return current; |
1889 } | 1899 } |
1890 current = current->next(); | 1900 current = current->next(); |
1891 } | 1901 } |
1892 return NULL; | 1902 return NULL; |
1893 } | 1903 } |
1894 | 1904 |
1895 } // namespace dart | 1905 } // namespace dart |
OLD | NEW |