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

Side by Side Diff: src/snapshot/serializer-common.cc

Issue 2010243003: Move hashmap into base/. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase Created 4 years, 6 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/snapshot/serializer-common.h ('k') | src/typing-asm.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 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 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/snapshot/serializer-common.h" 5 #include "src/snapshot/serializer-common.h"
6 6
7 #include "src/external-reference-table.h" 7 #include "src/external-reference-table.h"
8 #include "src/ic/stub-cache.h" 8 #include "src/ic/stub-cache.h"
9 #include "src/list-inl.h" 9 #include "src/list-inl.h"
10 10
11 namespace v8 { 11 namespace v8 {
12 namespace internal { 12 namespace internal {
13 13
14 ExternalReferenceEncoder::ExternalReferenceEncoder(Isolate* isolate) { 14 ExternalReferenceEncoder::ExternalReferenceEncoder(Isolate* isolate) {
15 map_ = isolate->external_reference_map(); 15 map_ = isolate->external_reference_map();
16 if (map_ != NULL) return; 16 if (map_ != NULL) return;
17 map_ = new HashMap(HashMap::PointersMatch); 17 map_ = new base::HashMap(base::HashMap::PointersMatch);
18 ExternalReferenceTable* table = ExternalReferenceTable::instance(isolate); 18 ExternalReferenceTable* table = ExternalReferenceTable::instance(isolate);
19 for (int i = 0; i < table->size(); ++i) { 19 for (int i = 0; i < table->size(); ++i) {
20 Address addr = table->address(i); 20 Address addr = table->address(i);
21 if (addr == ExternalReferenceTable::NotAvailable()) continue; 21 if (addr == ExternalReferenceTable::NotAvailable()) continue;
22 // We expect no duplicate external references entries in the table. 22 // We expect no duplicate external references entries in the table.
23 // AccessorRefTable getter may have duplicates, indicated by an empty string 23 // AccessorRefTable getter may have duplicates, indicated by an empty string
24 // as name. 24 // as name.
25 DCHECK(table->name(i)[0] == '\0' || 25 DCHECK(table->name(i)[0] == '\0' ||
26 map_->Lookup(addr, Hash(addr)) == nullptr); 26 map_->Lookup(addr, Hash(addr)) == nullptr);
27 map_->LookupOrInsert(addr, Hash(addr))->value = reinterpret_cast<void*>(i); 27 map_->LookupOrInsert(addr, Hash(addr))->value = reinterpret_cast<void*>(i);
28 } 28 }
29 isolate->set_external_reference_map(map_); 29 isolate->set_external_reference_map(map_);
30 } 30 }
31 31
32 uint32_t ExternalReferenceEncoder::Encode(Address address) const { 32 uint32_t ExternalReferenceEncoder::Encode(Address address) const {
33 DCHECK_NOT_NULL(address); 33 DCHECK_NOT_NULL(address);
34 HashMap::Entry* entry = 34 base::HashMap::Entry* entry =
35 const_cast<HashMap*>(map_)->Lookup(address, Hash(address)); 35 const_cast<base::HashMap*>(map_)->Lookup(address, Hash(address));
36 DCHECK_NOT_NULL(entry); 36 DCHECK_NOT_NULL(entry);
37 return static_cast<uint32_t>(reinterpret_cast<intptr_t>(entry->value)); 37 return static_cast<uint32_t>(reinterpret_cast<intptr_t>(entry->value));
38 } 38 }
39 39
40 const char* ExternalReferenceEncoder::NameOfAddress(Isolate* isolate, 40 const char* ExternalReferenceEncoder::NameOfAddress(Isolate* isolate,
41 Address address) const { 41 Address address) const {
42 HashMap::Entry* entry = 42 base::HashMap::Entry* entry =
43 const_cast<HashMap*>(map_)->Lookup(address, Hash(address)); 43 const_cast<base::HashMap*>(map_)->Lookup(address, Hash(address));
44 if (entry == NULL) return "<unknown>"; 44 if (entry == NULL) return "<unknown>";
45 uint32_t i = static_cast<uint32_t>(reinterpret_cast<intptr_t>(entry->value)); 45 uint32_t i = static_cast<uint32_t>(reinterpret_cast<intptr_t>(entry->value));
46 return ExternalReferenceTable::instance(isolate)->name(i); 46 return ExternalReferenceTable::instance(isolate)->name(i);
47 } 47 }
48 48
49 void SerializedData::AllocateData(int size) { 49 void SerializedData::AllocateData(int size) {
50 DCHECK(!owns_data_); 50 DCHECK(!owns_data_);
51 data_ = NewArray<byte>(size); 51 data_ = NewArray<byte>(size);
52 size_ = size; 52 size_ = size;
53 owns_data_ = true; 53 owns_data_ = true;
(...skipping 16 matching lines...) Expand all
70 if (cache->at(i)->IsUndefined(isolate)) break; 70 if (cache->at(i)->IsUndefined(isolate)) break;
71 } 71 }
72 } 72 }
73 73
74 bool SerializerDeserializer::CanBeDeferred(HeapObject* o) { 74 bool SerializerDeserializer::CanBeDeferred(HeapObject* o) {
75 return !o->IsString() && !o->IsScript(); 75 return !o->IsString() && !o->IsScript();
76 } 76 }
77 77
78 } // namespace internal 78 } // namespace internal
79 } // namespace v8 79 } // namespace v8
OLDNEW
« no previous file with comments | « src/snapshot/serializer-common.h ('k') | src/typing-asm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698