Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(251)

Side by Side Diff: src/debug/debug-evaluate.cc

Issue 2687013003: Revert of [debugger] expose side-effect free evaluate to inspector. (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/debug/debug-evaluate.h ('k') | src/debug/mirrors.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/compiler.h" 8 #include "src/compiler.h"
9 #include "src/contexts.h" 9 #include "src/contexts.h"
10 #include "src/debug/debug-frames.h" 10 #include "src/debug/debug-frames.h"
(...skipping 23 matching lines...) Expand all
34 while (top != NULL && IsDebugContext(isolate, *top->context())) { 34 while (top != NULL && IsDebugContext(isolate, *top->context())) {
35 top = top->prev(); 35 top = top->prev();
36 } 36 }
37 if (top != NULL) isolate->set_context(*top->context()); 37 if (top != NULL) isolate->set_context(*top->context());
38 38
39 // Get the native context now set to the top context from before the 39 // Get the native context now set to the top context from before the
40 // debugger was invoked. 40 // debugger was invoked.
41 Handle<Context> context = isolate->native_context(); 41 Handle<Context> context = isolate->native_context();
42 Handle<JSObject> receiver(context->global_proxy()); 42 Handle<JSObject> receiver(context->global_proxy());
43 Handle<SharedFunctionInfo> outer_info(context->closure()->shared(), isolate); 43 Handle<SharedFunctionInfo> outer_info(context->closure()->shared(), isolate);
44 return Evaluate(isolate, outer_info, context, receiver, source, false); 44 return Evaluate(isolate, outer_info, context, receiver, source);
45 } 45 }
46 46
47 MaybeHandle<Object> DebugEvaluate::Local(Isolate* isolate, 47 MaybeHandle<Object> DebugEvaluate::Local(Isolate* isolate,
48 StackFrame::Id frame_id, 48 StackFrame::Id frame_id,
49 int inlined_jsframe_index, 49 int inlined_jsframe_index,
50 Handle<String> source, 50 Handle<String> source) {
51 bool throw_on_side_effect) {
52 // Handle the processing of break. 51 // Handle the processing of break.
53 DisableBreak disable_break_scope(isolate->debug()); 52 DisableBreak disable_break_scope(isolate->debug());
54 53
55 // Get the frame where the debugging is performed. 54 // Get the frame where the debugging is performed.
56 StackTraceFrameIterator it(isolate, frame_id); 55 StackTraceFrameIterator it(isolate, frame_id);
57 if (!it.is_javascript()) return isolate->factory()->undefined_value(); 56 if (!it.is_javascript()) return isolate->factory()->undefined_value();
58 JavaScriptFrame* frame = it.javascript_frame(); 57 JavaScriptFrame* frame = it.javascript_frame();
59 58
60 // Traverse the saved contexts chain to find the active context for the 59 // Traverse the saved contexts chain to find the active context for the
61 // selected frame. 60 // selected frame.
62 SaveContext* save = 61 SaveContext* save =
63 DebugFrameHelper::FindSavedContextForFrame(isolate, frame); 62 DebugFrameHelper::FindSavedContextForFrame(isolate, frame);
64 SaveContext savex(isolate); 63 SaveContext savex(isolate);
65 isolate->set_context(*(save->context())); 64 isolate->set_context(*(save->context()));
66 65
67 // This is not a lot different than DebugEvaluate::Global, except that 66 // This is not a lot different than DebugEvaluate::Global, except that
68 // variables accessible by the function we are evaluating from are 67 // variables accessible by the function we are evaluating from are
69 // materialized and included on top of the native context. Changes to 68 // materialized and included on top of the native context. Changes to
70 // the materialized object are written back afterwards. 69 // the materialized object are written back afterwards.
71 // Note that the native context is taken from the original context chain, 70 // Note that the native context is taken from the original context chain,
72 // which may not be the current native context of the isolate. 71 // which may not be the current native context of the isolate.
73 ContextBuilder context_builder(isolate, frame, inlined_jsframe_index); 72 ContextBuilder context_builder(isolate, frame, inlined_jsframe_index);
74 if (isolate->has_pending_exception()) return MaybeHandle<Object>(); 73 if (isolate->has_pending_exception()) return MaybeHandle<Object>();
75 74
76 Handle<Context> context = context_builder.evaluation_context(); 75 Handle<Context> context = context_builder.evaluation_context();
77 Handle<JSObject> receiver(context->global_proxy()); 76 Handle<JSObject> receiver(context->global_proxy());
78 MaybeHandle<Object> maybe_result = 77 MaybeHandle<Object> maybe_result = Evaluate(
79 Evaluate(isolate, context_builder.outer_info(), context, receiver, source, 78 isolate, context_builder.outer_info(), context, receiver, source);
80 throw_on_side_effect);
81 if (!maybe_result.is_null()) context_builder.UpdateValues(); 79 if (!maybe_result.is_null()) context_builder.UpdateValues();
82 return maybe_result; 80 return maybe_result;
83 } 81 }
84 82
85 83
86 // Compile and evaluate source for the given context. 84 // Compile and evaluate source for the given context.
87 MaybeHandle<Object> DebugEvaluate::Evaluate( 85 MaybeHandle<Object> DebugEvaluate::Evaluate(
88 Isolate* isolate, Handle<SharedFunctionInfo> outer_info, 86 Isolate* isolate, Handle<SharedFunctionInfo> outer_info,
89 Handle<Context> context, Handle<Object> receiver, Handle<String> source, 87 Handle<Context> context, Handle<Object> receiver, Handle<String> source) {
90 bool throw_on_side_effect) {
91 Handle<JSFunction> eval_fun; 88 Handle<JSFunction> eval_fun;
92 ASSIGN_RETURN_ON_EXCEPTION( 89 ASSIGN_RETURN_ON_EXCEPTION(
93 isolate, eval_fun, 90 isolate, eval_fun,
94 Compiler::GetFunctionFromEval(source, outer_info, context, SLOPPY, 91 Compiler::GetFunctionFromEval(source, outer_info, context, SLOPPY,
95 NO_PARSE_RESTRICTION, kNoSourcePosition, 92 NO_PARSE_RESTRICTION, kNoSourcePosition,
96 kNoSourcePosition), 93 kNoSourcePosition),
97 Object); 94 Object);
98 95
99 Handle<Object> result; 96 Handle<Object> result;
100 { 97 {
101 NoSideEffectScope no_side_effect(isolate, throw_on_side_effect); 98 NoSideEffectScope no_side_effect(isolate,
99 FLAG_side_effect_free_debug_evaluate);
102 ASSIGN_RETURN_ON_EXCEPTION( 100 ASSIGN_RETURN_ON_EXCEPTION(
103 isolate, result, Execution::Call(isolate, eval_fun, receiver, 0, NULL), 101 isolate, result, Execution::Call(isolate, eval_fun, receiver, 0, NULL),
104 Object); 102 Object);
105 } 103 }
106 104
107 // Skip the global proxy as it has no properties and always delegates to the 105 // Skip the global proxy as it has no properties and always delegates to the
108 // real global object. 106 // real global object.
109 if (result->IsJSGlobalProxy()) { 107 if (result->IsJSGlobalProxy()) {
110 PrototypeIterator iter(isolate, Handle<JSGlobalProxy>::cast(result)); 108 PrototypeIterator iter(isolate, Handle<JSGlobalProxy>::cast(result));
111 // TODO(verwaest): This will crash when the global proxy is detached. 109 // TODO(verwaest): This will crash when the global proxy is detached.
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 510
513 if (FLAG_trace_side_effect_free_debug_evaluate) { 511 if (FLAG_trace_side_effect_free_debug_evaluate) {
514 PrintF("[debug-evaluate] API Callback at %p may cause side effect.\n", 512 PrintF("[debug-evaluate] API Callback at %p may cause side effect.\n",
515 reinterpret_cast<void*>(function_addr)); 513 reinterpret_cast<void*>(function_addr));
516 } 514 }
517 return false; 515 return false;
518 } 516 }
519 517
520 } // namespace internal 518 } // namespace internal
521 } // namespace v8 519 } // namespace v8
OLDNEW
« no previous file with comments | « src/debug/debug-evaluate.h ('k') | src/debug/mirrors.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698