Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1207)

Unified Diff: src/snapshot.h

Issue 848023002: Store embed-script flag as metadata into snapshot blob. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: addressed comment Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/heap/spaces.cc ('k') | src/snapshot-common.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/snapshot.h
diff --git a/src/snapshot.h b/src/snapshot.h
index 04c7ba6e7a8ea9f7ac1cab7c55d6e03eb47432f7..62e0b9bf853368f39cc6b46df2290811e3a8f3b3 100644
--- a/src/snapshot.h
+++ b/src/snapshot.h
@@ -12,6 +12,21 @@ namespace internal {
class Snapshot : public AllStatic {
public:
+ class Metadata {
+ public:
+ explicit Metadata(uint32_t data = 0) : data_(data) {}
+ bool embeds_script() { return EmbedsScriptBits::decode(data_); }
+ void set_embeds_script(bool v) {
+ data_ = EmbedsScriptBits::update(data_, v);
+ }
+
+ uint32_t& RawValue() { return data_; }
+
+ private:
+ class EmbedsScriptBits : public BitField<bool, 0, 1> {};
+ uint32_t data_;
+ };
+
// Initialize the Isolate from the internal snapshot. Returns false if no
// snapshot could be found.
static bool Initialize(Isolate* isolate);
@@ -21,17 +36,32 @@ class Snapshot : public AllStatic {
static bool HaveASnapshotToStartFrom();
+ static bool EmbedsScript();
+
// To be implemented by the snapshot source.
static const v8::StartupData SnapshotBlob();
static v8::StartupData CreateSnapshotBlob(
const Vector<const byte> startup_data,
- const Vector<const byte> context_data);
+ const Vector<const byte> context_data, Metadata metadata);
+
+#ifdef DEBUG
+ static bool SnapshotIsValid(v8::StartupData* snapshot_blob);
+#endif // DEBUG
+ private:
static Vector<const byte> ExtractStartupData(const v8::StartupData* data);
static Vector<const byte> ExtractContextData(const v8::StartupData* data);
+ static Metadata ExtractMetadata(const v8::StartupData* data);
+
+ static const int kMetadataOffset = 0;
+ static const int kStartupLengthOffset = kMetadataOffset + kInt32Size;
+ static const int kStartupDataOffset = kStartupLengthOffset + kInt32Size;
+
+ static int ContextOffset(int startup_length) {
+ return kStartupDataOffset + startup_length;
+ }
- private:
DISALLOW_IMPLICIT_CONSTRUCTORS(Snapshot);
};
« no previous file with comments | « src/heap/spaces.cc ('k') | src/snapshot-common.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698