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

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

Issue 2495213003: [serializer] print use count of external references. (Closed)
Patch Set: fix build Created 4 years, 1 month 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') | no next file » | 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 #if defined(DEBUG) && defined(V8_OS_LINUX) && !defined(V8_OS_ANDROID)
12 #define SYMBOLIZE_FUNCTION
13 #include <execinfo.h>
14 #endif // DEBUG && V8_OS_LINUX && !V8_OS_ANDROID
15
16 namespace v8 { 11 namespace v8 {
17 namespace internal { 12 namespace internal {
18 13
19 ExternalReferenceEncoder::ExternalReferenceEncoder(Isolate* isolate) { 14 ExternalReferenceEncoder::ExternalReferenceEncoder(Isolate* isolate) {
20 map_ = isolate->external_reference_map(); 15 map_ = isolate->external_reference_map();
16 #ifdef DEBUG
17 table_ = ExternalReferenceTable::instance(isolate);
18 #endif // DEBUG
21 if (map_ != nullptr) return; 19 if (map_ != nullptr) return;
22 map_ = new AddressToIndexHashMap(); 20 map_ = new AddressToIndexHashMap();
23 ExternalReferenceTable* table = ExternalReferenceTable::instance(isolate); 21 ExternalReferenceTable* table = ExternalReferenceTable::instance(isolate);
24 for (uint32_t i = 0; i < table->size(); ++i) { 22 for (uint32_t i = 0; i < table->size(); ++i) {
25 Address addr = table->address(i); 23 Address addr = table->address(i);
26 // We expect no duplicate external references entries in the table. 24 DCHECK(map_->Get(addr).IsNothing() ||
27 // AccessorRefTable getter may have duplicates, indicated by an empty string 25 strncmp(table->name(i), "Redirect to ", 12) == 0);
28 // as name.
29 DCHECK(table->name(i)[0] == '\0' || map_->Get(addr).IsNothing());
30 map_->Set(addr, i); 26 map_->Set(addr, i);
31 DCHECK(map_->Get(addr).IsJust()); 27 DCHECK(map_->Get(addr).IsJust());
32 } 28 }
33 isolate->set_external_reference_map(map_); 29 isolate->set_external_reference_map(map_);
34 } 30 }
35 31
36 uint32_t ExternalReferenceEncoder::Encode(Address address) const { 32 uint32_t ExternalReferenceEncoder::Encode(Address address) const {
37 Maybe<uint32_t> maybe_index = map_->Get(address); 33 Maybe<uint32_t> maybe_index = map_->Get(address);
38 if (maybe_index.IsNothing()) { 34 if (maybe_index.IsNothing()) {
39 void* function_addr = address; 35 void* addr = address;
40 v8::base::OS::PrintError("Unknown external reference %p.\n", function_addr); 36 v8::base::OS::PrintError("Unknown external reference %p.\n", addr);
41 #ifdef SYMBOLIZE_FUNCTION 37 v8::base::OS::PrintError("%s", ExternalReferenceTable::ResolveSymbol(addr));
42 v8::base::OS::PrintError("%s\n", backtrace_symbols(&function_addr, 1)[0]);
43 #endif // SYMBOLIZE_FUNCTION
44 v8::base::OS::Abort(); 38 v8::base::OS::Abort();
45 } 39 }
40 #ifdef DEBUG
41 table_->increment_count(maybe_index.FromJust());
42 #endif // DEBUG
46 return maybe_index.FromJust(); 43 return maybe_index.FromJust();
47 } 44 }
48 45
49 const char* ExternalReferenceEncoder::NameOfAddress(Isolate* isolate, 46 const char* ExternalReferenceEncoder::NameOfAddress(Isolate* isolate,
50 Address address) const { 47 Address address) const {
51 Maybe<uint32_t> maybe_index = map_->Get(address); 48 Maybe<uint32_t> maybe_index = map_->Get(address);
52 if (maybe_index.IsNothing()) return "<unknown>"; 49 if (maybe_index.IsNothing()) return "<unknown>";
53 return ExternalReferenceTable::instance(isolate)->name( 50 return ExternalReferenceTable::instance(isolate)->name(
54 maybe_index.FromJust()); 51 maybe_index.FromJust());
55 } 52 }
(...skipping 23 matching lines...) Expand all
79 if (cache->at(i)->IsUndefined(isolate)) break; 76 if (cache->at(i)->IsUndefined(isolate)) break;
80 } 77 }
81 } 78 }
82 79
83 bool SerializerDeserializer::CanBeDeferred(HeapObject* o) { 80 bool SerializerDeserializer::CanBeDeferred(HeapObject* o) {
84 return !o->IsString() && !o->IsScript(); 81 return !o->IsString() && !o->IsScript();
85 } 82 }
86 83
87 } // namespace internal 84 } // namespace internal
88 } // namespace v8 85 } // namespace v8
OLDNEW
« no previous file with comments | « src/snapshot/serializer-common.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698