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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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(isolate) || | 79 RUNTIME_ASSERT(args[0]->IsJSFunction() || args[0]->IsUndefined(isolate) || |
80 args[0]->IsNull()); | 80 args[0]->IsNull(isolate)); |
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) { |
90 SealHandleScope shs(isolate); | 90 SealHandleScope shs(isolate); |
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
559 int local = 0; | 559 int local = 0; |
560 int i = 0; | 560 int i = 0; |
561 for (; i < scope_info->StackLocalCount(); ++i) { | 561 for (; i < scope_info->StackLocalCount(); ++i) { |
562 // Use the value from the stack. | 562 // Use the value from the stack. |
563 if (ScopeInfo::VariableIsSynthetic(scope_info->LocalName(i))) continue; | 563 if (ScopeInfo::VariableIsSynthetic(scope_info->LocalName(i))) continue; |
564 locals->set(local * 2, scope_info->LocalName(i)); | 564 locals->set(local * 2, scope_info->LocalName(i)); |
565 Handle<Object> value = | 565 Handle<Object> value = |
566 frame_inspector.GetExpression(scope_info->StackLocalIndex(i)); | 566 frame_inspector.GetExpression(scope_info->StackLocalIndex(i)); |
567 // TODO(yangguo): We convert optimized out values to {undefined} when they | 567 // TODO(yangguo): We convert optimized out values to {undefined} when they |
568 // are passed to the debugger. Eventually we should handle them somehow. | 568 // are passed to the debugger. Eventually we should handle them somehow. |
569 if (value->IsOptimizedOut()) value = isolate->factory()->undefined_value(); | 569 if (value->IsOptimizedOut(isolate)) { |
| 570 value = isolate->factory()->undefined_value(); |
| 571 } |
570 locals->set(local * 2 + 1, *value); | 572 locals->set(local * 2 + 1, *value); |
571 local++; | 573 local++; |
572 } | 574 } |
573 if (local < local_count) { | 575 if (local < local_count) { |
574 // Get the context containing declarations. | 576 // Get the context containing declarations. |
575 Handle<Context> context( | 577 Handle<Context> context( |
576 Handle<Context>::cast(frame_inspector.GetContext())->closure_context()); | 578 Handle<Context>::cast(frame_inspector.GetContext())->closure_context()); |
577 for (; i < scope_info->LocalCount(); ++i) { | 579 for (; i < scope_info->LocalCount(); ++i) { |
578 Handle<String> name(scope_info->LocalName(i)); | 580 Handle<String> name(scope_info->LocalName(i)); |
579 if (ScopeInfo::VariableIsSynthetic(*name)) continue; | 581 if (ScopeInfo::VariableIsSynthetic(*name)) continue; |
(...skipping 1006 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1586 DCHECK(args.length() == 4); | 1588 DCHECK(args.length() == 4); |
1587 CONVERT_ARG_CHECKED(JSValue, script, 0); | 1589 CONVERT_ARG_CHECKED(JSValue, script, 0); |
1588 | 1590 |
1589 RUNTIME_ASSERT(script->value()->IsScript()); | 1591 RUNTIME_ASSERT(script->value()->IsScript()); |
1590 Handle<Script> script_handle = Handle<Script>(Script::cast(script->value())); | 1592 Handle<Script> script_handle = Handle<Script>(Script::cast(script->value())); |
1591 | 1593 |
1592 // Line and column are possibly undefined and we need to handle these cases, | 1594 // Line and column are possibly undefined and we need to handle these cases, |
1593 // additionally subtracting corresponding offsets. | 1595 // additionally subtracting corresponding offsets. |
1594 | 1596 |
1595 int32_t line; | 1597 int32_t line; |
1596 if (args[1]->IsNull() || args[1]->IsUndefined(isolate)) { | 1598 if (args[1]->IsNull(isolate) || args[1]->IsUndefined(isolate)) { |
1597 line = 0; | 1599 line = 0; |
1598 } else { | 1600 } else { |
1599 RUNTIME_ASSERT(args[1]->IsNumber()); | 1601 RUNTIME_ASSERT(args[1]->IsNumber()); |
1600 line = NumberToInt32(args[1]) - script_handle->line_offset(); | 1602 line = NumberToInt32(args[1]) - script_handle->line_offset(); |
1601 } | 1603 } |
1602 | 1604 |
1603 int32_t column; | 1605 int32_t column; |
1604 if (args[2]->IsNull() || args[2]->IsUndefined(isolate)) { | 1606 if (args[2]->IsNull(isolate) || args[2]->IsUndefined(isolate)) { |
1605 column = 0; | 1607 column = 0; |
1606 } else { | 1608 } else { |
1607 RUNTIME_ASSERT(args[2]->IsNumber()); | 1609 RUNTIME_ASSERT(args[2]->IsNumber()); |
1608 column = NumberToInt32(args[2]); | 1610 column = NumberToInt32(args[2]); |
1609 if (line == 0) column -= script_handle->column_offset(); | 1611 if (line == 0) column -= script_handle->column_offset(); |
1610 } | 1612 } |
1611 | 1613 |
1612 CONVERT_NUMBER_CHECKED(int32_t, offset_position, Int32, args[3]); | 1614 CONVERT_NUMBER_CHECKED(int32_t, offset_position, Int32, args[3]); |
1613 | 1615 |
1614 if (line < 0 || column < 0 || offset_position < 0) { | 1616 if (line < 0 || column < 0 || offset_position < 0) { |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1743 return Smi::FromInt(isolate->debug()->is_active()); | 1745 return Smi::FromInt(isolate->debug()->is_active()); |
1744 } | 1746 } |
1745 | 1747 |
1746 | 1748 |
1747 RUNTIME_FUNCTION(Runtime_DebugBreakInOptimizedCode) { | 1749 RUNTIME_FUNCTION(Runtime_DebugBreakInOptimizedCode) { |
1748 UNIMPLEMENTED(); | 1750 UNIMPLEMENTED(); |
1749 return NULL; | 1751 return NULL; |
1750 } | 1752 } |
1751 } // namespace internal | 1753 } // namespace internal |
1752 } // namespace v8 | 1754 } // namespace v8 |
OLD | NEW |