Commit 210beb90 authored by Dylan Cutler's avatar Dylan Cutler Committed by Commit Bot

Add V8 bindings support for instrumenting methods for the identifiability study.

Bug: 973801
Change-Id: Ie2de8e36520d28ea0063ab6c54695786eb1de5c1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2353028
Commit-Queue: Dylan Cutler <dylancutler@google.com>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Reviewed-by: default avatarYuki Shiino <yukishiino@chromium.org>
Reviewed-by: default avatarAsanka Herath <asanka@chromium.org>
Cr-Commit-Position: refs/heads/master@{#799848}
parent de0e0945
......@@ -990,7 +990,7 @@ This attribute must be accompanied by either `[Measure]` or `[MeasureAs]`.
[HighEntropy, Measure] const INTERESTING_CONSTANT = 1;
```
Attributes labeled with `[HighEntropy=Direct]` are simple surfaces which can be expressed as a sequence of bytes without any need for additional parsing logic.
Attributes and methods labeled with `[HighEntropy=Direct]` are simple surfaces which can be expressed as a sequence of bytes without any need for additional parsing logic.
For now, this label is only supported for attribute getters, although the `[HighEntropy]` label is supported more broadly.
```webidl
......
......@@ -126,7 +126,8 @@ def use_local_result(method):
or 'NewObject' in extended_attributes
or 'RaisesException' in extended_attributes
or idl_type.is_union_type or idl_type.is_dictionary
or idl_type.is_explicit_nullable)
or idl_type.is_explicit_nullable
or v8_utilities.high_entropy(method) == 'Direct')
def runtime_call_stats_context(interface, method):
......
......@@ -244,7 +244,7 @@ if (!{{argument.local_cpp_variable}}.IsUndefinedOrNull() && !{{argument.local_cp
{######################################}
{% macro cpp_method_call(method, v8_set_return_value, cpp_value) %}
{# Local variables #}
{% if method.is_call_with_execution_context %}
{% if method.is_call_with_execution_context or method.high_entropy == 'Direct' %}
{# [ConstructorCallWith=ExecutionContext] or [CallWith=ExecutionContext] #}
{% if method.is_constructor %}
ExecutionContext* execution_context = ToExecutionContext(
......@@ -270,6 +270,9 @@ Document& document = *ToLocalDOMWindow(
{{method.cpp_type}} impl = {{cpp_value}};
{% elif method.use_local_result %}
{{method.cpp_type}} result = {{cpp_value}};
{% if method.high_entropy == 'Direct' %}
Dactyloscoper::RecordDirectSurface(execution_context, WebFeature::k{{method.measure_as('Method')}}, result);
{% endif %}
{% endif %}
{# Post-call #}
{% if method.is_raises_exception %}
......
......@@ -472,11 +472,14 @@ interface TestObject {
[HighEntropy,MeasureAs=TestAttributeHighEntropy] attribute DOMString highEntropyAttributeWithMeasureAs;
[HighEntropy,MeasureAs=TestAttributeHighEntropy] readonly attribute DOMString highEntropyReadonlyAttributeWithMeasureAs;
// [HighEntropy=Direct]
// [HighEntropy=Direct] attributes
[HighEntropy=Direct,MeasureAs=TestAttributeHighEntropyUnsignedLong] readonly attribute unsigned long highEntropyDirectUnsignedLong;
[HighEntropy=Direct,MeasureAs=TestAttributeHighEntropyDOMString] readonly attribute DOMString highEntropyDirectDomString;
[HighEntropy=Direct,MeasureAs=TestAttributeHighEntropyArrayDOMString] readonly attribute FrozenArray<DOMString> highEntropyDirectArrayDomString;
// [HighEntropy=Direct] methods
[HighEntropy=Direct,MeasureAs=TestMethodHighEntropyDirectNoArgsRetBoolean] boolean highEntropyDirectBoolean();
// with [CEReactions] for not overloaded method
[CEReactions] void ceReactionsNotOverloadedMethod(boolean arg);
// with and without [CEReactions] for overloaded method
......
......@@ -7966,6 +7966,15 @@ static void HighEntropyMethodWithMeasureAsMethod(const v8::FunctionCallbackInfo<
impl->highEntropyMethodWithMeasureAs();
}
static void HighEntropyDirectBooleanMethod(const v8::FunctionCallbackInfo<v8::Value>& info) {
TestObject* impl = V8TestObject::ToImpl(info.Holder());
ExecutionContext* execution_context = ExecutionContext::ForRelevantRealm(info);
bool result = impl->highEntropyDirectBoolean();
Dactyloscoper::RecordDirectSurface(execution_context, WebFeature::kTestMethodHighEntropyDirectNoArgsRetBoolean, result);
V8SetReturnValueBool(info, result);
}
static void CeReactionsNotOverloadedMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info) {
ExceptionState exception_state(info.GetIsolate(), ExceptionState::kExecutionContext, "TestObject", "ceReactionsNotOverloadedMethod");
CEReactionsScope ce_reactions_scope;
......@@ -12579,6 +12588,16 @@ void V8TestObject::HighEntropyMethodWithMeasureAsMethodCallback(const v8::Functi
test_object_v8_internal::HighEntropyMethodWithMeasureAsMethod(info);
}
void V8TestObject::HighEntropyDirectBooleanMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
BLINK_BINDINGS_TRACE_EVENT("TestObject.highEntropyDirectBoolean");
RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestObject_highEntropyDirectBoolean");
ExecutionContext* execution_context_for_measurement = CurrentExecutionContext(info.GetIsolate());
UseCounter::Count(execution_context_for_measurement, WebFeature::kTestMethodHighEntropyDirectNoArgsRetBoolean);
Dactyloscoper::Record(execution_context_for_measurement, WebFeature::kTestMethodHighEntropyDirectNoArgsRetBoolean);
test_object_v8_internal::HighEntropyDirectBooleanMethod(info);
}
void V8TestObject::CeReactionsNotOverloadedMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
BLINK_BINDINGS_TRACE_EVENT("TestObject.ceReactionsNotOverloadedMethod");
RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestObject_ceReactionsNotOverloadedMethod");
......@@ -13191,6 +13210,7 @@ static constexpr V8DOMConfiguration::MethodConfiguration kV8TestObjectMethods[]
{"measureAsSameValueOverloadedMethod", V8TestObject::MeasureAsSameValueOverloadedMethodMethodCallback, 0, v8::None, V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kDoNotCheckAccess, V8DOMConfiguration::kHasSideEffect, V8DOMConfiguration::kAllWorlds},
{"highEntropyMethodWithMeasure", V8TestObject::HighEntropyMethodWithMeasureMethodCallback, 0, v8::None, V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kDoNotCheckAccess, V8DOMConfiguration::kHasSideEffect, V8DOMConfiguration::kAllWorlds},
{"highEntropyMethodWithMeasureAs", V8TestObject::HighEntropyMethodWithMeasureAsMethodCallback, 0, v8::None, V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kDoNotCheckAccess, V8DOMConfiguration::kHasSideEffect, V8DOMConfiguration::kAllWorlds},
{"highEntropyDirectBoolean", V8TestObject::HighEntropyDirectBooleanMethodCallback, 0, v8::None, V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kDoNotCheckAccess, V8DOMConfiguration::kHasSideEffect, V8DOMConfiguration::kAllWorlds},
{"ceReactionsNotOverloadedMethod", V8TestObject::CeReactionsNotOverloadedMethodMethodCallback, 1, v8::None, V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kDoNotCheckAccess, V8DOMConfiguration::kHasSideEffect, V8DOMConfiguration::kAllWorlds},
{"ceReactionsOverloadedMethod", V8TestObject::CeReactionsOverloadedMethodMethodCallback, 0, v8::None, V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kDoNotCheckAccess, V8DOMConfiguration::kHasSideEffect, V8DOMConfiguration::kAllWorlds},
{"deprecateAsMeasureAsSameValueOverloadedMethod", V8TestObject::DeprecateAsMeasureAsSameValueOverloadedMethodMethodCallback, 0, v8::None, V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kDoNotCheckAccess, V8DOMConfiguration::kHasSideEffect, V8DOMConfiguration::kAllWorlds},
......
......@@ -542,6 +542,7 @@ class V8TestObject {
CORE_EXPORT static void MeasureAsSameValueOverloadedMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>&);
CORE_EXPORT static void HighEntropyMethodWithMeasureMethodCallback(const v8::FunctionCallbackInfo<v8::Value>&);
CORE_EXPORT static void HighEntropyMethodWithMeasureAsMethodCallback(const v8::FunctionCallbackInfo<v8::Value>&);
CORE_EXPORT static void HighEntropyDirectBooleanMethodCallback(const v8::FunctionCallbackInfo<v8::Value>&);
CORE_EXPORT static void CeReactionsNotOverloadedMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>&);
CORE_EXPORT static void CeReactionsOverloadedMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>&);
CORE_EXPORT static void DeprecateAsMeasureAsSameValueOverloadedMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>&);
......
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