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

Side by Side Diff: src/objects.cc

Issue 2672213002: [inspector] introduced v8::debug::EntriesPreview for inspector (Closed)
Patch Set: addressed comments Created 3 years, 10 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/runtime/runtime-collections.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 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 18752 matching lines...) Expand 10 before | Expand all | Expand 10 after
18763 Handle<ObjectHashTable> new_table = 18763 Handle<ObjectHashTable> new_table =
18764 ObjectHashTable::Remove(table, key, &was_present, hash); 18764 ObjectHashTable::Remove(table, key, &was_present, hash);
18765 weak_collection->set_table(*new_table); 18765 weak_collection->set_table(*new_table);
18766 if (*table != *new_table) { 18766 if (*table != *new_table) {
18767 // Zap the old table since we didn't record slots for its elements. 18767 // Zap the old table since we didn't record slots for its elements.
18768 table->FillWithHoles(0, table->length()); 18768 table->FillWithHoles(0, table->length());
18769 } 18769 }
18770 return was_present; 18770 return was_present;
18771 } 18771 }
18772 18772
18773 Handle<JSArray> JSWeakCollection::GetEntries(Handle<JSWeakCollection> holder,
18774 int max_entries) {
18775 Isolate* isolate = holder->GetIsolate();
18776 Handle<ObjectHashTable> table(ObjectHashTable::cast(holder->table()));
18777 if (max_entries == 0 || max_entries > table->NumberOfElements()) {
18778 max_entries = table->NumberOfElements();
18779 }
18780 int values_per_entry = holder->IsJSWeakMap() ? 2 : 1;
18781 Handle<FixedArray> entries =
18782 isolate->factory()->NewFixedArray(max_entries * values_per_entry);
18783 // Recompute max_values because GC could have removed elements from the table.
18784 if (max_entries > table->NumberOfElements()) {
18785 max_entries = table->NumberOfElements();
18786 }
18787
18788 {
18789 DisallowHeapAllocation no_gc;
18790 int count = 0;
18791 for (int i = 0;
18792 count / values_per_entry < max_entries && i < table->Capacity(); i++) {
18793 Handle<Object> key(table->KeyAt(i), isolate);
18794 if (table->IsKey(isolate, *key)) {
18795 entries->set(count++, *key);
18796 if (values_per_entry > 1) {
18797 Object* value = table->Lookup(key);
18798 entries->set(count++, value);
18799 }
18800 }
18801 }
18802 DCHECK_EQ(max_entries * values_per_entry, count);
18803 }
18804 return isolate->factory()->NewJSArrayWithElements(entries);
18805 }
18806
18773 // Check if there is a break point at this source position. 18807 // Check if there is a break point at this source position.
18774 bool DebugInfo::HasBreakPoint(int source_position) { 18808 bool DebugInfo::HasBreakPoint(int source_position) {
18775 // Get the break point info object for this code offset. 18809 // Get the break point info object for this code offset.
18776 Object* break_point_info = GetBreakPointInfo(source_position); 18810 Object* break_point_info = GetBreakPointInfo(source_position);
18777 18811
18778 // If there is no break point info object or no break points in the break 18812 // If there is no break point info object or no break points in the break
18779 // point info object there is no break point at this code offset. 18813 // point info object there is no break point at this code offset.
18780 if (break_point_info->IsUndefined(GetIsolate())) return false; 18814 if (break_point_info->IsUndefined(GetIsolate())) return false;
18781 return BreakPointInfo::cast(break_point_info)->GetBreakPointCount() > 0; 18815 return BreakPointInfo::cast(break_point_info)->GetBreakPointCount() > 0;
18782 } 18816 }
(...skipping 1390 matching lines...) Expand 10 before | Expand all | Expand 10 after
20173 // depend on this. 20207 // depend on this.
20174 return DICTIONARY_ELEMENTS; 20208 return DICTIONARY_ELEMENTS;
20175 } 20209 }
20176 DCHECK_LE(kind, LAST_ELEMENTS_KIND); 20210 DCHECK_LE(kind, LAST_ELEMENTS_KIND);
20177 return kind; 20211 return kind;
20178 } 20212 }
20179 } 20213 }
20180 20214
20181 } // namespace internal 20215 } // namespace internal
20182 } // namespace v8 20216 } // namespace v8
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/runtime/runtime-collections.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698