Commit 76277759 authored by hablich's avatar hablich Committed by Commit bot

Provide a counter for thrown JavaScript errors per context

This will be used as a data source for an
UMA histogram.

LOG=N
BUG=chromium:546603
R=jochen@chromium.org,yangguo@chromium.org

Review URL: https://codereview.chromium.org/1413503007

Cr-Commit-Position: refs/heads/master@{#31851}
parent 2c74ec3f
......@@ -370,6 +370,9 @@ static void SetObjectPrototype(Handle<JSObject> object, Handle<Object> proto) {
void Bootstrapper::DetachGlobal(Handle<Context> env) {
env->GetIsolate()->counters()->errors_thrown_per_context()->AddSample(
env->GetErrorsThrown());
Factory* factory = env->GetIsolate()->factory();
Handle<JSGlobalProxy> global_proxy(JSGlobalProxy::cast(env->global_proxy()));
global_proxy->set_native_context(*factory->null_value());
......@@ -3171,6 +3174,9 @@ Genesis::Genesis(Isolate* isolate,
if (!ConfigureGlobalObjects(global_proxy_template)) return;
}
isolate->counters()->contexts_created_from_scratch()->Increment();
// Re-initialize the counter because it got incremented during snapshot
// creation.
isolate->native_context()->set_errors_thrown(Smi::FromInt(0));
}
// Install experimental natives. Do not include them into the
......
......@@ -577,5 +577,16 @@ bool Context::IsBootstrappingOrGlobalObject(Isolate* isolate, Object* object) {
}
#endif
void Context::IncrementErrorsThrown() {
DCHECK(IsNativeContext());
int previous_value = errors_thrown()->value();
set_errors_thrown(Smi::FromInt(previous_value + 1));
}
int Context::GetErrorsThrown() { return errors_thrown()->value(); }
} // namespace internal
} // namespace v8
......@@ -186,6 +186,7 @@ enum BindingFlags {
V(DATA_VIEW_FUN_INDEX, JSFunction, data_view_fun) \
V(ERROR_MESSAGE_FOR_CODE_GEN_FROM_STRINGS_INDEX, Object, \
error_message_for_code_gen_from_strings) \
V(ERRORS_THROWN_INDEX, Smi, errors_thrown) \
V(EXTRAS_EXPORTS_OBJECT_INDEX, JSObject, extras_binding_object) \
V(EXTRAS_UTILS_OBJECT_INDEX, JSObject, extras_utils_object) \
V(FAST_ALIASED_ARGUMENTS_MAP_INDEX, Map, fast_aliased_arguments_map) \
......@@ -396,6 +397,9 @@ class Context: public FixedArray {
THROWN_OBJECT_INDEX = MIN_CONTEXT_SLOTS,
};
void IncrementErrorsThrown();
int GetErrorsThrown();
// Direct slot access.
inline JSFunction* closure();
inline void set_closure(JSFunction* closure);
......
......@@ -483,7 +483,8 @@ double AggregatedMemoryHistogram<Histogram>::Aggregate(double current_ms,
HR(gc_idle_time_limit_overshot, V8.GCIdleTimeLimit.Overshot, 0, 10000, 101) \
HR(gc_idle_time_limit_undershot, V8.GCIdleTimeLimit.Undershot, 0, 10000, \
101) \
HR(code_cache_reject_reason, V8.CodeCacheRejectReason, 1, 6, 6)
HR(code_cache_reject_reason, V8.CodeCacheRejectReason, 1, 6, 6) \
HR(errors_thrown_per_context, V8.ErrorsThrownPerContext, 0, 200, 20)
#define HISTOGRAM_TIMER_LIST(HT) \
/* Garbage collection timers. */ \
......
......@@ -727,6 +727,7 @@ Handle<Context> Factory::NewNativeContext() {
array->set_map_no_write_barrier(*native_context_map());
Handle<Context> context = Handle<Context>::cast(array);
context->set_js_array_maps(*undefined_value());
context->set_errors_thrown(Smi::FromInt(0));
DCHECK(context->IsNativeContext());
return context;
}
......
......@@ -307,6 +307,7 @@ RUNTIME_FUNCTION(Runtime_FormatMessageString) {
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, result,
MessageTemplate::FormatMessage(template_index, arg0, arg1, arg2));
isolate->native_context()->IncrementErrorsThrown();
return *result;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment