summaryrefslogtreecommitdiff
path: root/deps/v8/src/snapshot/builtin-deserializer.h
diff options
context:
space:
mode:
authorMichaël Zasso <targos@protonmail.com>2017-12-05 16:41:55 +0100
committerMichaël Zasso <targos@protonmail.com>2017-12-06 12:52:07 +0100
commit1854ba04e9a68f062beb299dd6e1479279b26363 (patch)
treed5b2df9b8c1deb6388f7a728fca8e1c98c779abe /deps/v8/src/snapshot/builtin-deserializer.h
parentb52c23b75f96e1c9d2c7b3a7e5619170d0a0d8e1 (diff)
downloadnode-new-1854ba04e9a68f062beb299dd6e1479279b26363.tar.gz
deps: update V8 to 6.3.292.46
PR-URL: https://github.com/nodejs/node/pull/16271 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Myles Borins <myles.borins@gmail.com>
Diffstat (limited to 'deps/v8/src/snapshot/builtin-deserializer.h')
-rw-r--r--deps/v8/src/snapshot/builtin-deserializer.h89
1 files changed, 89 insertions, 0 deletions
diff --git a/deps/v8/src/snapshot/builtin-deserializer.h b/deps/v8/src/snapshot/builtin-deserializer.h
new file mode 100644
index 0000000000..a73c68ed34
--- /dev/null
+++ b/deps/v8/src/snapshot/builtin-deserializer.h
@@ -0,0 +1,89 @@
+// Copyright 2017 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_SNAPSHOT_BUILTIN_DESERIALIZER_H_
+#define V8_SNAPSHOT_BUILTIN_DESERIALIZER_H_
+
+#include "src/heap/heap.h"
+#include "src/snapshot/deserializer.h"
+
+namespace v8 {
+namespace internal {
+
+class BuiltinSnapshotData;
+
+// Deserializes the builtins blob.
+class BuiltinDeserializer final : public Deserializer {
+ public:
+ BuiltinDeserializer(Isolate* isolate, const BuiltinSnapshotData* data);
+
+ // Builtins deserialization is tightly integrated with deserialization of the
+ // startup blob. In particular, we need to ensure that no GC can occur
+ // between startup- and builtins deserialization, as all builtins have been
+ // pre-allocated and their pointers may not be invalidated.
+ //
+ // After this, the instruction cache must be flushed by the caller (we don't
+ // do it ourselves since the startup serializer batch-flushes all code pages).
+ void DeserializeEagerBuiltins();
+
+ // Deserializes the single given builtin. Assumes that reservations have
+ // already been allocated.
+ Code* DeserializeBuiltin(int builtin_id);
+
+ // These methods are used to pre-allocate builtin objects prior to
+ // deserialization.
+ // TODO(jgruber): Refactor reservation/allocation logic in deserializers to
+ // make this less messy.
+ Heap::Reservation CreateReservationsForEagerBuiltins();
+ void InitializeBuiltinsTable(const Heap::Reservation& reservation);
+
+ // Creates reservations and initializes the builtins table in preparation for
+ // lazily deserializing a single builtin.
+ void ReserveAndInitializeBuiltinsTableForBuiltin(int builtin_id);
+
+ private:
+ // TODO(jgruber): Remove once allocations have been refactored.
+ void SetPositionToBuiltin(int builtin_id);
+
+ // Extracts the size builtin Code objects (baked into the snapshot).
+ uint32_t ExtractBuiltinSize(int builtin_id);
+
+ // Used after memory allocation prior to isolate initialization, to register
+ // the newly created object in code space and add it to the builtins table.
+ void InitializeBuiltinFromReservation(const Heap::Chunk& chunk,
+ int builtin_id);
+
+ // Allocation works differently here than in other deserializers. Instead of
+ // a statically-known memory area determined at serialization-time, our
+ // memory requirements here are determined at runtime. Another major
+ // difference is that we create builtin Code objects up-front (before
+ // deserialization) in order to avoid having to patch builtin references
+ // later on. See also the kBuiltin case in deserializer.cc.
+ //
+ // Allocate simply returns the pre-allocated object prepared by
+ // InitializeBuiltinsTable.
+ Address Allocate(int space_index, int size) override;
+
+ // BuiltinDeserializer implements its own builtin iteration logic. Make sure
+ // the RootVisitor API is not used accidentally.
+ void VisitRootPointers(Root root, Object** start, Object** end) override {
+ UNREACHABLE();
+ }
+
+ // Stores the builtin currently being deserialized. We need this to determine
+ // where to 'allocate' from during deserialization.
+ static const int kNoBuiltinId = -1;
+ int current_builtin_id_ = kNoBuiltinId;
+
+ // The offsets of each builtin within the serialized data. Equivalent to
+ // BuiltinSerializer::builtin_offsets_ but on the deserialization side.
+ Vector<const uint32_t> builtin_offsets_;
+
+ friend class DeserializingBuiltinScope;
+};
+
+} // namespace internal
+} // namespace v8
+
+#endif // V8_SNAPSHOT_BUILTIN_DESERIALIZER_H_