 Chromium Code Reviews
 Chromium Code Reviews Issue 2105943002:
  Expose TickSample and its APIs in v8-profiler.h  (Closed) 
  Base URL: https://chromium.googlesource.com/v8/v8.git@master
    
  
    Issue 2105943002:
  Expose TickSample and its APIs in v8-profiler.h  (Closed) 
  Base URL: https://chromium.googlesource.com/v8/v8.git@master| OLD | NEW | 
|---|---|
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 #ifndef V8_PROFILER_TICK_SAMPLE_H_ | 5 #ifndef V8_PROFILER_TICK_SAMPLE_H_ | 
| 6 #define V8_PROFILER_TICK_SAMPLE_H_ | 6 #define V8_PROFILER_TICK_SAMPLE_H_ | 
| 7 | 7 | 
| 8 #include "include/v8.h" | 8 #include "include/v8-profiler.h" | 
| 9 | |
| 10 #include "src/base/platform/time.h" | 9 #include "src/base/platform/time.h" | 
| 11 #include "src/frames.h" | |
| 12 #include "src/globals.h" | 10 #include "src/globals.h" | 
| 13 | 11 | 
| 14 namespace v8 { | 12 namespace v8 { | 
| 13 | |
| 14 struct RegisterState; | |
| 15 struct TickSample; | |
| 
alph
2016/07/01 00:38:13
These two are not needed. The declaration is visib
 
lpy
2016/07/01 01:00:10
Done.
 | |
| 16 | |
| 15 namespace internal { | 17 namespace internal { | 
| 16 | 18 | 
| 17 class Isolate; | 19 class Isolate; | 
| 18 | 20 | 
| 19 // ---------------------------------------------------------------------------- | 21 struct TickSample : public v8::TickSample { | 
| 20 // Sampler | 22 TickSample() : v8::TickSample(), timestamp(base::TimeTicks()) {} | 
| 21 // | |
| 22 // A sampler periodically samples the state of the VM and optionally | |
| 23 // (if used for profiling) the program counter and stack pointer for | |
| 24 // the thread that created it. | |
| 25 | |
| 26 // TickSample captures the information collected for each sample. | |
| 27 struct TickSample { | |
| 28 // Internal profiling (with --prof + tools/$OS-tick-processor) wants to | |
| 29 // include the runtime function we're calling. Externally exposed tick | |
| 30 // samples don't care. | |
| 31 enum RecordCEntryFrame { kIncludeCEntryFrame, kSkipCEntryFrame }; | |
| 32 | |
| 33 TickSample() | |
| 34 : state(OTHER), | |
| 35 pc(NULL), | |
| 36 external_callback_entry(NULL), | |
| 37 frames_count(0), | |
| 38 has_external_callback(false), | |
| 39 update_stats(true) {} | |
| 40 void Init(Isolate* isolate, const v8::RegisterState& state, | |
| 41 RecordCEntryFrame record_c_entry_frame, bool update_stats); | |
| 42 static bool GetStackSample(Isolate* isolate, const v8::RegisterState& state, | |
| 43 RecordCEntryFrame record_c_entry_frame, | |
| 44 void** frames, size_t frames_limit, | |
| 45 v8::SampleInfo* sample_info); | |
| 46 StateTag state; // The state of the VM. | |
| 47 Address pc; // Instruction pointer. | |
| 48 union { | |
| 49 Address tos; // Top stack value (*sp). | |
| 50 Address external_callback_entry; | |
| 51 }; | |
| 52 static const unsigned kMaxFramesCountLog2 = 8; | |
| 53 static const unsigned kMaxFramesCount = (1 << kMaxFramesCountLog2) - 1; | |
| 54 Address stack[kMaxFramesCount]; // Call stack. | |
| 55 base::TimeTicks timestamp; | 23 base::TimeTicks timestamp; | 
| 56 unsigned frames_count : kMaxFramesCountLog2; // Number of captured frames. | |
| 57 bool has_external_callback : 1; | |
| 58 bool update_stats : 1; // Whether the sample should update aggregated stats. | |
| 59 }; | 24 }; | 
| 60 | 25 | 
| 61 | |
| 62 #if defined(USE_SIMULATOR) | 26 #if defined(USE_SIMULATOR) | 
| 63 class SimulatorHelper { | 27 class SimulatorHelper { | 
| 64 public: | 28 public: | 
| 65 // Returns true if register values were successfully retrieved | 29 // Returns true if register values were successfully retrieved | 
| 66 // from the simulator, otherwise returns false. | 30 // from the simulator, otherwise returns false. | 
| 67 static bool FillRegisters(Isolate* isolate, v8::RegisterState* state); | 31 static bool FillRegisters(Isolate* isolate, v8::RegisterState* state); | 
| 68 }; | 32 }; | 
| 69 #endif // USE_SIMULATOR | 33 #endif // USE_SIMULATOR | 
| 70 | 34 | 
| 71 } // namespace internal | 35 } // namespace internal | 
| 72 } // namespace v8 | 36 } // namespace v8 | 
| 73 | 37 | 
| 74 #endif // V8_PROFILER_TICK_SAMPLE_H_ | 38 #endif // V8_PROFILER_TICK_SAMPLE_H_ | 
| OLD | NEW |