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: https://github.com/nodejs/node/pull/3060 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trevor Norris <trev.norris@gmail.com>
This commit is contained in:
parent
6192c9892f
commit
590ee58e1c
@ -36,12 +36,26 @@ inline void Environment::IsolateData::Put() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Create string 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?
|
||||||
inline Environment::IsolateData::IsolateData(v8::Isolate* isolate,
|
inline Environment::IsolateData::IsolateData(v8::Isolate* isolate,
|
||||||
uv_loop_t* loop)
|
uv_loop_t* loop)
|
||||||
: event_loop_(loop),
|
: event_loop_(loop),
|
||||||
isolate_(isolate),
|
isolate_(isolate),
|
||||||
#define V(PropertyName, StringValue) \
|
#define V(PropertyName, StringValue) \
|
||||||
PropertyName ## _(isolate, FIXED_ONE_BYTE_STRING(isolate, StringValue)),
|
PropertyName ## _(isolate, \
|
||||||
|
v8::String::NewFromOneByte( \
|
||||||
|
isolate, \
|
||||||
|
reinterpret_cast<const uint8_t*>(StringValue), \
|
||||||
|
v8::NewStringType::kInternalized, \
|
||||||
|
sizeof(StringValue) - 1).ToLocalChecked()),
|
||||||
PER_ISOLATE_STRING_PROPERTIES(V)
|
PER_ISOLATE_STRING_PROPERTIES(V)
|
||||||
#undef V
|
#undef V
|
||||||
ref_count_(0) {}
|
ref_count_(0) {}
|
||||||
|
@ -39,7 +39,7 @@ namespace node {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Strings are per-isolate primitives but Environment proxies them
|
// Strings are per-isolate primitives but Environment proxies them
|
||||||
// for the sake of convenience.
|
// for the sake of convenience. Strings should be ASCII-only.
|
||||||
#define PER_ISOLATE_STRING_PROPERTIES(V) \
|
#define PER_ISOLATE_STRING_PROPERTIES(V) \
|
||||||
V(address_string, "address") \
|
V(address_string, "address") \
|
||||||
V(args_string, "args") \
|
V(args_string, "args") \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user