OLD | NEW |
---|---|
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
431 // Dump collected profile to have a better diagnostic in case of failure. | 431 // Dump collected profile to have a better diagnostic in case of failure. |
432 reinterpret_cast<i::CpuProfile*>(profile)->Print(); | 432 reinterpret_cast<i::CpuProfile*>(profile)->Print(); |
433 | 433 |
434 return profile; | 434 return profile; |
435 } | 435 } |
436 | 436 |
437 | 437 |
438 static bool ContainsString(v8::Handle<v8::String> string, | 438 static bool ContainsString(v8::Handle<v8::String> string, |
439 const Vector<v8::Handle<v8::String> >& vector) { | 439 const Vector<v8::Handle<v8::String> >& vector) { |
440 for (int i = 0; i < vector.length(); i++) { | 440 for (int i = 0; i < vector.length(); i++) { |
441 if (string->Equals(vector[i])) | 441 if (string->Equals(vector[i])) return true; |
442 return true; | |
443 } | 442 } |
444 return false; | 443 return false; |
445 } | 444 } |
446 | 445 |
447 | 446 |
448 static void CheckChildrenNames(const v8::CpuProfileNode* node, | 447 static void CheckChildrenNames(const v8::CpuProfileNode* node, |
449 const Vector<v8::Handle<v8::String> >& names) { | 448 const Vector<v8::Handle<v8::String> >& names) { |
450 int count = node->GetChildrenCount(); | 449 int count = node->GetChildrenCount(); |
451 for (int i = 0; i < count; i++) { | 450 for (int i = 0; i < count; i++) { |
452 v8::Handle<v8::String> name = node->GetChild(i)->GetFunctionName(); | 451 v8::Handle<v8::String> name = node->GetChild(i)->GetFunctionName(); |
453 CHECK(ContainsString(name, names)); | 452 if (!ContainsString(name, names)) { |
453 char buffer[100]; | |
454 i::SNPrintF(Vector<char>(buffer, arraysize(buffer)), | |
455 "Unexpected child '%s' found in '%s'", | |
456 *v8::String::Utf8Value(name), | |
457 *v8::String::Utf8Value(node->GetFunctionName())); | |
458 FATAL(buffer); | |
459 } | |
454 // Check that there are no duplicates. | 460 // Check that there are no duplicates. |
455 for (int j = 0; j < count; j++) { | 461 for (int j = 0; j < count; j++) { |
456 if (j == i) continue; | 462 if (j == i) continue; |
457 CHECK(!name->Equals(node->GetChild(j)->GetFunctionName())); | 463 if (name->Equals(node->GetChild(j)->GetFunctionName())) { |
464 char buffer[100]; | |
465 i::SNPrintF(Vector<char>(buffer, arraysize(buffer)), | |
466 "Second child with the same name '%s' found in '%s'", | |
467 *v8::String::Utf8Value(name), | |
468 *v8::String::Utf8Value(node->GetFunctionName())); | |
469 FATAL(buffer); | |
470 } | |
458 } | 471 } |
459 } | 472 } |
460 } | 473 } |
461 | 474 |
462 | 475 |
463 static const v8::CpuProfileNode* FindChild(const v8::CpuProfileNode* node, | 476 static const v8::CpuProfileNode* FindChild(const v8::CpuProfileNode* node, |
464 const char* name) { | 477 const char* name) { |
465 int count = node->GetChildrenCount(); | 478 int count = node->GetChildrenCount(); |
466 v8::Handle<v8::String> nameHandle = v8_str(name); | 479 v8::Handle<v8::String> nameHandle = v8_str(name); |
467 for (int i = 0; i < count; i++) { | 480 for (int i = 0; i < count; i++) { |
(...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1118 CHECK_EQ(2u, line_count); // Expect two hit source lines - #1 and #5. | 1131 CHECK_EQ(2u, line_count); // Expect two hit source lines - #1 and #5. |
1119 ScopedVector<v8::CpuProfileNode::LineTick> entries(line_count); | 1132 ScopedVector<v8::CpuProfileNode::LineTick> entries(line_count); |
1120 CHECK(func_node->GetLineTicks(&entries[0], line_count)); | 1133 CHECK(func_node->GetLineTicks(&entries[0], line_count)); |
1121 int value = 0; | 1134 int value = 0; |
1122 for (int i = 0; i < entries.length(); i++) | 1135 for (int i = 0; i < entries.length(); i++) |
1123 if (entries[i].line == hit_line) { | 1136 if (entries[i].line == hit_line) { |
1124 value = entries[i].hit_count; | 1137 value = entries[i].hit_count; |
1125 break; | 1138 break; |
1126 } | 1139 } |
1127 CHECK_EQ(hit_count, value); | 1140 CHECK_EQ(hit_count, value); |
1141 delete processor; | |
yurys
2015/03/05 14:57:40
Why not use SmartPointer?
Sven Panne
2015/03/05 15:05:48
Or even simpler: Just avoid pointers altogether he
| |
1128 } | 1142 } |
1129 | 1143 |
1130 | 1144 |
1131 static const char* call_function_test_source = "function bar(iterations) {\n" | 1145 static const char* call_function_test_source = "function bar(iterations) {\n" |
1132 "}\n" | 1146 "}\n" |
1133 "function start(duration) {\n" | 1147 "function start(duration) {\n" |
1134 " var start = Date.now();\n" | 1148 " var start = Date.now();\n" |
1135 " while (Date.now() - start < duration) {\n" | 1149 " while (Date.now() - start < duration) {\n" |
1136 " try {\n" | 1150 " try {\n" |
1137 " bar.call(this, 10 * 1000);\n" | 1151 " bar.call(this, 10 * 1000);\n" |
(...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1762 v8::HandleScope scope(CcTest::isolate()); | 1776 v8::HandleScope scope(CcTest::isolate()); |
1763 | 1777 |
1764 const char* source = | 1778 const char* source = |
1765 "function CompareStatementWithThis() {\n" | 1779 "function CompareStatementWithThis() {\n" |
1766 " if (this === 1) {}\n" | 1780 " if (this === 1) {}\n" |
1767 "}\n" | 1781 "}\n" |
1768 "CompareStatementWithThis();\n"; | 1782 "CompareStatementWithThis();\n"; |
1769 | 1783 |
1770 v8::Script::Compile(v8_str(source))->Run(); | 1784 v8::Script::Compile(v8_str(source))->Run(); |
1771 } | 1785 } |
OLD | NEW |