v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
protectors.cc
Go to the documentation of this file.
1// Copyright 2019 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
6
12#include "src/objects/smi.h"
14#include "src/utils/utils.h"
15
16namespace v8 {
17namespace internal {
18
19namespace {
20
21void TraceProtectorInvalidation(const char* protector_name) {
22 DCHECK(v8_flags.trace_protector_invalidation);
23 static constexpr char kInvalidateProtectorTracingCategory[] =
24 "V8.InvalidateProtector";
25 static constexpr char kInvalidateProtectorTracingArg[] = "protector-name";
26
27 DCHECK(v8_flags.trace_protector_invalidation);
28
29 // TODO(jgruber): Remove the PrintF once tracing can output to stdout.
30 i::PrintF("Invalidating protector cell %s\n", protector_name);
31 TRACE_EVENT_INSTANT1("v8", kInvalidateProtectorTracingCategory,
32 TRACE_EVENT_SCOPE_THREAD, kInvalidateProtectorTracingArg,
33 protector_name);
34}
35
36// Static asserts to ensure we have a use counter for every protector. If this
37// fails, add the use counter in V8 and chromium. Note: IsDefined is not
38// strictly needed but clarifies the intent of the static assert.
39constexpr bool IsDefined(v8::Isolate::UseCounterFeature) { return true; }
40#define V(Name, ...) \
41 static_assert(IsDefined(v8::Isolate::kInvalidated##Name##Protector));
42
44#undef V
45
46} // namespace
47
48#define INVALIDATE_PROTECTOR_ON_ISOLATE_DEFINITION(name, unused_index, cell) \
49 void Protectors::Invalidate##name(Isolate* isolate) { \
50 DCHECK(IsSmi(isolate->factory()->cell()->value())); \
51 DCHECK(Is##name##Intact(isolate)); \
52 if (v8_flags.trace_protector_invalidation) { \
53 TraceProtectorInvalidation(#name); \
54 } \
55 isolate->CountUsage(v8::Isolate::kInvalidated##name##Protector); \
56 isolate->factory()->cell()->InvalidateProtector(); \
57 DCHECK(!Is##name##Intact(isolate)); \
58 }
60#undef INVALIDATE_PROTECTOR_ON_ISOLATE_DEFINITION
61
62} // namespace internal
63} // namespace v8
void PrintF(const char *format,...)
Definition utils.cc:39
V8_EXPORT_PRIVATE FlagValues v8_flags
#define INVALIDATE_PROTECTOR_ON_ISOLATE_DEFINITION(name, unused_index, cell)
Definition protectors.cc:48
#define DECLARED_PROTECTORS_ON_ISOLATE(V)
Definition protectors.h:18
#define DCHECK(condition)
Definition logging.h:482
#define TRACE_EVENT_INSTANT1(category_group, name, scope, arg1_name, arg1_val)
#define TRACE_EVENT_SCOPE_THREAD