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