OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 25 matching lines...) Expand all Loading... |
36 | 36 |
37 #include "bootstrapper.h" | 37 #include "bootstrapper.h" |
38 #include "flags.h" | 38 #include "flags.h" |
39 #include "natives.h" | 39 #include "natives.h" |
40 #include "platform.h" | 40 #include "platform.h" |
41 #include "serialize.h" | 41 #include "serialize.h" |
42 #include "list.h" | 42 #include "list.h" |
43 | 43 |
44 using namespace v8; | 44 using namespace v8; |
45 | 45 |
46 static const unsigned int kMaxCounters = 256; | |
47 | |
48 // A single counter in a counter collection. | |
49 class Counter { | |
50 public: | |
51 static const int kMaxNameSize = 64; | |
52 int32_t* Bind(const char* name) { | |
53 int i; | |
54 for (i = 0; i < kMaxNameSize - 1 && name[i]; i++) { | |
55 name_[i] = name[i]; | |
56 } | |
57 name_[i] = '\0'; | |
58 return &counter_; | |
59 } | |
60 private: | |
61 int32_t counter_; | |
62 uint8_t name_[kMaxNameSize]; | |
63 }; | |
64 | |
65 | |
66 // A set of counters and associated information. An instance of this | |
67 // class is stored directly in the memory-mapped counters file if | |
68 // the --save-counters options is used | |
69 class CounterCollection { | |
70 public: | |
71 CounterCollection() { | |
72 magic_number_ = 0xDEADFACE; | |
73 max_counters_ = kMaxCounters; | |
74 max_name_size_ = Counter::kMaxNameSize; | |
75 counters_in_use_ = 0; | |
76 } | |
77 Counter* GetNextCounter() { | |
78 if (counters_in_use_ == kMaxCounters) return NULL; | |
79 return &counters_[counters_in_use_++]; | |
80 } | |
81 private: | |
82 uint32_t magic_number_; | |
83 uint32_t max_counters_; | |
84 uint32_t max_name_size_; | |
85 uint32_t counters_in_use_; | |
86 Counter counters_[kMaxCounters]; | |
87 }; | |
88 | |
89 | 46 |
90 class Compressor { | 47 class Compressor { |
91 public: | 48 public: |
92 virtual ~Compressor() {} | 49 virtual ~Compressor() {} |
93 virtual bool Compress(i::Vector<char> input) = 0; | 50 virtual bool Compress(i::Vector<char> input) = 0; |
94 virtual i::Vector<char>* output() = 0; | 51 virtual i::Vector<char>* output() = 0; |
95 }; | 52 }; |
96 | 53 |
97 | 54 |
98 class PartialSnapshotSink : public i::SnapshotByteSink { | 55 class PartialSnapshotSink : public i::SnapshotByteSink { |
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
437 "", | 394 "", |
438 ser.CurrentAllocationAddress(i::NEW_SPACE), | 395 ser.CurrentAllocationAddress(i::NEW_SPACE), |
439 ser.CurrentAllocationAddress(i::OLD_POINTER_SPACE), | 396 ser.CurrentAllocationAddress(i::OLD_POINTER_SPACE), |
440 ser.CurrentAllocationAddress(i::OLD_DATA_SPACE), | 397 ser.CurrentAllocationAddress(i::OLD_DATA_SPACE), |
441 ser.CurrentAllocationAddress(i::CODE_SPACE), | 398 ser.CurrentAllocationAddress(i::CODE_SPACE), |
442 ser.CurrentAllocationAddress(i::MAP_SPACE), | 399 ser.CurrentAllocationAddress(i::MAP_SPACE), |
443 ser.CurrentAllocationAddress(i::CELL_SPACE), | 400 ser.CurrentAllocationAddress(i::CELL_SPACE), |
444 ser.CurrentAllocationAddress(i::PROPERTY_CELL_SPACE)); | 401 ser.CurrentAllocationAddress(i::PROPERTY_CELL_SPACE)); |
445 return 0; | 402 return 0; |
446 } | 403 } |
OLD | NEW |