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}
This commit is contained in:
hablich 2015-11-06 00:07:52 -08:00 committed by Commit bot
parent 2c74ec3fec
commit 7627775948
6 changed files with 25 additions and 1 deletions

View File

@ -370,6 +370,9 @@ static void SetObjectPrototype(Handle<JSObject> object, Handle<Object> proto) {
void Bootstrapper::DetachGlobal(Handle<Context> env) { void Bootstrapper::DetachGlobal(Handle<Context> env) {
env->GetIsolate()->counters()->errors_thrown_per_context()->AddSample(
env->GetErrorsThrown());
Factory* factory = env->GetIsolate()->factory(); Factory* factory = env->GetIsolate()->factory();
Handle<JSGlobalProxy> global_proxy(JSGlobalProxy::cast(env->global_proxy())); Handle<JSGlobalProxy> global_proxy(JSGlobalProxy::cast(env->global_proxy()));
global_proxy->set_native_context(*factory->null_value()); global_proxy->set_native_context(*factory->null_value());
@ -3171,6 +3174,9 @@ Genesis::Genesis(Isolate* isolate,
if (!ConfigureGlobalObjects(global_proxy_template)) return; if (!ConfigureGlobalObjects(global_proxy_template)) return;
} }
isolate->counters()->contexts_created_from_scratch()->Increment(); 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 // Install experimental natives. Do not include them into the

View File

@ -577,5 +577,16 @@ bool Context::IsBootstrappingOrGlobalObject(Isolate* isolate, Object* object) {
} }
#endif #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 internal
} // namespace v8 } // namespace v8

View File

@ -186,6 +186,7 @@ enum BindingFlags {
V(DATA_VIEW_FUN_INDEX, JSFunction, data_view_fun) \ V(DATA_VIEW_FUN_INDEX, JSFunction, data_view_fun) \
V(ERROR_MESSAGE_FOR_CODE_GEN_FROM_STRINGS_INDEX, Object, \ V(ERROR_MESSAGE_FOR_CODE_GEN_FROM_STRINGS_INDEX, Object, \
error_message_for_code_gen_from_strings) \ 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_EXPORTS_OBJECT_INDEX, JSObject, extras_binding_object) \
V(EXTRAS_UTILS_OBJECT_INDEX, JSObject, extras_utils_object) \ V(EXTRAS_UTILS_OBJECT_INDEX, JSObject, extras_utils_object) \
V(FAST_ALIASED_ARGUMENTS_MAP_INDEX, Map, fast_aliased_arguments_map) \ 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, THROWN_OBJECT_INDEX = MIN_CONTEXT_SLOTS,
}; };
void IncrementErrorsThrown();
int GetErrorsThrown();
// Direct slot access. // Direct slot access.
inline JSFunction* closure(); inline JSFunction* closure();
inline void set_closure(JSFunction* closure); inline void set_closure(JSFunction* closure);

View File

@ -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_overshot, V8.GCIdleTimeLimit.Overshot, 0, 10000, 101) \
HR(gc_idle_time_limit_undershot, V8.GCIdleTimeLimit.Undershot, 0, 10000, \ HR(gc_idle_time_limit_undershot, V8.GCIdleTimeLimit.Undershot, 0, 10000, \
101) \ 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) \ #define HISTOGRAM_TIMER_LIST(HT) \
/* Garbage collection timers. */ \ /* Garbage collection timers. */ \

View File

@ -727,6 +727,7 @@ Handle<Context> Factory::NewNativeContext() {
array->set_map_no_write_barrier(*native_context_map()); array->set_map_no_write_barrier(*native_context_map());
Handle<Context> context = Handle<Context>::cast(array); Handle<Context> context = Handle<Context>::cast(array);
context->set_js_array_maps(*undefined_value()); context->set_js_array_maps(*undefined_value());
context->set_errors_thrown(Smi::FromInt(0));
DCHECK(context->IsNativeContext()); DCHECK(context->IsNativeContext());
return context; return context;
} }

View File

@ -307,6 +307,7 @@ RUNTIME_FUNCTION(Runtime_FormatMessageString) {
ASSIGN_RETURN_FAILURE_ON_EXCEPTION( ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, result, isolate, result,
MessageTemplate::FormatMessage(template_index, arg0, arg1, arg2)); MessageTemplate::FormatMessage(template_index, arg0, arg1, arg2));
isolate->native_context()->IncrementErrorsThrown();
return *result; return *result;
} }