Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(654)

Side by Side Diff: src/extensions/statistics-extension.cc

Issue 119753008: Revert r18451 "Revert r18449 "Reland r18383: More API cleanup." and r18450 "Unbreak build."" since … (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/d8-posix.cc ('k') | test/cctest/cctest.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 30 matching lines...) Expand all
41 return v8::FunctionTemplate::New(isolate, StatisticsExtension::GetCounters); 41 return v8::FunctionTemplate::New(isolate, StatisticsExtension::GetCounters);
42 } 42 }
43 43
44 44
45 static void AddCounter(v8::Isolate* isolate, 45 static void AddCounter(v8::Isolate* isolate,
46 v8::Local<v8::Object> object, 46 v8::Local<v8::Object> object,
47 StatsCounter* counter, 47 StatsCounter* counter,
48 const char* name) { 48 const char* name) {
49 if (counter->Enabled()) { 49 if (counter->Enabled()) {
50 object->Set(v8::String::NewFromUtf8(isolate, name), 50 object->Set(v8::String::NewFromUtf8(isolate, name),
51 v8::Number::New(*counter->GetInternalPointer())); 51 v8::Number::New(isolate, *counter->GetInternalPointer()));
52 } 52 }
53 } 53 }
54 54
55 static void AddNumber(v8::Isolate* isolate, 55 static void AddNumber(v8::Isolate* isolate,
56 v8::Local<v8::Object> object, 56 v8::Local<v8::Object> object,
57 intptr_t value, 57 intptr_t value,
58 const char* name) { 58 const char* name) {
59 object->Set(v8::String::NewFromUtf8(isolate, name), 59 object->Set(v8::String::NewFromUtf8(isolate, name),
60 v8::Number::New(static_cast<double>(value))); 60 v8::Number::New(isolate, static_cast<double>(value)));
61 } 61 }
62 62
63 63
64 static void AddNumber64(v8::Isolate* isolate, 64 static void AddNumber64(v8::Isolate* isolate,
65 v8::Local<v8::Object> object, 65 v8::Local<v8::Object> object,
66 int64_t value, 66 int64_t value,
67 const char* name) { 67 const char* name) {
68 object->Set(v8::String::NewFromUtf8(isolate, name), 68 object->Set(v8::String::NewFromUtf8(isolate, name),
69 v8::Number::New(static_cast<double>(value))); 69 v8::Number::New(isolate, static_cast<double>(value)));
70 } 70 }
71 71
72 72
73 void StatisticsExtension::GetCounters( 73 void StatisticsExtension::GetCounters(
74 const v8::FunctionCallbackInfo<v8::Value>& args) { 74 const v8::FunctionCallbackInfo<v8::Value>& args) {
75 Isolate* isolate = reinterpret_cast<Isolate*>(args.GetIsolate()); 75 Isolate* isolate = reinterpret_cast<Isolate*>(args.GetIsolate());
76 Heap* heap = isolate->heap(); 76 Heap* heap = isolate->heap();
77 77
78 if (args.Length() > 0) { // GC if first argument evaluates to true. 78 if (args.Length() > 0) { // GC if first argument evaluates to true.
79 if (args[0]->IsBoolean() && args[0]->ToBoolean()->Value()) { 79 if (args[0]->IsBoolean() && args[0]->ToBoolean()->Value()) {
80 heap->CollectAllGarbage(Heap::kNoGCFlags, "counters extension"); 80 heap->CollectAllGarbage(Heap::kNoGCFlags, "counters extension");
81 } 81 }
82 } 82 }
83 83
84 Counters* counters = isolate->counters(); 84 Counters* counters = isolate->counters();
85 v8::Local<v8::Object> result = v8::Object::New(); 85 v8::Local<v8::Object> result = v8::Object::New(args.GetIsolate());
86 86
87 #define ADD_COUNTER(name, caption) \ 87 #define ADD_COUNTER(name, caption) \
88 AddCounter(args.GetIsolate(), result, counters->name(), #name); 88 AddCounter(args.GetIsolate(), result, counters->name(), #name);
89 89
90 STATS_COUNTER_LIST_1(ADD_COUNTER) 90 STATS_COUNTER_LIST_1(ADD_COUNTER)
91 STATS_COUNTER_LIST_2(ADD_COUNTER) 91 STATS_COUNTER_LIST_2(ADD_COUNTER)
92 #undef ADD_COUNTER 92 #undef ADD_COUNTER
93 #define ADD_COUNTER(name) \ 93 #define ADD_COUNTER(name) \
94 AddCounter(args.GetIsolate(), result, counters->count_of_##name(), \ 94 AddCounter(args.GetIsolate(), result, counters->count_of_##name(), \
95 "count_of_" #name); \ 95 "count_of_" #name); \
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 args.GetReturnValue().Set(result); 170 args.GetReturnValue().Set(result);
171 } 171 }
172 172
173 173
174 void StatisticsExtension::Register() { 174 void StatisticsExtension::Register() {
175 static StatisticsExtension statistics_extension; 175 static StatisticsExtension statistics_extension;
176 static v8::DeclareExtension declaration(&statistics_extension); 176 static v8::DeclareExtension declaration(&statistics_extension);
177 } 177 }
178 178
179 } } // namespace v8::internal 179 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/d8-posix.cc ('k') | test/cctest/cctest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698