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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 } | 69 } |
70 | 70 |
71 | 71 |
72 // Adds a JavaScript function as a debug event listener. | 72 // Adds a JavaScript function as a debug event listener. |
73 // args[0]: debug event listener function to set or null or undefined for | 73 // args[0]: debug event listener function to set or null or undefined for |
74 // clearing the event listener function | 74 // clearing the event listener function |
75 // args[1]: object supplied during callback | 75 // args[1]: object supplied during callback |
76 RUNTIME_FUNCTION(Runtime_SetDebugEventListener) { | 76 RUNTIME_FUNCTION(Runtime_SetDebugEventListener) { |
77 SealHandleScope shs(isolate); | 77 SealHandleScope shs(isolate); |
78 DCHECK(args.length() == 2); | 78 DCHECK(args.length() == 2); |
79 RUNTIME_ASSERT(args[0]->IsJSFunction() || args[0]->IsUndefined() || | 79 RUNTIME_ASSERT(args[0]->IsJSFunction() || args[0]->IsUndefined(isolate) || |
80 args[0]->IsNull()); | 80 args[0]->IsNull()); |
81 CONVERT_ARG_HANDLE_CHECKED(Object, callback, 0); | 81 CONVERT_ARG_HANDLE_CHECKED(Object, callback, 0); |
82 CONVERT_ARG_HANDLE_CHECKED(Object, data, 1); | 82 CONVERT_ARG_HANDLE_CHECKED(Object, data, 1); |
83 isolate->debug()->SetEventListener(callback, data); | 83 isolate->debug()->SetEventListener(callback, data); |
84 | 84 |
85 return isolate->heap()->undefined_value(); | 85 return isolate->heap()->undefined_value(); |
86 } | 86 } |
87 | 87 |
88 | 88 |
89 RUNTIME_FUNCTION(Runtime_ScheduleBreak) { | 89 RUNTIME_FUNCTION(Runtime_ScheduleBreak) { |
(...skipping 866 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
956 if (!IsPositionAlignmentCodeCorrect(statement_aligned_code)) { | 956 if (!IsPositionAlignmentCodeCorrect(statement_aligned_code)) { |
957 return isolate->ThrowIllegalOperation(); | 957 return isolate->ThrowIllegalOperation(); |
958 } | 958 } |
959 BreakPositionAlignment alignment = | 959 BreakPositionAlignment alignment = |
960 static_cast<BreakPositionAlignment>(statement_aligned_code); | 960 static_cast<BreakPositionAlignment>(statement_aligned_code); |
961 | 961 |
962 Handle<SharedFunctionInfo> shared(fun->shared()); | 962 Handle<SharedFunctionInfo> shared(fun->shared()); |
963 // Find the number of break points | 963 // Find the number of break points |
964 Handle<Object> break_locations = | 964 Handle<Object> break_locations = |
965 Debug::GetSourceBreakLocations(shared, alignment); | 965 Debug::GetSourceBreakLocations(shared, alignment); |
966 if (break_locations->IsUndefined()) return isolate->heap()->undefined_value(); | 966 if (break_locations->IsUndefined(isolate)) { |
| 967 return isolate->heap()->undefined_value(); |
| 968 } |
967 // Return array as JS array | 969 // Return array as JS array |
968 return *isolate->factory()->NewJSArrayWithElements( | 970 return *isolate->factory()->NewJSArrayWithElements( |
969 Handle<FixedArray>::cast(break_locations)); | 971 Handle<FixedArray>::cast(break_locations)); |
970 } | 972 } |
971 | 973 |
972 | 974 |
973 // Set a break point in a function. | 975 // Set a break point in a function. |
974 // args[0]: function | 976 // args[0]: function |
975 // args[1]: number: break source position (within the function source) | 977 // args[1]: number: break source position (within the function source) |
976 // args[2]: number: break point object | 978 // args[2]: number: break point object |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1204 | 1206 |
1205 // Scan the heap for objects with direct references to an object | 1207 // Scan the heap for objects with direct references to an object |
1206 // args[0]: the object to find references to | 1208 // args[0]: the object to find references to |
1207 // args[1]: constructor function for instances to exclude (Mirror) | 1209 // args[1]: constructor function for instances to exclude (Mirror) |
1208 // args[2]: the the maximum number of objects to return | 1210 // args[2]: the the maximum number of objects to return |
1209 RUNTIME_FUNCTION(Runtime_DebugReferencedBy) { | 1211 RUNTIME_FUNCTION(Runtime_DebugReferencedBy) { |
1210 HandleScope scope(isolate); | 1212 HandleScope scope(isolate); |
1211 DCHECK(args.length() == 3); | 1213 DCHECK(args.length() == 3); |
1212 CONVERT_ARG_HANDLE_CHECKED(JSObject, target, 0); | 1214 CONVERT_ARG_HANDLE_CHECKED(JSObject, target, 0); |
1213 CONVERT_ARG_HANDLE_CHECKED(Object, filter, 1); | 1215 CONVERT_ARG_HANDLE_CHECKED(Object, filter, 1); |
1214 RUNTIME_ASSERT(filter->IsUndefined() || filter->IsJSObject()); | 1216 RUNTIME_ASSERT(filter->IsUndefined(isolate) || filter->IsJSObject()); |
1215 CONVERT_NUMBER_CHECKED(int32_t, max_references, Int32, args[2]); | 1217 CONVERT_NUMBER_CHECKED(int32_t, max_references, Int32, args[2]); |
1216 RUNTIME_ASSERT(max_references >= 0); | 1218 RUNTIME_ASSERT(max_references >= 0); |
1217 | 1219 |
1218 List<Handle<JSObject> > instances; | 1220 List<Handle<JSObject> > instances; |
1219 Heap* heap = isolate->heap(); | 1221 Heap* heap = isolate->heap(); |
1220 { | 1222 { |
1221 HeapIterator iterator(heap, HeapIterator::kFilterUnreachable); | 1223 HeapIterator iterator(heap, HeapIterator::kFilterUnreachable); |
1222 // Get the constructor function for context extension and arguments array. | 1224 // Get the constructor function for context extension and arguments array. |
1223 Object* arguments_fun = isolate->sloppy_arguments_map()->GetConstructor(); | 1225 Object* arguments_fun = isolate->sloppy_arguments_map()->GetConstructor(); |
1224 HeapObject* heap_obj; | 1226 HeapObject* heap_obj; |
1225 while ((heap_obj = iterator.next())) { | 1227 while ((heap_obj = iterator.next())) { |
1226 if (!heap_obj->IsJSObject()) continue; | 1228 if (!heap_obj->IsJSObject()) continue; |
1227 JSObject* obj = JSObject::cast(heap_obj); | 1229 JSObject* obj = JSObject::cast(heap_obj); |
1228 if (obj->IsJSContextExtensionObject()) continue; | 1230 if (obj->IsJSContextExtensionObject()) continue; |
1229 if (obj->map()->GetConstructor() == arguments_fun) continue; | 1231 if (obj->map()->GetConstructor() == arguments_fun) continue; |
1230 if (!obj->ReferencesObject(*target)) continue; | 1232 if (!obj->ReferencesObject(*target)) continue; |
1231 // Check filter if supplied. This is normally used to avoid | 1233 // Check filter if supplied. This is normally used to avoid |
1232 // references from mirror objects. | 1234 // references from mirror objects. |
1233 if (!filter->IsUndefined() && | 1235 if (!filter->IsUndefined(isolate) && |
1234 HasInPrototypeChainIgnoringProxies(isolate, obj, *filter)) { | 1236 HasInPrototypeChainIgnoringProxies(isolate, obj, *filter)) { |
1235 continue; | 1237 continue; |
1236 } | 1238 } |
1237 if (obj->IsJSGlobalObject()) { | 1239 if (obj->IsJSGlobalObject()) { |
1238 obj = JSGlobalObject::cast(obj)->global_proxy(); | 1240 obj = JSGlobalObject::cast(obj)->global_proxy(); |
1239 } | 1241 } |
1240 instances.Add(Handle<JSObject>(obj)); | 1242 instances.Add(Handle<JSObject>(obj)); |
1241 if (instances.length() == max_references) break; | 1243 if (instances.length() == max_references) break; |
1242 } | 1244 } |
1243 // Iterate the rest of the heap to satisfy HeapIterator constraints. | 1245 // Iterate the rest of the heap to satisfy HeapIterator constraints. |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1583 DCHECK(args.length() == 4); | 1585 DCHECK(args.length() == 4); |
1584 CONVERT_ARG_CHECKED(JSValue, script, 0); | 1586 CONVERT_ARG_CHECKED(JSValue, script, 0); |
1585 | 1587 |
1586 RUNTIME_ASSERT(script->value()->IsScript()); | 1588 RUNTIME_ASSERT(script->value()->IsScript()); |
1587 Handle<Script> script_handle = Handle<Script>(Script::cast(script->value())); | 1589 Handle<Script> script_handle = Handle<Script>(Script::cast(script->value())); |
1588 | 1590 |
1589 // Line and column are possibly undefined and we need to handle these cases, | 1591 // Line and column are possibly undefined and we need to handle these cases, |
1590 // additionally subtracting corresponding offsets. | 1592 // additionally subtracting corresponding offsets. |
1591 | 1593 |
1592 int32_t line; | 1594 int32_t line; |
1593 if (args[1]->IsNull() || args[1]->IsUndefined()) { | 1595 if (args[1]->IsNull() || args[1]->IsUndefined(isolate)) { |
1594 line = 0; | 1596 line = 0; |
1595 } else { | 1597 } else { |
1596 RUNTIME_ASSERT(args[1]->IsNumber()); | 1598 RUNTIME_ASSERT(args[1]->IsNumber()); |
1597 line = NumberToInt32(args[1]) - script_handle->line_offset(); | 1599 line = NumberToInt32(args[1]) - script_handle->line_offset(); |
1598 } | 1600 } |
1599 | 1601 |
1600 int32_t column; | 1602 int32_t column; |
1601 if (args[2]->IsNull() || args[2]->IsUndefined()) { | 1603 if (args[2]->IsNull() || args[2]->IsUndefined(isolate)) { |
1602 column = 0; | 1604 column = 0; |
1603 } else { | 1605 } else { |
1604 RUNTIME_ASSERT(args[2]->IsNumber()); | 1606 RUNTIME_ASSERT(args[2]->IsNumber()); |
1605 column = NumberToInt32(args[2]); | 1607 column = NumberToInt32(args[2]); |
1606 if (line == 0) column -= script_handle->column_offset(); | 1608 if (line == 0) column -= script_handle->column_offset(); |
1607 } | 1609 } |
1608 | 1610 |
1609 CONVERT_NUMBER_CHECKED(int32_t, offset_position, Int32, args[3]); | 1611 CONVERT_NUMBER_CHECKED(int32_t, offset_position, Int32, args[3]); |
1610 | 1612 |
1611 if (line < 0 || column < 0 || offset_position < 0) { | 1613 if (line < 0 || column < 0 || offset_position < 0) { |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1740 return Smi::FromInt(isolate->debug()->is_active()); | 1742 return Smi::FromInt(isolate->debug()->is_active()); |
1741 } | 1743 } |
1742 | 1744 |
1743 | 1745 |
1744 RUNTIME_FUNCTION(Runtime_DebugBreakInOptimizedCode) { | 1746 RUNTIME_FUNCTION(Runtime_DebugBreakInOptimizedCode) { |
1745 UNIMPLEMENTED(); | 1747 UNIMPLEMENTED(); |
1746 return NULL; | 1748 return NULL; |
1747 } | 1749 } |
1748 } // namespace internal | 1750 } // namespace internal |
1749 } // namespace v8 | 1751 } // namespace v8 |
OLD | NEW |