From ea700a8851023a1967083f22daa40f4c7a4366bf Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Thu, 16 Dec 2010 11:52:08 -0800 Subject: Upgrade V8 to 3.0.2 --- deps/v8/src/log-utils.h | 64 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 63 insertions(+), 1 deletion(-) (limited to 'deps/v8/src/log-utils.h') diff --git a/deps/v8/src/log-utils.h b/deps/v8/src/log-utils.h index 719d37030e..ffea9282cb 100644 --- a/deps/v8/src/log-utils.h +++ b/deps/v8/src/log-utils.h @@ -176,6 +176,50 @@ class Log : public AllStatic { friend class Logger; friend class LogMessageBuilder; + friend class LogRecordCompressor; +}; + + +// An utility class for performing backward reference compression +// of string ends. It operates using a window of previous strings. +class LogRecordCompressor { + public: + // 'window_size' is the size of backward lookup window. + explicit LogRecordCompressor(int window_size) + : buffer_(window_size + kNoCompressionWindowSize), + kMaxBackwardReferenceSize( + GetBackwardReferenceSize(window_size, Log::kMessageBufferSize)), + curr_(-1), prev_(-1) { + } + + ~LogRecordCompressor(); + + // Fills vector with a compressed version of the previous record. + // Returns false if there is no previous record. + bool RetrievePreviousCompressed(Vector* prev_record); + + // Stores a record if it differs from a previous one (or there's no previous). + // Returns true, if the record has been stored. + bool Store(const Vector& record); + + private: + // The minimum size of a buffer: a place needed for the current and + // the previous record. Since there is no place for precedessors of a previous + // record, it can't be compressed at all. + static const int kNoCompressionWindowSize = 2; + + // Formatting strings for back references. + static const char* kLineBackwardReferenceFormat; + static const char* kBackwardReferenceFormat; + + static int GetBackwardReferenceSize(int distance, int pos); + + static void PrintBackwardReference(Vector dest, int distance, int pos); + + ScopedVector< Vector > buffer_; + const int kMaxBackwardReferenceSize; + int curr_; + int prev_; }; @@ -200,14 +244,32 @@ class LogMessageBuilder BASE_EMBEDDED { // Append a heap string. void Append(String* str); - // Appends an address. + // Appends an address, compressing it if needed by offsetting + // from Logger::last_address_. void AppendAddress(Address addr); + // Appends an address, compressing it if needed. + void AppendAddress(Address addr, Address bias); + void AppendDetailed(String* str, bool show_impl_info); // Append a portion of a string. void AppendStringPart(const char* str, int len); + // Stores log message into compressor, returns true if the message + // was stored (i.e. doesn't repeat the previous one). + bool StoreInCompressor(LogRecordCompressor* compressor); + + // Sets log message to a previous version of compressed message. + // Returns false, if there is no previous message. + bool RetrieveCompressedPrevious(LogRecordCompressor* compressor) { + return RetrieveCompressedPrevious(compressor, ""); + } + + // Does the same at the version without arguments, and sets a prefix. + bool RetrieveCompressedPrevious(LogRecordCompressor* compressor, + const char* prefix); + // Write the log message to the log file currently opened. void WriteToLogFile(); -- cgit v1.2.1