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

Side by Side Diff: src/objects.cc

Issue 2230143002: [debugger] use source position to identify break points. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: address comment Created 4 years, 4 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/objects.h ('k') | src/objects-inl.h » ('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 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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/objects.h" 5 #include "src/objects.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 #include <iomanip> 8 #include <iomanip>
9 #include <memory> 9 #include <memory>
10 #include <sstream> 10 #include <sstream>
(...skipping 18444 matching lines...) Expand 10 before | Expand all | Expand 10 after
18455 Handle<ObjectHashTable> new_table = 18455 Handle<ObjectHashTable> new_table =
18456 ObjectHashTable::Remove(table, key, &was_present, hash); 18456 ObjectHashTable::Remove(table, key, &was_present, hash);
18457 weak_collection->set_table(*new_table); 18457 weak_collection->set_table(*new_table);
18458 if (*table != *new_table) { 18458 if (*table != *new_table) {
18459 // Zap the old table since we didn't record slots for its elements. 18459 // Zap the old table since we didn't record slots for its elements.
18460 table->FillWithHoles(0, table->length()); 18460 table->FillWithHoles(0, table->length());
18461 } 18461 }
18462 return was_present; 18462 return was_present;
18463 } 18463 }
18464 18464
18465 // Check if there is a break point at this code offset. 18465 // Check if there is a break point at this source position.
18466 bool DebugInfo::HasBreakPoint(int code_offset) { 18466 bool DebugInfo::HasBreakPoint(int source_position) {
18467 // Get the break point info object for this code offset. 18467 // Get the break point info object for this code offset.
18468 Object* break_point_info = GetBreakPointInfo(code_offset); 18468 Object* break_point_info = GetBreakPointInfo(source_position);
18469 18469
18470 // If there is no break point info object or no break points in the break 18470 // If there is no break point info object or no break points in the break
18471 // point info object there is no break point at this code offset. 18471 // point info object there is no break point at this code offset.
18472 if (break_point_info->IsUndefined(GetIsolate())) return false; 18472 if (break_point_info->IsUndefined(GetIsolate())) return false;
18473 return BreakPointInfo::cast(break_point_info)->GetBreakPointCount() > 0; 18473 return BreakPointInfo::cast(break_point_info)->GetBreakPointCount() > 0;
18474 } 18474 }
18475 18475
18476 // Get the break point info object for this code offset. 18476 // Get the break point info object for this source position.
18477 Object* DebugInfo::GetBreakPointInfo(int code_offset) { 18477 Object* DebugInfo::GetBreakPointInfo(int source_position) {
18478 // Find the index of the break point info object for this code offset. 18478 Isolate* isolate = GetIsolate();
18479 int index = GetBreakPointInfoIndex(code_offset); 18479 if (!break_points()->IsUndefined(isolate)) {
18480 18480 for (int i = 0; i < break_points()->length(); i++) {
18481 // Return the break point info object if any. 18481 if (!break_points()->get(i)->IsUndefined(isolate)) {
18482 if (index == kNoBreakPointInfo) return GetHeap()->undefined_value(); 18482 BreakPointInfo* break_point_info =
18483 return BreakPointInfo::cast(break_points()->get(index)); 18483 BreakPointInfo::cast(break_points()->get(i));
18484 if (break_point_info->source_position() == source_position) {
18485 return break_point_info;
18486 }
18487 }
18488 }
18489 }
18490 return isolate->heap()->undefined_value();
18484 } 18491 }
18485 18492
18486 // Clear a break point at the specified code offset. 18493 // Clear a break point at the specified source_position.
18487 void DebugInfo::ClearBreakPoint(Handle<DebugInfo> debug_info, int code_offset, 18494 void DebugInfo::ClearBreakPoint(Handle<DebugInfo> debug_info,
18495 int source_position,
18488 Handle<Object> break_point_object) { 18496 Handle<Object> break_point_object) {
18489 Isolate* isolate = debug_info->GetIsolate(); 18497 Isolate* isolate = debug_info->GetIsolate();
18490 Handle<Object> break_point_info(debug_info->GetBreakPointInfo(code_offset), 18498 Handle<Object> break_point_info(
18491 isolate); 18499 debug_info->GetBreakPointInfo(source_position), isolate);
18492 if (break_point_info->IsUndefined(isolate)) return; 18500 if (break_point_info->IsUndefined(isolate)) return;
18493 BreakPointInfo::ClearBreakPoint( 18501 BreakPointInfo::ClearBreakPoint(
18494 Handle<BreakPointInfo>::cast(break_point_info), 18502 Handle<BreakPointInfo>::cast(break_point_info),
18495 break_point_object); 18503 break_point_object);
18496 } 18504 }
18497 18505
18498 void DebugInfo::SetBreakPoint(Handle<DebugInfo> debug_info, int code_offset, 18506 void DebugInfo::SetBreakPoint(Handle<DebugInfo> debug_info, int source_position,
18499 int source_position, int statement_position, 18507 int statement_position,
18500 Handle<Object> break_point_object) { 18508 Handle<Object> break_point_object) {
18501 Isolate* isolate = debug_info->GetIsolate(); 18509 Isolate* isolate = debug_info->GetIsolate();
18502 Handle<Object> break_point_info(debug_info->GetBreakPointInfo(code_offset), 18510 Handle<Object> break_point_info(
18503 isolate); 18511 debug_info->GetBreakPointInfo(source_position), isolate);
18504 if (!break_point_info->IsUndefined(isolate)) { 18512 if (!break_point_info->IsUndefined(isolate)) {
18505 BreakPointInfo::SetBreakPoint( 18513 BreakPointInfo::SetBreakPoint(
18506 Handle<BreakPointInfo>::cast(break_point_info), 18514 Handle<BreakPointInfo>::cast(break_point_info),
18507 break_point_object); 18515 break_point_object);
18508 return; 18516 return;
18509 } 18517 }
18510 18518
18511 // Adding a new break point for a code offset which did not have any 18519 // Adding a new break point for a code offset which did not have any
18512 // break points before. Try to find a free slot. 18520 // break points before. Try to find a free slot.
18521 static const int kNoBreakPointInfo = -1;
18513 int index = kNoBreakPointInfo; 18522 int index = kNoBreakPointInfo;
18514 for (int i = 0; i < debug_info->break_points()->length(); i++) { 18523 for (int i = 0; i < debug_info->break_points()->length(); i++) {
18515 if (debug_info->break_points()->get(i)->IsUndefined(isolate)) { 18524 if (debug_info->break_points()->get(i)->IsUndefined(isolate)) {
18516 index = i; 18525 index = i;
18517 break; 18526 break;
18518 } 18527 }
18519 } 18528 }
18520 if (index == kNoBreakPointInfo) { 18529 if (index == kNoBreakPointInfo) {
18521 // No free slot - extend break point info array. 18530 // No free slot - extend break point info array.
18522 Handle<FixedArray> old_break_points = Handle<FixedArray>( 18531 Handle<FixedArray> old_break_points = Handle<FixedArray>(
18523 FixedArray::cast(debug_info->break_points()), isolate); 18532 FixedArray::cast(debug_info->break_points()), isolate);
18524 Handle<FixedArray> new_break_points = 18533 Handle<FixedArray> new_break_points =
18525 isolate->factory()->NewFixedArray( 18534 isolate->factory()->NewFixedArray(
18526 old_break_points->length() + 18535 old_break_points->length() +
18527 DebugInfo::kEstimatedNofBreakPointsInFunction); 18536 DebugInfo::kEstimatedNofBreakPointsInFunction);
18528 18537
18529 debug_info->set_break_points(*new_break_points); 18538 debug_info->set_break_points(*new_break_points);
18530 for (int i = 0; i < old_break_points->length(); i++) { 18539 for (int i = 0; i < old_break_points->length(); i++) {
18531 new_break_points->set(i, old_break_points->get(i)); 18540 new_break_points->set(i, old_break_points->get(i));
18532 } 18541 }
18533 index = old_break_points->length(); 18542 index = old_break_points->length();
18534 } 18543 }
18535 DCHECK(index != kNoBreakPointInfo); 18544 DCHECK(index != kNoBreakPointInfo);
18536 18545
18537 // Allocate new BreakPointInfo object and set the break point. 18546 // Allocate new BreakPointInfo object and set the break point.
18538 Handle<BreakPointInfo> new_break_point_info = Handle<BreakPointInfo>::cast( 18547 Handle<BreakPointInfo> new_break_point_info = Handle<BreakPointInfo>::cast(
18539 isolate->factory()->NewStruct(BREAK_POINT_INFO_TYPE)); 18548 isolate->factory()->NewStruct(BREAK_POINT_INFO_TYPE));
18540 new_break_point_info->set_code_offset(code_offset);
18541 new_break_point_info->set_source_position(source_position); 18549 new_break_point_info->set_source_position(source_position);
18542 new_break_point_info->set_statement_position(statement_position);
18543 new_break_point_info->set_break_point_objects( 18550 new_break_point_info->set_break_point_objects(
18544 isolate->heap()->undefined_value()); 18551 isolate->heap()->undefined_value());
18545 BreakPointInfo::SetBreakPoint(new_break_point_info, break_point_object); 18552 BreakPointInfo::SetBreakPoint(new_break_point_info, break_point_object);
18546 debug_info->break_points()->set(index, *new_break_point_info); 18553 debug_info->break_points()->set(index, *new_break_point_info);
18547 } 18554 }
18548 18555
18549 // Get the break point objects for a code offset. 18556 // Get the break point objects for a source position.
18550 Handle<Object> DebugInfo::GetBreakPointObjects(int code_offset) { 18557 Handle<Object> DebugInfo::GetBreakPointObjects(int source_position) {
18551 Object* break_point_info = GetBreakPointInfo(code_offset); 18558 Object* break_point_info = GetBreakPointInfo(source_position);
18552 Isolate* isolate = GetIsolate(); 18559 Isolate* isolate = GetIsolate();
18553 if (break_point_info->IsUndefined(isolate)) { 18560 if (break_point_info->IsUndefined(isolate)) {
18554 return isolate->factory()->undefined_value(); 18561 return isolate->factory()->undefined_value();
18555 } 18562 }
18556 return Handle<Object>( 18563 return Handle<Object>(
18557 BreakPointInfo::cast(break_point_info)->break_point_objects(), isolate); 18564 BreakPointInfo::cast(break_point_info)->break_point_objects(), isolate);
18558 } 18565 }
18559 18566
18560 18567
18561 // Get the total number of break points. 18568 // Get the total number of break points.
(...skipping 23 matching lines...) Expand all
18585 if (BreakPointInfo::HasBreakPointObject(break_point_info, 18592 if (BreakPointInfo::HasBreakPointObject(break_point_info,
18586 break_point_object)) { 18593 break_point_object)) {
18587 return break_point_info; 18594 return break_point_info;
18588 } 18595 }
18589 } 18596 }
18590 } 18597 }
18591 } 18598 }
18592 return isolate->factory()->undefined_value(); 18599 return isolate->factory()->undefined_value();
18593 } 18600 }
18594 18601
18595
18596 // Find the index of the break point info object for the specified code
18597 // position.
18598 int DebugInfo::GetBreakPointInfoIndex(int code_offset) {
18599 Isolate* isolate = GetIsolate();
18600 if (break_points()->IsUndefined(isolate)) return kNoBreakPointInfo;
18601 for (int i = 0; i < break_points()->length(); i++) {
18602 if (!break_points()->get(i)->IsUndefined(isolate)) {
18603 BreakPointInfo* break_point_info =
18604 BreakPointInfo::cast(break_points()->get(i));
18605 if (break_point_info->code_offset() == code_offset) {
18606 return i;
18607 }
18608 }
18609 }
18610 return kNoBreakPointInfo;
18611 }
18612
18613
18614 // Remove the specified break point object. 18602 // Remove the specified break point object.
18615 void BreakPointInfo::ClearBreakPoint(Handle<BreakPointInfo> break_point_info, 18603 void BreakPointInfo::ClearBreakPoint(Handle<BreakPointInfo> break_point_info,
18616 Handle<Object> break_point_object) { 18604 Handle<Object> break_point_object) {
18617 Isolate* isolate = break_point_info->GetIsolate(); 18605 Isolate* isolate = break_point_info->GetIsolate();
18618 // If there are no break points just ignore. 18606 // If there are no break points just ignore.
18619 if (break_point_info->break_point_objects()->IsUndefined(isolate)) return; 18607 if (break_point_info->break_point_objects()->IsUndefined(isolate)) return;
18620 // If there is a single break point clear it if it is the same. 18608 // If there is a single break point clear it if it is the same.
18621 if (!break_point_info->break_point_objects()->IsFixedArray()) { 18609 if (!break_point_info->break_point_objects()->IsFixedArray()) {
18622 if (break_point_info->break_point_objects() == *break_point_object) { 18610 if (break_point_info->break_point_objects() == *break_point_object) {
18623 break_point_info->set_break_point_objects( 18611 break_point_info->set_break_point_objects(
(...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after
19206 for (PrototypeIterator iter(isolate, this, kStartAtReceiver, 19194 for (PrototypeIterator iter(isolate, this, kStartAtReceiver,
19207 PrototypeIterator::END_AT_NULL); 19195 PrototypeIterator::END_AT_NULL);
19208 !iter.IsAtEnd(); iter.AdvanceIgnoringProxies()) { 19196 !iter.IsAtEnd(); iter.AdvanceIgnoringProxies()) {
19209 if (iter.GetCurrent<Object>()->IsJSProxy()) return true; 19197 if (iter.GetCurrent<Object>()->IsJSProxy()) return true;
19210 } 19198 }
19211 return false; 19199 return false;
19212 } 19200 }
19213 19201
19214 } // namespace internal 19202 } // namespace internal
19215 } // namespace v8 19203 } // namespace v8
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698