| OLD | NEW | 
| (Empty) |  | 
 |   1 // Copyright 2014 the V8 project authors. All rights reserved. | 
 |   2 // Use of this source code is governed by a BSD-style license that can be | 
 |   3 // found in the LICENSE file. | 
 |   4  | 
 |   5 #ifndef V8_V8_SAMPLER_H_ | 
 |   6 #define V8_V8_SAMPLER_H_ | 
 |   7  | 
 |   8 #include "v8.h" | 
 |   9  | 
 |  10 /** | 
 |  11  * Sampler API for the V8 JavaScript engine. | 
 |  12  * The API to be consumed by any code which | 
 |  13  * wants to build a sampling profiler for v8. | 
 |  14  */ | 
 |  15 namespace v8 { | 
 |  16   /* TODO(gholap): This should go away and struct Sample should | 
 |  17                    just use const void* instead of Address. | 
 |  18                    Currently we need it because of implementation details. */ | 
 |  19   typedef unsigned char* Address; | 
 |  20  | 
 |  21 /** | 
 |  22  * A collected sample contains, | 
 |  23  * - state       : The state of the VM at the time of collecting the sample. | 
 |  24  * - stack       : An array of addresses. | 
 |  25  *                 One address per stack frame. | 
 |  26  *                 The address is the instruction pointer, | 
 |  27  *                 pointing to the instruction which led to the | 
 |  28  *                 creation of the stack frame. | 
 |  29  *                 (for example, a function call) | 
 |  30  * - frames_count: Number of stack frames that were captured. | 
 |  31  *                 That is, stack[frames_count+i] might contain meaningless | 
 |  32  *                 addresses for any i >= 0. | 
 |  33  */ | 
 |  34 struct Sample { | 
 |  35   Sample() | 
 |  36       : frames_count(0) {} | 
 |  37   static const unsigned kMaxFramesCountLog2 = 8; | 
 |  38   static const unsigned kMaxFramesCount = (1 << kMaxFramesCountLog2) - 1; | 
 |  39  | 
 |  40   Address stack[kMaxFramesCount];               // Call stack. | 
 |  41   unsigned frames_count : kMaxFramesCountLog2;  // Number of captured frames. | 
 |  42 }; | 
 |  43  | 
 |  44 /** | 
 |  45  * Interface for collecting execution stack samples. | 
 |  46  */ | 
 |  47 class V8_EXPORT Sampler { | 
 |  48  public: | 
 |  49   /** | 
 |  50    * Obtain a sample from the isolate. | 
 |  51    * Updates the sample pointer with the newly obtained | 
 |  52    * sampling information. | 
 |  53    * On success, returns the sample pointer. | 
 |  54    * On failure, returns NULL. | 
 |  55    */ | 
 |  56   static Sample* GetSample(Isolate* isolate, | 
 |  57                            Sample* sample); | 
 |  58 }; | 
 |  59 }  // namespace v8 | 
 |  60 #endif  // V8_V8_SAMPLER_H_ | 
| OLD | NEW |