Skip to content

Commit 81de533

Browse files
ulanMylesBorins
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 b646566 commit 81de533

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

7173
IsolateData::~IsolateData() {

0 commit comments

Comments
 (0)