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

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

Issue 2622863003: [debugger] infrastructure for side-effect-free debug-evaluate. (Closed)
Patch Set: Created 3 years, 11 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
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"
11 #include "src/debug/debug-scopes.h" 11 #include "src/debug/debug-scopes.h"
12 #include "src/debug/debug.h" 12 #include "src/debug/debug.h"
13 #include "src/frames-inl.h" 13 #include "src/frames-inl.h"
14 #include "src/globals.h" 14 #include "src/globals.h"
15 #include "src/interpreter/bytecode-array-iterator.h"
16 #include "src/interpreter/bytecodes.h"
15 #include "src/isolate-inl.h" 17 #include "src/isolate-inl.h"
16 18
17 namespace v8 { 19 namespace v8 {
18 namespace internal { 20 namespace internal {
19 21
20 static inline bool IsDebugContext(Isolate* isolate, Context* context) { 22 static inline bool IsDebugContext(Isolate* isolate, Context* context) {
21 return context->native_context() == *isolate->debug()->debug_context(); 23 return context->native_context() == *isolate->debug()->debug_context();
22 } 24 }
23 25
24 MaybeHandle<Object> DebugEvaluate::Global(Isolate* isolate, 26 MaybeHandle<Object> DebugEvaluate::Global(Isolate* isolate,
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 Handle<Context> context, Handle<Object> receiver, Handle<String> source) { 87 Handle<Context> context, Handle<Object> receiver, Handle<String> source) {
86 Handle<JSFunction> eval_fun; 88 Handle<JSFunction> eval_fun;
87 ASSIGN_RETURN_ON_EXCEPTION( 89 ASSIGN_RETURN_ON_EXCEPTION(
88 isolate, eval_fun, 90 isolate, eval_fun,
89 Compiler::GetFunctionFromEval(source, outer_info, context, SLOPPY, 91 Compiler::GetFunctionFromEval(source, outer_info, context, SLOPPY,
90 NO_PARSE_RESTRICTION, kNoSourcePosition, 92 NO_PARSE_RESTRICTION, kNoSourcePosition,
91 kNoSourcePosition), 93 kNoSourcePosition),
92 Object); 94 Object);
93 95
94 Handle<Object> result; 96 Handle<Object> result;
95 ASSIGN_RETURN_ON_EXCEPTION( 97 {
96 isolate, result, Execution::Call(isolate, eval_fun, receiver, 0, NULL), 98 ReadOnlyEvaluate readonly_evaluate(isolate->debug(),
97 Object); 99 FLAG_readonly_debug_evaluate);
100 ASSIGN_RETURN_ON_EXCEPTION(
101 isolate, result, Execution::Call(isolate, eval_fun, receiver, 0, NULL),
102 Object);
103 }
98 104
99 // 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
100 // real global object. 106 // real global object.
101 if (result->IsJSGlobalProxy()) { 107 if (result->IsJSGlobalProxy()) {
102 PrototypeIterator iter(isolate, Handle<JSGlobalProxy>::cast(result)); 108 PrototypeIterator iter(isolate, Handle<JSGlobalProxy>::cast(result));
103 // TODO(verwaest): This will crash when the global proxy is detached. 109 // TODO(verwaest): This will crash when the global proxy is detached.
104 result = PrototypeIterator::GetCurrent<JSObject>(iter); 110 result = PrototypeIterator::GetCurrent<JSObject>(iter);
105 } 111 }
106 112
107 return result; 113 return result;
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 // 'this' is allocated in an outer context and is is already being 248 // 'this' is allocated in an outer context and is is already being
243 // referenced by the current function, so it can be correctly resolved. 249 // referenced by the current function, so it can be correctly resolved.
244 return; 250 return;
245 } else if (local_function->shared()->scope_info()->HasReceiver() && 251 } else if (local_function->shared()->scope_info()->HasReceiver() &&
246 !frame_->receiver()->IsTheHole(isolate_)) { 252 !frame_->receiver()->IsTheHole(isolate_)) {
247 recv = handle(frame_->receiver(), isolate_); 253 recv = handle(frame_->receiver(), isolate_);
248 } 254 }
249 JSObject::SetOwnPropertyIgnoreAttributes(target, name, recv, NONE).Check(); 255 JSObject::SetOwnPropertyIgnoreAttributes(target, name, recv, NONE).Check();
250 } 256 }
251 257
258 bool DebugEvaluate::IsReadOnly(Handle<BytecodeArray> bytecode_array) {
259 if (FLAG_trace_readonly_debug_evaluate) {
260 PrintF("[ro] Checking bytecode array\n");
261 bytecode_array->Print();
262 }
263 for (interpreter::BytecodeArrayIterator it(bytecode_array); !it.done();
264 it.Advance()) {
265 if (!interpreter::Bytecodes::BytecodeIsReadOnly(it.current_bytecode())) {
266 if (FLAG_trace_readonly_debug_evaluate) {
267 PrintF("[ro] %s is not a read-only bytecode.\n",
268 interpreter::Bytecodes::ToString(it.current_bytecode()));
269 }
270 return false;
271 }
272 }
273 return true;
274 }
275
252 } // namespace internal 276 } // namespace internal
253 } // namespace v8 277 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698