| 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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 }; | 98 }; |
| 99 | 99 |
| 100 } // namespace | 100 } // namespace |
| 101 | 101 |
| 102 | 102 |
| 103 i::Code* CreateCode(LocalContext* env) { | 103 i::Code* CreateCode(LocalContext* env) { |
| 104 static int counter = 0; | 104 static int counter = 0; |
| 105 i::EmbeddedVector<char, 256> script; | 105 i::EmbeddedVector<char, 256> script; |
| 106 i::EmbeddedVector<char, 32> name; | 106 i::EmbeddedVector<char, 32> name; |
| 107 | 107 |
| 108 i::OS::SNPrintF(name, "function_%d", ++counter); | 108 i::SNPrintF(name, "function_%d", ++counter); |
| 109 const char* name_start = name.start(); | 109 const char* name_start = name.start(); |
| 110 i::OS::SNPrintF(script, | 110 i::SNPrintF(script, |
| 111 "function %s() {\n" | 111 "function %s() {\n" |
| 112 "var counter = 0;\n" | 112 "var counter = 0;\n" |
| 113 "for (var i = 0; i < %d; ++i) counter += i;\n" | 113 "for (var i = 0; i < %d; ++i) counter += i;\n" |
| 114 "return '%s_' + counter;\n" | 114 "return '%s_' + counter;\n" |
| 115 "}\n" | 115 "}\n" |
| 116 "%s();\n", name_start, counter, name_start, name_start); | 116 "%s();\n", name_start, counter, name_start, name_start); |
| 117 CompileRun(script.start()); | 117 CompileRun(script.start()); |
| 118 i::Handle<i::JSFunction> fun = v8::Utils::OpenHandle( | 118 i::Handle<i::JSFunction> fun = v8::Utils::OpenHandle( |
| 119 *v8::Local<v8::Function>::Cast( | 119 *v8::Local<v8::Function>::Cast( |
| 120 (*env)->Global()->Get(v8_str(name_start)))); | 120 (*env)->Global()->Get(v8_str(name_start)))); |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 463 return NULL; | 463 return NULL; |
| 464 } | 464 } |
| 465 | 465 |
| 466 | 466 |
| 467 static const v8::CpuProfileNode* GetChild(v8::Isolate* isolate, | 467 static const v8::CpuProfileNode* GetChild(v8::Isolate* isolate, |
| 468 const v8::CpuProfileNode* node, | 468 const v8::CpuProfileNode* node, |
| 469 const char* name) { | 469 const char* name) { |
| 470 const v8::CpuProfileNode* result = FindChild(isolate, node, name); | 470 const v8::CpuProfileNode* result = FindChild(isolate, node, name); |
| 471 if (!result) { | 471 if (!result) { |
| 472 char buffer[100]; | 472 char buffer[100]; |
| 473 i::OS::SNPrintF(Vector<char>(buffer, ARRAY_SIZE(buffer)), | 473 i::SNPrintF(Vector<char>(buffer, ARRAY_SIZE(buffer)), |
| 474 "Failed to GetChild: %s", name); | 474 "Failed to GetChild: %s", name); |
| 475 FATAL(buffer); | 475 FATAL(buffer); |
| 476 } | 476 } |
| 477 return result; | 477 return result; |
| 478 } | 478 } |
| 479 | 479 |
| 480 | 480 |
| 481 static void CheckSimpleBranch(v8::Isolate* isolate, | 481 static void CheckSimpleBranch(v8::Isolate* isolate, |
| 482 const v8::CpuProfileNode* node, | 482 const v8::CpuProfileNode* node, |
| 483 const char* names[], int length) { | 483 const char* names[], int length) { |
| 484 for (int i = 0; i < length; i++) { | 484 for (int i = 0; i < length; i++) { |
| (...skipping 1176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1661 inner_profile = NULL; | 1661 inner_profile = NULL; |
| 1662 CHECK_EQ(0, iprofiler->GetProfilesCount()); | 1662 CHECK_EQ(0, iprofiler->GetProfilesCount()); |
| 1663 | 1663 |
| 1664 v8::CpuProfile* outer_profile = profiler->StopProfiling(outer); | 1664 v8::CpuProfile* outer_profile = profiler->StopProfiling(outer); |
| 1665 CHECK(outer_profile); | 1665 CHECK(outer_profile); |
| 1666 CHECK_EQ(1, iprofiler->GetProfilesCount()); | 1666 CHECK_EQ(1, iprofiler->GetProfilesCount()); |
| 1667 outer_profile->Delete(); | 1667 outer_profile->Delete(); |
| 1668 outer_profile = NULL; | 1668 outer_profile = NULL; |
| 1669 CHECK_EQ(0, iprofiler->GetProfilesCount()); | 1669 CHECK_EQ(0, iprofiler->GetProfilesCount()); |
| 1670 } | 1670 } |
| OLD | NEW |