Skip to content

Commit 76d5907

Browse files
committed
make gc flags constants
1 parent c9c9431 commit 76d5907

File tree

2 files changed

+43
-28
lines changed

2 files changed

+43
-28
lines changed

doc/api/v8.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1623,6 +1623,8 @@ Stopping collecting the profile and the profile will be discarded.
16231623
added: REPLACEME
16241624
-->
16251625
1626+
> Stability: 1 - Experimental
1627+
16261628
### `syncHeapProfileHandle.stop()`
16271629
16281630
<!-- YAML

src/node_v8.cc

Lines changed: 41 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ using v8::CpuProfile;
4040
using v8::CpuProfilingResult;
4141
using v8::CpuProfilingStatus;
4242
using v8::DictionaryTemplate;
43+
using v8::DontDelete;
4344
using v8::FunctionCallbackInfo;
4445
using v8::FunctionTemplate;
4546
using v8::HandleScope;
@@ -53,10 +54,12 @@ using v8::LocalVector;
5354
using v8::MaybeLocal;
5455
using v8::Number;
5556
using v8::Object;
57+
using v8::PropertyAttribute;
5658
using v8::ScriptCompiler;
5759
using v8::String;
5860
using v8::Uint32;
5961
using v8::V8;
62+
using v8::ReadOnly;
6063
using v8::Value;
6164

6265
#define HEAP_STATISTICS_PROPERTIES(V) \
@@ -769,41 +772,51 @@ void Initialize(Local<Object> target,
769772
SetMethod(context, target, "stopCpuProfile", StopCpuProfile);
770773
SetMethod(context, target, "startHeapProfile", StartHeapProfile);
771774
SetMethod(context, target, "stopHeapProfile", StopHeapProfile);
775+
const PropertyAttribute sampling_flag_attributes =
776+
static_cast<PropertyAttribute>(ReadOnly | DontDelete);
772777
target
773-
->Set(context,
774-
FIXED_ONE_BYTE_STRING(env->isolate(), "kSamplingNoFlags"),
775-
Uint32::NewFromUnsigned(
776-
env->isolate(),
777-
static_cast<uint32_t>(
778-
v8::HeapProfiler::SamplingFlags::kSamplingNoFlags)))
778+
->DefineOwnProperty(
779+
context,
780+
FIXED_ONE_BYTE_STRING(env->isolate(), "kSamplingNoFlags"),
781+
Uint32::NewFromUnsigned(
782+
env->isolate(),
783+
static_cast<uint32_t>(
784+
v8::HeapProfiler::SamplingFlags::kSamplingNoFlags)),
785+
sampling_flag_attributes)
779786
.Check();
780787
target
781-
->Set(context,
782-
FIXED_ONE_BYTE_STRING(env->isolate(), "kSamplingForceGC"),
783-
Uint32::NewFromUnsigned(
784-
env->isolate(),
785-
static_cast<uint32_t>(
786-
v8::HeapProfiler::SamplingFlags::kSamplingForceGC)))
788+
->DefineOwnProperty(
789+
context,
790+
FIXED_ONE_BYTE_STRING(env->isolate(), "kSamplingForceGC"),
791+
Uint32::NewFromUnsigned(
792+
env->isolate(),
793+
static_cast<uint32_t>(
794+
v8::HeapProfiler::SamplingFlags::kSamplingForceGC)),
795+
sampling_flag_attributes)
787796
.Check();
788797
target
789-
->Set(context,
790-
FIXED_ONE_BYTE_STRING(env->isolate(),
791-
"kSamplingIncludeObjectsCollectedByMajorGC"),
792-
Uint32::NewFromUnsigned(
793-
env->isolate(),
794-
static_cast<uint32_t>(
795-
v8::HeapProfiler::SamplingFlags::
796-
kSamplingIncludeObjectsCollectedByMajorGC)))
798+
->DefineOwnProperty(
799+
context,
800+
FIXED_ONE_BYTE_STRING(env->isolate(),
801+
"kSamplingIncludeObjectsCollectedByMajorGC"),
802+
Uint32::NewFromUnsigned(
803+
env->isolate(),
804+
static_cast<uint32_t>(
805+
v8::HeapProfiler::SamplingFlags::
806+
kSamplingIncludeObjectsCollectedByMajorGC)),
807+
sampling_flag_attributes)
797808
.Check();
798809
target
799-
->Set(context,
800-
FIXED_ONE_BYTE_STRING(env->isolate(),
801-
"kSamplingIncludeObjectsCollectedByMinorGC"),
802-
Uint32::NewFromUnsigned(
803-
env->isolate(),
804-
static_cast<uint32_t>(
805-
v8::HeapProfiler::SamplingFlags::
806-
kSamplingIncludeObjectsCollectedByMinorGC)))
810+
->DefineOwnProperty(
811+
context,
812+
FIXED_ONE_BYTE_STRING(env->isolate(),
813+
"kSamplingIncludeObjectsCollectedByMinorGC"),
814+
Uint32::NewFromUnsigned(
815+
env->isolate(),
816+
static_cast<uint32_t>(
817+
v8::HeapProfiler::SamplingFlags::
818+
kSamplingIncludeObjectsCollectedByMinorGC)),
819+
sampling_flag_attributes)
807820
.Check();
808821

809822
// Export symbols used by v8.isStringOneByteRepresentation()

0 commit comments

Comments
 (0)