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

Side by Side Diff: src/serialize.cc

Issue 293993021: Support external startup data in V8. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: review feedback Created 6 years, 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 #include "v8.h" 5 #include "v8.h"
6 6
7 #include "accessors.h" 7 #include "accessors.h"
8 #include "api.h" 8 #include "api.h"
9 #include "bootstrapper.h" 9 #include "bootstrapper.h"
10 #include "deoptimizer.h" 10 #include "deoptimizer.h"
11 #include "execution.h" 11 #include "execution.h"
12 #include "global-handles.h" 12 #include "global-handles.h"
13 #include "ic-inl.h" 13 #include "ic-inl.h"
14 #include "natives.h" 14 #include "natives.h"
15 #include "platform.h" 15 #include "platform.h"
16 #include "runtime.h" 16 #include "runtime.h"
17 #include "serialize.h" 17 #include "serialize.h"
18 #include "snapshot.h" 18 #include "snapshot.h"
19 #include "snapshot-source-sink.h"
Benedikt Meurer 2014/05/27 04:09:59 Nit: serialize.h already includes snapshout-source
vogelheim 2014/05/27 15:20:23 Done.
19 #include "stub-cache.h" 20 #include "stub-cache.h"
20 #include "v8threads.h" 21 #include "v8threads.h"
21 22
22 namespace v8 { 23 namespace v8 {
23 namespace internal { 24 namespace internal {
24 25
25 26
26 // ----------------------------------------------------------------------------- 27 // -----------------------------------------------------------------------------
27 // Coding of external references. 28 // Coding of external references.
28 29
(...skipping 1209 matching lines...) Expand 10 before | Expand all | Expand 10 after
1238 } 1239 }
1239 1240
1240 default: 1241 default:
1241 UNREACHABLE(); 1242 UNREACHABLE();
1242 } 1243 }
1243 } 1244 }
1244 ASSERT_EQ(limit, current); 1245 ASSERT_EQ(limit, current);
1245 } 1246 }
1246 1247
1247 1248
1248 void SnapshotByteSink::PutInt(uintptr_t integer, const char* description) {
1249 ASSERT(integer < 1 << 22);
1250 integer <<= 2;
1251 int bytes = 1;
1252 if (integer > 0xff) bytes = 2;
1253 if (integer > 0xffff) bytes = 3;
1254 integer |= bytes;
1255 Put(static_cast<int>(integer & 0xff), "IntPart1");
1256 if (bytes > 1) Put(static_cast<int>((integer >> 8) & 0xff), "IntPart2");
1257 if (bytes > 2) Put(static_cast<int>((integer >> 16) & 0xff), "IntPart3");
1258 }
1259
1260
1261 Serializer::Serializer(Isolate* isolate, SnapshotByteSink* sink) 1249 Serializer::Serializer(Isolate* isolate, SnapshotByteSink* sink)
1262 : isolate_(isolate), 1250 : isolate_(isolate),
1263 sink_(sink), 1251 sink_(sink),
1264 external_reference_encoder_(new ExternalReferenceEncoder(isolate)), 1252 external_reference_encoder_(new ExternalReferenceEncoder(isolate)),
1265 root_index_wave_front_(0) { 1253 root_index_wave_front_(0) {
1266 // The serializer is meant to be used only to generate initial heap images 1254 // The serializer is meant to be used only to generate initial heap images
1267 // from a context in which there is only one isolate. 1255 // from a context in which there is only one isolate.
1268 for (int i = 0; i <= LAST_SPACE; i++) { 1256 for (int i = 0; i <= LAST_SPACE; i++) {
1269 fullness_[i] = 0; 1257 fullness_[i] = 0;
1270 } 1258 }
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after
1856 1844
1857 void Serializer::Pad() { 1845 void Serializer::Pad() {
1858 // The non-branching GetInt will read up to 3 bytes too far, so we need 1846 // The non-branching GetInt will read up to 3 bytes too far, so we need
1859 // to pad the snapshot to make sure we don't read over the end. 1847 // to pad the snapshot to make sure we don't read over the end.
1860 for (unsigned i = 0; i < sizeof(int32_t) - 1; i++) { 1848 for (unsigned i = 0; i < sizeof(int32_t) - 1; i++) {
1861 sink_->Put(kNop, "Padding"); 1849 sink_->Put(kNop, "Padding");
1862 } 1850 }
1863 } 1851 }
1864 1852
1865 1853
1866 bool SnapshotByteSource::AtEOF() {
1867 if (0u + length_ - position_ > 2 * sizeof(uint32_t)) return false;
1868 for (int x = position_; x < length_; x++) {
1869 if (data_[x] != SerializerDeserializer::nop()) return false;
1870 }
1871 return true;
1872 }
1873
1874 } } // namespace v8::internal 1854 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698