OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/extensions/statistics-extension.h" | 5 #include "src/extensions/statistics-extension.h" |
6 | 6 |
7 namespace v8 { | 7 namespace v8 { |
8 namespace internal { | 8 namespace internal { |
9 | 9 |
10 const char* const StatisticsExtension::kSource = | 10 const char* const StatisticsExtension::kSource = |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 v8::Number::New(isolate, static_cast<double>(value))); | 46 v8::Number::New(isolate, static_cast<double>(value))); |
47 } | 47 } |
48 | 48 |
49 | 49 |
50 void StatisticsExtension::GetCounters( | 50 void StatisticsExtension::GetCounters( |
51 const v8::FunctionCallbackInfo<v8::Value>& args) { | 51 const v8::FunctionCallbackInfo<v8::Value>& args) { |
52 Isolate* isolate = reinterpret_cast<Isolate*>(args.GetIsolate()); | 52 Isolate* isolate = reinterpret_cast<Isolate*>(args.GetIsolate()); |
53 Heap* heap = isolate->heap(); | 53 Heap* heap = isolate->heap(); |
54 | 54 |
55 if (args.Length() > 0) { // GC if first argument evaluates to true. | 55 if (args.Length() > 0) { // GC if first argument evaluates to true. |
56 if (args[0]->IsBoolean() && args[0]->ToBoolean()->Value()) { | 56 if (args[0]->IsBoolean() && |
| 57 args[0]->ToBoolean(args.GetIsolate())->Value()) { |
57 heap->CollectAllGarbage(Heap::kNoGCFlags, "counters extension"); | 58 heap->CollectAllGarbage(Heap::kNoGCFlags, "counters extension"); |
58 } | 59 } |
59 } | 60 } |
60 | 61 |
61 Counters* counters = isolate->counters(); | 62 Counters* counters = isolate->counters(); |
62 v8::Local<v8::Object> result = v8::Object::New(args.GetIsolate()); | 63 v8::Local<v8::Object> result = v8::Object::New(args.GetIsolate()); |
63 | 64 |
64 #define ADD_COUNTER(name, caption) \ | 65 #define ADD_COUNTER(name, caption) \ |
65 AddCounter(args.GetIsolate(), result, counters->name(), #name); | 66 AddCounter(args.GetIsolate(), result, counters->name(), #name); |
66 | 67 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 "lo_space_available_bytes"); | 142 "lo_space_available_bytes"); |
142 AddNumber(args.GetIsolate(), result, heap->lo_space()->CommittedMemory(), | 143 AddNumber(args.GetIsolate(), result, heap->lo_space()->CommittedMemory(), |
143 "lo_space_commited_bytes"); | 144 "lo_space_commited_bytes"); |
144 AddNumber64(args.GetIsolate(), result, | 145 AddNumber64(args.GetIsolate(), result, |
145 heap->amount_of_external_allocated_memory(), | 146 heap->amount_of_external_allocated_memory(), |
146 "amount_of_external_allocated_memory"); | 147 "amount_of_external_allocated_memory"); |
147 args.GetReturnValue().Set(result); | 148 args.GetReturnValue().Set(result); |
148 } | 149 } |
149 | 150 |
150 } } // namespace v8::internal | 151 } } // namespace v8::internal |
OLD | NEW |