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

Side by Side Diff: src/api.cc

Issue 499483002: [WIP] A sampler thread in d8 for consuming the new API. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 4 months 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 | Annotate | Revision Log
OLDNEW
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"
(...skipping 7375 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 void Sampler::Install(Isolate* isolate,
7431 CodeEventHandler* codeEventHandler) {
7432 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
7433
7434 i::Logger* logger = internal_isolate->logger();
7435 if (logger == NULL) return;
7436
7437 logger->SetCodeEventHandler(codeEventHandler);
7438 }
7439
7440 Sample* Sampler::GetSample(Isolate* isolate,
7441 Sample* sample) {
7442 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
7443
7444 i::Logger* logger = internal_isolate->logger();
7445 if (logger == NULL) return NULL;
7446
7447 i::Sampler* sampler = logger->sampler();
7448 if (sampler == NULL) return NULL;
7449
7450 // TODO(gohlap): These checks and getters above are just transitory.
7451 // Get rid of those as we make the API mature.
7452 // We have these right now because we want the new API
7453 // to play well with the current cpu-profiler thread inside v8.
7454
7455 return sampler->GetSample(sample);
7456 }
7428 7457
7429 v8::Testing::StressType internal::Testing::stress_type_ = 7458 v8::Testing::StressType internal::Testing::stress_type_ =
7430 v8::Testing::kStressTypeOpt; 7459 v8::Testing::kStressTypeOpt;
7431 7460
7432 7461
7433 void Testing::SetStressRunType(Testing::StressType type) { 7462 void Testing::SetStressRunType(Testing::StressType type) {
7434 internal::Testing::set_stress_type(type); 7463 internal::Testing::set_stress_type(type);
7435 } 7464 }
7436 7465
7437 7466
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
7658 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); 7687 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate());
7659 Address callback_address = 7688 Address callback_address =
7660 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 7689 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
7661 VMState<EXTERNAL> state(isolate); 7690 VMState<EXTERNAL> state(isolate);
7662 ExternalCallbackScope call_scope(isolate, callback_address); 7691 ExternalCallbackScope call_scope(isolate, callback_address);
7663 callback(info); 7692 callback(info);
7664 } 7693 }
7665 7694
7666 7695
7667 } } // namespace v8::internal 7696 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698