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

Side by Side Diff: src/snapshot/serialize.cc

Issue 1074943002: Split TemplateHashMapImpl::Lookup into two methods (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix arm (and ppc) builds Created 5 years, 8 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
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/accessors.h" 7 #include "src/accessors.h"
8 #include "src/api.h" 8 #include "src/api.h"
9 #include "src/base/platform/platform.h" 9 #include "src/base/platform/platform.h"
10 #include "src/bootstrapper.h" 10 #include "src/bootstrapper.h"
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 332
333 ExternalReferenceEncoder::ExternalReferenceEncoder(Isolate* isolate) { 333 ExternalReferenceEncoder::ExternalReferenceEncoder(Isolate* isolate) {
334 map_ = isolate->external_reference_map(); 334 map_ = isolate->external_reference_map();
335 if (map_ != NULL) return; 335 if (map_ != NULL) return;
336 map_ = new HashMap(HashMap::PointersMatch); 336 map_ = new HashMap(HashMap::PointersMatch);
337 ExternalReferenceTable* table = ExternalReferenceTable::instance(isolate); 337 ExternalReferenceTable* table = ExternalReferenceTable::instance(isolate);
338 for (int i = 0; i < table->size(); ++i) { 338 for (int i = 0; i < table->size(); ++i) {
339 Address addr = table->address(i); 339 Address addr = table->address(i);
340 if (addr == ExternalReferenceTable::NotAvailable()) continue; 340 if (addr == ExternalReferenceTable::NotAvailable()) continue;
341 // We expect no duplicate external references entries in the table. 341 // We expect no duplicate external references entries in the table.
342 DCHECK_NULL(map_->Lookup(addr, Hash(addr), false)); 342 DCHECK_NULL(map_->Lookup(addr, Hash(addr)));
343 map_->Lookup(addr, Hash(addr), true)->value = reinterpret_cast<void*>(i); 343 map_->LookupOrInsert(addr, Hash(addr))->value = reinterpret_cast<void*>(i);
344 } 344 }
345 isolate->set_external_reference_map(map_); 345 isolate->set_external_reference_map(map_);
346 } 346 }
347 347
348 348
349 uint32_t ExternalReferenceEncoder::Encode(Address address) const { 349 uint32_t ExternalReferenceEncoder::Encode(Address address) const {
350 DCHECK_NOT_NULL(address); 350 DCHECK_NOT_NULL(address);
351 HashMap::Entry* entry = 351 HashMap::Entry* entry =
352 const_cast<HashMap*>(map_)->Lookup(address, Hash(address), false); 352 const_cast<HashMap*>(map_)->Lookup(address, Hash(address));
353 DCHECK_NOT_NULL(entry); 353 DCHECK_NOT_NULL(entry);
354 return static_cast<uint32_t>(reinterpret_cast<intptr_t>(entry->value)); 354 return static_cast<uint32_t>(reinterpret_cast<intptr_t>(entry->value));
355 } 355 }
356 356
357 357
358 const char* ExternalReferenceEncoder::NameOfAddress(Isolate* isolate, 358 const char* ExternalReferenceEncoder::NameOfAddress(Isolate* isolate,
359 Address address) const { 359 Address address) const {
360 HashMap::Entry* entry = 360 HashMap::Entry* entry =
361 const_cast<HashMap*>(map_)->Lookup(address, Hash(address), false); 361 const_cast<HashMap*>(map_)->Lookup(address, Hash(address));
362 if (entry == NULL) return "<unknown>"; 362 if (entry == NULL) return "<unknown>";
363 uint32_t i = static_cast<uint32_t>(reinterpret_cast<intptr_t>(entry->value)); 363 uint32_t i = static_cast<uint32_t>(reinterpret_cast<intptr_t>(entry->value));
364 return ExternalReferenceTable::instance(isolate)->name(i); 364 return ExternalReferenceTable::instance(isolate)->name(i);
365 } 365 }
366 366
367 367
368 RootIndexMap::RootIndexMap(Isolate* isolate) { 368 RootIndexMap::RootIndexMap(Isolate* isolate) {
369 map_ = isolate->root_index_map(); 369 map_ = isolate->root_index_map();
370 if (map_ != NULL) return; 370 if (map_ != NULL) return;
371 map_ = new HashMap(HashMap::PointersMatch); 371 map_ = new HashMap(HashMap::PointersMatch);
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 for (int i = 0; i < name_size; ++i) { 465 for (int i = 0; i < name_size; ++i) {
466 char c = name[i]; 466 char c = name[i];
467 if (c == '\0') c = ' '; 467 if (c == '\0') c = ' ';
468 result[i] = c; 468 result[i] = c;
469 } 469 }
470 result[name_size] = '\0'; 470 result[name_size] = '\0';
471 return result; 471 return result;
472 } 472 }
473 473
474 HashMap::Entry* FindOrCreateEntry(Address code_address) { 474 HashMap::Entry* FindOrCreateEntry(Address code_address) {
475 return impl_.Lookup(code_address, ComputePointerHash(code_address), true); 475 return impl_.LookupOrInsert(code_address,
476 ComputePointerHash(code_address));
476 } 477 }
477 478
478 HashMap::Entry* FindEntry(Address code_address) { 479 HashMap::Entry* FindEntry(Address code_address) {
479 return impl_.Lookup(code_address, 480 return impl_.Lookup(code_address, ComputePointerHash(code_address));
480 ComputePointerHash(code_address),
481 false);
482 } 481 }
483 482
484 void RemoveEntry(HashMap::Entry* entry) { 483 void RemoveEntry(HashMap::Entry* entry) {
485 impl_.Remove(entry->key, entry->hash); 484 impl_.Remove(entry->key, entry->hash);
486 } 485 }
487 486
488 HashMap impl_; 487 HashMap impl_;
489 488
490 DISALLOW_COPY_AND_ASSIGN(NameMap); 489 DISALLOW_COPY_AND_ASSIGN(NameMap);
491 }; 490 };
(...skipping 2031 matching lines...) Expand 10 before | Expand all | Expand 10 after
2523 DisallowHeapAllocation no_gc; 2522 DisallowHeapAllocation no_gc;
2524 SerializedCodeData* scd = new SerializedCodeData(cached_data); 2523 SerializedCodeData* scd = new SerializedCodeData(cached_data);
2525 SanityCheckResult r = scd->SanityCheck(isolate, source); 2524 SanityCheckResult r = scd->SanityCheck(isolate, source);
2526 if (r == CHECK_SUCCESS) return scd; 2525 if (r == CHECK_SUCCESS) return scd;
2527 cached_data->Reject(); 2526 cached_data->Reject();
2528 source->GetIsolate()->counters()->code_cache_reject_reason()->AddSample(r); 2527 source->GetIsolate()->counters()->code_cache_reject_reason()->AddSample(r);
2529 delete scd; 2528 delete scd;
2530 return NULL; 2529 return NULL;
2531 } 2530 }
2532 } } // namespace v8::internal 2531 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698