OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
61 defined(__arm__) && !defined(__BIONIC_HAVE_STRUCT_SIGCONTEXT) | 61 defined(__arm__) && !defined(__BIONIC_HAVE_STRUCT_SIGCONTEXT) |
62 #include <asm/sigcontext.h> | 62 #include <asm/sigcontext.h> |
63 #endif | 63 #endif |
64 | 64 |
65 #undef MAP_TYPE | 65 #undef MAP_TYPE |
66 | 66 |
67 #include "v8.h" | 67 #include "v8.h" |
68 | 68 |
69 #include "platform-posix.h" | 69 #include "platform-posix.h" |
70 #include "platform.h" | 70 #include "platform.h" |
71 #include "simulator.h" | |
71 #include "v8threads.h" | 72 #include "v8threads.h" |
72 #include "vm-state-inl.h" | 73 #include "vm-state-inl.h" |
73 | 74 |
74 | 75 |
75 namespace v8 { | 76 namespace v8 { |
76 namespace internal { | 77 namespace internal { |
77 | 78 |
78 // 0 is never a valid thread id on Linux since tids and pids share a | 79 // 0 is never a valid thread id on Linux since tids and pids share a |
79 // name space and pid 0 is reserved (see man 2 kill). | 80 // name space and pid 0 is reserved (see man 2 kill). |
80 static const pthread_t kNoThread = (pthread_t) 0; | 81 static const pthread_t kNoThread = (pthread_t) 0; |
(...skipping 1009 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1090 return; | 1091 return; |
1091 } | 1092 } |
1092 if (v8::Locker::IsActive() && | 1093 if (v8::Locker::IsActive() && |
1093 !isolate->thread_manager()->IsLockedByCurrentThread()) { | 1094 !isolate->thread_manager()->IsLockedByCurrentThread()) { |
1094 return; | 1095 return; |
1095 } | 1096 } |
1096 | 1097 |
1097 Sampler* sampler = isolate->logger()->sampler(); | 1098 Sampler* sampler = isolate->logger()->sampler(); |
1098 if (sampler == NULL || !sampler->IsActive()) return; | 1099 if (sampler == NULL || !sampler->IsActive()) return; |
1099 | 1100 |
1101 #if defined(USE_SIMULATOR) | |
1102 #if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_MIPS | |
Sven Panne
2013/04/11 09:58:02
I think we can remove this #if...
| |
1103 Isolate::PerIsolateThreadData* per_thread_data = | |
1104 isolate->FindPerThreadDataForThisThread(); | |
1105 if (!per_thread_data) return; | |
1106 Simulator* sim = per_thread_data->simulator(); | |
1107 // Check if there is active simulator before allocating TickSample. | |
1108 if (!sim) return; | |
1109 #endif | |
1110 #endif // USE_SIMULATOR | |
1111 | |
1100 TickSample sample_obj; | 1112 TickSample sample_obj; |
1101 TickSample* sample = isolate->cpu_profiler()->TickSampleEvent(); | 1113 TickSample* sample = isolate->cpu_profiler()->TickSampleEvent(); |
1102 if (sample == NULL) sample = &sample_obj; | 1114 if (sample == NULL) sample = &sample_obj; |
1103 | 1115 |
1116 #if defined(USE_SIMULATOR) | |
1117 #if V8_TARGET_ARCH_ARM | |
1118 sample->pc = reinterpret_cast<Address>(sim->get_register(Simulator::pc)); | |
1119 sample->sp = reinterpret_cast<Address>(sim->get_register(Simulator::sp)); | |
1120 sample->fp = reinterpret_cast<Address>(sim->get_register(Simulator::r11)); | |
1121 #elif V8_TARGET_ARCH_MIPS | |
1122 sample->pc = reinterpret_cast<Address>(sim->get_register(Simulator::pc)); | |
1123 sample->sp = reinterpret_cast<Address>(sim->get_register(Simulator::sp)); | |
1124 sample->fp = reinterpret_cast<Address>(sim->get_register(Simulator::fp)); | |
Sven Panne
2013/04/11 09:58:02
... and add an #else followed by #error here.
| |
1125 #endif | |
1126 #else | |
1104 // Extracting the sample from the context is extremely machine dependent. | 1127 // Extracting the sample from the context is extremely machine dependent. |
1105 ucontext_t* ucontext = reinterpret_cast<ucontext_t*>(context); | 1128 ucontext_t* ucontext = reinterpret_cast<ucontext_t*>(context); |
1106 mcontext_t& mcontext = ucontext->uc_mcontext; | 1129 mcontext_t& mcontext = ucontext->uc_mcontext; |
1107 sample->state = isolate->current_vm_state(); | 1130 sample->state = isolate->current_vm_state(); |
1108 #if V8_HOST_ARCH_IA32 | 1131 #if V8_HOST_ARCH_IA32 |
1109 sample->pc = reinterpret_cast<Address>(mcontext.gregs[REG_EIP]); | 1132 sample->pc = reinterpret_cast<Address>(mcontext.gregs[REG_EIP]); |
1110 sample->sp = reinterpret_cast<Address>(mcontext.gregs[REG_ESP]); | 1133 sample->sp = reinterpret_cast<Address>(mcontext.gregs[REG_ESP]); |
1111 sample->fp = reinterpret_cast<Address>(mcontext.gregs[REG_EBP]); | 1134 sample->fp = reinterpret_cast<Address>(mcontext.gregs[REG_EBP]); |
1112 #elif V8_HOST_ARCH_X64 | 1135 #elif V8_HOST_ARCH_X64 |
1113 sample->pc = reinterpret_cast<Address>(mcontext.gregs[REG_RIP]); | 1136 sample->pc = reinterpret_cast<Address>(mcontext.gregs[REG_RIP]); |
(...skipping 11 matching lines...) Expand all Loading... | |
1125 sample->pc = reinterpret_cast<Address>(mcontext.arm_pc); | 1148 sample->pc = reinterpret_cast<Address>(mcontext.arm_pc); |
1126 sample->sp = reinterpret_cast<Address>(mcontext.arm_sp); | 1149 sample->sp = reinterpret_cast<Address>(mcontext.arm_sp); |
1127 sample->fp = reinterpret_cast<Address>(mcontext.arm_fp); | 1150 sample->fp = reinterpret_cast<Address>(mcontext.arm_fp); |
1128 #endif // defined(__GLIBC__) && !defined(__UCLIBC__) && | 1151 #endif // defined(__GLIBC__) && !defined(__UCLIBC__) && |
1129 // (__GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ <= 3)) | 1152 // (__GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ <= 3)) |
1130 #elif V8_HOST_ARCH_MIPS | 1153 #elif V8_HOST_ARCH_MIPS |
1131 sample->pc = reinterpret_cast<Address>(mcontext.pc); | 1154 sample->pc = reinterpret_cast<Address>(mcontext.pc); |
1132 sample->sp = reinterpret_cast<Address>(mcontext.gregs[29]); | 1155 sample->sp = reinterpret_cast<Address>(mcontext.gregs[29]); |
1133 sample->fp = reinterpret_cast<Address>(mcontext.gregs[30]); | 1156 sample->fp = reinterpret_cast<Address>(mcontext.gregs[30]); |
1134 #endif // V8_HOST_ARCH_* | 1157 #endif // V8_HOST_ARCH_* |
1158 #endif // USE_SIMULATOR | |
1135 sampler->SampleStack(sample); | 1159 sampler->SampleStack(sample); |
1136 sampler->Tick(sample); | 1160 sampler->Tick(sample); |
1137 #endif // __native_client__ | 1161 #endif // __native_client__ |
1138 } | 1162 } |
1139 | 1163 |
1140 | 1164 |
1141 class Sampler::PlatformData : public Malloced { | 1165 class Sampler::PlatformData : public Malloced { |
1142 public: | 1166 public: |
1143 PlatformData() : vm_tid_(GetThreadID()) {} | 1167 PlatformData() : vm_tid_(GetThreadID()) {} |
1144 | 1168 |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1335 | 1359 |
1336 | 1360 |
1337 void Sampler::Stop() { | 1361 void Sampler::Stop() { |
1338 ASSERT(IsActive()); | 1362 ASSERT(IsActive()); |
1339 SignalSender::RemoveActiveSampler(this); | 1363 SignalSender::RemoveActiveSampler(this); |
1340 SetActive(false); | 1364 SetActive(false); |
1341 } | 1365 } |
1342 | 1366 |
1343 | 1367 |
1344 } } // namespace v8::internal | 1368 } } // namespace v8::internal |
OLD | NEW |