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

Unified Diff: src/runtime/runtime-debug.cc

Issue 2700743002: [inspector] extend protocol for code coverage. (Closed)
Patch Set: fix Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/inspector/v8-runtime-agent-impl.cc ('k') | test/cctest/test-debug.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime/runtime-debug.cc
diff --git a/src/runtime/runtime-debug.cc b/src/runtime/runtime-debug.cc
index fb2e893bbbb1275020354919de78671add5139e3..3649621b09972dc7dae2373f56edf3c0100c6e27 100644
--- a/src/runtime/runtime-debug.cc
+++ b/src/runtime/runtime-debug.cc
@@ -1895,49 +1895,16 @@ RUNTIME_FUNCTION(Runtime_DebugIsActive) {
return Smi::FromInt(isolate->debug()->is_active());
}
-
RUNTIME_FUNCTION(Runtime_DebugBreakInOptimizedCode) {
UNIMPLEMENTED();
return NULL;
}
-namespace {
-Handle<JSObject> CreateRangeObject(Isolate* isolate, const CoverageRange* range,
- Handle<String> inner_string,
- Handle<String> start_string,
- Handle<String> end_string,
- Handle<String> count_string) {
- HandleScope scope(isolate);
- Factory* factory = isolate->factory();
- Handle<JSObject> range_obj = factory->NewJSObjectWithNullProto();
- JSObject::AddProperty(range_obj, start_string,
- factory->NewNumberFromInt(range->start), NONE);
- JSObject::AddProperty(range_obj, end_string,
- factory->NewNumberFromInt(range->end), NONE);
- JSObject::AddProperty(range_obj, count_string,
- factory->NewNumberFromUint(range->count), NONE);
- JSObject::AddProperty(range_obj, factory->name_string(), range->name, NONE);
- if (!range->inner.empty()) {
- int size = static_cast<int>(range->inner.size());
- Handle<FixedArray> inner_array = factory->NewFixedArray(size);
- for (int i = 0; i < size; i++) {
- Handle<JSObject> element =
- CreateRangeObject(isolate, &range->inner[i], inner_string,
- start_string, end_string, count_string);
- inner_array->set(i, *element);
- }
- Handle<JSArray> inner =
- factory->NewJSArrayWithElements(inner_array, FAST_ELEMENTS);
- JSObject::AddProperty(range_obj, inner_string, inner, NONE);
- }
- return scope.CloseAndEscape(range_obj);
-}
-} // anonymous namespace
-
RUNTIME_FUNCTION(Runtime_DebugCollectCoverage) {
HandleScope scope(isolate);
+ DCHECK_EQ(0, args.length());
// Collect coverage data.
- std::unique_ptr<Coverage> coverage(Coverage::Collect(isolate));
+ std::unique_ptr<Coverage> coverage(Coverage::Collect(isolate, false));
Factory* factory = isolate->factory();
// Turn the returned data structure into JavaScript.
// Create an array of scripts.
@@ -1945,22 +1912,31 @@ RUNTIME_FUNCTION(Runtime_DebugCollectCoverage) {
// Prepare property keys.
Handle<FixedArray> scripts_array = factory->NewFixedArray(num_scripts);
Handle<String> script_string = factory->NewStringFromStaticChars("script");
- Handle<String> toplevel_string =
- factory->NewStringFromStaticChars("toplevel");
- Handle<String> inner_string = factory->NewStringFromStaticChars("inner");
Handle<String> start_string = factory->NewStringFromStaticChars("start");
Handle<String> end_string = factory->NewStringFromStaticChars("end");
Handle<String> count_string = factory->NewStringFromStaticChars("count");
for (int i = 0; i < num_scripts; i++) {
- const auto& data = coverage->at(i);
+ const auto& script_data = coverage->at(i);
HandleScope inner_scope(isolate);
- Handle<JSObject> script_obj = factory->NewJSObjectWithNullProto();
- Handle<JSObject> wrapper = Script::GetWrapper(data.script);
+ int num_functions = static_cast<int>(script_data.functions.size());
+ Handle<FixedArray> functions_array = factory->NewFixedArray(num_functions);
+ for (int j = 0; j < num_functions; j++) {
+ const auto& function_data = script_data.functions[j];
+ Handle<JSObject> range_obj = factory->NewJSObjectWithNullProto();
+ JSObject::AddProperty(range_obj, start_string,
+ factory->NewNumberFromInt(function_data.start),
+ NONE);
+ JSObject::AddProperty(range_obj, end_string,
+ factory->NewNumberFromInt(function_data.end), NONE);
+ JSObject::AddProperty(range_obj, count_string,
+ factory->NewNumberFromUint(function_data.count),
+ NONE);
+ functions_array->set(j, *range_obj);
+ }
+ Handle<JSArray> script_obj =
+ factory->NewJSArrayWithElements(functions_array, FAST_ELEMENTS);
+ Handle<JSObject> wrapper = Script::GetWrapper(script_data.script);
JSObject::AddProperty(script_obj, script_string, wrapper, NONE);
- Handle<JSObject> toplevel =
- CreateRangeObject(isolate, &data.toplevel, inner_string, start_string,
- end_string, count_string);
- JSObject::AddProperty(script_obj, toplevel_string, toplevel, NONE);
scripts_array->set(i, *script_obj);
}
return *factory->NewJSArrayWithElements(scripts_array, FAST_ELEMENTS);
« no previous file with comments | « src/inspector/v8-runtime-agent-impl.cc ('k') | test/cctest/test-debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698