Commit a62c0404 authored by Igor Sheludko's avatar Igor Sheludko Committed by V8 LUCI CQ

[rwx][mac] Fix component build

The issue is that a thread_local variable used in RwxMemoryWriteScope
can't be directly accessed from another component, so the workaround is
to avoid inlining accesses the variable into other components.

Bug: v8:12797, chromium:1324333
Change-Id: I0f83358ac0c663c92ef7b3dff54a068472d61aed
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3641169
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Auto-Submit: Igor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/main@{#80470}
parent e3addb6e
...@@ -108,6 +108,13 @@ ...@@ -108,6 +108,13 @@
namespace v8 { namespace v8 {
namespace internal { namespace internal {
CodePageCollectionMemoryModificationScopeForTesting::
CodePageCollectionMemoryModificationScopeForTesting(Heap* heap)
: CodePageCollectionMemoryModificationScope(heap) {}
CodePageCollectionMemoryModificationScopeForTesting::
~CodePageCollectionMemoryModificationScopeForTesting() = default;
#ifdef V8_ENABLE_THIRD_PARTY_HEAP #ifdef V8_ENABLE_THIRD_PARTY_HEAP
Isolate* Heap::GetIsolateFromWritableObject(HeapObject object) { Isolate* Heap::GetIsolateFromWritableObject(HeapObject object) {
return reinterpret_cast<Isolate*>( return reinterpret_cast<Isolate*>(
......
...@@ -2626,6 +2626,18 @@ class V8_NODISCARD CodePageCollectionMemoryModificationScope { ...@@ -2626,6 +2626,18 @@ class V8_NODISCARD CodePageCollectionMemoryModificationScope {
Heap* heap_; Heap* heap_;
}; };
// Same as the CodePageCollectionMemoryModificationScope but without inlining
// the code. This is a workaround for component build issue (crbug/1316800),
// when a thread_local value can't be properly exported.
class V8_EXPORT_PRIVATE V8_NODISCARD
CodePageCollectionMemoryModificationScopeForTesting
: public CodePageCollectionMemoryModificationScope {
public:
V8_NOINLINE explicit CodePageCollectionMemoryModificationScopeForTesting(
Heap* heap);
V8_NOINLINE ~CodePageCollectionMemoryModificationScopeForTesting();
};
// The CodePageHeaderModificationScope enables write access to Code space page // The CodePageHeaderModificationScope enables write access to Code space page
// headers. // headers.
// On most of the configurations it's a no-op because Code space page headers // On most of the configurations it's a no-op because Code space page headers
......
...@@ -201,7 +201,7 @@ void SimulateFullSpace(v8::internal::PagedSpace* space) { ...@@ -201,7 +201,7 @@ void SimulateFullSpace(v8::internal::PagedSpace* space) {
// FLAG_stress_concurrent_allocation = false; // FLAG_stress_concurrent_allocation = false;
// Background thread allocating concurrently interferes with this function. // Background thread allocating concurrently interferes with this function.
CHECK(!FLAG_stress_concurrent_allocation); CHECK(!FLAG_stress_concurrent_allocation);
CodePageCollectionMemoryModificationScope modification_scope(space->heap()); CodePageCollectionMemoryModificationScopeForTesting code_scope(space->heap());
i::MarkCompactCollector* collector = space->heap()->mark_compact_collector(); i::MarkCompactCollector* collector = space->heap()->mark_compact_collector();
if (collector->sweeping_in_progress()) { if (collector->sweeping_in_progress()) {
collector->EnsureSweepingCompleted( collector->EnsureSweepingCompleted(
......
...@@ -84,7 +84,7 @@ Handle<Object> HeapTester::TestAllocateAfterFailures() { ...@@ -84,7 +84,7 @@ Handle<Object> HeapTester::TestAllocateAfterFailures() {
// Code space. // Code space.
heap::SimulateFullSpace(heap->code_space()); heap::SimulateFullSpace(heap->code_space());
CodePageCollectionMemoryModificationScope code_scope(heap); CodePageCollectionMemoryModificationScopeForTesting code_scope(heap);
size = CcTest::i_isolate()->builtins()->code(Builtin::kIllegal).Size(); size = CcTest::i_isolate()->builtins()->code(Builtin::kIllegal).Size();
obj = obj =
heap->AllocateRaw(size, AllocationType::kCode, AllocationOrigin::kRuntime) heap->AllocateRaw(size, AllocationType::kCode, AllocationOrigin::kRuntime)
......
...@@ -483,7 +483,7 @@ UNINITIALIZED_TEST(ConcurrentRecordRelocSlot) { ...@@ -483,7 +483,7 @@ UNINITIALIZED_TEST(ConcurrentRecordRelocSlot) {
{ {
Code code; Code code;
HeapObject value; HeapObject value;
CodePageCollectionMemoryModificationScope modification_scope(heap); CodePageCollectionMemoryModificationScopeForTesting code_scope(heap);
{ {
HandleScope handle_scope(i_isolate); HandleScope handle_scope(i_isolate);
i::byte buffer[i::Assembler::kDefaultBufferSize]; i::byte buffer[i::Assembler::kDefaultBufferSize];
......
...@@ -6981,7 +6981,7 @@ TEST(CodeObjectRegistry) { ...@@ -6981,7 +6981,7 @@ TEST(CodeObjectRegistry) {
Isolate* isolate = CcTest::i_isolate(); Isolate* isolate = CcTest::i_isolate();
Heap* heap = isolate->heap(); Heap* heap = isolate->heap();
CodePageCollectionMemoryModificationScope code_scope(heap); CodePageCollectionMemoryModificationScopeForTesting code_scope(heap);
Handle<Code> code1; Handle<Code> code1;
HandleScope outer_scope(heap->isolate()); HandleScope outer_scope(heap->isolate());
...@@ -7165,7 +7165,7 @@ HEAP_TEST(CodeLargeObjectSpace) { ...@@ -7165,7 +7165,7 @@ HEAP_TEST(CodeLargeObjectSpace) {
TestAllocationTracker allocation_tracker{size_in_bytes}; TestAllocationTracker allocation_tracker{size_in_bytes};
heap->AddHeapObjectAllocationTracker(&allocation_tracker); heap->AddHeapObjectAllocationTracker(&allocation_tracker);
CodePageCollectionMemoryModificationScope code_scope(heap); CodePageCollectionMemoryModificationScopeForTesting code_scope(heap);
HeapObject obj; HeapObject obj;
{ {
AllocationResult allocation = heap->AllocateRaw( AllocationResult allocation = heap->AllocateRaw(
...@@ -7199,7 +7199,7 @@ UNINITIALIZED_HEAP_TEST(CodeLargeObjectSpace64k) { ...@@ -7199,7 +7199,7 @@ UNINITIALIZED_HEAP_TEST(CodeLargeObjectSpace64k) {
TestAllocationTracker allocation_tracker{size_in_bytes}; TestAllocationTracker allocation_tracker{size_in_bytes};
heap->AddHeapObjectAllocationTracker(&allocation_tracker); heap->AddHeapObjectAllocationTracker(&allocation_tracker);
CodePageCollectionMemoryModificationScope code_scope(heap); CodePageCollectionMemoryModificationScopeForTesting code_scope(heap);
HeapObject obj; HeapObject obj;
{ {
AllocationResult allocation = heap->AllocateRaw( AllocationResult allocation = heap->AllocateRaw(
...@@ -7221,7 +7221,7 @@ UNINITIALIZED_HEAP_TEST(CodeLargeObjectSpace64k) { ...@@ -7221,7 +7221,7 @@ UNINITIALIZED_HEAP_TEST(CodeLargeObjectSpace64k) {
TestAllocationTracker allocation_tracker{size_in_bytes}; TestAllocationTracker allocation_tracker{size_in_bytes};
heap->AddHeapObjectAllocationTracker(&allocation_tracker); heap->AddHeapObjectAllocationTracker(&allocation_tracker);
CodePageCollectionMemoryModificationScope code_scope(heap); CodePageCollectionMemoryModificationScopeForTesting code_scope(heap);
HeapObject obj; HeapObject obj;
{ {
AllocationResult allocation = heap->AllocateRaw( AllocationResult allocation = heap->AllocateRaw(
...@@ -7317,10 +7317,10 @@ TEST(Regress10900) { ...@@ -7317,10 +7317,10 @@ TEST(Regress10900) {
Handle<Code> code = Handle<Code> code =
Factory::CodeBuilder(isolate, desc, CodeKind::FOR_TESTING).Build(); Factory::CodeBuilder(isolate, desc, CodeKind::FOR_TESTING).Build();
{ {
CodePageCollectionMemoryModificationScopeForTesting code_scope(
isolate->heap());
for (int i = 0; i < 100; i++) { for (int i = 0; i < 100; i++) {
// Generate multiple code pages. // Generate multiple code pages.
CodePageCollectionMemoryModificationScope modification_scope(
isolate->heap());
factory->CopyCode(code); factory->CopyCode(code);
} }
} }
......
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