OLD | NEW |
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 18604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
18615 Handle<ObjectHashTable> new_table = | 18615 Handle<ObjectHashTable> new_table = |
18616 ObjectHashTable::Remove(table, key, &was_present, hash); | 18616 ObjectHashTable::Remove(table, key, &was_present, hash); |
18617 weak_collection->set_table(*new_table); | 18617 weak_collection->set_table(*new_table); |
18618 if (*table != *new_table) { | 18618 if (*table != *new_table) { |
18619 // Zap the old table since we didn't record slots for its elements. | 18619 // Zap the old table since we didn't record slots for its elements. |
18620 table->FillWithHoles(0, table->length()); | 18620 table->FillWithHoles(0, table->length()); |
18621 } | 18621 } |
18622 return was_present; | 18622 return was_present; |
18623 } | 18623 } |
18624 | 18624 |
| 18625 Handle<JSArray> JSWeakCollection::GetEntries(Handle<JSWeakCollection> holder, |
| 18626 int max_entries) { |
| 18627 Isolate* isolate = holder->GetIsolate(); |
| 18628 Handle<ObjectHashTable> table(ObjectHashTable::cast(holder->table())); |
| 18629 if (max_entries == 0 || max_entries > table->NumberOfElements()) { |
| 18630 max_entries = table->NumberOfElements(); |
| 18631 } |
| 18632 int values_per_entry = holder->IsJSWeakMap() ? 2 : 1; |
| 18633 Handle<FixedArray> entries = |
| 18634 isolate->factory()->NewFixedArray(max_entries * values_per_entry); |
| 18635 // Recompute max_values because GC could have removed elements from the table. |
| 18636 if (max_entries > table->NumberOfElements()) { |
| 18637 max_entries = table->NumberOfElements(); |
| 18638 } |
| 18639 |
| 18640 { |
| 18641 DisallowHeapAllocation no_gc; |
| 18642 int count = 0; |
| 18643 for (int i = 0; |
| 18644 count / values_per_entry < max_entries && i < table->Capacity(); i++) { |
| 18645 Handle<Object> key(table->KeyAt(i), isolate); |
| 18646 if (table->IsKey(isolate, *key)) { |
| 18647 entries->set(count++, *key); |
| 18648 if (values_per_entry > 1) { |
| 18649 Object* value = table->Lookup(key); |
| 18650 entries->set(count++, value); |
| 18651 } |
| 18652 } |
| 18653 } |
| 18654 DCHECK_EQ(max_entries * values_per_entry, count); |
| 18655 } |
| 18656 return isolate->factory()->NewJSArrayWithElements(entries); |
| 18657 } |
| 18658 |
18625 // Check if there is a break point at this source position. | 18659 // Check if there is a break point at this source position. |
18626 bool DebugInfo::HasBreakPoint(int source_position) { | 18660 bool DebugInfo::HasBreakPoint(int source_position) { |
18627 // Get the break point info object for this code offset. | 18661 // Get the break point info object for this code offset. |
18628 Object* break_point_info = GetBreakPointInfo(source_position); | 18662 Object* break_point_info = GetBreakPointInfo(source_position); |
18629 | 18663 |
18630 // If there is no break point info object or no break points in the break | 18664 // If there is no break point info object or no break points in the break |
18631 // point info object there is no break point at this code offset. | 18665 // point info object there is no break point at this code offset. |
18632 if (break_point_info->IsUndefined(GetIsolate())) return false; | 18666 if (break_point_info->IsUndefined(GetIsolate())) return false; |
18633 return BreakPointInfo::cast(break_point_info)->GetBreakPointCount() > 0; | 18667 return BreakPointInfo::cast(break_point_info)->GetBreakPointCount() > 0; |
18634 } | 18668 } |
(...skipping 1390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
20025 // depend on this. | 20059 // depend on this. |
20026 return DICTIONARY_ELEMENTS; | 20060 return DICTIONARY_ELEMENTS; |
20027 } | 20061 } |
20028 DCHECK_LE(kind, LAST_ELEMENTS_KIND); | 20062 DCHECK_LE(kind, LAST_ELEMENTS_KIND); |
20029 return kind; | 20063 return kind; |
20030 } | 20064 } |
20031 } | 20065 } |
20032 | 20066 |
20033 } // namespace internal | 20067 } // namespace internal |
20034 } // namespace v8 | 20068 } // namespace v8 |
OLD | NEW |