| OLD | NEW |
| 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. |
| 2 // | 2 // |
| 3 // Tests of logging functions from log.h | 3 // Tests of logging functions from log.h |
| 4 | 4 |
| 5 #ifdef ENABLE_LOGGING_AND_PROFILING | 5 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 6 | 6 |
| 7 #include "v8.h" | 7 #include "v8.h" |
| 8 | 8 |
| 9 #include "log.h" | 9 #include "log.h" |
| 10 #include "cctest.h" | 10 #include "cctest.h" |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 namespace { | 256 namespace { |
| 257 | 257 |
| 258 // A code entity is a pointer to a position of code-creation event in buffer log | 258 // A code entity is a pointer to a position of code-creation event in buffer log |
| 259 // offset to a point where entity size begins, i.e.: '255,"func"\n'. This makes | 259 // offset to a point where entity size begins, i.e.: '255,"func"\n'. This makes |
| 260 // comparing code entities pretty easy. | 260 // comparing code entities pretty easy. |
| 261 typedef char* CodeEntityInfo; | 261 typedef char* CodeEntityInfo; |
| 262 | 262 |
| 263 class Interval { | 263 class Interval { |
| 264 public: | 264 public: |
| 265 Interval() | 265 Interval() |
| 266 : min_addr(reinterpret_cast<Address>(-1)), | 266 : min_addr_(reinterpret_cast<Address>(-1)), |
| 267 max_addr(reinterpret_cast<Address>(0)), next(NULL) {} | 267 max_addr_(reinterpret_cast<Address>(0)), next_(NULL) {} |
| 268 | 268 |
| 269 ~Interval() { delete next; } | 269 ~Interval() { delete next_; } |
| 270 | 270 |
| 271 size_t Length() { | 271 size_t Length() { |
| 272 size_t result = max_addr - min_addr + 1; | 272 size_t result = max_addr_ - min_addr_ + 1; |
| 273 if (next != NULL) result += next->Length(); | 273 if (next_ != NULL) result += next_->Length(); |
| 274 return result; | 274 return result; |
| 275 } | 275 } |
| 276 | 276 |
| 277 void CloneFrom(Interval* src) { | 277 void CloneFrom(Interval* src) { |
| 278 while (src != NULL) { | 278 while (src != NULL) { |
| 279 RegisterAddress(src->min_addr); | 279 RegisterAddress(src->min_addr_); |
| 280 RegisterAddress(src->max_addr); | 280 RegisterAddress(src->max_addr_); |
| 281 src = src->next; | 281 src = src->next_; |
| 282 } | 282 } |
| 283 } | 283 } |
| 284 | 284 |
| 285 bool Contains(Address addr) { | 285 bool Contains(Address addr) { |
| 286 if (min_addr <= addr && addr <= max_addr) { | 286 if (min_addr_ <= addr && addr <= max_addr_) { |
| 287 return true; | 287 return true; |
| 288 } | 288 } |
| 289 if (next != NULL) return next->Contains(addr); | 289 if (next_ != NULL) { |
| 290 return false; | 290 return next_->Contains(addr); |
| 291 } else { |
| 292 return false; |
| 293 } |
| 291 } | 294 } |
| 292 | 295 |
| 293 size_t GetIndex(Address addr) { | 296 size_t GetIndex(Address addr) { |
| 294 if (min_addr <= addr && addr <= max_addr) { | 297 if (min_addr_ <= addr && addr <= max_addr_) { |
| 295 return addr - min_addr; | 298 return addr - min_addr_; |
| 296 } | 299 } |
| 297 CHECK_NE(NULL, next); | 300 CHECK_NE(NULL, next_); |
| 298 return (max_addr - min_addr + 1) + next->GetIndex(addr); | 301 return (max_addr_ - min_addr_ + 1) + next_->GetIndex(addr); |
| 299 } | 302 } |
| 300 | 303 |
| 301 Address GetMinAddr() { | 304 Address GetMinAddr() { |
| 302 return next == NULL ? min_addr : i::Min(min_addr, next->GetMinAddr()); | 305 return next_ == NULL ? min_addr_ : i::Min(min_addr_, next_->GetMinAddr()); |
| 303 } | 306 } |
| 304 | 307 |
| 305 Address GetMaxAddr() { | 308 Address GetMaxAddr() { |
| 306 return next == NULL ? max_addr : i::Max(max_addr, next->GetMaxAddr()); | 309 return next_ == NULL ? max_addr_ : i::Max(max_addr_, next_->GetMaxAddr()); |
| 307 } | 310 } |
| 308 | 311 |
| 309 void RegisterAddress(Address addr) { | 312 void RegisterAddress(Address addr) { |
| 310 if (min_addr == reinterpret_cast<Address>(-1) | 313 if (min_addr_ == reinterpret_cast<Address>(-1) |
| 311 || (size_t)(addr > min_addr ? | 314 || (size_t)(addr > min_addr_ ? |
| 312 addr - min_addr : min_addr - addr) < MAX_DELTA) { | 315 addr - min_addr_ : min_addr_ - addr) < MAX_DELTA) { |
| 313 if (addr < min_addr) min_addr = addr; | 316 if (addr < min_addr_) min_addr_ = addr; |
| 314 if (addr > max_addr) max_addr = addr; | 317 if (addr > max_addr_) max_addr_ = addr; |
| 315 } else { | 318 } else { |
| 316 if (next == NULL) next = new Interval(); | 319 if (next_ == NULL) next_ = new Interval(); |
| 317 next->RegisterAddress(addr); | 320 next_->RegisterAddress(addr); |
| 318 } | 321 } |
| 319 } | 322 } |
| 320 | 323 |
| 321 Address raw_min_addr() { return min_addr; } | 324 Address raw_min_addr() { return min_addr_; } |
| 322 | 325 |
| 323 Address raw_max_addr() { return max_addr; } | 326 Address raw_max_addr() { return max_addr_; } |
| 324 | 327 |
| 325 Interval* get_next() { return next; } | 328 Interval* get_next() { return next_; } |
| 326 | 329 |
| 327 private: | 330 private: |
| 328 static const size_t MAX_DELTA = 0x100000; | 331 static const size_t MAX_DELTA = 0x100000; |
| 329 Address min_addr; | 332 Address min_addr_; |
| 330 Address max_addr; | 333 Address max_addr_; |
| 331 Interval* next; | 334 Interval* next_; |
| 332 }; | 335 }; |
| 333 | 336 |
| 334 | 337 |
| 335 // A structure used to return log parsing results. | 338 // A structure used to return log parsing results. |
| 336 class ParseLogResult { | 339 class ParseLogResult { |
| 337 public: | 340 public: |
| 338 ParseLogResult() | 341 ParseLogResult() |
| 339 : entities_map(NULL), entities(NULL), | 342 : entities_map(NULL), entities(NULL), |
| 340 max_entities(0) {} | 343 max_entities(0) {} |
| 341 | 344 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 Address ConsumeAddress(char** start) { | 391 Address ConsumeAddress(char** start) { |
| 389 char* end_ptr; | 392 char* end_ptr; |
| 390 Address addr = | 393 Address addr = |
| 391 reinterpret_cast<Address>(strtoul(*start, &end_ptr, 16)); // NOLINT | 394 reinterpret_cast<Address>(strtoul(*start, &end_ptr, 16)); // NOLINT |
| 392 CHECK(HasIndexForAddress(addr)); | 395 CHECK(HasIndexForAddress(addr)); |
| 393 *start = end_ptr; | 396 *start = end_ptr; |
| 394 return addr; | 397 return addr; |
| 395 } | 398 } |
| 396 | 399 |
| 397 Interval bounds; | 400 Interval bounds; |
| 398 // Memory map of entities start addresses. Biased by bounds.min_addr. | 401 // Memory map of entities start addresses. |
| 399 int* entities_map; | 402 int* entities_map; |
| 400 // An array of code entities. | 403 // An array of code entities. |
| 401 CodeEntityInfo* entities; | 404 CodeEntityInfo* entities; |
| 402 // Maximal entities count. Actual entities count can be lower, | 405 // Maximal entities count. Actual entities count can be lower, |
| 403 // empty entity slots are pointing to NULL. | 406 // empty entity slots are pointing to NULL. |
| 404 int max_entities; | 407 int max_entities; |
| 405 }; | 408 }; |
| 406 | 409 |
| 407 } // namespace | 410 } // namespace |
| 408 | 411 |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 696 fflush(stdout); | 699 fflush(stdout); |
| 697 CHECK(results_equal); | 700 CHECK(results_equal); |
| 698 | 701 |
| 699 env->Exit(); | 702 env->Exit(); |
| 700 Logger::TearDown(); | 703 Logger::TearDown(); |
| 701 i::FLAG_always_compact = saved_always_compact; | 704 i::FLAG_always_compact = saved_always_compact; |
| 702 } | 705 } |
| 703 | 706 |
| 704 | 707 |
| 705 #endif // ENABLE_LOGGING_AND_PROFILING | 708 #endif // ENABLE_LOGGING_AND_PROFILING |
| OLD | NEW |