diff --git a/src/api/api.cc b/src/api/api.cc index 07e521aeac..52f8dea72b 100644 --- a/src/api/api.cc +++ b/src/api/api.cc @@ -1127,20 +1127,41 @@ bool Data::IsFunctionTemplate() const { bool Data::IsContext() const { return Utils::OpenHandle(this)->IsContext(); } -size_t GetCPUFeatureMask() { +// Reece: +V8_EXPORT size_t GetCPUFeatureMask() { return internal::CpuFeatures::SupportedFeatures(); } -size_t GetCPUFeatureMaskRescan() { +// Reece: +V8_EXPORT size_t GetCPUFeatureMaskRescan() { internal::CpuFeatures::initialized_ = 0; internal::CpuFeatures::supported_ = 0; return internal::CpuFeatures::SupportedFeatures(); } -void SetCPUFeatureMask(size_t features) { +// Reece: +V8_EXPORT void SetCPUFeatureMask(size_t features) { internal::CpuFeatures::supported_ = features; } +// Reece: +V8_EXPORT void Safepoint(v8::Isolate* pIsolate) { + reinterpret_cast(pIsolate) + ->heap() + ->main_thread_local_heap() + ->Safepoint(); +} + +// Reece: +V8_EXPORT void SafepointParkIsolate(v8::Isolate* pIsolate) { + reinterpret_cast(pIsolate)->heap()->safepoint()->NotifyParkEx(); +} + +// Reece: +V8_EXPORT void SafepointUnparkIsolate(v8::Isolate* pIsolate) { + reinterpret_cast(pIsolate)->heap()->safepoint()->NotifyUnpark(); +} + void Context::Enter() { i::DisallowGarbageCollection no_gc; i::Context env = *Utils::OpenHandle(this); @@ -2703,6 +2724,7 @@ MaybeLocal ScriptCompiler::CompileUnboundScript( return CompileUnboundInternal(v8_isolate, source, options, no_cache_reason); } +// Reece: MaybeLocal ScriptCompiler::EvaluateGlobal( v8::Isolate* isolate, v8::Local source, bool repl) { @@ -5445,6 +5467,7 @@ MaybeLocal Function::NewInstanceWithSideEffectType( RETURN_ESCAPED(result); } +// Reece: MaybeLocal Function::Bind(v8::Local that, v8::Local bound_args) { i::Handle self; @@ -6053,6 +6076,7 @@ bool v8::String::IsExternalOneByte() const { return false; } +// Reece: v8::Local v8::String::GloballyInternalize() { i::DisallowGarbageCollection no_gc; i::Handle str = Utils::OpenHandle(this); diff --git a/src/heap/safepoint.cc b/src/heap/safepoint.cc index 9dfd95a5e5..7c901a6e6e 100644 --- a/src/heap/safepoint.cc +++ b/src/heap/safepoint.cc @@ -206,6 +206,10 @@ void IsolateSafepoint::WaitInUnpark() { barrier_.WaitInUnpark(); } void IsolateSafepoint::NotifyPark() { barrier_.NotifyPark(); } +void IsolateSafepoint::NotifyParkEx() { barrier_.NotifyParkEx(); } + +void IsolateSafepoint::NotifyUnpark() { barrier_.NotifyUnpark(); } + void IsolateSafepoint::WaitUntilRunningThreadsInSafepoint( const PerClientSafepointData* client_data) { barrier_.WaitUntilRunningThreadsInSafepoint(client_data->running()); @@ -243,6 +247,19 @@ void IsolateSafepoint::Barrier::NotifyPark() { cv_stopped_.NotifyOne(); } +void IsolateSafepoint::Barrier::NotifyParkEx() { + base::MutexGuard guard(&mutex_); + armed_ = true; + stopped_++; + cv_stopped_.NotifyOne(); +} + +void IsolateSafepoint::Barrier::NotifyUnpark() { + base::MutexGuard guard(&mutex_); + stopped_--; + cv_stopped_.NotifyOne(); +} + void IsolateSafepoint::Barrier::WaitInSafepoint() { base::MutexGuard guard(&mutex_); CHECK(IsArmed()); diff --git a/src/heap/safepoint.h b/src/heap/safepoint.h index 23bc905580..29c32a702b 100644 --- a/src/heap/safepoint.h +++ b/src/heap/safepoint.h @@ -43,6 +43,18 @@ class IsolateSafepoint final { V8_EXPORT_PRIVATE void AssertMainThreadIsOnlyThread(); + // Wait until unpark operation is safe again. + void WaitInUnpark(); + + // Enter the safepoint from a running thread. + void WaitInSafepoint(); + + // Running thread reached a safepoint by parking itself. + void NotifyPark(); + void NotifyParkEx(); + void NotifyUnpark(); + + private: class Barrier { base::Mutex mutex_; @@ -57,26 +69,20 @@ class IsolateSafepoint final { public: Barrier() : armed_(false), stopped_(0) {} - void Arm(); - void Disarm(); void WaitUntilRunningThreadsInSafepoint(size_t running); + void Arm(); + + void Disarm(); void WaitInSafepoint(); void WaitInUnpark(); + void NotifyUnpark(); + void NotifyParkEx(); void NotifyPark(); }; enum class IncludeMainThread { kYes, kNo }; - // Wait until unpark operation is safe again. - void WaitInUnpark(); - - // Enter the safepoint from a running thread. - void WaitInSafepoint(); - - // Running thread reached a safepoint by parking itself. - void NotifyPark(); - // Methods for entering/leaving local safepoint scopes. void EnterLocalSafepointScope(); void LeaveLocalSafepointScope();