Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: src/debug.cc

Issue 998253005: Debugger: deduplicate shared function info when setting script break points. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fixed nit Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/compiler.cc ('k') | src/liveedit.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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* shared = function->shared();
2107 if (shared != *target && shared->script() == target->script() &&
2108 shared->start_position_and_type() ==
2109 target->start_position_and_type()) {
2110 function->set_shared(*target);
2111 }
2112 }
2113
2101 return target; 2114 return target;
2102 } 2115 }
2103 2116
2104 2117
2105 // Ensures the debug information is present for shared. 2118 // Ensures the debug information is present for shared.
2106 bool Debug::EnsureDebugInfo(Handle<SharedFunctionInfo> shared, 2119 bool Debug::EnsureDebugInfo(Handle<SharedFunctionInfo> shared,
2107 Handle<JSFunction> function) { 2120 Handle<JSFunction> function) {
2108 Isolate* isolate = shared->GetIsolate(); 2121 Isolate* isolate = shared->GetIsolate();
2109 2122
2110 // Return if we already have the debug info for shared. 2123 // Return if we already have the debug info for shared.
(...skipping 1279 matching lines...) Expand 10 before | Expand all | Expand 10 after
3390 logger_->DebugEvent("Put", message.text()); 3403 logger_->DebugEvent("Put", message.text());
3391 } 3404 }
3392 3405
3393 3406
3394 void LockingCommandMessageQueue::Clear() { 3407 void LockingCommandMessageQueue::Clear() {
3395 base::LockGuard<base::Mutex> lock_guard(&mutex_); 3408 base::LockGuard<base::Mutex> lock_guard(&mutex_);
3396 queue_.Clear(); 3409 queue_.Clear();
3397 } 3410 }
3398 3411
3399 } } // namespace v8::internal 3412 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/compiler.cc ('k') | src/liveedit.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698