OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 // ---------------------------------------------------------------------------- | 415 // ---------------------------------------------------------------------------- |
416 // Sampler | 416 // Sampler |
417 // | 417 // |
418 // A sampler periodically samples the state of the VM and optionally | 418 // A sampler periodically samples the state of the VM and optionally |
419 // (if used for profiling) the program counter and stack pointer for | 419 // (if used for profiling) the program counter and stack pointer for |
420 // the thread that created it. | 420 // the thread that created it. |
421 | 421 |
422 // TickSample captures the information collected for each sample. | 422 // TickSample captures the information collected for each sample. |
423 class TickSample { | 423 class TickSample { |
424 public: | 424 public: |
425 TickSample() : pc(0), sp(0), state(OTHER) {} | 425 TickSample() : pc(0), sp(0), fp(0), state(OTHER) {} |
426 unsigned int pc; // Instruction pointer. | 426 unsigned int pc; // Instruction pointer. |
427 unsigned int sp; // Stack pointer. | 427 unsigned int sp; // Stack pointer. |
| 428 unsigned int fp; // Frame pointer. |
428 StateTag state; // The state of the VM. | 429 StateTag state; // The state of the VM. |
| 430 SmartPointer<Address> stack; // Call stack, null-terminated. |
| 431 |
| 432 inline TickSample& operator=(const TickSample& rhs) { |
| 433 if (this == &rhs) return *this; |
| 434 pc = rhs.pc; |
| 435 sp = rhs.sp; |
| 436 fp = rhs.fp; |
| 437 state = rhs.state; |
| 438 DeleteArray(stack.Detach()); |
| 439 stack = rhs.stack; |
| 440 return *this; |
| 441 } |
| 442 |
| 443 inline void InitStack(int depth) { |
| 444 stack = SmartPointer<Address>(NewArray<Address>(depth + 1)); |
| 445 // null-terminate |
| 446 stack[depth] = 0; |
| 447 } |
429 }; | 448 }; |
430 | 449 |
431 class Sampler { | 450 class Sampler { |
432 public: | 451 public: |
433 // Initialize sampler. | 452 // Initialize sampler. |
434 explicit Sampler(int interval, bool profiling); | 453 explicit Sampler(int interval, bool profiling); |
435 virtual ~Sampler(); | 454 virtual ~Sampler(); |
436 | 455 |
437 // This method is called for each sampling period with the current | 456 // This method is called for each sampling period with the current |
438 // program counter. | 457 // program counter. |
(...skipping 16 matching lines...) Expand all Loading... |
455 bool active_; | 474 bool active_; |
456 PlatformData* data_; // Platform specific data. | 475 PlatformData* data_; // Platform specific data. |
457 DISALLOW_IMPLICIT_CONSTRUCTORS(Sampler); | 476 DISALLOW_IMPLICIT_CONSTRUCTORS(Sampler); |
458 }; | 477 }; |
459 | 478 |
460 #endif // ENABLE_LOGGING_AND_PROFILING | 479 #endif // ENABLE_LOGGING_AND_PROFILING |
461 | 480 |
462 } } // namespace v8::internal | 481 } } // namespace v8::internal |
463 | 482 |
464 #endif // V8_PLATFORM_H_ | 483 #endif // V8_PLATFORM_H_ |
OLD | NEW |