OLD | NEW |
---|---|
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 Loading... | |
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 (uint32_t 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 | |
vogelheim
2016/11/14 11:09:36
super nitpick: No empty line here. :-)
Yang
2016/11/14 11:45:05
Done.
| |
63 #endif // DEBUG | |
64 | |
65 // static | |
66 const char* ExternalReferenceTable::ResolveSymbol(void* address) { | |
67 #ifdef SYMBOLIZE_FUNCTION | |
68 return backtrace_symbols(&address, 1)[0]; | |
69 #endif // SYMBOLIZE_FUNCTION | |
vogelheim
2016/11/14 11:09:36
Nitpick: Does this even compile if SYMBOLIZE_FUNCT
Yang
2016/11/14 11:45:05
Done.
| |
70 return "<unresolved>"; | |
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 Loading... | |
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), \ |
341 ACCESSOR_INFO_LIST(ACCESSOR_INFO_DECLARATION) | 368 "Redirect to Accessors::" #name "Getter"}, |
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 Add(getters[i].address, getters[i].name + 12); |
vogelheim
2016/11/14 11:09:36
Huh? Why .name + 12?
vogelheim
2016/11/14 11:09:36
Ah... the assert in serialize-common.cc explains i
Yang
2016/11/14 11:45:05
Added a comment.
| |
353 Add(AccessorInfo::redirect(isolate, getters[i].address, ACCESSOR_GETTER), | 381 Add(AccessorInfo::redirect(isolate, getters[i].address, ACCESSOR_GETTER), |
354 ""); | 382 getters[i].name); |
355 } | 383 } |
356 | 384 |
357 for (unsigned i = 0; i < arraysize(setters); ++i) { | 385 for (unsigned i = 0; i < arraysize(setters); ++i) { |
358 Add(setters[i].address, setters[i].name); | 386 Add(setters[i].address, setters[i].name); |
359 } | 387 } |
360 } | 388 } |
361 | 389 |
362 void ExternalReferenceTable::AddStubCache(Isolate* isolate) { | 390 void ExternalReferenceTable::AddStubCache(Isolate* isolate) { |
363 StubCache* load_stub_cache = isolate->load_stub_cache(); | 391 StubCache* load_stub_cache = isolate->load_stub_cache(); |
364 | 392 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
405 Add(address, "lazy_deopt"); | 433 Add(address, "lazy_deopt"); |
406 } | 434 } |
407 } | 435 } |
408 | 436 |
409 void ExternalReferenceTable::AddApiReferences(Isolate* isolate) { | 437 void ExternalReferenceTable::AddApiReferences(Isolate* isolate) { |
410 // Add external references provided by the embedder (a null-terminated | 438 // Add external references provided by the embedder (a null-terminated |
411 // array). | 439 // array). |
412 intptr_t* api_external_references = isolate->api_external_references(); | 440 intptr_t* api_external_references = isolate->api_external_references(); |
413 if (api_external_references != nullptr) { | 441 if (api_external_references != nullptr) { |
414 while (*api_external_references != 0) { | 442 while (*api_external_references != 0) { |
415 Add(reinterpret_cast<Address>(*api_external_references), "<embedder>"); | 443 Address address = reinterpret_cast<Address>(*api_external_references); |
444 Add(address, ResolveSymbol(address)); | |
416 api_external_references++; | 445 api_external_references++; |
417 } | 446 } |
418 } | 447 } |
419 } | 448 } |
420 | 449 |
421 } // namespace internal | 450 } // namespace internal |
422 } // namespace v8 | 451 } // namespace v8 |
OLD | NEW |