Commit daf59562 authored by Jakob Gruber's avatar Jakob Gruber Committed by Commit Bot

Revert "[protectors] Add use counters to track invalidations"

This reverts commit 52412058.

Reason for revert: Use counters are not the right approach, we
need histograms instead.

Original change's description:
> [protectors] Add use counters to track invalidations
> 
> ... to make real world protector invalidations measurable.
> 
> Chromium CL: https://crrev.com/c/2149324
> 
> Drive-by: Add missing newline in protector tracing.
> Drive-by: Consistent naming for the regexp species protector.
> 
> Bug: v8:9496
> Change-Id: I3c7238aa8024e03ea9e89daf83345b8ec4f0d768
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2149428
> Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
> Commit-Queue: Jakob Gruber <jgruber@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#67149}

TBR=ulan@chromium.org,jgruber@chromium.org

Change-Id: Ia36b598844fbad2166772298c2e2ec8f6b4f92b1
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: v8:9496
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2151358Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Commit-Queue: Jakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#67170}
parent fa3e37e5
...@@ -8463,22 +8463,6 @@ class V8_EXPORT Isolate { ...@@ -8463,22 +8463,6 @@ class V8_EXPORT Isolate {
kDateTimeFormatDateTimeStyle = 87, kDateTimeFormatDateTimeStyle = 87,
kBreakIteratorTypeWord = 88, kBreakIteratorTypeWord = 88,
kBreakIteratorTypeLine = 89, kBreakIteratorTypeLine = 89,
kInvalidatedArrayBufferDetachingProtector = 90,
kInvalidatedArrayConstructorProtector = 91,
kInvalidatedArrayIteratorLookupChainProtector = 92,
kInvalidatedArraySpeciesLookupChainProtector = 93,
kInvalidatedIsConcatSpreadableLookupChainProtector = 94,
kInvalidatedMapIteratorLookupChainProtector = 95,
kInvalidatedNoElementsProtector = 96,
kInvalidatedPromiseHookProtector = 97,
kInvalidatedPromiseResolveLookupChainProtector = 98,
kInvalidatedPromiseSpeciesLookupChainProtector = 99,
kInvalidatedPromiseThenLookupChainProtector = 100,
kInvalidatedRegExpSpeciesLookupChainProtector = 101,
kInvalidatedSetIteratorLookupChainProtector = 102,
kInvalidatedStringIteratorLookupChainProtector = 103,
kInvalidatedStringLengthOverflowLookupChainProtector = 104,
kInvalidatedTypedArraySpeciesLookupChainProtector = 105,
// If you add new values here, you'll also need to update Chromium's: // If you add new values here, you'll also need to update Chromium's:
// web_feature.mojom, use_counter_callback.cc, and enums.xml. V8 changes to // web_feature.mojom, use_counter_callback.cc, and enums.xml. V8 changes to
......
...@@ -17,7 +17,6 @@ namespace v8 { ...@@ -17,7 +17,6 @@ namespace v8 {
namespace internal { namespace internal {
namespace { namespace {
void TraceProtectorInvalidation(const char* protector_name) { void TraceProtectorInvalidation(const char* protector_name) {
DCHECK(FLAG_trace_protector_invalidation); DCHECK(FLAG_trace_protector_invalidation);
static constexpr char kInvalidateProtectorTracingCategory[] = static constexpr char kInvalidateProtectorTracingCategory[] =
...@@ -27,23 +26,11 @@ void TraceProtectorInvalidation(const char* protector_name) { ...@@ -27,23 +26,11 @@ void TraceProtectorInvalidation(const char* protector_name) {
DCHECK(FLAG_trace_protector_invalidation); DCHECK(FLAG_trace_protector_invalidation);
// TODO(jgruber): Remove the PrintF once tracing can output to stdout. // TODO(jgruber): Remove the PrintF once tracing can output to stdout.
i::PrintF("Invalidating protector cell %s\n", protector_name); i::PrintF("Invalidating protector cell %s", protector_name);
TRACE_EVENT_INSTANT1("v8", kInvalidateProtectorTracingCategory, TRACE_EVENT_INSTANT1("v8", kInvalidateProtectorTracingCategory,
TRACE_EVENT_SCOPE_THREAD, kInvalidateProtectorTracingArg, TRACE_EVENT_SCOPE_THREAD, kInvalidateProtectorTracingArg,
protector_name); protector_name);
} }
// Static asserts to ensure we have a use counter for every protector. If this
// fails, add the use counter in V8 and chromium. Note: IsDefined is not
// strictly needed but clarifies the intent of the static assert.
constexpr bool IsDefined(v8::Isolate::UseCounterFeature) { return true; }
#define V(Name, ...) \
STATIC_ASSERT(IsDefined(v8::Isolate::kInvalidated##Name##Protector));
DECLARED_PROTECTORS_ON_ISOLATE(V)
DECLARED_PROTECTORS_ON_NATIVE_CONTEXT(V)
#undef V
} // namespace } // namespace
#define INVALIDATE_PROTECTOR_ON_NATIVE_CONTEXT_DEFINITION(name, cell) \ #define INVALIDATE_PROTECTOR_ON_NATIVE_CONTEXT_DEFINITION(name, cell) \
...@@ -71,7 +58,6 @@ DECLARED_PROTECTORS_ON_NATIVE_CONTEXT( ...@@ -71,7 +58,6 @@ DECLARED_PROTECTORS_ON_NATIVE_CONTEXT(
if (FLAG_trace_protector_invalidation) { \ if (FLAG_trace_protector_invalidation) { \
TraceProtectorInvalidation(#name); \ TraceProtectorInvalidation(#name); \
} \ } \
isolate->CountUsage(v8::Isolate::kInvalidated##name##Protector); \
PropertyCell::SetValueWithInvalidation( \ PropertyCell::SetValueWithInvalidation( \
isolate, #cell, isolate->factory()->cell(), \ isolate, #cell, isolate->factory()->cell(), \
handle(Smi::FromInt(kProtectorInvalid), isolate)); \ handle(Smi::FromInt(kProtectorInvalid), isolate)); \
......
...@@ -16,7 +16,7 @@ class Protectors : public AllStatic { ...@@ -16,7 +16,7 @@ class Protectors : public AllStatic {
static const int kProtectorInvalid = 0; static const int kProtectorInvalid = 0;
#define DECLARED_PROTECTORS_ON_NATIVE_CONTEXT(V) \ #define DECLARED_PROTECTORS_ON_NATIVE_CONTEXT(V) \
V(RegExpSpeciesLookupChain, regexp_species_protector) V(RegExpSpeciesLookupChainProtector, regexp_species_protector)
#define DECLARED_PROTECTORS_ON_ISOLATE(V) \ #define DECLARED_PROTECTORS_ON_ISOLATE(V) \
V(ArrayBufferDetaching, ArrayBufferDetachingProtector, \ V(ArrayBufferDetaching, ArrayBufferDetachingProtector, \
......
...@@ -205,7 +205,8 @@ void LookupIterator::InternalUpdateProtector(Isolate* isolate, ...@@ -205,7 +205,8 @@ void LookupIterator::InternalUpdateProtector(Isolate* isolate,
if (!Protectors::IsArraySpeciesLookupChainIntact(isolate) && if (!Protectors::IsArraySpeciesLookupChainIntact(isolate) &&
!Protectors::IsPromiseSpeciesLookupChainIntact(isolate) && !Protectors::IsPromiseSpeciesLookupChainIntact(isolate) &&
!Protectors::IsRegExpSpeciesLookupChainIntact(native_context) && !Protectors::IsRegExpSpeciesLookupChainProtectorIntact(
native_context) &&
!Protectors::IsTypedArraySpeciesLookupChainIntact(isolate)) { !Protectors::IsTypedArraySpeciesLookupChainIntact(isolate)) {
return; return;
} }
...@@ -221,10 +222,12 @@ void LookupIterator::InternalUpdateProtector(Isolate* isolate, ...@@ -221,10 +222,12 @@ void LookupIterator::InternalUpdateProtector(Isolate* isolate,
Protectors::InvalidatePromiseSpeciesLookupChain(isolate); Protectors::InvalidatePromiseSpeciesLookupChain(isolate);
return; return;
} else if (receiver->IsJSRegExp(isolate)) { } else if (receiver->IsJSRegExp(isolate)) {
if (!Protectors::IsRegExpSpeciesLookupChainIntact(native_context)) { if (!Protectors::IsRegExpSpeciesLookupChainProtectorIntact(
native_context)) {
return; return;
} }
Protectors::InvalidateRegExpSpeciesLookupChain(isolate, native_context); Protectors::InvalidateRegExpSpeciesLookupChainProtector(isolate,
native_context);
return; return;
} else if (receiver->IsJSTypedArray(isolate)) { } else if (receiver->IsJSTypedArray(isolate)) {
if (!Protectors::IsTypedArraySpeciesLookupChainIntact(isolate)) return; if (!Protectors::IsTypedArraySpeciesLookupChainIntact(isolate)) return;
...@@ -250,10 +253,12 @@ void LookupIterator::InternalUpdateProtector(Isolate* isolate, ...@@ -250,10 +253,12 @@ void LookupIterator::InternalUpdateProtector(Isolate* isolate,
Protectors::InvalidatePromiseSpeciesLookupChain(isolate); Protectors::InvalidatePromiseSpeciesLookupChain(isolate);
} else if (isolate->IsInAnyContext(*receiver, } else if (isolate->IsInAnyContext(*receiver,
Context::REGEXP_PROTOTYPE_INDEX)) { Context::REGEXP_PROTOTYPE_INDEX)) {
if (!Protectors::IsRegExpSpeciesLookupChainIntact(native_context)) { if (!Protectors::IsRegExpSpeciesLookupChainProtectorIntact(
native_context)) {
return; return;
} }
Protectors::InvalidateRegExpSpeciesLookupChain(isolate, native_context); Protectors::InvalidateRegExpSpeciesLookupChainProtector(isolate,
native_context);
} else if (isolate->IsInAnyContext( } else if (isolate->IsInAnyContext(
receiver->map(isolate).prototype(isolate), receiver->map(isolate).prototype(isolate),
Context::TYPED_ARRAY_PROTOTYPE_INDEX)) { Context::TYPED_ARRAY_PROTOTYPE_INDEX)) {
...@@ -296,7 +301,8 @@ void LookupIterator::InternalUpdateProtector(Isolate* isolate, ...@@ -296,7 +301,8 @@ void LookupIterator::InternalUpdateProtector(Isolate* isolate,
if (!Protectors::IsArraySpeciesLookupChainIntact(isolate) && if (!Protectors::IsArraySpeciesLookupChainIntact(isolate) &&
!Protectors::IsPromiseSpeciesLookupChainIntact(isolate) && !Protectors::IsPromiseSpeciesLookupChainIntact(isolate) &&
!Protectors::IsRegExpSpeciesLookupChainIntact(native_context) && !Protectors::IsRegExpSpeciesLookupChainProtectorIntact(
native_context) &&
!Protectors::IsTypedArraySpeciesLookupChainIntact(isolate)) { !Protectors::IsTypedArraySpeciesLookupChainIntact(isolate)) {
return; return;
} }
...@@ -313,10 +319,12 @@ void LookupIterator::InternalUpdateProtector(Isolate* isolate, ...@@ -313,10 +319,12 @@ void LookupIterator::InternalUpdateProtector(Isolate* isolate,
Protectors::InvalidatePromiseSpeciesLookupChain(isolate); Protectors::InvalidatePromiseSpeciesLookupChain(isolate);
} else if (isolate->IsInAnyContext(*receiver, } else if (isolate->IsInAnyContext(*receiver,
Context::REGEXP_FUNCTION_INDEX)) { Context::REGEXP_FUNCTION_INDEX)) {
if (!Protectors::IsRegExpSpeciesLookupChainIntact(native_context)) { if (!Protectors::IsRegExpSpeciesLookupChainProtectorIntact(
native_context)) {
return; return;
} }
Protectors::InvalidateRegExpSpeciesLookupChain(isolate, native_context); Protectors::InvalidateRegExpSpeciesLookupChainProtector(isolate,
native_context);
} else if (IsTypedArrayFunctionInAnyContext(isolate, *receiver)) { } else if (IsTypedArrayFunctionInAnyContext(isolate, *receiver)) {
if (!Protectors::IsTypedArraySpeciesLookupChainIntact(isolate)) return; if (!Protectors::IsTypedArraySpeciesLookupChainIntact(isolate)) return;
Protectors::InvalidateTypedArraySpeciesLookupChain(isolate); Protectors::InvalidateTypedArraySpeciesLookupChain(isolate);
......
...@@ -185,7 +185,7 @@ bool RegExpUtils::IsUnmodifiedRegExp(Isolate* isolate, Handle<Object> obj) { ...@@ -185,7 +185,7 @@ bool RegExpUtils::IsUnmodifiedRegExp(Isolate* isolate, Handle<Object> obj) {
// property. Similar spots in CSA would use BranchIfFastRegExp_Strict in this // property. Similar spots in CSA would use BranchIfFastRegExp_Strict in this
// case. // case.
if (!Protectors::IsRegExpSpeciesLookupChainIntact( if (!Protectors::IsRegExpSpeciesLookupChainProtectorIntact(
recv.GetCreationContext())) { recv.GetCreationContext())) {
return false; return false;
} }
......
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