|
| 1 | +From 47e6d11cc8b6db025c43451ad68afd42c2892071 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Peter Collingbourne < [email protected]> |
| 3 | +Date: Mon, 3 Mar 2025 20:07:20 -0800 |
| 4 | +Subject: [PATCH] PFP fixes |
| 5 | + |
| 6 | +--- |
| 7 | + runtime/platform/allocation.h | 4 ++++ |
| 8 | + runtime/vm/dart.cc | 5 ++--- |
| 9 | + runtime/vm/isolate.cc | 5 ++++- |
| 10 | + runtime/vm/isolate.h | 4 ++-- |
| 11 | + runtime/vm/timeline.cc | 4 ++++ |
| 12 | + 5 files changed, 16 insertions(+), 6 deletions(-) |
| 13 | + |
| 14 | +diff --git a/runtime/platform/allocation.h b/runtime/platform/allocation.h |
| 15 | +index 26001ac54f2..5bc2a10960b 100644 |
| 16 | +--- a/runtime/platform/allocation.h |
| 17 | ++++ b/runtime/platform/allocation.h |
| 18 | +@@ -40,6 +40,10 @@ class MallocAllocated { |
| 19 | + public: |
| 20 | + MallocAllocated() {} |
| 21 | + |
| 22 | ++ // Placement new. |
| 23 | ++ void* operator new(size_t size, void *p) { return p; } |
| 24 | ++ void* operator new[](size_t size, void *p) { return p; } |
| 25 | ++ |
| 26 | + // Intercept operator new to produce clearer error messages when we run out |
| 27 | + // of memory. Don't do this when running under ASAN so it can continue to |
| 28 | + // check malloc/new/new[] are paired with free/delete/delete[] respectively. |
| 29 | +diff --git a/runtime/vm/dart.cc b/runtime/vm/dart.cc |
| 30 | +index 490549316ef..d78779a511a 100644 |
| 31 | +--- a/runtime/vm/dart.cc |
| 32 | ++++ b/runtime/vm/dart.cc |
| 33 | +@@ -165,12 +165,12 @@ class DartInitializationState : public AllStatic { |
| 34 | + std::atomic<uint8_t> DartInitializationState::state_ = {kUnInitialized}; |
| 35 | + std::atomic<uint64_t> DartInitializationState::in_use_count_ = {0}; |
| 36 | + |
| 37 | +-#if defined(DART_PRECOMPILER) || defined(DART_PRECOMPILED_RUNTIME) |
| 38 | + static void CheckOffsets() { |
| 39 | + #if !defined(IS_SIMARM_HOST64) |
| 40 | + // These offsets are embedded in precompiled instructions. We need the |
| 41 | + // compiler and the runtime to agree. |
| 42 | + bool ok = true; |
| 43 | ++ (void)ok; |
| 44 | + #define CHECK_OFFSET(expr, offset) \ |
| 45 | + if ((expr) != (offset)) { \ |
| 46 | + OS::PrintErr("%s got %" Pd ", %s expected %" Pd "\n", #expr, \ |
| 47 | +@@ -226,7 +226,6 @@ static void CheckOffsets() { |
| 48 | + } \ |
| 49 | + } |
| 50 | + #define CHECK_CONSTANT(Class, Name) CHECK_OFFSET(Class::Name, Class##_##Name); |
| 51 | +-#endif // defined(DART_PRECOMPILED_RUNTIME) |
| 52 | + |
| 53 | + COMMON_OFFSETS_LIST(CHECK_FIELD, CHECK_ARRAY, CHECK_SIZEOF, |
| 54 | + CHECK_ARRAY_SIZEOF, CHECK_PAYLOAD_SIZEOF, CHECK_RANGE, |
| 55 | +@@ -258,8 +257,8 @@ static void CheckOffsets() { |
| 56 | + #endif // defined(DART_PRECOMPILER) || defined(DART_PRECOMPILED_RUNTIME) |
| 57 | + |
| 58 | + char* Dart::DartInit(const Dart_InitializeParams* params) { |
| 59 | +-#if defined(DART_PRECOMPILER) || defined(DART_PRECOMPILED_RUNTIME) |
| 60 | + CheckOffsets(); |
| 61 | ++#if defined(DART_PRECOMPILER) || defined(DART_PRECOMPILED_RUNTIME) |
| 62 | + #elif defined(ARCH_IS_64_BIT) != defined(TARGET_ARCH_IS_64_BIT) |
| 63 | + return Utils::StrDup( |
| 64 | + "JIT cannot simulate target architecture with different word size than " |
| 65 | +diff --git a/runtime/vm/isolate.cc b/runtime/vm/isolate.cc |
| 66 | +index 11cb004f448..c48623b8907 100644 |
| 67 | +--- a/runtime/vm/isolate.cc |
| 68 | ++++ b/runtime/vm/isolate.cc |
| 69 | +@@ -448,6 +448,8 @@ IsolateGroup::~IsolateGroup() { |
| 70 | + delete debugger_; |
| 71 | + debugger_ = nullptr; |
| 72 | + #endif |
| 73 | ++ |
| 74 | ++ delete object_store_; |
| 75 | + } |
| 76 | + |
| 77 | + void IsolateGroup::RegisterIsolate(Isolate* isolate) { |
| 78 | +@@ -1112,7 +1114,8 @@ bool Isolate::SendInternalLibMessage(Dart_Port main_port, |
| 79 | + } |
| 80 | + |
| 81 | + void IsolateGroup::set_object_store(ObjectStore* object_store) { |
| 82 | +- object_store_.reset(object_store); |
| 83 | ++ delete object_store_; |
| 84 | ++ object_store_ = object_store; |
| 85 | + } |
| 86 | + |
| 87 | + class IsolateMessageHandler : public MessageHandler { |
| 88 | +diff --git a/runtime/vm/isolate.h b/runtime/vm/isolate.h |
| 89 | +index 9f5d27fb404..5b501b3fc4f 100644 |
| 90 | +--- a/runtime/vm/isolate.h |
| 91 | ++++ b/runtime/vm/isolate.h |
| 92 | +@@ -506,7 +506,7 @@ class IsolateGroup : public IntrusiveDListEntry<IsolateGroup> { |
| 93 | + void DropOriginalClassTable(); |
| 94 | + |
| 95 | + StoreBuffer* store_buffer() const { return store_buffer_.get(); } |
| 96 | +- ObjectStore* object_store() const { return object_store_.get(); } |
| 97 | ++ ObjectStore* object_store() const { return object_store_; } |
| 98 | + Mutex* symbols_mutex() { return &symbols_mutex_; } |
| 99 | + Mutex* type_canonicalization_mutex() { return &type_canonicalization_mutex_; } |
| 100 | + Mutex* type_arguments_canonicalization_mutex() { |
| 101 | +@@ -819,7 +819,7 @@ class IsolateGroup : public IntrusiveDListEntry<IsolateGroup> { |
| 102 | + // Accessed from generated code. |
| 103 | + ClassTable* class_table_; |
| 104 | + AcqRelAtomic<ClassPtr*> cached_class_table_table_; |
| 105 | +- std::unique_ptr<ObjectStore> object_store_; |
| 106 | ++ ObjectStore* object_store_; |
| 107 | + // End accessed from generated code. |
| 108 | + |
| 109 | + ClassTableAllocator class_table_allocator_; |
| 110 | +diff --git a/runtime/vm/timeline.cc b/runtime/vm/timeline.cc |
| 111 | +index 211f0e28741..ba07afac27c 100644 |
| 112 | +--- a/runtime/vm/timeline.cc |
| 113 | ++++ b/runtime/vm/timeline.cc |
| 114 | +@@ -1595,6 +1595,10 @@ TimelineEventFixedBufferRecorder::TimelineEventFixedBufferRecorder( |
| 115 | + if (memory_ == nullptr) { |
| 116 | + OUT_OF_MEMORY(); |
| 117 | + } |
| 118 | ++ for (intptr_t i = 0; i != num_blocks_; ++i) { |
| 119 | ++ new (reinterpret_cast<char*>(memory_->address()) + |
| 120 | ++ i * sizeof(TimelineEventBlock)) TimelineEventBlock(i); |
| 121 | ++ } |
| 122 | + blocks_ = reinterpret_cast<TimelineEventBlock*>(memory_->address()); |
| 123 | + } |
| 124 | + |
| 125 | +-- |
| 126 | +2.48.1 |
| 127 | + |
0 commit comments