OLD | NEW |
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 1340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1351 if (function->IsJSBoundFunction()) { | 1351 if (function->IsJSBoundFunction()) { |
1352 RETURN_RESULT_OR_FAILURE( | 1352 RETURN_RESULT_OR_FAILURE( |
1353 isolate, JSBoundFunction::GetName( | 1353 isolate, JSBoundFunction::GetName( |
1354 isolate, Handle<JSBoundFunction>::cast(function))); | 1354 isolate, Handle<JSBoundFunction>::cast(function))); |
1355 } else { | 1355 } else { |
1356 return *JSFunction::GetDebugName(Handle<JSFunction>::cast(function)); | 1356 return *JSFunction::GetDebugName(Handle<JSFunction>::cast(function)); |
1357 } | 1357 } |
1358 } | 1358 } |
1359 | 1359 |
1360 | 1360 |
1361 // A testing entry. Returns statement position which is the closest to | |
1362 // source_position. | |
1363 RUNTIME_FUNCTION(Runtime_GetFunctionCodePositionFromSource) { | |
1364 HandleScope scope(isolate); | |
1365 CHECK(isolate->debug()->live_edit_enabled()); | |
1366 DCHECK(args.length() == 2); | |
1367 RUNTIME_ASSERT(isolate->debug()->is_active()); | |
1368 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | |
1369 CONVERT_NUMBER_CHECKED(int32_t, source_position, Int32, args[1]); | |
1370 | |
1371 Handle<Code> code(function->code(), isolate); | |
1372 | |
1373 if (code->kind() != Code::FUNCTION && | |
1374 code->kind() != Code::OPTIMIZED_FUNCTION) { | |
1375 return isolate->heap()->undefined_value(); | |
1376 } | |
1377 | |
1378 RelocIterator it(*code, RelocInfo::ModeMask(RelocInfo::STATEMENT_POSITION)); | |
1379 int closest_pc = 0; | |
1380 int distance = kMaxInt; | |
1381 while (!it.done()) { | |
1382 int statement_position = static_cast<int>(it.rinfo()->data()); | |
1383 // Check if this break point is closer that what was previously found. | |
1384 if (source_position <= statement_position && | |
1385 statement_position - source_position < distance) { | |
1386 closest_pc = | |
1387 static_cast<int>(it.rinfo()->pc() - code->instruction_start()); | |
1388 distance = statement_position - source_position; | |
1389 // Check whether we can't get any closer. | |
1390 if (distance == 0) break; | |
1391 } | |
1392 it.next(); | |
1393 } | |
1394 | |
1395 return Smi::FromInt(closest_pc); | |
1396 } | |
1397 | |
1398 | |
1399 // Calls specified function with or without entering the debugger. | 1361 // Calls specified function with or without entering the debugger. |
1400 // This is used in unit tests to run code as if debugger is entered or simply | 1362 // This is used in unit tests to run code as if debugger is entered or simply |
1401 // to have a stack with C++ frame in the middle. | 1363 // to have a stack with C++ frame in the middle. |
1402 RUNTIME_FUNCTION(Runtime_ExecuteInDebugContext) { | 1364 RUNTIME_FUNCTION(Runtime_ExecuteInDebugContext) { |
1403 HandleScope scope(isolate); | 1365 HandleScope scope(isolate); |
1404 DCHECK(args.length() == 1); | 1366 DCHECK(args.length() == 1); |
1405 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 1367 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
1406 | 1368 |
1407 DebugScope debug_scope(isolate->debug()); | 1369 DebugScope debug_scope(isolate->debug()); |
1408 if (debug_scope.failed()) { | 1370 if (debug_scope.failed()) { |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1752 return Smi::FromInt(isolate->debug()->is_active()); | 1714 return Smi::FromInt(isolate->debug()->is_active()); |
1753 } | 1715 } |
1754 | 1716 |
1755 | 1717 |
1756 RUNTIME_FUNCTION(Runtime_DebugBreakInOptimizedCode) { | 1718 RUNTIME_FUNCTION(Runtime_DebugBreakInOptimizedCode) { |
1757 UNIMPLEMENTED(); | 1719 UNIMPLEMENTED(); |
1758 return NULL; | 1720 return NULL; |
1759 } | 1721 } |
1760 } // namespace internal | 1722 } // namespace internal |
1761 } // namespace v8 | 1723 } // namespace v8 |
OLD | NEW |