| OLD | NEW |
| 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 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 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 | 420 |
| 421 | 421 |
| 422 // Test that logging of code create / move events is equivalent to traversal of | 422 // Test that logging of code create / move events is equivalent to traversal of |
| 423 // a resulting heap. | 423 // a resulting heap. |
| 424 TEST(EquivalenceOfLoggingAndTraversal) { | 424 TEST(EquivalenceOfLoggingAndTraversal) { |
| 425 // This test needs to be run on a "clean" V8 to ensure that snapshot log | 425 // This test needs to be run on a "clean" V8 to ensure that snapshot log |
| 426 // is loaded. This is always true when running using tools/test.py because | 426 // is loaded. This is always true when running using tools/test.py because |
| 427 // it launches a new cctest instance for every test. To be sure that launching | 427 // it launches a new cctest instance for every test. To be sure that launching |
| 428 // cctest manually also works, please be sure that no tests below | 428 // cctest manually also works, please be sure that no tests below |
| 429 // are using V8. | 429 // are using V8. |
| 430 // | |
| 431 // P.S. No, V8 can't be re-initialized after disposal, see include/v8.h. | |
| 432 CHECK(!i::V8::IsRunning()); | |
| 433 | 430 |
| 434 // Start with profiling to capture all code events from the beginning. | 431 // Start with profiling to capture all code events from the beginning. |
| 435 ScopedLoggerInitializer initialize_logger; | 432 ScopedLoggerInitializer initialize_logger; |
| 436 Logger* logger = initialize_logger.logger(); | 433 Logger* logger = initialize_logger.logger(); |
| 437 | 434 |
| 438 // Compile and run a function that creates other functions. | 435 // Compile and run a function that creates other functions. |
| 439 CompileRun( | 436 CompileRun( |
| 440 "(function f(obj) {\n" | 437 "(function f(obj) {\n" |
| 441 " obj.test =\n" | 438 " obj.test =\n" |
| 442 " (function a(j) { return function b() { return j; } })(100);\n" | 439 " (function a(j) { return function b() { return j; } })(100);\n" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 477 v8::Local<v8::String> s = result->ToString(); | 474 v8::Local<v8::String> s = result->ToString(); |
| 478 i::ScopedVector<char> data(s->Utf8Length() + 1); | 475 i::ScopedVector<char> data(s->Utf8Length() + 1); |
| 479 CHECK_NE(NULL, data.start()); | 476 CHECK_NE(NULL, data.start()); |
| 480 s->WriteUtf8(data.start()); | 477 s->WriteUtf8(data.start()); |
| 481 printf("%s\n", data.start()); | 478 printf("%s\n", data.start()); |
| 482 // Make sure that our output is written prior crash due to CHECK failure. | 479 // Make sure that our output is written prior crash due to CHECK failure. |
| 483 fflush(stdout); | 480 fflush(stdout); |
| 484 CHECK(false); | 481 CHECK(false); |
| 485 } | 482 } |
| 486 } | 483 } |
| OLD | NEW |