| 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 1477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1488 CHECK_EQ(line, node->GetLineNumber()); | 1488 CHECK_EQ(line, node->GetLineNumber()); |
| 1489 CHECK_EQ(column, node->GetColumnNumber()); | 1489 CHECK_EQ(column, node->GetColumnNumber()); |
| 1490 } | 1490 } |
| 1491 | 1491 |
| 1492 | 1492 |
| 1493 TEST(FunctionDetails) { | 1493 TEST(FunctionDetails) { |
| 1494 v8::HandleScope scope(CcTest::isolate()); | 1494 v8::HandleScope scope(CcTest::isolate()); |
| 1495 v8::Local<v8::Context> env = CcTest::NewContext(PROFILER_EXTENSION); | 1495 v8::Local<v8::Context> env = CcTest::NewContext(PROFILER_EXTENSION); |
| 1496 v8::Context::Scope context_scope(env); | 1496 v8::Context::Scope context_scope(env); |
| 1497 | 1497 |
| 1498 v8::Handle<v8::Script> script_a = CompileWithOrigin( | 1498 v8::Handle<v8::Script> script_a = v8::Script::Compile( |
| 1499 v8::String::NewFromUtf8( |
| 1500 env->GetIsolate(), |
| 1499 " function foo\n() { try { bar(); } catch(e) {} }\n" | 1501 " function foo\n() { try { bar(); } catch(e) {} }\n" |
| 1500 " function bar() { startProfiling(); }\n", | 1502 " function bar() { startProfiling(); }\n"), |
| 1501 "script_a"); | 1503 v8::String::NewFromUtf8(env->GetIsolate(), "script_a")); |
| 1502 script_a->Run(); | 1504 script_a->Run(); |
| 1503 v8::Handle<v8::Script> script_b = CompileWithOrigin( | 1505 v8::Handle<v8::Script> script_b = v8::Script::Compile( |
| 1506 v8::String::NewFromUtf8( |
| 1507 env->GetIsolate(), |
| 1504 "\n\n function baz() { try { foo(); } catch(e) {} }\n" | 1508 "\n\n function baz() { try { foo(); } catch(e) {} }\n" |
| 1505 "\n\nbaz();\n" | 1509 "\n\nbaz();\n" |
| 1506 "stopProfiling();\n", | 1510 "stopProfiling();\n"), |
| 1507 "script_b"); | 1511 v8::String::NewFromUtf8(env->GetIsolate(), "script_b")); |
| 1508 script_b->Run(); | 1512 script_b->Run(); |
| 1509 const v8::CpuProfile* profile = i::ProfilerExtension::last_profile; | 1513 const v8::CpuProfile* profile = i::ProfilerExtension::last_profile; |
| 1510 const v8::CpuProfileNode* current = profile->GetTopDownRoot(); | 1514 const v8::CpuProfileNode* current = profile->GetTopDownRoot(); |
| 1511 reinterpret_cast<ProfileNode*>( | 1515 reinterpret_cast<ProfileNode*>( |
| 1512 const_cast<v8::CpuProfileNode*>(current))->Print(0); | 1516 const_cast<v8::CpuProfileNode*>(current))->Print(0); |
| 1513 // The tree should look like this: | 1517 // The tree should look like this: |
| 1514 // 0 (root) 0 #1 | 1518 // 0 (root) 0 #1 |
| 1515 // 0 (anonymous function) 19 #2 no reason script_b:1 | 1519 // 0 (anonymous function) 19 #2 no reason script_b:1 |
| 1516 // 0 baz 19 #3 TryCatchStatement script_b:3 | 1520 // 0 baz 19 #3 TryCatchStatement script_b:3 |
| 1517 // 0 foo 18 #4 TryCatchStatement script_a:2 | 1521 // 0 foo 18 #4 TryCatchStatement script_a:2 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1559 inner_profile = NULL; | 1563 inner_profile = NULL; |
| 1560 CHECK_EQ(0, iprofiler->GetProfilesCount()); | 1564 CHECK_EQ(0, iprofiler->GetProfilesCount()); |
| 1561 | 1565 |
| 1562 const v8::CpuProfile* outer_profile = profiler->StopCpuProfiling(outer); | 1566 const v8::CpuProfile* outer_profile = profiler->StopCpuProfiling(outer); |
| 1563 CHECK(outer_profile); | 1567 CHECK(outer_profile); |
| 1564 CHECK_EQ(1, iprofiler->GetProfilesCount()); | 1568 CHECK_EQ(1, iprofiler->GetProfilesCount()); |
| 1565 const_cast<v8::CpuProfile*>(outer_profile)->Delete(); | 1569 const_cast<v8::CpuProfile*>(outer_profile)->Delete(); |
| 1566 outer_profile = NULL; | 1570 outer_profile = NULL; |
| 1567 CHECK_EQ(0, iprofiler->GetProfilesCount()); | 1571 CHECK_EQ(0, iprofiler->GetProfilesCount()); |
| 1568 } | 1572 } |
| OLD | NEW |