Chromium Code Reviews| 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 1483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1494 if (!HasDebugInfo(shared)) { | 1494 if (!HasDebugInfo(shared)) { |
| 1495 return Handle<Object>(heap->undefined_value(), isolate); | 1495 return Handle<Object>(heap->undefined_value(), isolate); |
| 1496 } | 1496 } |
| 1497 Handle<DebugInfo> debug_info = GetDebugInfo(shared); | 1497 Handle<DebugInfo> debug_info = GetDebugInfo(shared); |
| 1498 if (debug_info->GetBreakPointCount() == 0) { | 1498 if (debug_info->GetBreakPointCount() == 0) { |
| 1499 return Handle<Object>(heap->undefined_value(), isolate); | 1499 return Handle<Object>(heap->undefined_value(), isolate); |
| 1500 } | 1500 } |
| 1501 Handle<FixedArray> locations = | 1501 Handle<FixedArray> locations = |
| 1502 isolate->factory()->NewFixedArray(debug_info->GetBreakPointCount()); | 1502 isolate->factory()->NewFixedArray(debug_info->GetBreakPointCount()); |
| 1503 int count = 0; | 1503 int count = 0; |
| 1504 for (int i = 0; i < debug_info->break_points()->length(); i++) { | 1504 for (int i = 0; i < debug_info->break_points()->length(); ++i) { |
| 1505 if (!debug_info->break_points()->get(i)->IsUndefined()) { | 1505 if (!debug_info->break_points()->get(i)->IsUndefined()) { |
| 1506 BreakPointInfo* break_point_info = | 1506 BreakPointInfo* break_point_info = |
| 1507 BreakPointInfo::cast(debug_info->break_points()->get(i)); | 1507 BreakPointInfo::cast(debug_info->break_points()->get(i)); |
| 1508 if (break_point_info->GetBreakPointCount() > 0) { | 1508 int break_points = break_point_info->GetBreakPointCount(); |
| 1509 Smi* position = NULL; | 1509 if (break_points == 0) continue; |
| 1510 switch (position_alignment) { | 1510 Smi* position = NULL; |
| 1511 case STATEMENT_ALIGNED: | 1511 switch (position_alignment) { |
| 1512 position = break_point_info->statement_position(); | 1512 case STATEMENT_ALIGNED: |
| 1513 break; | 1513 position = break_point_info->statement_position(); |
| 1514 case BREAK_POSITION_ALIGNED: | 1514 break; |
| 1515 position = break_point_info->source_position(); | 1515 case BREAK_POSITION_ALIGNED: |
| 1516 break; | 1516 position = break_point_info->source_position(); |
| 1517 } | 1517 break; |
| 1518 | |
| 1519 locations->set(count++, position); | |
| 1520 } | 1518 } |
| 1519 for (int j = 0; j < break_points; ++j) locations->set(count++, position); | |
| 1521 } | 1520 } |
| 1522 } | 1521 } |
| 1523 return locations; | 1522 return locations; |
| 1524 } | 1523 } |
| 1525 | 1524 |
| 1526 | 1525 |
| 1527 // Handle stepping into a function. | 1526 // Handle stepping into a function. |
| 1528 void Debug::HandleStepIn(Handle<Object> function_obj, Handle<Object> holder, | 1527 void Debug::HandleStepIn(Handle<Object> function_obj, Handle<Object> holder, |
| 1529 Address fp, bool is_constructor) { | 1528 Address fp, bool is_constructor) { |
| 1530 // Flood getter/setter if we either step in or step to another frame. | 1529 // 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... | |
| 1810 int code_offset = generators[i]->continuation(); | 1809 int code_offset = generators[i]->continuation(); |
| 1811 int pc_offset = ComputePcOffsetFromCodeOffset(fun->code(), code_offset); | 1810 int pc_offset = ComputePcOffsetFromCodeOffset(fun->code(), code_offset); |
| 1812 generators[i]->set_continuation(pc_offset); | 1811 generators[i]->set_continuation(pc_offset); |
| 1813 } | 1812 } |
| 1814 } | 1813 } |
| 1815 | 1814 |
| 1816 | 1815 |
| 1817 static bool SkipSharedFunctionInfo(SharedFunctionInfo* shared, | 1816 static bool SkipSharedFunctionInfo(SharedFunctionInfo* shared, |
| 1818 Object* active_code_marker) { | 1817 Object* active_code_marker) { |
| 1819 if (!shared->allows_lazy_compilation()) return true; | 1818 if (!shared->allows_lazy_compilation()) return true; |
| 1820 if (!shared->script()->IsScript()) return true; | |
| 1821 Object* script = shared->script(); | 1819 Object* script = shared->script(); |
| 1822 if (!script->IsScript()) return true; | 1820 if (!script->IsScript()) return true; |
| 1823 if (Script::cast(script)->type()->value() == Script::TYPE_NATIVE) return true; | 1821 if (Script::cast(script)->type()->value() == Script::TYPE_NATIVE) return true; |
| 1824 Code* shared_code = shared->code(); | 1822 Code* shared_code = shared->code(); |
| 1825 return shared_code->gc_metadata() == active_code_marker; | 1823 return shared_code->gc_metadata() == active_code_marker; |
| 1826 } | 1824 } |
| 1827 | 1825 |
| 1828 | 1826 |
| 1829 static inline bool HasDebugBreakSlots(Code* code) { | 1827 static inline bool HasDebugBreakSlots(Code* code) { |
| 1830 return code->kind() == Code::FUNCTION && code->has_debug_break_slots(); | 1828 return code->kind() == Code::FUNCTION && code->has_debug_break_slots(); |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2091 // will compile all inner functions that cannot be compiled without a | 2089 // will compile all inner functions that cannot be compiled without a |
| 2092 // context, because Compiler::BuildFunctionInfo checks whether the | 2090 // context, because Compiler::BuildFunctionInfo checks whether the |
| 2093 // debugger is active. | 2091 // debugger is active. |
| 2094 MaybeHandle<Code> maybe_result = target_function.is_null() | 2092 MaybeHandle<Code> maybe_result = target_function.is_null() |
| 2095 ? Compiler::GetUnoptimizedCode(target) | 2093 ? Compiler::GetUnoptimizedCode(target) |
| 2096 : Compiler::GetUnoptimizedCode(target_function); | 2094 : Compiler::GetUnoptimizedCode(target_function); |
| 2097 if (maybe_result.is_null()) return isolate_->factory()->undefined_value(); | 2095 if (maybe_result.is_null()) return isolate_->factory()->undefined_value(); |
| 2098 } | 2096 } |
| 2099 } // End while loop. | 2097 } // End while loop. |
| 2100 | 2098 |
| 2099 // JSFunctions from the same literal may not have the same shared function | |
| 2100 // info. Find those JSFunctions and deduplicate the shared function info. | |
| 2101 HeapIterator iterator(heap, FLAG_lazy ? HeapIterator::kNoFiltering | |
| 2102 : HeapIterator::kFilterUnreachable); | |
| 2103 for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) { | |
| 2104 if (!obj->IsJSFunction()) continue; | |
| 2105 JSFunction* function = JSFunction::cast(obj); | |
| 2106 SharedFunctionInfo* s = function->shared(); | |
|
Michael Starzinger
2015/03/25 13:44:08
nit: s/s/shared/ here.
| |
| 2107 if (s != *target && s->script() == target->script() && | |
| 2108 s->start_position_and_type() == target->start_position_and_type()) { | |
| 2109 function->set_shared(*target); | |
| 2110 } | |
| 2111 } | |
| 2112 | |
| 2101 return target; | 2113 return target; |
| 2102 } | 2114 } |
| 2103 | 2115 |
| 2104 | 2116 |
| 2105 // Ensures the debug information is present for shared. | 2117 // Ensures the debug information is present for shared. |
| 2106 bool Debug::EnsureDebugInfo(Handle<SharedFunctionInfo> shared, | 2118 bool Debug::EnsureDebugInfo(Handle<SharedFunctionInfo> shared, |
| 2107 Handle<JSFunction> function) { | 2119 Handle<JSFunction> function) { |
| 2108 Isolate* isolate = shared->GetIsolate(); | 2120 Isolate* isolate = shared->GetIsolate(); |
| 2109 | 2121 |
| 2110 // Return if we already have the debug info for shared. | 2122 // Return if we already have the debug info for shared. |
| (...skipping 1279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3390 logger_->DebugEvent("Put", message.text()); | 3402 logger_->DebugEvent("Put", message.text()); |
| 3391 } | 3403 } |
| 3392 | 3404 |
| 3393 | 3405 |
| 3394 void LockingCommandMessageQueue::Clear() { | 3406 void LockingCommandMessageQueue::Clear() { |
| 3395 base::LockGuard<base::Mutex> lock_guard(&mutex_); | 3407 base::LockGuard<base::Mutex> lock_guard(&mutex_); |
| 3396 queue_.Clear(); | 3408 queue_.Clear(); |
| 3397 } | 3409 } |
| 3398 | 3410 |
| 3399 } } // namespace v8::internal | 3411 } } // namespace v8::internal |
| OLD | NEW |