diff --git a/include/v8-primitive.h b/include/v8-primitive.h index 4fef8da7f8..adb575367c 100644 --- a/include/v8-primitive.h +++ b/include/v8-primitive.h @@ -223,6 +223,10 @@ class V8_EXPORT String : public Name { */ bool IsExternalOneByte() const; + v8::Local GloballyInternalize(); + + v8::Local Share(v8::Isolate *pIsolate); + class V8_EXPORT ExternalStringResourceBase { public: virtual ~ExternalStringResourceBase() = default; diff --git a/include/v8-script.h b/include/v8-script.h index dbd98ed55b..fdf9e32c95 100644 --- a/include/v8-script.h +++ b/include/v8-script.h @@ -597,6 +597,11 @@ class V8_EXPORT ScriptCompiler { CompileOptions options = kNoCompileOptions, NoCacheReason no_cache_reason = kNoCacheNoReason); + static MaybeLocal EvaluateGlobal(v8::Isolate* isolate, + v8::Local source, + bool repl); + + /** * Compiles the specified script (bound to current context). * diff --git a/include/v8-template.h b/include/v8-template.h index 669012a981..da355f80e9 100644 --- a/include/v8-template.h +++ b/include/v8-template.h @@ -165,6 +165,9 @@ class V8_EXPORT Template : public Data { using GenericNamedPropertyGetterCallback = void (*)(Local property, const PropertyCallbackInfo& info); +using GenericNamedPropertyGetterFastCallback = v8::Local (*)( + v8::Isolate* pIsolate, Local that, Local property, bool *pShouldCheckBase); + /** * Interceptor for set requests on an object. * @@ -190,6 +193,11 @@ using GenericNamedPropertySetterCallback = void (*)(Local property, Local value, const PropertyCallbackInfo& info); +using GenericNamedPropertySetterFastCallback = bool (*)(v8::Isolate *pIsolate, + Local that, + Local property, + Local &value); + /** * Intercepts all requests that query the attributes of the * property, e.g., getOwnPropertyDescriptor(), propertyIsEnumerable(), and @@ -302,6 +310,10 @@ using GenericNamedPropertyDescriptorCallback = using IndexedPropertyGetterCallback = void (*)(uint32_t index, const PropertyCallbackInfo& info); +using IndexedPropertyGetterFastCallback = + v8::Local (*)(v8::Isolate* pIsolate, + Local that, + uint32_t index); /** * See `v8::GenericNamedPropertySetterCallback`. */ @@ -309,6 +321,11 @@ using IndexedPropertySetterCallback = void (*)(uint32_t index, Local value, const PropertyCallbackInfo& info); +using IndexedPropertySetterFastCallback = bool (*)(v8::Isolate* pIsolate, + Local that, + uint32_t index, + v8::Local value); + /** * See `v8::GenericNamedPropertyQueryCallback`. */ @@ -623,6 +640,11 @@ enum class PropertyHandlerFlags { * The getter, query, enumerator callbacks do not produce side effects. */ kHasNoSideEffect = 1 << 3, + + /** + * + */ + kUseNoProxyNoExternalCallbackInfoFastPath = 1 << 4 }; struct NamedPropertyHandlerConfiguration { diff --git a/src/api/api.cc b/src/api/api.cc index e507f18f55..2388a0921c 100644 --- a/src/api/api.cc +++ b/src/api/api.cc @@ -140,6 +140,8 @@ #include "src/wasm/wasm-serialization.h" #endif // V8_ENABLE_WEBASSEMBLY +#include "src/debug/debug-evaluate.h" + #if V8_OS_LINUX || V8_OS_DARWIN || V8_OS_FREEBSD #include @@ -1725,6 +1727,8 @@ i::Handle CreateInterceptorInfo( obj->set_has_no_side_effect( static_cast(flags) & static_cast(PropertyHandlerFlags::kHasNoSideEffect)); + obj->set_use_fastpath((static_cast(flags) & + static_cast(PropertyHandlerFlags::kUseNoProxyNoExternalCallbackInfoFastPath)) != 0); if (data.IsEmpty()) { data = v8::Undefined(reinterpret_cast(i_isolate)); @@ -2555,6 +2559,22 @@ MaybeLocal ScriptCompiler::CompileUnboundScript( return CompileUnboundInternal(v8_isolate, source, options, no_cache_reason); } +MaybeLocal ScriptCompiler::EvaluateGlobal( + v8::Isolate* isolate, v8::Local source, + bool repl) { + i::Isolate* i_isolate = reinterpret_cast(isolate); + PREPARE_FOR_DEBUG_INTERFACE_EXECUTION_WITH_ISOLATE(i_isolate, Value); + i::REPLMode repl_mode = repl ? i::REPLMode::kYes : i::REPLMode::kNo; + Local result; + has_pending_exception = !ToLocal( + i::DebugEvaluate::Global(i_isolate, Utils::OpenHandle(*source), + debug::EvaluateGlobalMode::kDefault, + repl_mode), + &result); + RETURN_ON_FAILED_EXECUTION(Value); + RETURN_ESCAPED(result) +} + MaybeLocal