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

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

Issue 2006673002: Reduce boilerplace for common pattern to return MaybeHandle. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebase and fix Created 4 years, 7 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/runtime/runtime-classes.cc ('k') | src/runtime/runtime-forin.cc » ('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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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/runtime/runtime-utils.h" 5 #include "src/runtime/runtime-utils.h"
6 6
7 #include "src/arguments.h" 7 #include "src/arguments.h"
8 #include "src/debug/debug-evaluate.h" 8 #include "src/debug/debug-evaluate.h"
9 #include "src/debug/debug-frames.h" 9 #include "src/debug/debug-frames.h"
10 #include "src/debug/debug-scopes.h" 10 #include "src/debug/debug-scopes.h"
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 return factory->NewJSArrayWithElements(result); 306 return factory->NewJSArrayWithElements(result);
307 } 307 }
308 return factory->NewJSArray(0); 308 return factory->NewJSArray(0);
309 } 309 }
310 310
311 311
312 RUNTIME_FUNCTION(Runtime_DebugGetInternalProperties) { 312 RUNTIME_FUNCTION(Runtime_DebugGetInternalProperties) {
313 HandleScope scope(isolate); 313 HandleScope scope(isolate);
314 DCHECK(args.length() == 1); 314 DCHECK(args.length() == 1);
315 CONVERT_ARG_HANDLE_CHECKED(Object, obj, 0); 315 CONVERT_ARG_HANDLE_CHECKED(Object, obj, 0);
316 Handle<JSArray> result; 316 RETURN_RESULT_OR_FAILURE(isolate,
317 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 317 Runtime::GetInternalProperties(isolate, obj));
318 isolate, result, Runtime::GetInternalProperties(isolate, obj));
319 return *result;
320 } 318 }
321 319
322 320
323 // Get debugger related details for an object property, in the following format: 321 // Get debugger related details for an object property, in the following format:
324 // 0: Property value 322 // 0: Property value
325 // 1: Property details 323 // 1: Property details
326 // 2: Property value is exception 324 // 2: Property value is exception
327 // 3: Getter function if defined 325 // 3: Getter function if defined
328 // 4: Setter function if defined 326 // 4: Setter function if defined
329 // Items 2-4 are only filled if the property has either a getter or a setter. 327 // Items 2-4 are only filled if the property has either a getter or a setter.
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after
757 755
758 // Find the requested scope. 756 // Find the requested scope.
759 int n = 0; 757 int n = 0;
760 ScopeIterator it(isolate, &frame_inspector); 758 ScopeIterator it(isolate, &frame_inspector);
761 for (; !it.Done() && n < index; it.Next()) { 759 for (; !it.Done() && n < index; it.Next()) {
762 n++; 760 n++;
763 } 761 }
764 if (it.Done()) { 762 if (it.Done()) {
765 return isolate->heap()->undefined_value(); 763 return isolate->heap()->undefined_value();
766 } 764 }
767 Handle<JSObject> details; 765 RETURN_RESULT_OR_FAILURE(isolate, it.MaterializeScopeDetails());
768 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, details,
769 it.MaterializeScopeDetails());
770 return *details;
771 } 766 }
772 767
773 768
774 // Return an array of scope details 769 // Return an array of scope details
775 // args[0]: number: break id 770 // args[0]: number: break id
776 // args[1]: number: frame index 771 // args[1]: number: frame index
777 // args[2]: number: inlined frame index 772 // args[2]: number: inlined frame index
778 // args[3]: boolean: ignore nested scopes 773 // args[3]: boolean: ignore nested scopes
779 // 774 //
780 // The array returned contains arrays with the following information: 775 // The array returned contains arrays with the following information:
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
849 // Find the requested scope. 844 // Find the requested scope.
850 int n = 0; 845 int n = 0;
851 ScopeIterator it(isolate, fun); 846 ScopeIterator it(isolate, fun);
852 for (; !it.Done() && n < index; it.Next()) { 847 for (; !it.Done() && n < index; it.Next()) {
853 n++; 848 n++;
854 } 849 }
855 if (it.Done()) { 850 if (it.Done()) {
856 return isolate->heap()->undefined_value(); 851 return isolate->heap()->undefined_value();
857 } 852 }
858 853
859 Handle<JSObject> details; 854 RETURN_RESULT_OR_FAILURE(isolate, it.MaterializeScopeDetails());
860 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, details,
861 it.MaterializeScopeDetails());
862 return *details;
863 } 855 }
864 856
865 857
866 static bool SetScopeVariableValue(ScopeIterator* it, int index, 858 static bool SetScopeVariableValue(ScopeIterator* it, int index,
867 Handle<String> variable_name, 859 Handle<String> variable_name,
868 Handle<Object> new_value) { 860 Handle<Object> new_value) {
869 for (int n = 0; !it->Done() && n < index; it->Next()) { 861 for (int n = 0; !it->Done() && n < index; it->Next()) {
870 n++; 862 n++;
871 } 863 }
872 if (it->Done()) { 864 if (it->Done()) {
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
1134 RUNTIME_ASSERT(isolate->debug()->CheckExecutionState(break_id)); 1126 RUNTIME_ASSERT(isolate->debug()->CheckExecutionState(break_id));
1135 1127
1136 CONVERT_SMI_ARG_CHECKED(wrapped_id, 1); 1128 CONVERT_SMI_ARG_CHECKED(wrapped_id, 1);
1137 CONVERT_NUMBER_CHECKED(int, inlined_jsframe_index, Int32, args[2]); 1129 CONVERT_NUMBER_CHECKED(int, inlined_jsframe_index, Int32, args[2]);
1138 CONVERT_ARG_HANDLE_CHECKED(String, source, 3); 1130 CONVERT_ARG_HANDLE_CHECKED(String, source, 3);
1139 CONVERT_BOOLEAN_ARG_CHECKED(disable_break, 4); 1131 CONVERT_BOOLEAN_ARG_CHECKED(disable_break, 4);
1140 CONVERT_ARG_HANDLE_CHECKED(HeapObject, context_extension, 5); 1132 CONVERT_ARG_HANDLE_CHECKED(HeapObject, context_extension, 5);
1141 1133
1142 StackFrame::Id id = DebugFrameHelper::UnwrapFrameId(wrapped_id); 1134 StackFrame::Id id = DebugFrameHelper::UnwrapFrameId(wrapped_id);
1143 1135
1144 Handle<Object> result; 1136 RETURN_RESULT_OR_FAILURE(
1145 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 1137 isolate, DebugEvaluate::Local(isolate, id, inlined_jsframe_index, source,
1146 isolate, result, 1138 disable_break, context_extension));
1147 DebugEvaluate::Local(isolate, id, inlined_jsframe_index, source,
1148 disable_break, context_extension));
1149 return *result;
1150 } 1139 }
1151 1140
1152 1141
1153 RUNTIME_FUNCTION(Runtime_DebugEvaluateGlobal) { 1142 RUNTIME_FUNCTION(Runtime_DebugEvaluateGlobal) {
1154 HandleScope scope(isolate); 1143 HandleScope scope(isolate);
1155 1144
1156 // Check the execution state and decode arguments frame and source to be 1145 // Check the execution state and decode arguments frame and source to be
1157 // evaluated. 1146 // evaluated.
1158 DCHECK(args.length() == 4); 1147 DCHECK(args.length() == 4);
1159 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); 1148 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]);
1160 RUNTIME_ASSERT(isolate->debug()->CheckExecutionState(break_id)); 1149 RUNTIME_ASSERT(isolate->debug()->CheckExecutionState(break_id));
1161 1150
1162 CONVERT_ARG_HANDLE_CHECKED(String, source, 1); 1151 CONVERT_ARG_HANDLE_CHECKED(String, source, 1);
1163 CONVERT_BOOLEAN_ARG_CHECKED(disable_break, 2); 1152 CONVERT_BOOLEAN_ARG_CHECKED(disable_break, 2);
1164 CONVERT_ARG_HANDLE_CHECKED(HeapObject, context_extension, 3); 1153 CONVERT_ARG_HANDLE_CHECKED(HeapObject, context_extension, 3);
1165 1154
1166 Handle<Object> result; 1155 RETURN_RESULT_OR_FAILURE(
1167 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 1156 isolate,
1168 isolate, result,
1169 DebugEvaluate::Global(isolate, source, disable_break, context_extension)); 1157 DebugEvaluate::Global(isolate, source, disable_break, context_extension));
1170 return *result;
1171 } 1158 }
1172 1159
1173 1160
1174 RUNTIME_FUNCTION(Runtime_DebugGetLoadedScripts) { 1161 RUNTIME_FUNCTION(Runtime_DebugGetLoadedScripts) {
1175 HandleScope scope(isolate); 1162 HandleScope scope(isolate);
1176 DCHECK(args.length() == 0); 1163 DCHECK(args.length() == 0);
1177 RUNTIME_ASSERT(isolate->debug()->is_active()); 1164 RUNTIME_ASSERT(isolate->debug()->is_active());
1178 1165
1179 Handle<FixedArray> instances; 1166 Handle<FixedArray> instances;
1180 { 1167 {
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
1306 return *isolate->factory()->NewJSArrayWithElements(result); 1293 return *isolate->factory()->NewJSArrayWithElements(result);
1307 } 1294 }
1308 1295
1309 1296
1310 // Find the effective prototype object as returned by __proto__. 1297 // Find the effective prototype object as returned by __proto__.
1311 // args[0]: the object to find the prototype for. 1298 // args[0]: the object to find the prototype for.
1312 RUNTIME_FUNCTION(Runtime_DebugGetPrototype) { 1299 RUNTIME_FUNCTION(Runtime_DebugGetPrototype) {
1313 HandleScope shs(isolate); 1300 HandleScope shs(isolate);
1314 DCHECK(args.length() == 1); 1301 DCHECK(args.length() == 1);
1315 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); 1302 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0);
1316 Handle<Object> prototype;
1317 // TODO(1543): Come up with a solution for clients to handle potential errors 1303 // TODO(1543): Come up with a solution for clients to handle potential errors
1318 // thrown by an intermediate proxy. 1304 // thrown by an intermediate proxy.
1319 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, prototype, 1305 RETURN_RESULT_OR_FAILURE(isolate, JSReceiver::GetPrototype(isolate, obj));
1320 JSReceiver::GetPrototype(isolate, obj));
1321 return *prototype;
1322 } 1306 }
1323 1307
1324 1308
1325 // Patches script source (should be called upon BeforeCompile event). 1309 // Patches script source (should be called upon BeforeCompile event).
1326 RUNTIME_FUNCTION(Runtime_DebugSetScriptSource) { 1310 RUNTIME_FUNCTION(Runtime_DebugSetScriptSource) {
1327 HandleScope scope(isolate); 1311 HandleScope scope(isolate);
1328 DCHECK(args.length() == 2); 1312 DCHECK(args.length() == 2);
1329 1313
1330 CONVERT_ARG_HANDLE_CHECKED(JSValue, script_wrapper, 0); 1314 CONVERT_ARG_HANDLE_CHECKED(JSValue, script_wrapper, 0);
1331 CONVERT_ARG_HANDLE_CHECKED(String, source, 1); 1315 CONVERT_ARG_HANDLE_CHECKED(String, source, 1);
(...skipping 20 matching lines...) Expand all
1352 return isolate->heap()->empty_string(); 1336 return isolate->heap()->empty_string();
1353 } 1337 }
1354 1338
1355 1339
1356 RUNTIME_FUNCTION(Runtime_FunctionGetDebugName) { 1340 RUNTIME_FUNCTION(Runtime_FunctionGetDebugName) {
1357 HandleScope scope(isolate); 1341 HandleScope scope(isolate);
1358 DCHECK_EQ(1, args.length()); 1342 DCHECK_EQ(1, args.length());
1359 1343
1360 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, function, 0); 1344 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, function, 0);
1361 1345
1362 Handle<Object> name;
1363 if (function->IsJSBoundFunction()) { 1346 if (function->IsJSBoundFunction()) {
1364 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 1347 RETURN_RESULT_OR_FAILURE(
1365 isolate, name, JSBoundFunction::GetName( 1348 isolate, JSBoundFunction::GetName(
1366 isolate, Handle<JSBoundFunction>::cast(function))); 1349 isolate, Handle<JSBoundFunction>::cast(function)));
1367 } else { 1350 } else {
1368 name = JSFunction::GetDebugName(Handle<JSFunction>::cast(function)); 1351 return *JSFunction::GetDebugName(Handle<JSFunction>::cast(function));
1369 } 1352 }
1370 return *name;
1371 } 1353 }
1372 1354
1373 1355
1374 // A testing entry. Returns statement position which is the closest to 1356 // A testing entry. Returns statement position which is the closest to
1375 // source_position. 1357 // source_position.
1376 RUNTIME_FUNCTION(Runtime_GetFunctionCodePositionFromSource) { 1358 RUNTIME_FUNCTION(Runtime_GetFunctionCodePositionFromSource) {
1377 HandleScope scope(isolate); 1359 HandleScope scope(isolate);
1378 CHECK(isolate->debug()->live_edit_enabled()); 1360 CHECK(isolate->debug()->live_edit_enabled());
1379 DCHECK(args.length() == 2); 1361 DCHECK(args.length() == 2);
1380 RUNTIME_ASSERT(isolate->debug()->is_active()); 1362 RUNTIME_ASSERT(isolate->debug()->is_active());
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1416 HandleScope scope(isolate); 1398 HandleScope scope(isolate);
1417 DCHECK(args.length() == 1); 1399 DCHECK(args.length() == 1);
1418 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); 1400 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
1419 1401
1420 DebugScope debug_scope(isolate->debug()); 1402 DebugScope debug_scope(isolate->debug());
1421 if (debug_scope.failed()) { 1403 if (debug_scope.failed()) {
1422 DCHECK(isolate->has_pending_exception()); 1404 DCHECK(isolate->has_pending_exception());
1423 return isolate->heap()->exception(); 1405 return isolate->heap()->exception();
1424 } 1406 }
1425 1407
1426 Handle<Object> result; 1408 RETURN_RESULT_OR_FAILURE(
1427 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 1409 isolate, Execution::Call(isolate, function,
1428 isolate, result, 1410 handle(function->global_proxy()), 0, NULL));
1429 Execution::Call(isolate, function, handle(function->global_proxy()), 0,
1430 NULL));
1431 return *result;
1432 } 1411 }
1433 1412
1434 1413
1435 RUNTIME_FUNCTION(Runtime_GetDebugContext) { 1414 RUNTIME_FUNCTION(Runtime_GetDebugContext) {
1436 HandleScope scope(isolate); 1415 HandleScope scope(isolate);
1437 DCHECK(args.length() == 0); 1416 DCHECK(args.length() == 0);
1438 Handle<Context> context; 1417 Handle<Context> context;
1439 { 1418 {
1440 DebugScope debug_scope(isolate->debug()); 1419 DebugScope debug_scope(isolate->debug());
1441 if (debug_scope.failed()) { 1420 if (debug_scope.failed()) {
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
1647 return Smi::FromInt(isolate->debug()->is_active()); 1626 return Smi::FromInt(isolate->debug()->is_active());
1648 } 1627 }
1649 1628
1650 1629
1651 RUNTIME_FUNCTION(Runtime_DebugBreakInOptimizedCode) { 1630 RUNTIME_FUNCTION(Runtime_DebugBreakInOptimizedCode) {
1652 UNIMPLEMENTED(); 1631 UNIMPLEMENTED();
1653 return NULL; 1632 return NULL;
1654 } 1633 }
1655 } // namespace internal 1634 } // namespace internal
1656 } // namespace v8 1635 } // namespace v8
OLDNEW
« no previous file with comments | « src/runtime/runtime-classes.cc ('k') | src/runtime/runtime-forin.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698