Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c8175fc

Browse filesBrowse files
bnoordhuisrvagg
authored andcommitted
src: internalize per-isolate string properties
Speeds up property lookups a little and it creates the string in the old space straight away. It's a little easier on the garbage collector because it doesn't have to track eternalized strings in the new space. PR-URL: #3060 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trevor Norris <trev.norris@gmail.com>
1 parent ac2bce0 commit c8175fc
Copy full SHA for c8175fc

File tree

Expand file treeCollapse file tree

2 files changed

+16
-2
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+16
-2
lines changed
Open diff view settings
Collapse file

‎src/env-inl.h‎

Copy file name to clipboardExpand all lines: src/env-inl.h
+15-1Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,26 @@ inline void Environment::IsolateData::Put() {
3636
}
3737
}
3838

39+
// Create string properties as internalized one byte strings.
40+
//
41+
// Internalized because it makes property lookups a little faster and because
42+
// the string is created in the old space straight away. It's going to end up
43+
// in the old space sooner or later anyway but now it doesn't go through
44+
// 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. It's a one-time cost, but why pay it when you don't have to?
3948
inline Environment::IsolateData::IsolateData(v8::Isolate* isolate,
4049
uv_loop_t* loop)
4150
: event_loop_(loop),
4251
isolate_(isolate),
4352
#define V(PropertyName, StringValue) \
44-
PropertyName ## _(isolate, FIXED_ONE_BYTE_STRING(isolate, StringValue)),
53+
PropertyName ## _(isolate, \
54+
v8::String::NewFromOneByte( \
55+
isolate, \
56+
reinterpret_cast<const uint8_t*>(StringValue), \
57+
v8::NewStringType::kInternalized, \
58+
sizeof(StringValue) - 1).ToLocalChecked()),
4559
PER_ISOLATE_STRING_PROPERTIES(V)
4660
#undef V
4761
ref_count_(0) {}
Collapse file

‎src/env.h‎

Copy file name to clipboardExpand all lines: src/env.h
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ namespace node {
3939
#endif
4040

4141
// Strings are per-isolate primitives but Environment proxies them
42-
// for the sake of convenience.
42+
// for the sake of convenience. Strings should be ASCII-only.
4343
#define PER_ISOLATE_STRING_PROPERTIES(V) \
4444
V(address_string, "address") \
4545
V(args_string, "args") \

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.