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 "src/debug/debug-evaluate.h" | 5 #include "src/debug/debug-evaluate.h" |
6 | 6 |
7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
8 #include "src/contexts.h" | 8 #include "src/contexts.h" |
9 #include "src/debug/debug.h" | 9 #include "src/debug/debug.h" |
10 #include "src/debug/debug-frames.h" | 10 #include "src/debug/debug-frames.h" |
11 #include "src/debug/debug-scopes.h" | 11 #include "src/debug/debug-scopes.h" |
12 #include "src/frames-inl.h" | 12 #include "src/frames-inl.h" |
13 #include "src/isolate-inl.h" | 13 #include "src/isolate-inl.h" |
14 | 14 |
15 namespace v8 { | 15 namespace v8 { |
16 namespace internal { | 16 namespace internal { |
17 | 17 |
18 static inline bool IsDebugContext(Isolate* isolate, Context* context) { | 18 static inline bool IsDebugContext(Isolate* isolate, Context* context) { |
19 return context->native_context() == *isolate->debug()->debug_context(); | 19 return context->native_context() == *isolate->debug()->debug_context(); |
20 } | 20 } |
21 | 21 |
22 | 22 |
23 MaybeHandle<Object> DebugEvaluate::Global(Isolate* isolate, | 23 MaybeHandle<Object> DebugEvaluate::Global( |
24 Handle<String> source, | 24 Isolate* isolate, Handle<String> source, bool disable_break, |
25 bool disable_break, | 25 Handle<HeapObject> context_extension) { |
26 Handle<Object> context_extension) { | |
27 // Handle the processing of break. | 26 // Handle the processing of break. |
28 DisableBreak disable_break_scope(isolate->debug(), disable_break); | 27 DisableBreak disable_break_scope(isolate->debug(), disable_break); |
29 | 28 |
30 // Enter the top context from before the debugger was invoked. | 29 // Enter the top context from before the debugger was invoked. |
31 SaveContext save(isolate); | 30 SaveContext save(isolate); |
32 SaveContext* top = &save; | 31 SaveContext* top = &save; |
33 while (top != NULL && IsDebugContext(isolate, *top->context())) { | 32 while (top != NULL && IsDebugContext(isolate, *top->context())) { |
34 top = top->prev(); | 33 top = top->prev(); |
35 } | 34 } |
36 if (top != NULL) isolate->set_context(*top->context()); | 35 if (top != NULL) isolate->set_context(*top->context()); |
37 | 36 |
38 // Get the native context now set to the top context from before the | 37 // Get the native context now set to the top context from before the |
39 // debugger was invoked. | 38 // debugger was invoked. |
40 Handle<Context> context = isolate->native_context(); | 39 Handle<Context> context = isolate->native_context(); |
41 Handle<JSObject> receiver(context->global_proxy()); | 40 Handle<JSObject> receiver(context->global_proxy()); |
42 Handle<SharedFunctionInfo> outer_info(context->closure()->shared(), isolate); | 41 Handle<SharedFunctionInfo> outer_info(context->closure()->shared(), isolate); |
43 return Evaluate(isolate, outer_info, context, context_extension, receiver, | 42 return Evaluate(isolate, outer_info, context, context_extension, receiver, |
44 source); | 43 source); |
45 } | 44 } |
46 | 45 |
47 | 46 |
48 MaybeHandle<Object> DebugEvaluate::Local(Isolate* isolate, | 47 MaybeHandle<Object> DebugEvaluate::Local(Isolate* isolate, |
49 StackFrame::Id frame_id, | 48 StackFrame::Id frame_id, |
50 int inlined_jsframe_index, | 49 int inlined_jsframe_index, |
51 Handle<String> source, | 50 Handle<String> source, |
52 bool disable_break, | 51 bool disable_break, |
53 Handle<Object> context_extension) { | 52 Handle<HeapObject> context_extension) { |
54 // Handle the processing of break. | 53 // Handle the processing of break. |
55 DisableBreak disable_break_scope(isolate->debug(), disable_break); | 54 DisableBreak disable_break_scope(isolate->debug(), disable_break); |
56 | 55 |
57 // Get the frame where the debugging is performed. | 56 // Get the frame where the debugging is performed. |
58 JavaScriptFrameIterator it(isolate, frame_id); | 57 JavaScriptFrameIterator it(isolate, frame_id); |
59 JavaScriptFrame* frame = it.frame(); | 58 JavaScriptFrame* frame = it.frame(); |
60 | 59 |
61 // Traverse the saved contexts chain to find the active context for the | 60 // Traverse the saved contexts chain to find the active context for the |
62 // selected frame. | 61 // selected frame. |
63 SaveContext* save = | 62 SaveContext* save = |
(...skipping 10 matching lines...) Expand all Loading... |
74 isolate, context_builder.outer_info(), | 73 isolate, context_builder.outer_info(), |
75 context_builder.innermost_context(), context_extension, receiver, source); | 74 context_builder.innermost_context(), context_extension, receiver, source); |
76 if (!maybe_result.is_null()) context_builder.UpdateValues(); | 75 if (!maybe_result.is_null()) context_builder.UpdateValues(); |
77 return maybe_result; | 76 return maybe_result; |
78 } | 77 } |
79 | 78 |
80 | 79 |
81 // Compile and evaluate source for the given context. | 80 // Compile and evaluate source for the given context. |
82 MaybeHandle<Object> DebugEvaluate::Evaluate( | 81 MaybeHandle<Object> DebugEvaluate::Evaluate( |
83 Isolate* isolate, Handle<SharedFunctionInfo> outer_info, | 82 Isolate* isolate, Handle<SharedFunctionInfo> outer_info, |
84 Handle<Context> context, Handle<Object> context_extension, | 83 Handle<Context> context, Handle<HeapObject> context_extension, |
85 Handle<Object> receiver, Handle<String> source) { | 84 Handle<Object> receiver, Handle<String> source) { |
86 if (context_extension->IsJSObject()) { | 85 if (context_extension->IsJSObject()) { |
87 Handle<JSObject> extension = Handle<JSObject>::cast(context_extension); | 86 Handle<JSObject> extension = Handle<JSObject>::cast(context_extension); |
88 Handle<JSFunction> closure(context->closure(), isolate); | 87 Handle<JSFunction> closure(context->closure(), isolate); |
89 context = isolate->factory()->NewWithContext(closure, context, extension); | 88 context = isolate->factory()->NewWithContext(closure, context, extension); |
90 } | 89 } |
91 | 90 |
92 Handle<JSFunction> eval_fun; | 91 Handle<JSFunction> eval_fun; |
93 ASSIGN_RETURN_ON_EXCEPTION(isolate, eval_fun, | 92 ASSIGN_RETURN_ON_EXCEPTION(isolate, eval_fun, |
94 Compiler::GetFunctionFromEval( | 93 Compiler::GetFunctionFromEval( |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 // to materialize. | 303 // to materialize. |
305 return target; | 304 return target; |
306 } | 305 } |
307 | 306 |
308 return isolate_->factory()->NewCatchContext( | 307 return isolate_->factory()->NewCatchContext( |
309 function, target, isolate_->factory()->this_string(), receiver); | 308 function, target, isolate_->factory()->this_string(), receiver); |
310 } | 309 } |
311 | 310 |
312 } // namespace internal | 311 } // namespace internal |
313 } // namespace v8 | 312 } // namespace v8 |
OLD | NEW |