| 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 | |
| 19 namespace v8 { | 14 namespace v8 { |
| 20 namespace internal { | 15 namespace internal { |
| 21 | 16 |
| 22 // Forward declarations for C++ builtins. | 17 // Forward declarations for C++ builtins. |
| 23 #define FORWARD_DECLARE(Name) \ | 18 #define FORWARD_DECLARE(Name) \ |
| 24 Object* Builtin_##Name(int argc, Object** args, Isolate* isolate); | 19 Object* Builtin_##Name(int argc, Object** args, Isolate* isolate); |
| 25 BUILTIN_LIST_C(FORWARD_DECLARE) | 20 BUILTIN_LIST_C(FORWARD_DECLARE) |
| 26 #undef FORWARD_DECLARE | 21 #undef FORWARD_DECLARE |
| 27 | 22 |
| 28 ExternalReferenceTable* ExternalReferenceTable::instance(Isolate* isolate) { | 23 ExternalReferenceTable* ExternalReferenceTable::instance(Isolate* isolate) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 41 AddReferences(isolate); | 36 AddReferences(isolate); |
| 42 AddBuiltins(isolate); | 37 AddBuiltins(isolate); |
| 43 AddRuntimeFunctions(isolate); | 38 AddRuntimeFunctions(isolate); |
| 44 AddIsolateAddresses(isolate); | 39 AddIsolateAddresses(isolate); |
| 45 AddAccessors(isolate); | 40 AddAccessors(isolate); |
| 46 AddStubCache(isolate); | 41 AddStubCache(isolate); |
| 47 AddDeoptEntries(isolate); | 42 AddDeoptEntries(isolate); |
| 48 AddApiReferences(isolate); | 43 AddApiReferences(isolate); |
| 49 } | 44 } |
| 50 | 45 |
| 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 | |
| 73 void ExternalReferenceTable::AddReferences(Isolate* isolate) { | 46 void ExternalReferenceTable::AddReferences(Isolate* isolate) { |
| 74 // Miscellaneous | 47 // Miscellaneous |
| 75 Add(ExternalReference::roots_array_start(isolate).address(), | 48 Add(ExternalReference::roots_array_start(isolate).address(), |
| 76 "Heap::roots_array_start()"); | 49 "Heap::roots_array_start()"); |
| 77 Add(ExternalReference::address_of_stack_limit(isolate).address(), | 50 Add(ExternalReference::address_of_stack_limit(isolate).address(), |
| 78 "StackGuard::address_of_jslimit()"); | 51 "StackGuard::address_of_jslimit()"); |
| 79 Add(ExternalReference::address_of_real_stack_limit(isolate).address(), | 52 Add(ExternalReference::address_of_real_stack_limit(isolate).address(), |
| 80 "StackGuard::address_of_real_jslimit()"); | 53 "StackGuard::address_of_real_jslimit()"); |
| 81 Add(ExternalReference::new_space_allocation_limit_address(isolate).address(), | 54 Add(ExternalReference::new_space_allocation_limit_address(isolate).address(), |
| 82 "Heap::NewSpaceAllocationLimitAddress()"); | 55 "Heap::NewSpaceAllocationLimitAddress()"); |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 } | 329 } |
| 357 | 330 |
| 358 void ExternalReferenceTable::AddAccessors(Isolate* isolate) { | 331 void ExternalReferenceTable::AddAccessors(Isolate* isolate) { |
| 359 // Accessors | 332 // Accessors |
| 360 struct AccessorRefTable { | 333 struct AccessorRefTable { |
| 361 Address address; | 334 Address address; |
| 362 const char* name; | 335 const char* name; |
| 363 }; | 336 }; |
| 364 | 337 |
| 365 static const AccessorRefTable getters[] = { | 338 static const AccessorRefTable getters[] = { |
| 366 #define ACCESSOR_INFO_DECLARATION(name) \ | 339 #define ACCESSOR_INFO_DECLARATION(name) \ |
| 367 { FUNCTION_ADDR(&Accessors::name##Getter), \ | 340 {FUNCTION_ADDR(&Accessors::name##Getter), "Accessors::" #name "Getter"}, |
| 368 "Redirect to Accessors::" #name "Getter"}, | 341 ACCESSOR_INFO_LIST(ACCESSOR_INFO_DECLARATION) |
| 369 ACCESSOR_INFO_LIST(ACCESSOR_INFO_DECLARATION) | |
| 370 #undef ACCESSOR_INFO_DECLARATION | 342 #undef ACCESSOR_INFO_DECLARATION |
| 371 }; | 343 }; |
| 372 static const AccessorRefTable setters[] = { | 344 static const AccessorRefTable setters[] = { |
| 373 #define ACCESSOR_SETTER_DECLARATION(name) \ | 345 #define ACCESSOR_SETTER_DECLARATION(name) \ |
| 374 { FUNCTION_ADDR(&Accessors::name), "Accessors::" #name}, | 346 {FUNCTION_ADDR(&Accessors::name), "Accessors::" #name}, |
| 375 ACCESSOR_SETTER_LIST(ACCESSOR_SETTER_DECLARATION) | 347 ACCESSOR_SETTER_LIST(ACCESSOR_SETTER_DECLARATION) |
| 376 #undef ACCESSOR_INFO_DECLARATION | 348 #undef ACCESSOR_INFO_DECLARATION |
| 377 }; | 349 }; |
| 378 | 350 |
| 379 for (unsigned i = 0; i < arraysize(getters); ++i) { | 351 for (unsigned i = 0; i < arraysize(getters); ++i) { |
| 380 const char* name = getters[i].name + 12; // Skip "Redirect to " prefix. | 352 Add(getters[i].address, getters[i].name); |
| 381 Add(getters[i].address, name); | |
| 382 Add(AccessorInfo::redirect(isolate, getters[i].address, ACCESSOR_GETTER), | 353 Add(AccessorInfo::redirect(isolate, getters[i].address, ACCESSOR_GETTER), |
| 383 getters[i].name); | 354 ""); |
| 384 } | 355 } |
| 385 | 356 |
| 386 for (unsigned i = 0; i < arraysize(setters); ++i) { | 357 for (unsigned i = 0; i < arraysize(setters); ++i) { |
| 387 Add(setters[i].address, setters[i].name); | 358 Add(setters[i].address, setters[i].name); |
| 388 } | 359 } |
| 389 } | 360 } |
| 390 | 361 |
| 391 void ExternalReferenceTable::AddStubCache(Isolate* isolate) { | 362 void ExternalReferenceTable::AddStubCache(Isolate* isolate) { |
| 392 StubCache* load_stub_cache = isolate->load_stub_cache(); | 363 StubCache* load_stub_cache = isolate->load_stub_cache(); |
| 393 | 364 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 Add(address, "lazy_deopt"); | 405 Add(address, "lazy_deopt"); |
| 435 } | 406 } |
| 436 } | 407 } |
| 437 | 408 |
| 438 void ExternalReferenceTable::AddApiReferences(Isolate* isolate) { | 409 void ExternalReferenceTable::AddApiReferences(Isolate* isolate) { |
| 439 // Add external references provided by the embedder (a null-terminated | 410 // Add external references provided by the embedder (a null-terminated |
| 440 // array). | 411 // array). |
| 441 intptr_t* api_external_references = isolate->api_external_references(); | 412 intptr_t* api_external_references = isolate->api_external_references(); |
| 442 if (api_external_references != nullptr) { | 413 if (api_external_references != nullptr) { |
| 443 while (*api_external_references != 0) { | 414 while (*api_external_references != 0) { |
| 444 Address address = reinterpret_cast<Address>(*api_external_references); | 415 Add(reinterpret_cast<Address>(*api_external_references), "<embedder>"); |
| 445 Add(address, ResolveSymbol(address)); | |
| 446 api_external_references++; | 416 api_external_references++; |
| 447 } | 417 } |
| 448 } | 418 } |
| 449 } | 419 } |
| 450 | 420 |
| 451 } // namespace internal | 421 } // namespace internal |
| 452 } // namespace v8 | 422 } // namespace v8 |
| OLD | NEW |