Commit a3277080 authored by Jakob Gruber's avatar Jakob Gruber Committed by V8 LUCI CQ

[handles] Branch hints and force-inline in HandleScope

Force-inline the HandleScope constructor and destructor, and
add branch hints for two commonly-mispredicted branches. This
moves the overall JetStream2/cdjs score by roughly 4% on d8. I
suspect no change will be visible in chromium builds (with PGO).

Bug: v8:12196
Change-Id: I0fd7b67aa554876d2dad2d706b874df21dbb72e2
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3270542
Commit-Queue: Jakob Gruber <jgruber@chromium.org>
Reviewed-by: 's avatarDominik Inführ <dinfuehr@chromium.org>
Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#77836}
parent e60dc99e
...@@ -1199,7 +1199,7 @@ class V8_EXPORT_PRIVATE Isolate final : private HiddenFactory { ...@@ -1199,7 +1199,7 @@ class V8_EXPORT_PRIVATE Isolate final : private HiddenFactory {
return descriptor_lookup_cache_; return descriptor_lookup_cache_;
} }
HandleScopeData* handle_scope_data() { return &handle_scope_data_; } V8_INLINE HandleScopeData* handle_scope_data() { return &handle_scope_data_; }
HandleScopeImplementer* handle_scope_implementer() const { HandleScopeImplementer* handle_scope_implementer() const {
DCHECK(handle_scope_implementer_); DCHECK(handle_scope_implementer_);
......
...@@ -95,7 +95,7 @@ HandleScope::HandleScope(HandleScope&& other) V8_NOEXCEPT ...@@ -95,7 +95,7 @@ HandleScope::HandleScope(HandleScope&& other) V8_NOEXCEPT
} }
HandleScope::~HandleScope() { HandleScope::~HandleScope() {
if (isolate_ == nullptr) return; if (V8_UNLIKELY(isolate_ == nullptr)) return;
CloseScope(isolate_, prev_next_, prev_limit_); CloseScope(isolate_, prev_next_, prev_limit_);
} }
...@@ -123,7 +123,7 @@ void HandleScope::CloseScope(Isolate* isolate, Address* prev_next, ...@@ -123,7 +123,7 @@ void HandleScope::CloseScope(Isolate* isolate, Address* prev_next,
std::swap(current->next, prev_next); std::swap(current->next, prev_next);
current->level--; current->level--;
Address* limit = prev_next; Address* limit = prev_next;
if (current->limit != prev_limit) { if (V8_UNLIKELY(current->limit != prev_limit)) {
current->limit = prev_limit; current->limit = prev_limit;
limit = prev_limit; limit = prev_limit;
DeleteExtensions(isolate); DeleteExtensions(isolate);
......
...@@ -199,7 +199,7 @@ inline std::ostream& operator<<(std::ostream& os, Handle<T> handle); ...@@ -199,7 +199,7 @@ inline std::ostream& operator<<(std::ostream& os, Handle<T> handle);
// for which the handle scope has been deleted is undefined. // for which the handle scope has been deleted is undefined.
class V8_NODISCARD HandleScope { class V8_NODISCARD HandleScope {
public: public:
explicit inline HandleScope(Isolate* isolate); explicit V8_INLINE HandleScope(Isolate* isolate);
inline HandleScope(HandleScope&& other) V8_NOEXCEPT; inline HandleScope(HandleScope&& other) V8_NOEXCEPT;
HandleScope(const HandleScope&) = delete; HandleScope(const HandleScope&) = delete;
HandleScope& operator=(const HandleScope&) = delete; HandleScope& operator=(const HandleScope&) = delete;
...@@ -213,7 +213,7 @@ class V8_NODISCARD HandleScope { ...@@ -213,7 +213,7 @@ class V8_NODISCARD HandleScope {
void* operator new(size_t size) = delete; void* operator new(size_t size) = delete;
void operator delete(void* size_t) = delete; void operator delete(void* size_t) = delete;
inline ~HandleScope(); V8_INLINE ~HandleScope();
inline HandleScope& operator=(HandleScope&& other) V8_NOEXCEPT; inline HandleScope& operator=(HandleScope&& other) V8_NOEXCEPT;
...@@ -253,8 +253,8 @@ class V8_NODISCARD HandleScope { ...@@ -253,8 +253,8 @@ class V8_NODISCARD HandleScope {
Address* prev_limit_; Address* prev_limit_;
// Close the handle scope resetting limits to a previous state. // Close the handle scope resetting limits to a previous state.
static inline void CloseScope(Isolate* isolate, Address* prev_next, static V8_INLINE void CloseScope(Isolate* isolate, Address* prev_next,
Address* prev_limit); Address* prev_limit);
// Extend the handle scope making room for more handles. // Extend the handle scope making room for more handles.
V8_EXPORT_PRIVATE static Address* Extend(Isolate* isolate); V8_EXPORT_PRIVATE static Address* Extend(Isolate* isolate);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment