OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <utility> | 5 #include <utility> |
6 | 6 |
7 #include "src/compilation-info.h" | 7 #include "src/compilation-info.h" |
8 #include "src/compiler/pipeline.h" | 8 #include "src/compiler/pipeline.h" |
| 9 #include "src/debug/debug-interface.h" |
9 #include "src/execution.h" | 10 #include "src/execution.h" |
10 #include "src/handles.h" | 11 #include "src/handles.h" |
11 #include "src/interpreter/bytecode-array-builder.h" | 12 #include "src/interpreter/bytecode-array-builder.h" |
12 #include "src/interpreter/interpreter.h" | 13 #include "src/interpreter/interpreter.h" |
13 #include "src/objects-inl.h" | 14 #include "src/objects-inl.h" |
14 #include "src/parsing/parse-info.h" | 15 #include "src/parsing/parse-info.h" |
15 #include "test/cctest/cctest.h" | 16 #include "test/cctest/cctest.h" |
16 | 17 |
17 namespace v8 { | 18 namespace v8 { |
18 namespace internal { | 19 namespace internal { |
(...skipping 2940 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2959 BytecodeGraphTester tester(isolate, script.start()); | 2960 BytecodeGraphTester tester(isolate, script.start()); |
2960 v8::Local<v8::String> message = tester.CheckThrowsReturnMessage()->Get(); | 2961 v8::Local<v8::String> message = tester.CheckThrowsReturnMessage()->Get(); |
2961 v8::Local<v8::String> expected_string = | 2962 v8::Local<v8::String> expected_string = |
2962 v8_str(illegal_const_decl[i].return_value()); | 2963 v8_str(illegal_const_decl[i].return_value()); |
2963 CHECK( | 2964 CHECK( |
2964 message->Equals(CcTest::isolate()->GetCurrentContext(), expected_string) | 2965 message->Equals(CcTest::isolate()->GetCurrentContext(), expected_string) |
2965 .FromJust()); | 2966 .FromJust()); |
2966 } | 2967 } |
2967 } | 2968 } |
2968 | 2969 |
2969 static int debug_break_count = 0; | 2970 class CountBreakDebugDelegate : public v8::debug::DebugDelegate { |
2970 static void DebugEventCounter(const v8::Debug::EventDetails& event_details) { | 2971 public: |
2971 if (event_details.GetEvent() == v8::Break) debug_break_count++; | 2972 void BreakProgramRequested(v8::Local<v8::Context> paused_context, |
2972 } | 2973 v8::Local<v8::Object> exec_state, |
| 2974 v8::Local<v8::Value> break_points_hit) override { |
| 2975 debug_break_count++; |
| 2976 } |
| 2977 int debug_break_count = 0; |
| 2978 }; |
2973 | 2979 |
2974 TEST(BytecodeGraphBuilderDebuggerStatement) { | 2980 TEST(BytecodeGraphBuilderDebuggerStatement) { |
| 2981 CountBreakDebugDelegate delegate; |
2975 HandleAndZoneScope scope; | 2982 HandleAndZoneScope scope; |
2976 Isolate* isolate = scope.main_isolate(); | 2983 Isolate* isolate = scope.main_isolate(); |
2977 | 2984 |
2978 v8::Debug::SetDebugEventListener(CcTest::isolate(), DebugEventCounter); | 2985 v8::debug::SetDebugDelegate(CcTest::isolate(), &delegate); |
2979 | 2986 |
2980 ExpectedSnippet<0> snippet = { | 2987 ExpectedSnippet<0> snippet = { |
2981 "function f() {" | 2988 "function f() {" |
2982 " debugger;" | 2989 " debugger;" |
2983 "}" | 2990 "}" |
2984 "f();", | 2991 "f();", |
2985 {isolate->factory()->undefined_value()}}; | 2992 {isolate->factory()->undefined_value()}}; |
2986 | 2993 |
2987 BytecodeGraphTester tester(isolate, snippet.code_snippet); | 2994 BytecodeGraphTester tester(isolate, snippet.code_snippet); |
2988 auto callable = tester.GetCallable<>(); | 2995 auto callable = tester.GetCallable<>(); |
2989 Handle<Object> return_value = callable().ToHandleChecked(); | 2996 Handle<Object> return_value = callable().ToHandleChecked(); |
2990 | 2997 |
2991 v8::Debug::SetDebugEventListener(CcTest::isolate(), nullptr); | 2998 v8::debug::SetDebugDelegate(CcTest::isolate(), nullptr); |
2992 CHECK(return_value.is_identical_to(snippet.return_value())); | 2999 CHECK(return_value.is_identical_to(snippet.return_value())); |
2993 CHECK_EQ(2, debug_break_count); | 3000 CHECK_EQ(2, delegate.debug_break_count); |
2994 } | 3001 } |
2995 | 3002 |
2996 } // namespace compiler | 3003 } // namespace compiler |
2997 } // namespace internal | 3004 } // namespace internal |
2998 } // namespace v8 | 3005 } // namespace v8 |
OLD | NEW |