Commit 4f7b00c7 authored by Leszek Swirski's avatar Leszek Swirski Committed by Commit Bot

[offthread] Allow cleared references allocation off-thread

Allow cleared references to be created with an OffThreadIsolate.
This includes allowing isolate_root to be accessed from the
OffThreadIsolate, for pointer decompression.

Bug: chromium:1075999
Change-Id: I62e0fe2c1c6166a7b816593ae1ec5ddb1c25d861
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2183911
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Auto-Submit: Leszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/master@{#67599}
parent afd9493a
......@@ -2332,6 +2332,7 @@ v8_source_set("v8_base_without_compiler") {
"src/execution/messages.h",
"src/execution/microtask-queue.cc",
"src/execution/microtask-queue.h",
"src/execution/off-thread-isolate-inl.h",
"src/execution/off-thread-isolate.cc",
"src/execution/off-thread-isolate.h",
"src/execution/pointer-authentication.h",
......
......@@ -651,6 +651,7 @@ class NewSpace;
class NewLargeObjectSpace;
class NumberDictionary;
class Object;
class OffThreadIsolate;
class OldLargeObjectSpace;
template <HeapObjectReferenceType kRefType, typename StorageType>
class TaggedImpl;
......
......@@ -8,6 +8,7 @@
#include "include/v8-internal.h"
#include "src/common/ptr-compr.h"
#include "src/execution/isolate.h"
#include "src/execution/off-thread-isolate-inl.h"
namespace v8 {
namespace internal {
......@@ -36,6 +37,15 @@ V8_INLINE Address GetIsolateRoot(const Isolate* isolate) {
return isolate_root;
}
V8_INLINE Address GetIsolateRoot(const OffThreadIsolate* isolate) {
Address isolate_root = isolate->isolate_root();
#ifdef V8_COMPRESS_POINTERS
isolate_root = reinterpret_cast<Address>(V8_ASSUME_ALIGNED(
reinterpret_cast<void*>(isolate_root), kPtrComprIsolateRootAlignment));
#endif
return isolate_root;
}
// Decompresses smi value.
V8_INLINE Address DecompressTaggedSigned(Tagged_t raw_value) {
// For runtime code the upper 32-bits of the Smi value do not matter.
......
// Copyright 2020 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef V8_EXECUTION_OFF_THREAD_ISOLATE_INL_H_
#define V8_EXECUTION_OFF_THREAD_ISOLATE_INL_H_
#include "src/execution/isolate.h"
#include "src/execution/off-thread-isolate.h"
#include "src/roots/roots-inl.h"
namespace v8 {
namespace internal {
Address OffThreadIsolate::isolate_root() const {
return isolate_->isolate_root();
}
} // namespace internal
} // namespace v8
#endif // V8_EXECUTION_OFF_THREAD_ISOLATE_INL_H_
......@@ -5,7 +5,7 @@
#ifndef V8_EXECUTION_OFF_THREAD_ISOLATE_H_
#define V8_EXECUTION_OFF_THREAD_ISOLATE_H_
#include "src/base/logging.h"
#include "src/base/macros.h"
#include "src/execution/thread-id.h"
#include "src/handles/handles.h"
#include "src/handles/maybe-handles.h"
......@@ -80,6 +80,8 @@ class V8_EXPORT_PRIVATE OffThreadIsolate final
OffThreadHeap* heap() { return &heap_; }
inline Address isolate_root() const;
v8::internal::OffThreadFactory* factory() {
// Upcast to the privately inherited base-class using c-style casts to avoid
// undefined behavior (as static_cast cannot cast across private bases).
......
......@@ -5,11 +5,8 @@
#ifndef V8_OBJECTS_MAYBE_OBJECT_INL_H_
#define V8_OBJECTS_MAYBE_OBJECT_INL_H_
#include "src/common/ptr-compr-inl.h"
#include "src/objects/maybe-object.h"
#ifdef V8_COMPRESS_POINTERS
#include "src/execution/isolate.h"
#endif
#include "src/objects/smi-inl.h"
#include "src/objects/tagged-impl-inl.h"
......@@ -59,16 +56,32 @@ HeapObjectReference HeapObjectReference::Weak(Object object) {
}
// static
HeapObjectReference HeapObjectReference::ClearedValue(Isolate* isolate) {
HeapObjectReference HeapObjectReference::ClearedValue(const Isolate* isolate) {
// Construct cleared weak ref value.
#ifdef V8_COMPRESS_POINTERS
// This is necessary to make pointer decompression computation also
// suitable for cleared weak references.
Address raw_value =
DecompressTaggedPointer(isolate, kClearedWeakHeapObjectLower32);
#else
Address raw_value = kClearedWeakHeapObjectLower32;
#endif
// The rest of the code will check only the lower 32-bits.
DCHECK_EQ(kClearedWeakHeapObjectLower32, static_cast<uint32_t>(raw_value));
return HeapObjectReference(raw_value);
}
// static
HeapObjectReference HeapObjectReference::ClearedValue(
const OffThreadIsolate* isolate) {
// Construct cleared weak ref value.
#ifdef V8_COMPRESS_POINTERS
// This is necessary to make pointer decompression computation also
// suitable for cleared weak references.
Address isolate_root = isolate->isolate_root();
raw_value |= isolate_root;
DCHECK_EQ(raw_value & (~static_cast<Address>(kClearedWeakHeapObjectLower32)),
isolate_root);
Address raw_value =
DecompressTaggedPointer(isolate, kClearedWeakHeapObjectLower32);
#else
Address raw_value = kClearedWeakHeapObjectLower32;
#endif
// The rest of the code will check only the lower 32-bits.
DCHECK_EQ(kClearedWeakHeapObjectLower32, static_cast<uint32_t>(raw_value));
......
......@@ -47,7 +47,10 @@ class HeapObjectReference : public MaybeObject {
V8_INLINE static HeapObjectReference Weak(Object object);
V8_INLINE static HeapObjectReference ClearedValue(Isolate* isolate);
V8_INLINE static HeapObjectReference ClearedValue(const Isolate* isolate);
V8_INLINE static HeapObjectReference ClearedValue(
const OffThreadIsolate* isolate);
template <typename THeapObjectSlot>
V8_INLINE static void Update(THeapObjectSlot slot, HeapObject value);
......
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