summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorUlan Degenbaev <ulan@chromium.org>2018-04-20 19:33:32 +0200
committerRuben Bridgewater <ruben@bridgewater.de>2018-04-26 19:49:49 +0200
commit8c12e01bf869fc1a796abd0917c4f4df7188b859 (patch)
tree7b8971dce96ebe634c1de25eee67049cda527fb0 /src
parent78d95b4032fbdc633b1e2a8ae4a4cbcc813c4a09 (diff)
downloadandroid-node-v8-8c12e01bf869fc1a796abd0917c4f4df7188b859.tar.gz
android-node-v8-8c12e01bf869fc1a796abd0917c4f4df7188b859.tar.bz2
android-node-v8-8c12e01bf869fc1a796abd0917c4f4df7188b859.zip
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: https://github.com/nodejs/node/pull/20175 Fixes: https://github.com/nodejs/node/issues/20171 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Yang Guo <yangguo@chromium.org> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/env.cc66
1 files changed, 34 insertions, 32 deletions
diff --git a/src/env.cc b/src/env.cc
index 1f47ea21af..08d719a510 100644
--- a/src/env.cc
+++ b/src/env.cc
@@ -28,44 +28,46 @@ IsolateData::IsolateData(Isolate* isolate,
uv_loop_t* event_loop,
MultiIsolatePlatform* platform,
uint32_t* zero_fill_field) :
-
-// Create string and private symbol properties as internalized one byte strings.
-//
-// Internalized because it makes property lookups a little faster and because
-// the string is created in the old space straight away. It's going to end up
-// in the old space sooner or later anyway but now it doesn't go through
-// v8::Eternal's new space handling first.
-//
-// One byte because our strings are ASCII and we can safely skip V8's UTF-8
-// decoding step. It's a one-time cost, but why pay it when you don't have to?
-#define V(PropertyName, StringValue) \
- PropertyName ## _( \
- isolate, \
- Private::New( \
- isolate, \
- String::NewFromOneByte( \
- isolate, \
- reinterpret_cast<const uint8_t*>(StringValue), \
- v8::NewStringType::kInternalized, \
- sizeof(StringValue) - 1).ToLocalChecked())),
- PER_ISOLATE_PRIVATE_SYMBOL_PROPERTIES(V)
-#undef V
-#define V(PropertyName, StringValue) \
- PropertyName ## _( \
- isolate, \
- String::NewFromOneByte( \
- isolate, \
- reinterpret_cast<const uint8_t*>(StringValue), \
- v8::NewStringType::kInternalized, \
- sizeof(StringValue) - 1).ToLocalChecked()),
- PER_ISOLATE_STRING_PROPERTIES(V)
-#undef V
isolate_(isolate),
event_loop_(event_loop),
zero_fill_field_(zero_fill_field),
platform_(platform) {
if (platform_ != nullptr)
platform_->RegisterIsolate(this, event_loop);
+
+ // Create string and private symbol properties as internalized one byte
+ // strings after the platform is properly initialized.
+ //
+ // Internalized because it makes property lookups a little faster and
+ // because the string is created in the old space straight away. It's going
+ // to end up in the old space sooner or later anyway but now it doesn't go
+ // through v8::Eternal's new space handling first.
+ //
+ // One byte because our strings are ASCII and we can safely skip V8's UTF-8
+ // decoding step.
+
+#define V(PropertyName, StringValue) \
+ PropertyName ## _.Set( \
+ isolate, \
+ Private::New( \
+ isolate, \
+ String::NewFromOneByte( \
+ isolate, \
+ reinterpret_cast<const uint8_t*>(StringValue), \
+ v8::NewStringType::kInternalized, \
+ sizeof(StringValue) - 1).ToLocalChecked()));
+ PER_ISOLATE_PRIVATE_SYMBOL_PROPERTIES(V)
+#undef V
+#define V(PropertyName, StringValue) \
+ PropertyName ## _.Set( \
+ isolate, \
+ String::NewFromOneByte( \
+ isolate, \
+ reinterpret_cast<const uint8_t*>(StringValue), \
+ v8::NewStringType::kInternalized, \
+ sizeof(StringValue) - 1).ToLocalChecked());
+ PER_ISOLATE_STRING_PROPERTIES(V)
+#undef V
}
IsolateData::~IsolateData() {