OLD | NEW |
1 // Copyright 2007-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2007-2008 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 2662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2673 foo->Call(env->Global(), 0, NULL); | 2673 foo->Call(env->Global(), 0, NULL); |
2674 | 2674 |
2675 // With stepping all break locations are hit. | 2675 // With stepping all break locations are hit. |
2676 CHECK_EQ(53, break_point_hit_count); | 2676 CHECK_EQ(53, break_point_hit_count); |
2677 | 2677 |
2678 v8::Debug::SetDebugEventListener(NULL); | 2678 v8::Debug::SetDebugEventListener(NULL); |
2679 CheckDebuggerUnloaded(); | 2679 CheckDebuggerUnloaded(); |
2680 } | 2680 } |
2681 | 2681 |
2682 | 2682 |
| 2683 static void DoDebugStepNamedStoreLoop(int expected, bool full_compiler = true) { |
| 2684 v8::HandleScope scope; |
| 2685 DebugLocalContext env; |
| 2686 |
| 2687 // Register a debug event listener which steps and counts before compiling the |
| 2688 // function to ensure the full compiler is used. |
| 2689 if (full_compiler) { |
| 2690 v8::Debug::SetDebugEventListener(DebugEventStep); |
| 2691 } |
| 2692 |
| 2693 // Create a function for testing stepping of named store. |
| 2694 v8::Local<v8::Function> foo = CompileFunction( |
| 2695 &env, |
| 2696 "function foo() {\n" |
| 2697 " var a = {a:1};\n" |
| 2698 " for (var i = 0; i < 10; i++) {\n" |
| 2699 " a.a = 2\n" |
| 2700 " }\n" |
| 2701 "}\n", |
| 2702 "foo"); |
| 2703 |
| 2704 // Call function without any break points to ensure inlining is in place. |
| 2705 foo->Call(env->Global(), 0, NULL); |
| 2706 |
| 2707 // Register a debug event listener which steps and counts after compiling the |
| 2708 // function to ensure the optimizing compiler is used. |
| 2709 if (!full_compiler) { |
| 2710 v8::Debug::SetDebugEventListener(DebugEventStep); |
| 2711 } |
| 2712 |
| 2713 // Setup break point and step through the function. |
| 2714 SetBreakPoint(foo, 3); |
| 2715 step_action = StepNext; |
| 2716 break_point_hit_count = 0; |
| 2717 foo->Call(env->Global(), 0, NULL); |
| 2718 |
| 2719 // With stepping all expected break locations are hit. |
| 2720 CHECK_EQ(expected, break_point_hit_count); |
| 2721 |
| 2722 v8::Debug::SetDebugEventListener(NULL); |
| 2723 CheckDebuggerUnloaded(); |
| 2724 } |
| 2725 |
| 2726 |
| 2727 // Test of the stepping mechanism for named load in a loop. |
| 2728 TEST(DebugStepNamedStoreLoopFull) { |
| 2729 // With the full compiler it is possible to break on the for statement. |
| 2730 DoDebugStepNamedStoreLoop(22); |
| 2731 } |
| 2732 |
| 2733 |
| 2734 // Test of the stepping mechanism for named load in a loop. |
| 2735 TEST(DebugStepNamedStoreLoopOptimizing) { |
| 2736 // With the optimizing compiler it is not possible to break on the for |
| 2737 // statement as it uses a local variable thus no IC's. |
| 2738 DoDebugStepNamedStoreLoop(11, false); |
| 2739 } |
| 2740 |
| 2741 |
2683 // Test the stepping mechanism with different ICs. | 2742 // Test the stepping mechanism with different ICs. |
2684 TEST(DebugStepLinearMixedICs) { | 2743 TEST(DebugStepLinearMixedICs) { |
2685 v8::HandleScope scope; | 2744 v8::HandleScope scope; |
2686 DebugLocalContext env; | 2745 DebugLocalContext env; |
2687 | 2746 |
2688 // Register a debug event listener which steps and counts. | 2747 // Register a debug event listener which steps and counts. |
2689 v8::Debug::SetDebugEventListener(DebugEventStep); | 2748 v8::Debug::SetDebugEventListener(DebugEventStep); |
2690 | 2749 |
2691 // Create a function for testing stepping. | 2750 // Create a function for testing stepping. |
2692 v8::Local<v8::Function> foo = CompileFunction(&env, | 2751 v8::Local<v8::Function> foo = CompileFunction(&env, |
(...skipping 4052 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6745 | 6804 |
6746 CHECK_EQ(2, TestClientData::constructor_call_counter); | 6805 CHECK_EQ(2, TestClientData::constructor_call_counter); |
6747 CHECK_EQ(TestClientData::constructor_call_counter, | 6806 CHECK_EQ(TestClientData::constructor_call_counter, |
6748 TestClientData::destructor_call_counter); | 6807 TestClientData::destructor_call_counter); |
6749 | 6808 |
6750 v8::Debug::SetDebugEventListener(NULL); | 6809 v8::Debug::SetDebugEventListener(NULL); |
6751 CheckDebuggerUnloaded(); | 6810 CheckDebuggerUnloaded(); |
6752 } | 6811 } |
6753 | 6812 |
6754 #endif // ENABLE_DEBUGGER_SUPPORT | 6813 #endif // ENABLE_DEBUGGER_SUPPORT |
OLD | NEW |