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

Side by Side Diff: src/serialize.h

Issue 435003: Patch for allowing several V8 instances in process:... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years 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
« no previous file with comments | « src/scopeinfo.cc ('k') | src/serialize.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. 1 // Copyright 2006-2009 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 class SnapshotByteSink { 282 class SnapshotByteSink {
283 public: 283 public:
284 virtual ~SnapshotByteSink() { } 284 virtual ~SnapshotByteSink() { }
285 virtual void Put(int byte, const char* description) = 0; 285 virtual void Put(int byte, const char* description) = 0;
286 virtual void PutSection(int byte, const char* description) { 286 virtual void PutSection(int byte, const char* description) {
287 Put(byte, description); 287 Put(byte, description);
288 } 288 }
289 void PutInt(uintptr_t integer, const char* description); 289 void PutInt(uintptr_t integer, const char* description);
290 }; 290 };
291 291
292 class SerializerPrivateData;
293
294 class SerializerData {
295 public:
296 SerializerPrivateData& private_data_;
297 private:
298 bool serialization_enabled_;
299 // Did we already make use of the fact that serialization was not enabled?
300 bool too_late_to_enable_now_;
301
302 SerializerData();
303 ~SerializerData();
304
305 friend class V8Context;
306 friend class Serializer;
307 DISALLOW_COPY_AND_ASSIGN(SerializerData);
308 };
292 309
293 class Serializer : public SerDes { 310 class Serializer : public SerDes {
294 public: 311 public:
295 explicit Serializer(SnapshotByteSink* sink); 312 explicit Serializer(SnapshotByteSink* sink);
296 // Serialize the current state of the heap. This operation destroys the 313 // Serialize the current state of the heap. This operation destroys the
297 // heap contents. 314 // heap contents.
298 void Serialize(); 315 void Serialize();
299 void VisitPointers(Object** start, Object** end); 316 void VisitPointers(Object** start, Object** end);
300 317
301 static void Enable() { 318 static void Enable() {
302 if (!serialization_enabled_) { 319 SerializerData& serializer_data = v8_context()->serializer_data_;
303 ASSERT(!too_late_to_enable_now_); 320 if (!serializer_data.serialization_enabled_) {
321 ASSERT(!serializer_data.too_late_to_enable_now_);
304 } 322 }
305 serialization_enabled_ = true; 323 serializer_data.serialization_enabled_ = true;
306 } 324 }
307 325
308 static void Disable() { serialization_enabled_ = false; } 326 static void Disable() {
327 v8_context()->serializer_data_.serialization_enabled_ = false;
328 }
309 // Call this when you have made use of the fact that there is no serialization 329 // Call this when you have made use of the fact that there is no serialization
310 // going on. 330 // going on.
311 static void TooLateToEnableNow() { too_late_to_enable_now_ = true; } 331 static void TooLateToEnableNow() {
312 static bool enabled() { return serialization_enabled_; } 332 v8_context()->serializer_data_.too_late_to_enable_now_ = true;
333 }
334 static bool enabled() {
335 return v8_context()->serializer_data_.serialization_enabled_;
336 }
313 #ifdef DEBUG 337 #ifdef DEBUG
314 virtual void Synchronize(const char* tag); 338 virtual void Synchronize(const char* tag);
315 #endif 339 #endif
316 340
317 private: 341 private:
318 enum ReferenceRepresentation { 342 enum ReferenceRepresentation {
319 TAGGED_REPRESENTATION, // A tagged object reference. 343 TAGGED_REPRESENTATION, // A tagged object reference.
320 CODE_TARGET_REPRESENTATION // A reference to first instruction in target. 344 CODE_TARGET_REPRESENTATION // A reference to first instruction in target.
321 }; 345 };
322 class ObjectSerializer : public ObjectVisitor { 346 class ObjectSerializer : public ObjectVisitor {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 } 399 }
376 400
377 // Keep track of the fullness of each space in order to generate 401 // Keep track of the fullness of each space in order to generate
378 // relative addresses for back references. Large objects are 402 // relative addresses for back references. Large objects are
379 // just numbered sequentially since relative addresses make no 403 // just numbered sequentially since relative addresses make no
380 // sense in large object space. 404 // sense in large object space.
381 int fullness_[LAST_SPACE + 1]; 405 int fullness_[LAST_SPACE + 1];
382 SnapshotByteSink* sink_; 406 SnapshotByteSink* sink_;
383 int current_root_index_; 407 int current_root_index_;
384 ExternalReferenceEncoder* external_reference_encoder_; 408 ExternalReferenceEncoder* external_reference_encoder_;
385 static bool serialization_enabled_;
386 // Did we already make use of the fact that serialization was not enabled?
387 static bool too_late_to_enable_now_;
388
389 friend class ObjectSerializer; 409 friend class ObjectSerializer;
390 friend class Deserializer; 410 friend class Deserializer;
391 411
392 DISALLOW_COPY_AND_ASSIGN(Serializer); 412 DISALLOW_COPY_AND_ASSIGN(Serializer);
393 }; 413 };
394 414
395 } } // namespace v8::internal 415 } } // namespace v8::internal
396 416
397 #endif // V8_SERIALIZE_H_ 417 #endif // V8_SERIALIZE_H_
OLDNEW
« no previous file with comments | « src/scopeinfo.cc ('k') | src/serialize.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698