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

Side by Side Diff: src/external-reference-table.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/external-reference-table.h ('k') | src/flag-definitions.h » ('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/external-reference-table.h" 5 #include "src/external-reference-table.h"
6 6
7 #include "src/accessors.h" 7 #include "src/accessors.h"
8 #include "src/assembler.h" 8 #include "src/assembler.h"
9 #include "src/builtins/builtins.h" 9 #include "src/builtins/builtins.h"
10 #include "src/counters.h" 10 #include "src/counters.h"
11 #include "src/deoptimizer.h" 11 #include "src/deoptimizer.h"
12 #include "src/ic/stub-cache.h" 12 #include "src/ic/stub-cache.h"
13 13
14 #if defined(DEBUG) && defined(V8_OS_LINUX) && !defined(V8_OS_ANDROID)
15 #define SYMBOLIZE_FUNCTION
16 #include <execinfo.h>
17 #endif // DEBUG && V8_OS_LINUX && !V8_OS_ANDROID
18
14 namespace v8 { 19 namespace v8 {
15 namespace internal { 20 namespace internal {
16 21
17 // Forward declarations for C++ builtins. 22 // Forward declarations for C++ builtins.
18 #define FORWARD_DECLARE(Name) \ 23 #define FORWARD_DECLARE(Name) \
19 Object* Builtin_##Name(int argc, Object** args, Isolate* isolate); 24 Object* Builtin_##Name(int argc, Object** args, Isolate* isolate);
20 BUILTIN_LIST_C(FORWARD_DECLARE) 25 BUILTIN_LIST_C(FORWARD_DECLARE)
21 #undef FORWARD_DECLARE 26 #undef FORWARD_DECLARE
22 27
23 ExternalReferenceTable* ExternalReferenceTable::instance(Isolate* isolate) { 28 ExternalReferenceTable* ExternalReferenceTable::instance(Isolate* isolate) {
(...skipping 12 matching lines...) Expand all
36 AddReferences(isolate); 41 AddReferences(isolate);
37 AddBuiltins(isolate); 42 AddBuiltins(isolate);
38 AddRuntimeFunctions(isolate); 43 AddRuntimeFunctions(isolate);
39 AddIsolateAddresses(isolate); 44 AddIsolateAddresses(isolate);
40 AddAccessors(isolate); 45 AddAccessors(isolate);
41 AddStubCache(isolate); 46 AddStubCache(isolate);
42 AddDeoptEntries(isolate); 47 AddDeoptEntries(isolate);
43 AddApiReferences(isolate); 48 AddApiReferences(isolate);
44 } 49 }
45 50
51 #ifdef DEBUG
52 void ExternalReferenceTable::ResetCount() {
53 for (ExternalReferenceEntry& entry : refs_) entry.count = 0;
54 }
55
56 void ExternalReferenceTable::PrintCount() {
57 for (int i = 0; i < refs_.length(); i++) {
58 v8::base::OS::Print("index=%5d count=%5d %-60s\n", i, refs_[i].count,
59 refs_[i].name);
60 }
61 }
62 #endif // DEBUG
63
64 // static
65 const char* ExternalReferenceTable::ResolveSymbol(void* address) {
66 #ifdef SYMBOLIZE_FUNCTION
67 return backtrace_symbols(&address, 1)[0];
68 #else
69 return "<unresolved>";
70 #endif // SYMBOLIZE_FUNCTION
71 }
72
46 void ExternalReferenceTable::AddReferences(Isolate* isolate) { 73 void ExternalReferenceTable::AddReferences(Isolate* isolate) {
47 // Miscellaneous 74 // Miscellaneous
48 Add(ExternalReference::roots_array_start(isolate).address(), 75 Add(ExternalReference::roots_array_start(isolate).address(),
49 "Heap::roots_array_start()"); 76 "Heap::roots_array_start()");
50 Add(ExternalReference::address_of_stack_limit(isolate).address(), 77 Add(ExternalReference::address_of_stack_limit(isolate).address(),
51 "StackGuard::address_of_jslimit()"); 78 "StackGuard::address_of_jslimit()");
52 Add(ExternalReference::address_of_real_stack_limit(isolate).address(), 79 Add(ExternalReference::address_of_real_stack_limit(isolate).address(),
53 "StackGuard::address_of_real_jslimit()"); 80 "StackGuard::address_of_real_jslimit()");
54 Add(ExternalReference::new_space_allocation_limit_address(isolate).address(), 81 Add(ExternalReference::new_space_allocation_limit_address(isolate).address(),
55 "Heap::NewSpaceAllocationLimitAddress()"); 82 "Heap::NewSpaceAllocationLimitAddress()");
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 } 356 }
330 357
331 void ExternalReferenceTable::AddAccessors(Isolate* isolate) { 358 void ExternalReferenceTable::AddAccessors(Isolate* isolate) {
332 // Accessors 359 // Accessors
333 struct AccessorRefTable { 360 struct AccessorRefTable {
334 Address address; 361 Address address;
335 const char* name; 362 const char* name;
336 }; 363 };
337 364
338 static const AccessorRefTable getters[] = { 365 static const AccessorRefTable getters[] = {
339 #define ACCESSOR_INFO_DECLARATION(name) \ 366 #define ACCESSOR_INFO_DECLARATION(name) \
340 {FUNCTION_ADDR(&Accessors::name##Getter), "Accessors::" #name "Getter"}, 367 { FUNCTION_ADDR(&Accessors::name##Getter), \
368 "Redirect to Accessors::" #name "Getter"},
341 ACCESSOR_INFO_LIST(ACCESSOR_INFO_DECLARATION) 369 ACCESSOR_INFO_LIST(ACCESSOR_INFO_DECLARATION)
342 #undef ACCESSOR_INFO_DECLARATION 370 #undef ACCESSOR_INFO_DECLARATION
343 }; 371 };
344 static const AccessorRefTable setters[] = { 372 static const AccessorRefTable setters[] = {
345 #define ACCESSOR_SETTER_DECLARATION(name) \ 373 #define ACCESSOR_SETTER_DECLARATION(name) \
346 {FUNCTION_ADDR(&Accessors::name), "Accessors::" #name}, 374 { FUNCTION_ADDR(&Accessors::name), "Accessors::" #name},
347 ACCESSOR_SETTER_LIST(ACCESSOR_SETTER_DECLARATION) 375 ACCESSOR_SETTER_LIST(ACCESSOR_SETTER_DECLARATION)
348 #undef ACCESSOR_INFO_DECLARATION 376 #undef ACCESSOR_INFO_DECLARATION
349 }; 377 };
350 378
351 for (unsigned i = 0; i < arraysize(getters); ++i) { 379 for (unsigned i = 0; i < arraysize(getters); ++i) {
352 Add(getters[i].address, getters[i].name); 380 const char* name = getters[i].name + 12; // Skip "Redirect to " prefix.
381 Add(getters[i].address, name);
353 Add(AccessorInfo::redirect(isolate, getters[i].address, ACCESSOR_GETTER), 382 Add(AccessorInfo::redirect(isolate, getters[i].address, ACCESSOR_GETTER),
354 ""); 383 getters[i].name);
355 } 384 }
356 385
357 for (unsigned i = 0; i < arraysize(setters); ++i) { 386 for (unsigned i = 0; i < arraysize(setters); ++i) {
358 Add(setters[i].address, setters[i].name); 387 Add(setters[i].address, setters[i].name);
359 } 388 }
360 } 389 }
361 390
362 void ExternalReferenceTable::AddStubCache(Isolate* isolate) { 391 void ExternalReferenceTable::AddStubCache(Isolate* isolate) {
363 StubCache* load_stub_cache = isolate->load_stub_cache(); 392 StubCache* load_stub_cache = isolate->load_stub_cache();
364 393
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 Add(address, "lazy_deopt"); 434 Add(address, "lazy_deopt");
406 } 435 }
407 } 436 }
408 437
409 void ExternalReferenceTable::AddApiReferences(Isolate* isolate) { 438 void ExternalReferenceTable::AddApiReferences(Isolate* isolate) {
410 // Add external references provided by the embedder (a null-terminated 439 // Add external references provided by the embedder (a null-terminated
411 // array). 440 // array).
412 intptr_t* api_external_references = isolate->api_external_references(); 441 intptr_t* api_external_references = isolate->api_external_references();
413 if (api_external_references != nullptr) { 442 if (api_external_references != nullptr) {
414 while (*api_external_references != 0) { 443 while (*api_external_references != 0) {
415 Add(reinterpret_cast<Address>(*api_external_references), "<embedder>"); 444 Address address = reinterpret_cast<Address>(*api_external_references);
445 Add(address, ResolveSymbol(address));
416 api_external_references++; 446 api_external_references++;
417 } 447 }
418 } 448 }
419 } 449 }
420 450
421 } // namespace internal 451 } // namespace internal
422 } // namespace v8 452 } // namespace v8
OLDNEW
« no previous file with comments | « src/external-reference-table.h ('k') | src/flag-definitions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698