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

Side by Side Diff: src/snapshot/serializer-common.h

Issue 2083303002: [serializer] reorder some bytecodes to free up large blocks. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 6 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 unified diff | Download patch
« src/snapshot/deserializer.cc ('K') | « src/snapshot/deserializer.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_SNAPSHOT_SERIALIZER_COMMON_H_ 5 #ifndef V8_SNAPSHOT_SERIALIZER_COMMON_H_
6 #define V8_SNAPSHOT_SERIALIZER_COMMON_H_ 6 #define V8_SNAPSHOT_SERIALIZER_COMMON_H_
7 7
8 #include "src/address-map.h" 8 #include "src/address-map.h"
9 #include "src/external-reference-table.h" 9 #include "src/external-reference-table.h"
10 #include "src/globals.h" 10 #include "src/globals.h"
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 static bool CanBeDeferred(HeapObject* o); 87 static bool CanBeDeferred(HeapObject* o);
88 88
89 // ---------- byte code range 0x00..0x7f ---------- 89 // ---------- byte code range 0x00..0x7f ----------
90 // Byte codes in this range represent Where, HowToCode and WhereToPoint. 90 // Byte codes in this range represent Where, HowToCode and WhereToPoint.
91 // Where the pointed-to object can be found: 91 // Where the pointed-to object can be found:
92 // The static assert below will trigger when the number of preallocated spaces 92 // The static assert below will trigger when the number of preallocated spaces
93 // changed. If that happens, update the bytecode ranges in the comments below. 93 // changed. If that happens, update the bytecode ranges in the comments below.
94 STATIC_ASSERT(5 == kNumberOfSpaces); 94 STATIC_ASSERT(5 == kNumberOfSpaces);
95 enum Where { 95 enum Where {
96 // 0x00..0x04 Allocate new object, in specified space. 96 // 0x00..0x04 Allocate new object, in specified space.
97 kNewObject = 0, 97 kNewObject = 0x00,
98 // 0x05 Unused (including 0x25, 0x45, 0x65).
99 // 0x06 Unused (including 0x26, 0x46, 0x66).
100 // 0x07 Unused (including 0x27, 0x47, 0x67).
101 // 0x08..0x0c Reference to previous object from space. 98 // 0x08..0x0c Reference to previous object from space.
102 kBackref = 0x08, 99 kBackref = 0x08,
103 // 0x0d Unused (including 0x2d, 0x4d, 0x6d).
104 // 0x0e Unused (including 0x2e, 0x4e, 0x6e).
105 // 0x0f Unused (including 0x2f, 0x4f, 0x6f).
106 // 0x10..0x14 Reference to previous object from space after skip. 100 // 0x10..0x14 Reference to previous object from space after skip.
107 kBackrefWithSkip = 0x10, 101 kBackrefWithSkip = 0x10,
108 // 0x15 Unused (including 0x35, 0x55, 0x75). 102
109 // 0x16 Unused (including 0x36, 0x56, 0x76). 103 // 0x05 Root array item.
110 // 0x17 Misc (including 0x37, 0x57, 0x77). 104 kRootArray = 0x05,
111 // 0x18 Root array item. 105 // 0x06 Object in the partial snapshot cache.
112 kRootArray = 0x18, 106 kPartialSnapshotCache = 0x06,
113 // 0x19 Object in the partial snapshot cache. 107 // 0x07 External reference referenced by id.
114 kPartialSnapshotCache = 0x19, 108 kExternalReference = 0x07,
115 // 0x1a External reference referenced by id. 109
116 kExternalReference = 0x1a, 110 // 0x0d Object provided in the attached list.
117 // 0x1b Object provided in the attached list. 111 kAttachedReference = 0x0d,
118 kAttachedReference = 0x1b, 112 // 0x0e Builtin code referenced by index.
119 // 0x1c Builtin code referenced by index. 113 kBuiltin = 0x0e,
120 kBuiltin = 0x1c 114
121 // 0x1d..0x1f Misc (including 0x3d..0x3f, 0x5d..0x5f, 0x7d..0x7f) 115 // 0x0f Misc, see below (incl. 0x2f, 0x4f, 0x6f).
116 // 0x15..0x1f Misc, see below (incl. 0x35..0x3f, 0x55..0x5f, 0x75..0x7f).
122 }; 117 };
123 118
124 static const int kWhereMask = 0x1f; 119 static const int kWhereMask = 0x1f;
125 static const int kSpaceMask = 7; 120 static const int kSpaceMask = 7;
126 STATIC_ASSERT(kNumberOfSpaces <= kSpaceMask + 1); 121 STATIC_ASSERT(kNumberOfSpaces <= kSpaceMask + 1);
127 122
128 // How to code the pointer to the object. 123 // How to code the pointer to the object.
129 enum HowToCode { 124 enum HowToCode {
130 // Straight pointer. 125 // Straight pointer.
131 kPlain = 0, 126 kPlain = 0,
132 // A pointer inlined in code. What this means depends on the architecture. 127 // A pointer inlined in code. What this means depends on the architecture.
133 kFromCode = 0x20 128 kFromCode = 0x20
134 }; 129 };
135 130
136 static const int kHowToCodeMask = 0x20; 131 static const int kHowToCodeMask = 0x20;
137 132
138 // Where to point within the object. 133 // Where to point within the object.
139 enum WhereToPoint { 134 enum WhereToPoint {
140 // Points to start of object 135 // Points to start of object
141 kStartOfObject = 0, 136 kStartOfObject = 0,
142 // Points to instruction in code object or payload of cell. 137 // Points to instruction in code object or payload of cell.
143 kInnerPointer = 0x40 138 kInnerPointer = 0x40
144 }; 139 };
145 140
146 static const int kWhereToPointMask = 0x40; 141 static const int kWhereToPointMask = 0x40;
147 142
148 // ---------- Misc ---------- 143 // ---------- Misc ----------
149 // Skip. 144 // Skip.
150 static const int kSkip = 0x1d; 145 static const int kSkip = 0x0f;
151 // Internal reference encoded as offsets of pc and target from code entry.
152 static const int kInternalReference = 0x1e;
153 static const int kInternalReferenceEncoded = 0x1f;
154 // Do nothing, used for padding. 146 // Do nothing, used for padding.
155 static const int kNop = 0x3d; 147 static const int kNop = 0x2f;
156 // Move to next reserved chunk. 148 // Move to next reserved chunk.
157 static const int kNextChunk = 0x3e; 149 static const int kNextChunk = 0x4f;
158 // Deferring object content. 150 // Deferring object content.
159 static const int kDeferred = 0x3f; 151 static const int kDeferred = 0x6f;
160 // Used for the source code of the natives, which is in the executable, but 152 // Alignment prefixes 0x15..0x17
161 // is referred to from external strings in the snapshot. 153 static const int kAlignmentPrefix = 0x15;
162 static const int kNativesStringResource = 0x5d;
163 // Used for the source code for compiled stubs, which is in the executable,
164 // but is referred to from external strings in the snapshot.
165 static const int kExtraNativesStringResource = 0x5e;
166 // A tag emitted at strategic points in the snapshot to delineate sections. 154 // A tag emitted at strategic points in the snapshot to delineate sections.
167 // If the deserializer does not find these at the expected moments then it 155 // If the deserializer does not find these at the expected moments then it
168 // is an indication that the snapshot and the VM do not fit together. 156 // is an indication that the snapshot and the VM do not fit together.
169 // Examine the build process for architecture, version or configuration 157 // Examine the build process for architecture, version or configuration
170 // mismatches. 158 // mismatches.
171 static const int kSynchronize = 0x17; 159 static const int kSynchronize = 0x18;
172 // Repeats of variable length. 160 // Repeats of variable length.
173 static const int kVariableRepeat = 0x37; 161 static const int kVariableRepeat = 0x19;
174 // Raw data of variable length. 162 // Raw data of variable length.
175 static const int kVariableRawData = 0x57; 163 static const int kVariableRawData = 0x1a;
176 // Alignment prefixes 0x7d..0x7f 164 // Internal reference encoded as offsets of pc and target from code entry.
177 static const int kAlignmentPrefix = 0x7d; 165 static const int kInternalReference = 0x1b;
166 static const int kInternalReferenceEncoded = 0x1c;
167 // Used for the source code of the natives, which is in the executable, but
168 // is referred to from external strings in the snapshot.
169 static const int kNativesStringResource = 0x1d;
170 // Used for the source code for compiled stubs, which is in the executable,
171 // but is referred to from external strings in the snapshot.
172 static const int kExtraNativesStringResource = 0x1e;
178 173
179 // 0x77 unused 174 // 8 hot (recently seen or back-referenced) objects with optional skip.
175 static const int kNumberOfHotObjects = 8;
176 STATIC_ASSERT(kNumberOfHotObjects == HotObjectsList::kSize);
177 // 0x38..0x3f
178 static const int kHotObject = 0x38;
179 // 0x58..0x5f
180 static const int kHotObjectWithSkip = 0x58;
181 static const int kHotObjectMask = 0x07;
182
183 // 0x1f, 0x35..0x37, 0x55..0x57, 0x75..0x7f unused.
180 184
181 // ---------- byte code range 0x80..0xff ---------- 185 // ---------- byte code range 0x80..0xff ----------
182 // First 32 root array items. 186 // First 32 root array items.
183 static const int kNumberOfRootArrayConstants = 0x20; 187 static const int kNumberOfRootArrayConstants = 0x20;
184 // 0x80..0x9f 188 // 0x80..0x9f
185 static const int kRootArrayConstants = 0x80; 189 static const int kRootArrayConstants = 0x80;
186 // 0xa0..0xbf 190 // 0xa0..0xbf
187 static const int kRootArrayConstantsWithSkip = 0xa0; 191 static const int kRootArrayConstantsWithSkip = 0xa0;
188 static const int kRootArrayConstantsMask = 0x1f; 192 static const int kRootArrayConstantsMask = 0x1f;
189 193
190 // 8 hot (recently seen or back-referenced) objects with optional skip.
191 static const int kNumberOfHotObjects = 0x08;
192 // 0xc0..0xc7
193 static const int kHotObject = 0xc0;
194 // 0xc8..0xcf
195 static const int kHotObjectWithSkip = 0xc8;
196 static const int kHotObjectMask = 0x07;
197
198 // 32 common raw data lengths. 194 // 32 common raw data lengths.
199 static const int kNumberOfFixedRawData = 0x20; 195 static const int kNumberOfFixedRawData = 0x20;
200 // 0xd0..0xef 196 // 0xc0..0xdf
201 static const int kFixedRawData = 0xd0; 197 static const int kFixedRawData = 0xc0;
202 static const int kOnePointerRawData = kFixedRawData; 198 static const int kOnePointerRawData = kFixedRawData;
203 static const int kFixedRawDataStart = kFixedRawData - 1; 199 static const int kFixedRawDataStart = kFixedRawData - 1;
204 200
205 // 16 repeats lengths. 201 // 16 repeats lengths.
206 static const int kNumberOfFixedRepeat = 0x10; 202 static const int kNumberOfFixedRepeat = 0x10;
207 // 0xf0..0xff 203 // 0xe0..0xef
208 static const int kFixedRepeat = 0xf0; 204 static const int kFixedRepeat = 0xe0;
209 static const int kFixedRepeatStart = kFixedRepeat - 1; 205 static const int kFixedRepeatStart = kFixedRepeat - 1;
210 206
207 // 0xf0..0xff unused.
vogelheim 2016/06/22 09:22:31 Just so I understand this... The whole point is to
Yang 2016/06/22 09:43:02 Yes. I have some ideas I want to play around with.
208
211 // ---------- special values ---------- 209 // ---------- special values ----------
212 static const int kAnyOldSpace = -1; 210 static const int kAnyOldSpace = -1;
213 211
214 // Sentinel after a new object to indicate that double alignment is needed. 212 // Sentinel after a new object to indicate that double alignment is needed.
215 static const int kDoubleAlignmentSentinel = 0; 213 static const int kDoubleAlignmentSentinel = 0;
216 214
217 // ---------- member variable ---------- 215 // ---------- member variable ----------
218 HotObjectsList hot_objects_; 216 HotObjectsList hot_objects_;
219 }; 217 };
220 218
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 276
279 byte* data_; 277 byte* data_;
280 int size_; 278 int size_;
281 bool owns_data_; 279 bool owns_data_;
282 }; 280 };
283 281
284 } // namespace internal 282 } // namespace internal
285 } // namespace v8 283 } // namespace v8
286 284
287 #endif // V8_SNAPSHOT_SERIALIZER_COMMON_H_ 285 #endif // V8_SNAPSHOT_SERIALIZER_COMMON_H_
OLDNEW
« src/snapshot/deserializer.cc ('K') | « src/snapshot/deserializer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698