OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 } | 51 } |
52 | 52 |
53 static void AddNumber(v8::Local<v8::Object> object, | 53 static void AddNumber(v8::Local<v8::Object> object, |
54 intptr_t value, | 54 intptr_t value, |
55 const char* name) { | 55 const char* name) { |
56 object->Set(v8::String::New(name), | 56 object->Set(v8::String::New(name), |
57 v8::Number::New(static_cast<double>(value))); | 57 v8::Number::New(static_cast<double>(value))); |
58 } | 58 } |
59 | 59 |
60 | 60 |
| 61 static void AddNumber64(v8::Local<v8::Object> object, |
| 62 int64_t value, |
| 63 const char* name) { |
| 64 object->Set(v8::String::New(name), |
| 65 v8::Number::New(static_cast<double>(value))); |
| 66 } |
| 67 |
| 68 |
61 void StatisticsExtension::GetCounters( | 69 void StatisticsExtension::GetCounters( |
62 const v8::FunctionCallbackInfo<v8::Value>& args) { | 70 const v8::FunctionCallbackInfo<v8::Value>& args) { |
63 Isolate* isolate = reinterpret_cast<Isolate*>(args.GetIsolate()); | 71 Isolate* isolate = reinterpret_cast<Isolate*>(args.GetIsolate()); |
64 Heap* heap = isolate->heap(); | 72 Heap* heap = isolate->heap(); |
65 | 73 |
66 if (args.Length() > 0) { // GC if first argument evaluates to true. | 74 if (args.Length() > 0) { // GC if first argument evaluates to true. |
67 if (args[0]->IsBoolean() && args[0]->ToBoolean()->Value()) { | 75 if (args[0]->IsBoolean() && args[0]->ToBoolean()->Value()) { |
68 heap->CollectAllGarbage(Heap::kNoGCFlags, "counters extension"); | 76 heap->CollectAllGarbage(Heap::kNoGCFlags, "counters extension"); |
69 } | 77 } |
70 } | 78 } |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 AddNumber(result, heap->property_cell_space()->Available(), | 146 AddNumber(result, heap->property_cell_space()->Available(), |
139 "property_cell_space_available_bytes"); | 147 "property_cell_space_available_bytes"); |
140 AddNumber(result, heap->property_cell_space()->CommittedMemory(), | 148 AddNumber(result, heap->property_cell_space()->CommittedMemory(), |
141 "property_cell_space_commited_bytes"); | 149 "property_cell_space_commited_bytes"); |
142 AddNumber(result, heap->lo_space()->Size(), | 150 AddNumber(result, heap->lo_space()->Size(), |
143 "lo_space_live_bytes"); | 151 "lo_space_live_bytes"); |
144 AddNumber(result, heap->lo_space()->Available(), | 152 AddNumber(result, heap->lo_space()->Available(), |
145 "lo_space_available_bytes"); | 153 "lo_space_available_bytes"); |
146 AddNumber(result, heap->lo_space()->CommittedMemory(), | 154 AddNumber(result, heap->lo_space()->CommittedMemory(), |
147 "lo_space_commited_bytes"); | 155 "lo_space_commited_bytes"); |
148 AddNumber(result, heap->amount_of_external_allocated_memory(), | 156 AddNumber64(result, heap->amount_of_external_allocated_memory(), |
149 "amount_of_external_allocated_memory"); | 157 "amount_of_external_allocated_memory"); |
150 args.GetReturnValue().Set(result); | 158 args.GetReturnValue().Set(result); |
151 } | 159 } |
152 | 160 |
153 | 161 |
154 void StatisticsExtension::Register() { | 162 void StatisticsExtension::Register() { |
155 static StatisticsExtension statistics_extension; | 163 static StatisticsExtension statistics_extension; |
156 static v8::DeclareExtension declaration(&statistics_extension); | 164 static v8::DeclareExtension declaration(&statistics_extension); |
157 } | 165 } |
158 | 166 |
159 } } // namespace v8::internal | 167 } } // namespace v8::internal |
OLD | NEW |