Kill some unused code.
It doesn't mean I'm participating in some fixit, just spotted some code which doesn't have usages and decided to remove it. Review URL: http://codereview.chromium.org/646007 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3896 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
70c7e513af
commit
b740dea517
@ -351,15 +351,6 @@ void LogMessageBuilder::WriteToLogFile() {
|
||||
}
|
||||
|
||||
|
||||
void LogMessageBuilder::WriteCStringToLogFile(const char* str) {
|
||||
const int len = StrLength(str);
|
||||
const int written = Log::Write(str, len);
|
||||
if (written != len && write_failure_handler != NULL) {
|
||||
write_failure_handler();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Formatting string for back references to the whole line. E.g. "#2" means
|
||||
// "the second line above".
|
||||
const char* LogRecordCompressor::kLineBackwardReferenceFormat = "#%d";
|
||||
|
@ -268,9 +268,6 @@ class LogMessageBuilder BASE_EMBEDDED {
|
||||
// Write the log message to the log file currently opened.
|
||||
void WriteToLogFile();
|
||||
|
||||
// Write a null-terminated string to to the log file currently opened.
|
||||
void WriteCStringToLogFile(const char* str);
|
||||
|
||||
// A handler that is called when Log::Write fails.
|
||||
typedef void (*WriteFailureHandler)();
|
||||
|
||||
|
@ -370,15 +370,6 @@ void Logger::LogAliases() {
|
||||
#endif // ENABLE_LOGGING_AND_PROFILING
|
||||
|
||||
|
||||
void Logger::Preamble(const char* content) {
|
||||
#ifdef ENABLE_LOGGING_AND_PROFILING
|
||||
if (!Log::IsEnabled() || !FLAG_log_code) return;
|
||||
LogMessageBuilder msg;
|
||||
msg.WriteCStringToLogFile(content);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void Logger::StringEvent(const char* name, const char* value) {
|
||||
#ifdef ENABLE_LOGGING_AND_PROFILING
|
||||
if (FLAG_log) UncheckedStringEvent(name, value);
|
||||
|
@ -161,12 +161,6 @@ class Logger {
|
||||
// Enable the computation of a sliding window of states.
|
||||
static void EnableSlidingStateWindow();
|
||||
|
||||
// Write a raw string to the log to be used as a preamble.
|
||||
// No check is made that the 'preamble' is actually at the beginning
|
||||
// of the log. The preample is used to write code events saved in the
|
||||
// snapshot.
|
||||
static void Preamble(const char* content);
|
||||
|
||||
// Emits an event with a string value -> (name, value).
|
||||
static void StringEvent(const char* name, const char* value);
|
||||
|
||||
|
37
src/utils.cc
37
src/utils.cc
@ -51,43 +51,6 @@ uint32_t RoundUpToPowerOf2(uint32_t x) {
|
||||
}
|
||||
|
||||
|
||||
byte* EncodeInt(byte* p, int x) {
|
||||
while (x < -64 || x >= 64) {
|
||||
*p++ = static_cast<byte>(x & 127);
|
||||
x = ArithmeticShiftRight(x, 7);
|
||||
}
|
||||
// -64 <= x && x < 64
|
||||
*p++ = static_cast<byte>(x + 192);
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
byte* DecodeInt(byte* p, int* x) {
|
||||
int r = 0;
|
||||
unsigned int s = 0;
|
||||
byte b = *p++;
|
||||
while (b < 128) {
|
||||
r |= static_cast<int>(b) << s;
|
||||
s += 7;
|
||||
b = *p++;
|
||||
}
|
||||
// b >= 128
|
||||
*x = r | ((static_cast<int>(b) - 192) << s);
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
byte* EncodeUnsignedIntBackward(byte* p, unsigned int x) {
|
||||
while (x >= 128) {
|
||||
*--p = static_cast<byte>(x & 127);
|
||||
x = x >> 7;
|
||||
}
|
||||
// x < 128
|
||||
*--p = static_cast<byte>(x + 128);
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
// Thomas Wang, Integer Hash Functions.
|
||||
// http://www.concentric.net/~Ttwang/tech/inthash.htm
|
||||
uint32_t ComputeIntegerHash(uint32_t key) {
|
||||
|
42
src/utils.h
42
src/utils.h
@ -173,48 +173,6 @@ class BitField {
|
||||
};
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Support for compressed, machine-independent encoding
|
||||
// and decoding of integer values of arbitrary size.
|
||||
|
||||
// Encoding and decoding from/to a buffer at position p;
|
||||
// the result is the position after the encoded integer.
|
||||
// Small signed integers in the range -64 <= x && x < 64
|
||||
// are encoded in 1 byte; larger values are encoded in 2
|
||||
// or more bytes. At most sizeof(int) + 1 bytes are used
|
||||
// in the worst case.
|
||||
byte* EncodeInt(byte* p, int x);
|
||||
byte* DecodeInt(byte* p, int* x);
|
||||
|
||||
|
||||
// Encoding and decoding from/to a buffer at position p - 1
|
||||
// moving backward; the result is the position of the last
|
||||
// byte written. These routines are useful to read/write
|
||||
// into a buffer starting at the end of the buffer.
|
||||
byte* EncodeUnsignedIntBackward(byte* p, unsigned int x);
|
||||
|
||||
// The decoding function is inlined since its performance is
|
||||
// important to mark-sweep garbage collection.
|
||||
inline byte* DecodeUnsignedIntBackward(byte* p, unsigned int* x) {
|
||||
byte b = *--p;
|
||||
if (b >= 128) {
|
||||
*x = static_cast<unsigned int>(b) - 128;
|
||||
return p;
|
||||
}
|
||||
unsigned int r = static_cast<unsigned int>(b);
|
||||
unsigned int s = 7;
|
||||
b = *--p;
|
||||
while (b < 128) {
|
||||
r |= static_cast<unsigned int>(b) << s;
|
||||
s += 7;
|
||||
b = *--p;
|
||||
}
|
||||
// b >= 128
|
||||
*x = r | ((static_cast<unsigned int>(b) - 128) << s);
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Hash function.
|
||||
|
||||
|
@ -35,111 +35,6 @@
|
||||
using namespace v8::internal;
|
||||
|
||||
|
||||
enum Mode {
|
||||
forward,
|
||||
backward_unsigned
|
||||
};
|
||||
|
||||
|
||||
static v8::internal::byte* Write(v8::internal::byte* p, Mode m, int x) {
|
||||
v8::internal::byte* q = NULL;
|
||||
switch (m) {
|
||||
case forward:
|
||||
q = EncodeInt(p, x);
|
||||
CHECK(q <= p + sizeof(x) + 1);
|
||||
break;
|
||||
case backward_unsigned:
|
||||
q = EncodeUnsignedIntBackward(p, x);
|
||||
CHECK(q >= p - sizeof(x) - 1);
|
||||
break;
|
||||
}
|
||||
return q;
|
||||
}
|
||||
|
||||
|
||||
static v8::internal::byte* Read(v8::internal::byte* p, Mode m, int x) {
|
||||
v8::internal::byte* q = NULL;
|
||||
int y;
|
||||
switch (m) {
|
||||
case forward:
|
||||
q = DecodeInt(p, &y);
|
||||
CHECK(q <= p + sizeof(y) + 1);
|
||||
break;
|
||||
case backward_unsigned: {
|
||||
unsigned int uy;
|
||||
q = DecodeUnsignedIntBackward(p, &uy);
|
||||
y = uy;
|
||||
CHECK(q >= p - sizeof(uy) - 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
CHECK(y == x);
|
||||
return q;
|
||||
}
|
||||
|
||||
|
||||
static v8::internal::byte* WriteMany(v8::internal::byte* p, Mode m, int x) {
|
||||
p = Write(p, m, x - 7);
|
||||
p = Write(p, m, x - 1);
|
||||
p = Write(p, m, x);
|
||||
p = Write(p, m, x + 1);
|
||||
p = Write(p, m, x + 2);
|
||||
p = Write(p, m, -x - 5);
|
||||
p = Write(p, m, -x - 1);
|
||||
p = Write(p, m, -x);
|
||||
p = Write(p, m, -x + 1);
|
||||
p = Write(p, m, -x + 3);
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
static v8::internal::byte* ReadMany(v8::internal::byte* p, Mode m, int x) {
|
||||
p = Read(p, m, x - 7);
|
||||
p = Read(p, m, x - 1);
|
||||
p = Read(p, m, x);
|
||||
p = Read(p, m, x + 1);
|
||||
p = Read(p, m, x + 2);
|
||||
p = Read(p, m, -x - 5);
|
||||
p = Read(p, m, -x - 1);
|
||||
p = Read(p, m, -x);
|
||||
p = Read(p, m, -x + 1);
|
||||
p = Read(p, m, -x + 3);
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
void ProcessValues(int* values, int n, Mode m) {
|
||||
v8::internal::byte buf[4 * KB]; // make this big enough
|
||||
v8::internal::byte* p0 = (m == forward ? buf : buf + ARRAY_SIZE(buf));
|
||||
|
||||
v8::internal::byte* p = p0;
|
||||
for (int i = 0; i < n; i++) {
|
||||
p = WriteMany(p, m, values[i]);
|
||||
}
|
||||
|
||||
v8::internal::byte* q = p0;
|
||||
for (int i = 0; i < n; i++) {
|
||||
q = ReadMany(q, m, values[i]);
|
||||
}
|
||||
|
||||
CHECK(p == q);
|
||||
}
|
||||
|
||||
|
||||
TEST(Utils0) {
|
||||
int values[] = {
|
||||
0, 1, 10, 16, 32, 64, 128, 256, 512, 1024, 1234, 5731,
|
||||
10000, 100000, 1000000, 10000000, 100000000, 1000000000
|
||||
};
|
||||
const int n = ARRAY_SIZE(values);
|
||||
|
||||
ProcessValues(values, n, forward);
|
||||
ProcessValues(values, n, backward_unsigned);
|
||||
}
|
||||
|
||||
|
||||
TEST(Utils1) {
|
||||
CHECK_EQ(-1000000, FastD2I(-1000000.0));
|
||||
CHECK_EQ(-1, FastD2I(-1.0));
|
||||
|
Loading…
Reference in New Issue
Block a user