OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/api.h" | 7 #include "src/api.h" |
8 #include "src/arguments.h" | 8 #include "src/arguments.h" |
9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
(...skipping 1488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1499 if (!HasDebugInfo(shared)) { | 1499 if (!HasDebugInfo(shared)) { |
1500 return Handle<Object>(heap->undefined_value(), isolate); | 1500 return Handle<Object>(heap->undefined_value(), isolate); |
1501 } | 1501 } |
1502 Handle<DebugInfo> debug_info = GetDebugInfo(shared); | 1502 Handle<DebugInfo> debug_info = GetDebugInfo(shared); |
1503 if (debug_info->GetBreakPointCount() == 0) { | 1503 if (debug_info->GetBreakPointCount() == 0) { |
1504 return Handle<Object>(heap->undefined_value(), isolate); | 1504 return Handle<Object>(heap->undefined_value(), isolate); |
1505 } | 1505 } |
1506 Handle<FixedArray> locations = | 1506 Handle<FixedArray> locations = |
1507 isolate->factory()->NewFixedArray(debug_info->GetBreakPointCount()); | 1507 isolate->factory()->NewFixedArray(debug_info->GetBreakPointCount()); |
1508 int count = 0; | 1508 int count = 0; |
1509 for (int i = 0; i < debug_info->break_points()->length(); i++) { | 1509 for (int i = 0; i < debug_info->break_points()->length(); ++i) { |
1510 if (!debug_info->break_points()->get(i)->IsUndefined()) { | 1510 if (!debug_info->break_points()->get(i)->IsUndefined()) { |
1511 BreakPointInfo* break_point_info = | 1511 BreakPointInfo* break_point_info = |
1512 BreakPointInfo::cast(debug_info->break_points()->get(i)); | 1512 BreakPointInfo::cast(debug_info->break_points()->get(i)); |
1513 if (break_point_info->GetBreakPointCount() > 0) { | 1513 int break_points = break_point_info->GetBreakPointCount(); |
1514 Smi* position = NULL; | 1514 if (break_points == 0) continue; |
1515 switch (position_alignment) { | 1515 Smi* position = NULL; |
1516 case STATEMENT_ALIGNED: | 1516 switch (position_alignment) { |
1517 position = break_point_info->statement_position(); | 1517 case STATEMENT_ALIGNED: |
1518 break; | 1518 position = break_point_info->statement_position(); |
1519 case BREAK_POSITION_ALIGNED: | 1519 break; |
1520 position = break_point_info->source_position(); | 1520 case BREAK_POSITION_ALIGNED: |
1521 break; | 1521 position = break_point_info->source_position(); |
1522 } | 1522 break; |
1523 | |
1524 locations->set(count++, position); | |
1525 } | 1523 } |
| 1524 for (int j = 0; j < break_points; ++j) locations->set(count++, position); |
1526 } | 1525 } |
1527 } | 1526 } |
1528 return locations; | 1527 return locations; |
1529 } | 1528 } |
1530 | 1529 |
1531 | 1530 |
1532 // Handle stepping into a function. | 1531 // Handle stepping into a function. |
1533 void Debug::HandleStepIn(Handle<Object> function_obj, Handle<Object> holder, | 1532 void Debug::HandleStepIn(Handle<Object> function_obj, Handle<Object> holder, |
1534 Address fp, bool is_constructor) { | 1533 Address fp, bool is_constructor) { |
1535 // Flood getter/setter if we either step in or step to another frame. | 1534 // Flood getter/setter if we either step in or step to another frame. |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1815 int code_offset = generators[i]->continuation(); | 1814 int code_offset = generators[i]->continuation(); |
1816 int pc_offset = ComputePcOffsetFromCodeOffset(fun->code(), code_offset); | 1815 int pc_offset = ComputePcOffsetFromCodeOffset(fun->code(), code_offset); |
1817 generators[i]->set_continuation(pc_offset); | 1816 generators[i]->set_continuation(pc_offset); |
1818 } | 1817 } |
1819 } | 1818 } |
1820 | 1819 |
1821 | 1820 |
1822 static bool SkipSharedFunctionInfo(SharedFunctionInfo* shared, | 1821 static bool SkipSharedFunctionInfo(SharedFunctionInfo* shared, |
1823 Object* active_code_marker) { | 1822 Object* active_code_marker) { |
1824 if (!shared->allows_lazy_compilation()) return true; | 1823 if (!shared->allows_lazy_compilation()) return true; |
1825 if (!shared->script()->IsScript()) return true; | |
1826 Object* script = shared->script(); | 1824 Object* script = shared->script(); |
1827 if (!script->IsScript()) return true; | 1825 if (!script->IsScript()) return true; |
1828 if (Script::cast(script)->type()->value() == Script::TYPE_NATIVE) return true; | 1826 if (Script::cast(script)->type()->value() == Script::TYPE_NATIVE) return true; |
1829 Code* shared_code = shared->code(); | 1827 Code* shared_code = shared->code(); |
1830 return shared_code->gc_metadata() == active_code_marker; | 1828 return shared_code->gc_metadata() == active_code_marker; |
1831 } | 1829 } |
1832 | 1830 |
1833 | 1831 |
1834 static inline bool HasDebugBreakSlots(Code* code) { | 1832 static inline bool HasDebugBreakSlots(Code* code) { |
1835 return code->kind() == Code::FUNCTION && code->has_debug_break_slots(); | 1833 return code->kind() == Code::FUNCTION && code->has_debug_break_slots(); |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2096 // will compile all inner functions that cannot be compiled without a | 2094 // will compile all inner functions that cannot be compiled without a |
2097 // context, because Compiler::BuildFunctionInfo checks whether the | 2095 // context, because Compiler::BuildFunctionInfo checks whether the |
2098 // debugger is active. | 2096 // debugger is active. |
2099 MaybeHandle<Code> maybe_result = target_function.is_null() | 2097 MaybeHandle<Code> maybe_result = target_function.is_null() |
2100 ? Compiler::GetUnoptimizedCode(target) | 2098 ? Compiler::GetUnoptimizedCode(target) |
2101 : Compiler::GetUnoptimizedCode(target_function); | 2099 : Compiler::GetUnoptimizedCode(target_function); |
2102 if (maybe_result.is_null()) return isolate_->factory()->undefined_value(); | 2100 if (maybe_result.is_null()) return isolate_->factory()->undefined_value(); |
2103 } | 2101 } |
2104 } // End while loop. | 2102 } // End while loop. |
2105 | 2103 |
| 2104 // JSFunctions from the same literal may not have the same shared function |
| 2105 // info. Find those JSFunctions and deduplicate the shared function info. |
| 2106 HeapIterator iterator(heap, FLAG_lazy ? HeapIterator::kNoFiltering |
| 2107 : HeapIterator::kFilterUnreachable); |
| 2108 for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) { |
| 2109 if (!obj->IsJSFunction()) continue; |
| 2110 JSFunction* function = JSFunction::cast(obj); |
| 2111 SharedFunctionInfo* shared = function->shared(); |
| 2112 if (shared != *target && shared->script() == target->script() && |
| 2113 shared->start_position_and_type() == |
| 2114 target->start_position_and_type()) { |
| 2115 function->set_shared(*target); |
| 2116 } |
| 2117 } |
| 2118 |
2106 return target; | 2119 return target; |
2107 } | 2120 } |
2108 | 2121 |
2109 | 2122 |
2110 // Ensures the debug information is present for shared. | 2123 // Ensures the debug information is present for shared. |
2111 bool Debug::EnsureDebugInfo(Handle<SharedFunctionInfo> shared, | 2124 bool Debug::EnsureDebugInfo(Handle<SharedFunctionInfo> shared, |
2112 Handle<JSFunction> function) { | 2125 Handle<JSFunction> function) { |
2113 Isolate* isolate = shared->GetIsolate(); | 2126 Isolate* isolate = shared->GetIsolate(); |
2114 | 2127 |
2115 // Return if we already have the debug info for shared. | 2128 // Return if we already have the debug info for shared. |
(...skipping 1280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3396 logger_->DebugEvent("Put", message.text()); | 3409 logger_->DebugEvent("Put", message.text()); |
3397 } | 3410 } |
3398 | 3411 |
3399 | 3412 |
3400 void LockingCommandMessageQueue::Clear() { | 3413 void LockingCommandMessageQueue::Clear() { |
3401 base::LockGuard<base::Mutex> lock_guard(&mutex_); | 3414 base::LockGuard<base::Mutex> lock_guard(&mutex_); |
3402 queue_.Clear(); | 3415 queue_.Clear(); |
3403 } | 3416 } |
3404 | 3417 |
3405 } } // namespace v8::internal | 3418 } } // namespace v8::internal |
OLD | NEW |