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

Unified Diff: src/serialize.h

Issue 564035: Remove lazy loading of natives files and the natives cache.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/partial_snapshots/
Patch Set: Created 10 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/runtime.cc ('k') | src/serialize.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/serialize.h
===================================================================
--- src/serialize.h (revision 3777)
+++ src/serialize.h (working copy)
@@ -120,28 +120,9 @@
return data_[position_++];
}
- void CopyRaw(byte* to, int number_of_bytes) {
- memcpy(to, data_ + position_, number_of_bytes);
- position_ += number_of_bytes;
- }
+ inline void CopyRaw(byte* to, int number_of_bytes);
- int GetInt() {
- // A little unwind to catch the really small ints.
- int snapshot_byte = Get();
- if ((snapshot_byte & 0x80) == 0) {
- return snapshot_byte;
- }
- int accumulator = (snapshot_byte & 0x7f) << 7;
- while (true) {
- snapshot_byte = Get();
- if ((snapshot_byte & 0x80) == 0) {
- return accumulator | snapshot_byte;
- }
- accumulator = (accumulator | (snapshot_byte & 0x7f)) << 7;
- }
- UNREACHABLE();
- return accumulator;
- }
+ inline int GetInt();
bool AtEOF() {
return position_ == length_;
@@ -192,6 +173,21 @@
public:
static void Iterate(ObjectVisitor* visitor);
static void SetSnapshotCacheSize(int size);
+#ifdef DEBUG
+ static void StartTracing() { tracing_ = true; }
+ static void StopTracing() { tracing_ = false; }
+ static void Trace(const char *msg, int arg) { if (tracing_) printf("%s %d\n", msg, arg); }
+ static void Trace(const char *msg, const char* arg) { if (tracing_) printf("%s %s\n", msg, arg); }
+ static void Trace(const char *msg, const char* arg1, int arg2) { if (tracing_) printf("%s %s %d\n", msg, arg1, arg2); }
+ static bool tracing() { return tracing_; }
+#else
+ static void StartTracing() { }
+ static void StopTracing() { }
+ static void Trace(const char *msg, int arg) { }
+ static void Trace(const char *msg, const char* arg) { }
+ static void Trace(const char *msg, const char* arg1, int arg2) { }
+ static bool tracing() { return false; }
+#endif
protected:
enum DataType {
@@ -237,10 +233,44 @@
static int partial_snapshot_cache_length_;
static const int kPartialSnapshotCacheCapacity = 1024;
static Object* partial_snapshot_cache_[];
+ static bool tracing_;
};
+int SnapshotByteSource::GetInt() {
+ // A little unwind to catch the really small ints.
+ int snapshot_byte = Get();
+ if ((snapshot_byte & 0x80) == 0) {
+ SerializerDeserializer::Trace("Tag IntLastPart", snapshot_byte);
+ return snapshot_byte;
+ }
+ SerializerDeserializer::Trace("Tag IntPart", snapshot_byte);
+ int accumulator = (snapshot_byte & 0x7f) << 7;
+ while (true) {
+ snapshot_byte = Get();
+ if ((snapshot_byte & 0x80) == 0) {
+ SerializerDeserializer::Trace("Tag IntLastPart", snapshot_byte);
+ return accumulator | snapshot_byte;
+ }
+ SerializerDeserializer::Trace("Tag IntPart", snapshot_byte);
+ accumulator = (accumulator | (snapshot_byte & 0x7f)) << 7;
+ }
+ UNREACHABLE();
+ return accumulator;
+}
+
+void SnapshotByteSource::CopyRaw(byte* to, int number_of_bytes) {
+ if (SerializerDeserializer::tracing()) {
+ for (int i = 0; i < number_of_bytes; i++) {
+ SerializerDeserializer::Trace("Tag Byte", data_[position_ + i]);
+ }
+ }
+ memcpy(to, data_ + position_, number_of_bytes);
+ position_ += number_of_bytes;
+}
+
+
// A Deserializer reads a snapshot and reconstructs the Object graph it defines.
class Deserializer: public SerializerDeserializer {
public:
@@ -530,6 +560,7 @@
}
};
+
} } // namespace v8::internal
#endif // V8_SERIALIZE_H_
« no previous file with comments | « src/runtime.cc ('k') | src/serialize.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698