| 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 24 matching lines...) Expand all Loading... |
| 35 #include <bzlib.h> | 35 #include <bzlib.h> |
| 36 #endif | 36 #endif |
| 37 | 37 |
| 38 #include <errno.h> | 38 #include <errno.h> |
| 39 #include <stdlib.h> | 39 #include <stdlib.h> |
| 40 #include <string.h> | 40 #include <string.h> |
| 41 #include <sys/stat.h> | 41 #include <sys/stat.h> |
| 42 | 42 |
| 43 #ifdef V8_SHARED | 43 #ifdef V8_SHARED |
| 44 #include <assert.h> | 44 #include <assert.h> |
| 45 #endif // V8_SHARED |
| 46 |
| 47 #ifndef V8_SHARED |
| 48 #include <algorithm> |
| 49 #endif // !V8_SHARED |
| 50 |
| 51 #ifdef V8_SHARED |
| 45 #include "../include/v8-testing.h" | 52 #include "../include/v8-testing.h" |
| 46 #endif // V8_SHARED | 53 #endif // V8_SHARED |
| 47 | 54 |
| 48 #ifdef ENABLE_VTUNE_JIT_INTERFACE | 55 #ifdef ENABLE_VTUNE_JIT_INTERFACE |
| 49 #include "third_party/vtune/v8-vtune.h" | 56 #include "third_party/vtune/v8-vtune.h" |
| 50 #endif | 57 #endif |
| 51 | 58 |
| 52 #include "d8.h" | 59 #include "d8.h" |
| 53 | 60 |
| 54 #ifndef V8_SHARED | 61 #ifndef V8_SHARED |
| (...skipping 1298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1353 } | 1360 } |
| 1354 | 1361 |
| 1355 | 1362 |
| 1356 #ifndef V8_SHARED | 1363 #ifndef V8_SHARED |
| 1357 struct CounterAndKey { | 1364 struct CounterAndKey { |
| 1358 Counter* counter; | 1365 Counter* counter; |
| 1359 const char* key; | 1366 const char* key; |
| 1360 }; | 1367 }; |
| 1361 | 1368 |
| 1362 | 1369 |
| 1363 int CompareKeys(const void* a, const void* b) { | 1370 inline bool operator<(const CounterAndKey& lhs, const CounterAndKey& rhs) { |
| 1364 return strcmp(static_cast<const CounterAndKey*>(a)->key, | 1371 return strcmp(lhs.key, rhs.key) < 0; |
| 1365 static_cast<const CounterAndKey*>(b)->key); | |
| 1366 } | 1372 } |
| 1367 #endif // V8_SHARED | 1373 #endif // V8_SHARED |
| 1368 | 1374 |
| 1369 | 1375 |
| 1370 void Shell::OnExit() { | 1376 void Shell::OnExit() { |
| 1371 LineEditor* line_editor = LineEditor::Get(); | 1377 LineEditor* line_editor = LineEditor::Get(); |
| 1372 if (line_editor) line_editor->Close(); | 1378 if (line_editor) line_editor->Close(); |
| 1373 #ifndef V8_SHARED | 1379 #ifndef V8_SHARED |
| 1374 if (i::FLAG_dump_counters) { | 1380 if (i::FLAG_dump_counters) { |
| 1375 int number_of_counters = 0; | 1381 int number_of_counters = 0; |
| 1376 for (CounterMap::Iterator i(counter_map_); i.More(); i.Next()) { | 1382 for (CounterMap::Iterator i(counter_map_); i.More(); i.Next()) { |
| 1377 number_of_counters++; | 1383 number_of_counters++; |
| 1378 } | 1384 } |
| 1379 CounterAndKey* counters = new CounterAndKey[number_of_counters]; | 1385 CounterAndKey* counters = new CounterAndKey[number_of_counters]; |
| 1380 int j = 0; | 1386 int j = 0; |
| 1381 for (CounterMap::Iterator i(counter_map_); i.More(); i.Next(), j++) { | 1387 for (CounterMap::Iterator i(counter_map_); i.More(); i.Next(), j++) { |
| 1382 counters[j].counter = i.CurrentValue(); | 1388 counters[j].counter = i.CurrentValue(); |
| 1383 counters[j].key = i.CurrentKey(); | 1389 counters[j].key = i.CurrentKey(); |
| 1384 } | 1390 } |
| 1385 qsort(counters, number_of_counters, sizeof(counters[0]), CompareKeys); | 1391 std::sort(counters, counters + number_of_counters); |
| 1386 printf("+----------------------------------------------------------------+" | 1392 printf("+----------------------------------------------------------------+" |
| 1387 "-------------+\n"); | 1393 "-------------+\n"); |
| 1388 printf("| Name |" | 1394 printf("| Name |" |
| 1389 " Value |\n"); | 1395 " Value |\n"); |
| 1390 printf("+----------------------------------------------------------------+" | 1396 printf("+----------------------------------------------------------------+" |
| 1391 "-------------+\n"); | 1397 "-------------+\n"); |
| 1392 for (j = 0; j < number_of_counters; j++) { | 1398 for (j = 0; j < number_of_counters; j++) { |
| 1393 Counter* counter = counters[j].counter; | 1399 Counter* counter = counters[j].counter; |
| 1394 const char* key = counters[j].key; | 1400 const char* key = counters[j].key; |
| 1395 if (counter->is_histogram()) { | 1401 if (counter->is_histogram()) { |
| (...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1993 } | 1999 } |
| 1994 | 2000 |
| 1995 } // namespace v8 | 2001 } // namespace v8 |
| 1996 | 2002 |
| 1997 | 2003 |
| 1998 #ifndef GOOGLE3 | 2004 #ifndef GOOGLE3 |
| 1999 int main(int argc, char* argv[]) { | 2005 int main(int argc, char* argv[]) { |
| 2000 return v8::Shell::Main(argc, argv); | 2006 return v8::Shell::Main(argc, argv); |
| 2001 } | 2007 } |
| 2002 #endif | 2008 #endif |
| OLD | NEW |