@ -15,28 +15,6 @@
namespace node {
inline IsolateData * IsolateData : : Get ( v8 : : Isolate * isolate ) {
return static_cast < IsolateData * > ( isolate - > GetData ( kIsolateSlot ) ) ;
}
inline IsolateData * IsolateData : : GetOrCreate ( v8 : : Isolate * isolate ,
uv_loop_t * loop ) {
IsolateData * isolate_data = Get ( isolate ) ;
if ( isolate_data = = nullptr ) {
isolate_data = new IsolateData ( isolate , loop ) ;
isolate - > SetData ( kIsolateSlot , isolate_data ) ;
}
isolate_data - > ref_count_ + = 1 ;
return isolate_data ;
}
inline void IsolateData : : Put ( ) {
if ( - - ref_count_ = = 0 ) {
isolate ( ) - > SetData ( kIsolateSlot , nullptr ) ;
delete this ;
}
}
// Create string properties as internalized one byte strings.
//
// Internalized because it makes property lookups a little faster and because
@ -46,9 +24,8 @@ inline void IsolateData::Put() {
//
// 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 IsolateData : : IsolateData ( v8 : : Isolate * isolate , uv_loop_t * loop )
: event_loop_ ( loop ) ,
isolate_ ( isolate ) ,
inline IsolateData : : IsolateData ( v8 : : Isolate * isolate , uv_loop_t * event_loop )
:
# define V(PropertyName, StringValue) \
PropertyName # # _ ( \
isolate , \
@ -71,16 +48,12 @@ inline IsolateData::IsolateData(v8::Isolate* isolate, uv_loop_t* loop)
sizeof ( StringValue ) - 1 ) . ToLocalChecked ( ) ) ,
PER_ISOLATE_STRING_PROPERTIES ( V )
# undef V
ref_count_ ( 0 ) { }
isolate_ ( isolate ) , event_loop_ ( event_loop ) { }
inline uv_loop_t * IsolateData : : event_loop ( ) const {
return event_loop_ ;
}
inline v8 : : Isolate * IsolateData : : isolate ( ) const {
return isolate_ ;
}
inline Environment : : AsyncHooks : : AsyncHooks ( ) {
for ( int i = 0 ; i < kFieldsCount ; i + + ) fields_ [ i ] = 0 ;
}
@ -176,9 +149,9 @@ inline void Environment::ArrayBufferAllocatorInfo::reset_fill_flag() {
fields_ [ kNoZeroFill ] = 0 ;
}
inline Environment * Environment : : New ( v8 : : Local < v8 : : Context > context ,
uv_loop_t * loop ) {
Environment * env = new Environment ( context , loop ) ;
inline Environment * Environment : : New ( IsolateData * isolate_data ,
v8 : : Local < v8 : : Context > context ) {
Environment * env = new Environment ( isolate_data , context ) ;
env - > AssignToContext ( context ) ;
return env ;
}
@ -212,11 +185,11 @@ inline Environment* Environment::GetCurrent(
return static_cast < Environment * > ( data . As < v8 : : External > ( ) - > Value ( ) ) ;
}
inline Environment : : Environment ( v8 : : Local < v8 : : Context > context ,
uv_loop_t * loop )
inline Environment : : Environment ( IsolateData * isolate_data ,
v8 : : Local < v8 : : Context > context )
: isolate_ ( context - > GetIsolate ( ) ) ,
isolate_data_ ( IsolateData : : GetOrCreate ( context - > GetIsolate ( ) , loop ) ) ,
timer_base_ ( uv_now ( loop ) ) ,
isolate_data_ ( isolate_data ) ,
timer_base_ ( uv_now ( isolate_data - > event_ loop( ) ) ) ,
using_domains_ ( false ) ,
printed_error_ ( false ) ,
trace_sync_io_ ( false ) ,
@ -253,7 +226,6 @@ inline Environment::~Environment() {
# define V(PropertyName, TypeName) PropertyName ## _.Reset();
ENVIRONMENT_STRONG_PERSISTENT_PROPERTIES ( V )
# undef V
isolate_data ( ) - > Put ( ) ;
delete [ ] heap_statistics_buffer_ ;
delete [ ] heap_space_statistics_buffer_ ;
@ -541,9 +513,9 @@ inline v8::Local<v8::Object> Environment::NewInternalFieldObject() {
# define VS(PropertyName, StringValue) V(v8::String, PropertyName, StringValue)
# define V(TypeName, PropertyName, StringValue) \
inline \
v8 : : Local < TypeName > IsolateData : : PropertyName ( ) const { \
v8 : : Local < TypeName > IsolateData : : PropertyName ( v8 : : Isolate * isolate ) const { \
/* Strings are immutable so casting away const-ness here is okay. */ \
return const_cast < IsolateData * > ( this ) - > PropertyName # # _ . Get ( isolate ( ) ) ; \
return const_cast < IsolateData * > ( this ) - > PropertyName # # _ . Get ( isolate ) ; \
}
PER_ISOLATE_PRIVATE_SYMBOL_PROPERTIES ( VP )
PER_ISOLATE_STRING_PROPERTIES ( VS )
@ -555,7 +527,7 @@ inline v8::Local<v8::Object> Environment::NewInternalFieldObject() {
# define VS(PropertyName, StringValue) V(v8::String, PropertyName, StringValue)
# define V(TypeName, PropertyName, StringValue) \
inline v8 : : Local < TypeName > Environment : : PropertyName ( ) const { \
return isolate_data ( ) - > PropertyName ( ) ; \
return isolate_data ( ) - > PropertyName ( isolate ( ) ) ; \
}
PER_ISOLATE_PRIVATE_SYMBOL_PROPERTIES ( VP )
PER_ISOLATE_STRING_PROPERTIES ( VS )