Skip to content

Commit e17f05a

Browse files
ulanrvagg
authored andcommitted
src: create per-isolate strings after platform setup
Allocation of strings may cause a garbage collection that uses the platform to post tasks. PR-URL: #20175 Fixes: #20171 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Tiancheng "Timothy" Gu <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Yang Guo <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Daniel Bevenius <[email protected]>
1 parent bf09b7a commit e17f05a

File tree

1 file changed

+34
-32
lines changed

1 file changed

+34
-32
lines changed

src/env.cc

+34-32
Original file line numberDiff line numberDiff line change
@@ -30,44 +30,46 @@ IsolateData::IsolateData(Isolate* isolate,
3030
uv_loop_t* event_loop,
3131
MultiIsolatePlatform* platform,
3232
uint32_t* zero_fill_field) :
33-
34-
// Create string and private symbol properties as internalized one byte strings.
35-
//
36-
// Internalized because it makes property lookups a little faster and because
37-
// the string is created in the old space straight away. It's going to end up
38-
// in the old space sooner or later anyway but now it doesn't go through
39-
// v8::Eternal's new space handling first.
40-
//
41-
// One byte because our strings are ASCII and we can safely skip V8's UTF-8
42-
// decoding step. It's a one-time cost, but why pay it when you don't have to?
43-
#define V(PropertyName, StringValue) \
44-
PropertyName ## _( \
45-
isolate, \
46-
Private::New( \
47-
isolate, \
48-
String::NewFromOneByte( \
49-
isolate, \
50-
reinterpret_cast<const uint8_t*>(StringValue), \
51-
v8::NewStringType::kInternalized, \
52-
sizeof(StringValue) - 1).ToLocalChecked())),
53-
PER_ISOLATE_PRIVATE_SYMBOL_PROPERTIES(V)
54-
#undef V
55-
#define V(PropertyName, StringValue) \
56-
PropertyName ## _( \
57-
isolate, \
58-
String::NewFromOneByte( \
59-
isolate, \
60-
reinterpret_cast<const uint8_t*>(StringValue), \
61-
v8::NewStringType::kInternalized, \
62-
sizeof(StringValue) - 1).ToLocalChecked()),
63-
PER_ISOLATE_STRING_PROPERTIES(V)
64-
#undef V
6533
isolate_(isolate),
6634
event_loop_(event_loop),
6735
zero_fill_field_(zero_fill_field),
6836
platform_(platform) {
6937
if (platform_ != nullptr)
7038
platform_->RegisterIsolate(this, event_loop);
39+
40+
// Create string and private symbol properties as internalized one byte
41+
// strings after the platform is properly initialized.
42+
//
43+
// Internalized because it makes property lookups a little faster and
44+
// because the string is created in the old space straight away. It's going
45+
// to end up in the old space sooner or later anyway but now it doesn't go
46+
// through v8::Eternal's new space handling first.
47+
//
48+
// One byte because our strings are ASCII and we can safely skip V8's UTF-8
49+
// decoding step.
50+
51+
#define V(PropertyName, StringValue) \
52+
PropertyName ## _.Set( \
53+
isolate, \
54+
Private::New( \
55+
isolate, \
56+
String::NewFromOneByte( \
57+
isolate, \
58+
reinterpret_cast<const uint8_t*>(StringValue), \
59+
v8::NewStringType::kInternalized, \
60+
sizeof(StringValue) - 1).ToLocalChecked()));
61+
PER_ISOLATE_PRIVATE_SYMBOL_PROPERTIES(V)
62+
#undef V
63+
#define V(PropertyName, StringValue) \
64+
PropertyName ## _.Set( \
65+
isolate, \
66+
String::NewFromOneByte( \
67+
isolate, \
68+
reinterpret_cast<const uint8_t*>(StringValue), \
69+
v8::NewStringType::kInternalized, \
70+
sizeof(StringValue) - 1).ToLocalChecked());
71+
PER_ISOLATE_STRING_PROPERTIES(V)
72+
#undef V
7173
}
7274

7375
IsolateData::~IsolateData() {

0 commit comments

Comments
 (0)