| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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/api.h" | 5 #include "src/api.h" |
| 6 | 6 |
| 7 #include <string.h> // For memcpy, strlen. | 7 #include <string.h> // For memcpy, strlen. |
| 8 #ifdef V8_USE_ADDRESS_SANITIZER | 8 #ifdef V8_USE_ADDRESS_SANITIZER |
| 9 #include <sanitizer/asan_interface.h> | 9 #include <sanitizer/asan_interface.h> |
| 10 #endif // V8_USE_ADDRESS_SANITIZER | 10 #endif // V8_USE_ADDRESS_SANITIZER |
| 11 #include <cmath> // For isnan. | 11 #include <cmath> // For isnan. |
| 12 #include "include/v8-debug.h" | 12 #include "include/v8-debug.h" |
| 13 #include "include/v8-profiler.h" | 13 #include "include/v8-profiler.h" |
| 14 #include "include/v8-sampler.h" |
| 14 #include "include/v8-testing.h" | 15 #include "include/v8-testing.h" |
| 15 #include "src/assert-scope.h" | 16 #include "src/assert-scope.h" |
| 16 #include "src/base/platform/platform.h" | 17 #include "src/base/platform/platform.h" |
| 17 #include "src/base/platform/time.h" | 18 #include "src/base/platform/time.h" |
| 18 #include "src/base/utils/random-number-generator.h" | 19 #include "src/base/utils/random-number-generator.h" |
| 19 #include "src/bootstrapper.h" | 20 #include "src/bootstrapper.h" |
| 20 #include "src/code-stubs.h" | 21 #include "src/code-stubs.h" |
| 21 #include "src/compiler.h" | 22 #include "src/compiler.h" |
| 22 #include "src/conversions-inl.h" | 23 #include "src/conversions-inl.h" |
| 23 #include "src/counters.h" | 24 #include "src/counters.h" |
| 24 #include "src/cpu-profiler.h" | 25 #include "src/cpu-profiler.h" |
| 25 #include "src/debug.h" | 26 #include "src/debug.h" |
| 26 #include "src/deoptimizer.h" | 27 #include "src/deoptimizer.h" |
| 27 #include "src/execution.h" | 28 #include "src/execution.h" |
| 28 #include "src/global-handles.h" | 29 #include "src/global-handles.h" |
| 29 #include "src/heap-profiler.h" | 30 #include "src/heap-profiler.h" |
| 30 #include "src/heap-snapshot-generator-inl.h" | 31 #include "src/heap-snapshot-generator-inl.h" |
| 31 #include "src/icu_util.h" | 32 #include "src/icu_util.h" |
| 32 #include "src/json-parser.h" | 33 #include "src/json-parser.h" |
| 34 #include "src/log.h" |
| 33 #include "src/messages.h" | 35 #include "src/messages.h" |
| 34 #include "src/natives.h" | 36 #include "src/natives.h" |
| 35 #include "src/parser.h" | 37 #include "src/parser.h" |
| 36 #include "src/profile-generator-inl.h" | 38 #include "src/profile-generator-inl.h" |
| 37 #include "src/property.h" | 39 #include "src/property.h" |
| 38 #include "src/property-details.h" | 40 #include "src/property-details.h" |
| 39 #include "src/runtime.h" | 41 #include "src/runtime.h" |
| 40 #include "src/runtime-profiler.h" | 42 #include "src/runtime-profiler.h" |
| 41 #include "src/scanner-character-streams.h" | 43 #include "src/scanner-character-streams.h" |
| 42 #include "src/simulator.h" | 44 #include "src/simulator.h" |
| 43 #include "src/snapshot.h" | 45 #include "src/snapshot.h" |
| 44 #include "src/unicode-inl.h" | 46 #include "src/unicode-inl.h" |
| 45 #include "src/v8threads.h" | 47 #include "src/v8threads.h" |
| 46 #include "src/version.h" | 48 #include "src/version.h" |
| 47 #include "src/vm-state-inl.h" | 49 #include "src/vm-state-inl.h" |
| 48 | 50 |
| 49 | 51 |
| 50 #define LOG_API(isolate, expr) LOG(isolate, ApiEntryCall(expr)) | 52 #define LOG_API(isolate, expr) LOG(isolate, ApiEntryCall(expr)) |
| 51 | 53 |
| 52 #define ENTER_V8(isolate) \ | 54 #define ENTER_V8(isolate) \ |
| 53 ASSERT((isolate)->IsInitialized()); \ | 55 ASSERT((isolate)->IsInitialized()); \ |
| 54 i::VMState<i::OTHER> __state__((isolate)) | 56 i::VMState<OTHER> __state__((isolate)) |
| 55 | 57 |
| 56 namespace v8 { | 58 namespace v8 { |
| 57 | 59 |
| 58 #define ON_BAILOUT(isolate, location, code) \ | 60 #define ON_BAILOUT(isolate, location, code) \ |
| 59 if (IsExecutionTerminatingCheck(isolate)) { \ | 61 if (IsExecutionTerminatingCheck(isolate)) { \ |
| 60 code; \ | 62 code; \ |
| 61 UNREACHABLE(); \ | 63 UNREACHABLE(); \ |
| 62 } | 64 } |
| 63 | 65 |
| 64 | 66 |
| (...skipping 7104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7169 } | 7171 } |
| 7170 | 7172 |
| 7171 | 7173 |
| 7172 const CpuProfile* CpuProfiler::StopCpuProfiling(Handle<String> title) { | 7174 const CpuProfile* CpuProfiler::StopCpuProfiling(Handle<String> title) { |
| 7173 return StopProfiling(title); | 7175 return StopProfiling(title); |
| 7174 } | 7176 } |
| 7175 | 7177 |
| 7176 | 7178 |
| 7177 void CpuProfiler::SetIdle(bool is_idle) { | 7179 void CpuProfiler::SetIdle(bool is_idle) { |
| 7178 i::Isolate* isolate = reinterpret_cast<i::CpuProfiler*>(this)->isolate(); | 7180 i::Isolate* isolate = reinterpret_cast<i::CpuProfiler*>(this)->isolate(); |
| 7179 i::StateTag state = isolate->current_vm_state(); | 7181 StateTag state = isolate->current_vm_state(); |
| 7180 ASSERT(state == i::EXTERNAL || state == i::IDLE); | 7182 ASSERT(state == EXTERNAL || state == IDLE); |
| 7181 if (isolate->js_entry_sp() != NULL) return; | 7183 if (isolate->js_entry_sp() != NULL) return; |
| 7182 if (is_idle) { | 7184 if (is_idle) { |
| 7183 isolate->set_current_vm_state(i::IDLE); | 7185 isolate->set_current_vm_state(IDLE); |
| 7184 } else if (state == i::IDLE) { | 7186 } else if (state == IDLE) { |
| 7185 isolate->set_current_vm_state(i::EXTERNAL); | 7187 isolate->set_current_vm_state(EXTERNAL); |
| 7186 } | 7188 } |
| 7187 } | 7189 } |
| 7188 | 7190 |
| 7189 | 7191 |
| 7190 static i::HeapGraphEdge* ToInternal(const HeapGraphEdge* edge) { | 7192 static i::HeapGraphEdge* ToInternal(const HeapGraphEdge* edge) { |
| 7191 return const_cast<i::HeapGraphEdge*>( | 7193 return const_cast<i::HeapGraphEdge*>( |
| 7192 reinterpret_cast<const i::HeapGraphEdge*>(edge)); | 7194 reinterpret_cast<const i::HeapGraphEdge*>(edge)); |
| 7193 } | 7195 } |
| 7194 | 7196 |
| 7195 | 7197 |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7418 return reinterpret_cast<i::HeapProfiler*>(this)-> | 7420 return reinterpret_cast<i::HeapProfiler*>(this)-> |
| 7419 GetMemorySizeUsedByProfiler(); | 7421 GetMemorySizeUsedByProfiler(); |
| 7420 } | 7422 } |
| 7421 | 7423 |
| 7422 | 7424 |
| 7423 void HeapProfiler::SetRetainedObjectInfo(UniqueId id, | 7425 void HeapProfiler::SetRetainedObjectInfo(UniqueId id, |
| 7424 RetainedObjectInfo* info) { | 7426 RetainedObjectInfo* info) { |
| 7425 reinterpret_cast<i::HeapProfiler*>(this)->SetRetainedObjectInfo(id, info); | 7427 reinterpret_cast<i::HeapProfiler*>(this)->SetRetainedObjectInfo(id, info); |
| 7426 } | 7428 } |
| 7427 | 7429 |
| 7430 Sample* Sampler::GetSample(Isolate* isolate, |
| 7431 Sample* sample) { |
| 7432 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 7433 |
| 7434 i::Logger* logger = internal_isolate->logger(); |
| 7435 if (logger == NULL) return NULL; |
| 7436 |
| 7437 i::Sampler* sampler = logger->sampler(); |
| 7438 if (sampler == NULL) return NULL; |
| 7439 |
| 7440 // TODO(gohlap): These checks and getters above are just transitory. |
| 7441 // Get rid of those as we make the API mature. |
| 7442 // We have these right now because we want the new API |
| 7443 // to play well with the current cpu-profiler thread inside v8. |
| 7444 |
| 7445 return sampler->GetSample(sample); |
| 7446 } |
| 7428 | 7447 |
| 7429 v8::Testing::StressType internal::Testing::stress_type_ = | 7448 v8::Testing::StressType internal::Testing::stress_type_ = |
| 7430 v8::Testing::kStressTypeOpt; | 7449 v8::Testing::kStressTypeOpt; |
| 7431 | 7450 |
| 7432 | 7451 |
| 7433 void Testing::SetStressRunType(Testing::StressType type) { | 7452 void Testing::SetStressRunType(Testing::StressType type) { |
| 7434 internal::Testing::set_stress_type(type); | 7453 internal::Testing::set_stress_type(type); |
| 7435 } | 7454 } |
| 7436 | 7455 |
| 7437 | 7456 |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7658 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 7677 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
| 7659 Address callback_address = | 7678 Address callback_address = |
| 7660 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 7679 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
| 7661 VMState<EXTERNAL> state(isolate); | 7680 VMState<EXTERNAL> state(isolate); |
| 7662 ExternalCallbackScope call_scope(isolate, callback_address); | 7681 ExternalCallbackScope call_scope(isolate, callback_address); |
| 7663 callback(info); | 7682 callback(info); |
| 7664 } | 7683 } |
| 7665 | 7684 |
| 7666 | 7685 |
| 7667 } } // namespace v8::internal | 7686 } } // namespace v8::internal |
| OLD | NEW |