From f86bf4d78510de3f79555b861ec2089126320756 Mon Sep 17 00:00:00 2001 From: Reece Wilson Date: Tue, 8 Nov 2022 23:37:52 +0000 Subject: [PATCH] [*] Speed glorious speed [+] Removed isolate entropy from the AstXXX hash seed bases, string inls, and string hash to ensure v8::Names deterministic across instances. Hashes are expected to colloid. Doubt anything depends on isolate entropy. [+] v8::String::GloballyInternalize(...) [+] v8::String::Share(...) [+] ScriptCompiler::EvaluateGlobal Previous aurora commits: 4c7c7d1a24844fb7109cb3fb6443b33ac894e943, c9b547e373b67c111e26977eedbe27cae559889d, 97450cb8d14d20617a8b57e22a650216d2c4b939, 07e2139b4f874768568b69b4677c85f824073447, ... --- include/v8-primitive.h | 4 + include/v8-script.h | 5 + include/v8-template.h | 22 +++ src/api/api.cc | 40 ++++- src/ic/ic.cc | 264 +++++++++++++++++++++++++------- src/numbers/hash-seed-inl.h | 2 + src/objects/api-callbacks-inl.h | 1 + src/objects/api-callbacks.h | 3 +- src/objects/api-callbacks.tq | 8 + src/objects/js-objects.cc | 135 ++++++++++------ src/objects/map.h | 1 + src/objects/map.tq | 3 + src/objects/string-inl.h | 4 +- src/objects/string.cc | 2 +- 14 files changed, 386 insertions(+), 108 deletions(-) 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