summaryrefslogtreecommitdiff
path: root/chromium/v8/src/snapshot/code-serializer.cc
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2020-10-12 14:27:29 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2020-10-13 09:35:20 +0000
commitc30a6232df03e1efbd9f3b226777b07e087a1122 (patch)
treee992f45784689f373bcc38d1b79a239ebe17ee23 /chromium/v8/src/snapshot/code-serializer.cc
parent7b5b123ac58f58ffde0f4f6e488bcd09aa4decd3 (diff)
downloadqtwebengine-chromium-85-based.tar.gz
BASELINE: Update Chromium to 85.0.4183.14085-based
Change-Id: Iaa42f4680837c57725b1344f108c0196741f6057 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/v8/src/snapshot/code-serializer.cc')
-rw-r--r--chromium/v8/src/snapshot/code-serializer.cc70
1 files changed, 63 insertions, 7 deletions
diff --git a/chromium/v8/src/snapshot/code-serializer.cc b/chromium/v8/src/snapshot/code-serializer.cc
index f9093012b27..f4cf0b07072 100644
--- a/chromium/v8/src/snapshot/code-serializer.cc
+++ b/chromium/v8/src/snapshot/code-serializer.cc
@@ -4,9 +4,12 @@
#include "src/snapshot/code-serializer.h"
+#include "src/base/platform/platform.h"
#include "src/codegen/macro-assembler.h"
+#include "src/common/globals.h"
#include "src/debug/debug.h"
#include "src/heap/heap-inl.h"
+#include "src/heap/off-thread-factory-inl.h"
#include "src/logging/counters.h"
#include "src/logging/log.h"
#include "src/objects/objects-inl.h"
@@ -104,14 +107,14 @@ bool CodeSerializer::SerializeReadOnlyObject(HeapObject obj) {
// create a back reference that encodes the page number as the chunk_index and
// the offset within the page as the chunk_offset.
Address address = obj.address();
- Page* page = Page::FromAddress(address);
+ BasicMemoryChunk* chunk = BasicMemoryChunk::FromAddress(address);
uint32_t chunk_index = 0;
ReadOnlySpace* const read_only_space = isolate()->heap()->read_only_space();
- for (Page* p : *read_only_space) {
- if (p == page) break;
+ for (ReadOnlyPage* page : read_only_space->pages()) {
+ if (chunk == page) break;
++chunk_index;
}
- uint32_t chunk_offset = static_cast<uint32_t>(page->Offset(address));
+ uint32_t chunk_offset = static_cast<uint32_t>(chunk->Offset(address));
SerializerReference back_reference = SerializerReference::BackReference(
SnapshotSpace::kReadOnlyHeap, chunk_index, chunk_offset);
reference_map()->Add(reinterpret_cast<void*>(obj.ptr()), back_reference);
@@ -259,6 +262,39 @@ void CreateInterpreterDataForDeserializedCode(Isolate* isolate,
}
#endif // V8_TARGET_ARCH_ARM
+namespace {
+class StressOffThreadDeserializeThread final : public base::Thread {
+ public:
+ explicit StressOffThreadDeserializeThread(
+ OffThreadIsolate* off_thread_isolate, const SerializedCodeData* scd)
+ : Thread(
+ base::Thread::Options("StressOffThreadDeserializeThread", 2 * MB)),
+ off_thread_isolate_(off_thread_isolate),
+ scd_(scd) {}
+
+ MaybeHandle<SharedFunctionInfo> maybe_result() const {
+ return maybe_result_.ToHandle();
+ }
+
+ void Run() final {
+ off_thread_isolate_->PinToCurrentThread();
+
+ MaybeHandle<SharedFunctionInfo> off_thread_maybe_result =
+ ObjectDeserializer::DeserializeSharedFunctionInfoOffThread(
+ off_thread_isolate_, scd_,
+ off_thread_isolate_->factory()->empty_string());
+
+ maybe_result_ =
+ off_thread_isolate_->TransferHandle(off_thread_maybe_result);
+ }
+
+ private:
+ OffThreadIsolate* off_thread_isolate_;
+ const SerializedCodeData* scd_;
+ OffThreadTransferMaybeHandle<SharedFunctionInfo> maybe_result_;
+};
+} // namespace
+
MaybeHandle<SharedFunctionInfo> CodeSerializer::Deserialize(
Isolate* isolate, ScriptData* cached_data, Handle<String> source,
ScriptOriginOptions origin_options) {
@@ -281,8 +317,29 @@ MaybeHandle<SharedFunctionInfo> CodeSerializer::Deserialize(
}
// Deserialize.
- MaybeHandle<SharedFunctionInfo> maybe_result =
- ObjectDeserializer::DeserializeSharedFunctionInfo(isolate, &scd, source);
+ MaybeHandle<SharedFunctionInfo> maybe_result;
+ if (FLAG_stress_background_compile) {
+ Zone zone(isolate->allocator(), "Deserialize");
+ OffThreadIsolate off_thread_isolate(isolate, &zone);
+
+ StressOffThreadDeserializeThread thread(&off_thread_isolate, &scd);
+ CHECK(thread.Start());
+ thread.Join();
+
+ off_thread_isolate.FinishOffThread();
+ off_thread_isolate.Publish(isolate);
+
+ maybe_result = thread.maybe_result();
+
+ // Fix-up result script source.
+ Handle<SharedFunctionInfo> result;
+ if (maybe_result.ToHandle(&result)) {
+ Script::cast(result->script()).set_source(*source);
+ }
+ } else {
+ maybe_result = ObjectDeserializer::DeserializeSharedFunctionInfo(
+ isolate, &scd, source);
+ }
Handle<SharedFunctionInfo> result;
if (!maybe_result.ToHandle(&result)) {
@@ -356,7 +413,6 @@ MaybeHandle<SharedFunctionInfo> CodeSerializer::Deserialize(
return scope.CloseAndEscape(result);
}
-
SerializedCodeData::SerializedCodeData(const std::vector<byte>* payload,
const CodeSerializer* cs) {
DisallowHeapAllocation no_gc;