| 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 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 // Return the property attribute calculated from the property details. | 403 // Return the property attribute calculated from the property details. |
| 404 // args[0]: smi with property details. | 404 // args[0]: smi with property details. |
| 405 RUNTIME_FUNCTION(Runtime_DebugPropertyAttributesFromDetails) { | 405 RUNTIME_FUNCTION(Runtime_DebugPropertyAttributesFromDetails) { |
| 406 SealHandleScope shs(isolate); | 406 SealHandleScope shs(isolate); |
| 407 DCHECK(args.length() == 1); | 407 DCHECK(args.length() == 1); |
| 408 CONVERT_PROPERTY_DETAILS_CHECKED(details, 0); | 408 CONVERT_PROPERTY_DETAILS_CHECKED(details, 0); |
| 409 return Smi::FromInt(static_cast<int>(details.attributes())); | 409 return Smi::FromInt(static_cast<int>(details.attributes())); |
| 410 } | 410 } |
| 411 | 411 |
| 412 | 412 |
| 413 // Return the property insertion index calculated from the property details. | |
| 414 // args[0]: smi with property details. | |
| 415 RUNTIME_FUNCTION(Runtime_DebugPropertyIndexFromDetails) { | |
| 416 SealHandleScope shs(isolate); | |
| 417 DCHECK(args.length() == 1); | |
| 418 CONVERT_PROPERTY_DETAILS_CHECKED(details, 0); | |
| 419 // TODO(verwaest): Works only for dictionary mode holders. | |
| 420 return Smi::FromInt(details.dictionary_index()); | |
| 421 } | |
| 422 | |
| 423 | |
| 424 // Return property value from named interceptor. | |
| 425 // args[0]: object | |
| 426 // args[1]: property name | |
| 427 RUNTIME_FUNCTION(Runtime_DebugNamedInterceptorPropertyValue) { | |
| 428 HandleScope scope(isolate); | |
| 429 DCHECK(args.length() == 2); | |
| 430 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); | |
| 431 RUNTIME_ASSERT(obj->HasNamedInterceptor()); | |
| 432 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); | |
| 433 | |
| 434 Handle<Object> result; | |
| 435 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, | |
| 436 JSObject::GetProperty(obj, name)); | |
| 437 return *result; | |
| 438 } | |
| 439 | |
| 440 | |
| 441 // Return element value from indexed interceptor. | |
| 442 // args[0]: object | |
| 443 // args[1]: index | |
| 444 RUNTIME_FUNCTION(Runtime_DebugIndexedInterceptorElementValue) { | |
| 445 HandleScope scope(isolate); | |
| 446 DCHECK(args.length() == 2); | |
| 447 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); | |
| 448 RUNTIME_ASSERT(obj->HasIndexedInterceptor()); | |
| 449 CONVERT_NUMBER_CHECKED(uint32_t, index, Uint32, args[1]); | |
| 450 Handle<Object> result; | |
| 451 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | |
| 452 isolate, result, JSReceiver::GetElement(isolate, obj, index)); | |
| 453 return *result; | |
| 454 } | |
| 455 | |
| 456 | |
| 457 RUNTIME_FUNCTION(Runtime_CheckExecutionState) { | 413 RUNTIME_FUNCTION(Runtime_CheckExecutionState) { |
| 458 SealHandleScope shs(isolate); | 414 SealHandleScope shs(isolate); |
| 459 DCHECK(args.length() == 1); | 415 DCHECK(args.length() == 1); |
| 460 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); | 416 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); |
| 461 RUNTIME_ASSERT(isolate->debug()->CheckExecutionState(break_id)); | 417 RUNTIME_ASSERT(isolate->debug()->CheckExecutionState(break_id)); |
| 462 return isolate->heap()->true_value(); | 418 return isolate->heap()->true_value(); |
| 463 } | 419 } |
| 464 | 420 |
| 465 | 421 |
| 466 RUNTIME_FUNCTION(Runtime_GetFrameCount) { | 422 RUNTIME_FUNCTION(Runtime_GetFrameCount) { |
| (...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 953 FrameInspector frame_inspector(frame, 0, isolate); | 909 FrameInspector frame_inspector(frame, 0, isolate); |
| 954 | 910 |
| 955 for (ScopeIterator it(isolate, &frame_inspector); !it.Done(); it.Next()) { | 911 for (ScopeIterator it(isolate, &frame_inspector); !it.Done(); it.Next()) { |
| 956 it.DebugPrint(); | 912 it.DebugPrint(); |
| 957 } | 913 } |
| 958 #endif | 914 #endif |
| 959 return isolate->heap()->undefined_value(); | 915 return isolate->heap()->undefined_value(); |
| 960 } | 916 } |
| 961 | 917 |
| 962 | 918 |
| 963 RUNTIME_FUNCTION(Runtime_GetThreadCount) { | |
| 964 HandleScope scope(isolate); | |
| 965 DCHECK(args.length() == 1); | |
| 966 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); | |
| 967 RUNTIME_ASSERT(isolate->debug()->CheckExecutionState(break_id)); | |
| 968 | |
| 969 // Count all archived V8 threads. | |
| 970 int n = 0; | |
| 971 for (ThreadState* thread = isolate->thread_manager()->FirstThreadStateInUse(); | |
| 972 thread != NULL; thread = thread->Next()) { | |
| 973 n++; | |
| 974 } | |
| 975 | |
| 976 // Total number of threads is current thread and archived threads. | |
| 977 return Smi::FromInt(n + 1); | |
| 978 } | |
| 979 | |
| 980 | |
| 981 static const int kThreadDetailsCurrentThreadIndex = 0; | |
| 982 static const int kThreadDetailsThreadIdIndex = 1; | |
| 983 static const int kThreadDetailsSize = 2; | |
| 984 | |
| 985 // Return an array with thread details | |
| 986 // args[0]: number: break id | |
| 987 // args[1]: number: thread index | |
| 988 // | |
| 989 // The array returned contains the following information: | |
| 990 // 0: Is current thread? | |
| 991 // 1: Thread id | |
| 992 RUNTIME_FUNCTION(Runtime_GetThreadDetails) { | |
| 993 HandleScope scope(isolate); | |
| 994 DCHECK(args.length() == 2); | |
| 995 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); | |
| 996 RUNTIME_ASSERT(isolate->debug()->CheckExecutionState(break_id)); | |
| 997 | |
| 998 CONVERT_NUMBER_CHECKED(int, index, Int32, args[1]); | |
| 999 | |
| 1000 // Allocate array for result. | |
| 1001 Handle<FixedArray> details = | |
| 1002 isolate->factory()->NewFixedArray(kThreadDetailsSize); | |
| 1003 | |
| 1004 // Thread index 0 is current thread. | |
| 1005 if (index == 0) { | |
| 1006 // Fill the details. | |
| 1007 details->set(kThreadDetailsCurrentThreadIndex, | |
| 1008 isolate->heap()->true_value()); | |
| 1009 details->set(kThreadDetailsThreadIdIndex, | |
| 1010 Smi::FromInt(ThreadId::Current().ToInteger())); | |
| 1011 } else { | |
| 1012 // Find the thread with the requested index. | |
| 1013 int n = 1; | |
| 1014 ThreadState* thread = isolate->thread_manager()->FirstThreadStateInUse(); | |
| 1015 while (index != n && thread != NULL) { | |
| 1016 thread = thread->Next(); | |
| 1017 n++; | |
| 1018 } | |
| 1019 if (thread == NULL) { | |
| 1020 return isolate->heap()->undefined_value(); | |
| 1021 } | |
| 1022 | |
| 1023 // Fill the details. | |
| 1024 details->set(kThreadDetailsCurrentThreadIndex, | |
| 1025 isolate->heap()->false_value()); | |
| 1026 details->set(kThreadDetailsThreadIdIndex, | |
| 1027 Smi::FromInt(thread->id().ToInteger())); | |
| 1028 } | |
| 1029 | |
| 1030 // Convert to JS array and return. | |
| 1031 return *isolate->factory()->NewJSArrayWithElements(details); | |
| 1032 } | |
| 1033 | |
| 1034 | |
| 1035 // Sets the disable break state | 919 // Sets the disable break state |
| 1036 // args[0]: disable break state | 920 // args[0]: disable break state |
| 1037 RUNTIME_FUNCTION(Runtime_SetBreakPointsActive) { | 921 RUNTIME_FUNCTION(Runtime_SetBreakPointsActive) { |
| 1038 HandleScope scope(isolate); | 922 HandleScope scope(isolate); |
| 1039 DCHECK(args.length() == 1); | 923 DCHECK(args.length() == 1); |
| 1040 CONVERT_BOOLEAN_ARG_CHECKED(active, 0); | 924 CONVERT_BOOLEAN_ARG_CHECKED(active, 0); |
| 1041 isolate->debug()->set_break_points_active(active); | 925 isolate->debug()->set_break_points_active(active); |
| 1042 return isolate->heap()->undefined_value(); | 926 return isolate->heap()->undefined_value(); |
| 1043 } | 927 } |
| 1044 | 928 |
| (...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1645 return Smi::FromInt(isolate->debug()->is_active()); | 1529 return Smi::FromInt(isolate->debug()->is_active()); |
| 1646 } | 1530 } |
| 1647 | 1531 |
| 1648 | 1532 |
| 1649 RUNTIME_FUNCTION(Runtime_DebugBreakInOptimizedCode) { | 1533 RUNTIME_FUNCTION(Runtime_DebugBreakInOptimizedCode) { |
| 1650 UNIMPLEMENTED(); | 1534 UNIMPLEMENTED(); |
| 1651 return NULL; | 1535 return NULL; |
| 1652 } | 1536 } |
| 1653 } // namespace internal | 1537 } // namespace internal |
| 1654 } // namespace v8 | 1538 } // namespace v8 |
| OLD | NEW |