| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 6714 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6725 | 6725 |
| 6726 | 6726 |
| 6727 // Test that debug messages get processed when ProcessDebugMessages is called. | 6727 // Test that debug messages get processed when ProcessDebugMessages is called. |
| 6728 TEST(Backtrace) { | 6728 TEST(Backtrace) { |
| 6729 DebugLocalContext env; | 6729 DebugLocalContext env; |
| 6730 v8::Isolate* isolate = env->GetIsolate(); | 6730 v8::Isolate* isolate = env->GetIsolate(); |
| 6731 v8::HandleScope scope(isolate); | 6731 v8::HandleScope scope(isolate); |
| 6732 | 6732 |
| 6733 v8::Debug::SetMessageHandler(BacktraceData::MessageHandler); | 6733 v8::Debug::SetMessageHandler(BacktraceData::MessageHandler); |
| 6734 | 6734 |
| 6735 // TODO(3995): This doesn't work with --always-opt because we don't have |
| 6736 // correct source positions in optimized code. Enable once we have. |
| 6737 i::FLAG_always_opt = false; |
| 6738 |
| 6735 const int kBufferSize = 1000; | 6739 const int kBufferSize = 1000; |
| 6736 uint16_t buffer[kBufferSize]; | 6740 uint16_t buffer[kBufferSize]; |
| 6737 const char* scripts_command = | 6741 const char* scripts_command = |
| 6738 "{\"seq\":0," | 6742 "{\"seq\":0," |
| 6739 "\"type\":\"request\"," | 6743 "\"type\":\"request\"," |
| 6740 "\"command\":\"backtrace\"}"; | 6744 "\"command\":\"backtrace\"}"; |
| 6741 | 6745 |
| 6742 // Check backtrace from ProcessDebugMessages. | 6746 // Check backtrace from ProcessDebugMessages. |
| 6743 BacktraceData::frame_counter = -10; | 6747 BacktraceData::frame_counter = -10; |
| 6744 v8::Debug::SendCommand( | 6748 v8::Debug::SendCommand( |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7055 TEST(DeoptimizeDuringDebugBreak) { | 7059 TEST(DeoptimizeDuringDebugBreak) { |
| 7056 DebugLocalContext env; | 7060 DebugLocalContext env; |
| 7057 v8::HandleScope scope(env->GetIsolate()); | 7061 v8::HandleScope scope(env->GetIsolate()); |
| 7058 env.ExposeDebug(); | 7062 env.ExposeDebug(); |
| 7059 | 7063 |
| 7060 // Create a function for checking the function when hitting a break point. | 7064 // Create a function for checking the function when hitting a break point. |
| 7061 frame_function_name = CompileFunction(&env, | 7065 frame_function_name = CompileFunction(&env, |
| 7062 frame_function_name_source, | 7066 frame_function_name_source, |
| 7063 "frame_function_name"); | 7067 "frame_function_name"); |
| 7064 | 7068 |
| 7065 | |
| 7066 // Set a debug event listener which will keep interrupting execution until | 7069 // Set a debug event listener which will keep interrupting execution until |
| 7067 // debug break. When inside function bar it will deoptimize all functions. | 7070 // debug break. When inside function bar it will deoptimize all functions. |
| 7068 // This tests lazy deoptimization bailout for the stack check, as the first | 7071 // This tests lazy deoptimization bailout for the stack check, as the first |
| 7069 // time in function bar when using debug break and no break points will be at | 7072 // time in function bar when using debug break and no break points will be at |
| 7070 // the initial stack check. | 7073 // the initial stack check. |
| 7071 v8::Debug::SetDebugEventListener(DebugEventBreakDeoptimize); | 7074 v8::Debug::SetDebugEventListener(DebugEventBreakDeoptimize); |
| 7072 | 7075 |
| 7073 // Compile and run function bar which will optimize it for some flag settings. | 7076 // Compile and run function bar which will optimize it for some flag settings. |
| 7074 v8::Script::Compile(v8::String::NewFromUtf8( | 7077 v8::Local<v8::Function> f = CompileFunction(&env, "function bar(){}", "bar"); |
| 7075 env->GetIsolate(), "function bar(){}; bar()"))->Run(); | 7078 f->Call(v8::Undefined(env->GetIsolate()), 0, NULL); |
| 7076 | 7079 |
| 7077 // Set debug break and call bar again. | 7080 // Set debug break and call bar again. |
| 7078 v8::Debug::DebugBreak(env->GetIsolate()); | 7081 v8::Debug::DebugBreak(env->GetIsolate()); |
| 7079 v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), "bar()")) | 7082 f->Call(v8::Undefined(env->GetIsolate()), 0, NULL); |
| 7080 ->Run(); | |
| 7081 | 7083 |
| 7082 CHECK(debug_event_break_deoptimize_done); | 7084 CHECK(debug_event_break_deoptimize_done); |
| 7083 | 7085 |
| 7084 v8::Debug::SetDebugEventListener(NULL); | 7086 v8::Debug::SetDebugEventListener(NULL); |
| 7085 } | 7087 } |
| 7086 | 7088 |
| 7087 | 7089 |
| 7088 static void DebugEventBreakWithOptimizedStack( | 7090 static void DebugEventBreakWithOptimizedStack( |
| 7089 const v8::Debug::EventDetails& event_details) { | 7091 const v8::Debug::EventDetails& event_details) { |
| 7090 v8::Isolate* isolate = event_details.GetEventContext()->GetIsolate(); | 7092 v8::Isolate* isolate = event_details.GetEventContext()->GetIsolate(); |
| (...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7662 "let y = 2; \n" | 7664 "let y = 2; \n" |
| 7663 "debugger; \n" | 7665 "debugger; \n" |
| 7664 "x * y", | 7666 "x * y", |
| 7665 30); | 7667 30); |
| 7666 ExpectInt32( | 7668 ExpectInt32( |
| 7667 "x = 1; y = 2; \n" | 7669 "x = 1; y = 2; \n" |
| 7668 "debugger;" | 7670 "debugger;" |
| 7669 "x * y", | 7671 "x * y", |
| 7670 30); | 7672 30); |
| 7671 } | 7673 } |
| OLD | NEW |