| 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 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 459 // the thread that created it. | 459 // the thread that created it. |
| 460 | 460 |
| 461 // TickSample captures the information collected for each sample. | 461 // TickSample captures the information collected for each sample. |
| 462 class TickSample { | 462 class TickSample { |
| 463 public: | 463 public: |
| 464 TickSample() : pc(0), sp(0), fp(0), state(OTHER) {} | 464 TickSample() : pc(0), sp(0), fp(0), state(OTHER) {} |
| 465 unsigned int pc; // Instruction pointer. | 465 unsigned int pc; // Instruction pointer. |
| 466 unsigned int sp; // Stack pointer. | 466 unsigned int sp; // Stack pointer. |
| 467 unsigned int fp; // Frame pointer. | 467 unsigned int fp; // Frame pointer. |
| 468 StateTag state; // The state of the VM. | 468 StateTag state; // The state of the VM. |
| 469 SmartPointer<Address> stack; // Call stack, null-terminated. | 469 static const int kMaxFramesCount = 5; |
| 470 | 470 EmbeddedVector<Address, kMaxFramesCount> stack; // Call stack. |
| 471 inline TickSample& operator=(const TickSample& rhs) { | 471 int frames_count; // Number of captured frames. |
| 472 if (this == &rhs) return *this; | |
| 473 pc = rhs.pc; | |
| 474 sp = rhs.sp; | |
| 475 fp = rhs.fp; | |
| 476 state = rhs.state; | |
| 477 DeleteArray(stack.Detach()); | |
| 478 stack = rhs.stack; | |
| 479 return *this; | |
| 480 } | |
| 481 | |
| 482 inline void InitStack(int depth) { | |
| 483 if (depth) { | |
| 484 stack = SmartPointer<Address>(NewArray<Address>(depth + 1)); | |
| 485 // null-terminate | |
| 486 stack[depth] = 0; | |
| 487 } | |
| 488 } | |
| 489 }; | 472 }; |
| 490 | 473 |
| 491 class Sampler { | 474 class Sampler { |
| 492 public: | 475 public: |
| 493 // Initialize sampler. | 476 // Initialize sampler. |
| 494 explicit Sampler(int interval, bool profiling); | 477 explicit Sampler(int interval, bool profiling); |
| 495 virtual ~Sampler(); | 478 virtual ~Sampler(); |
| 496 | 479 |
| 497 // This method is called for each sampling period with the current | 480 // This method is called for each sampling period with the current |
| 498 // program counter. | 481 // program counter. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 515 bool active_; | 498 bool active_; |
| 516 PlatformData* data_; // Platform specific data. | 499 PlatformData* data_; // Platform specific data. |
| 517 DISALLOW_IMPLICIT_CONSTRUCTORS(Sampler); | 500 DISALLOW_IMPLICIT_CONSTRUCTORS(Sampler); |
| 518 }; | 501 }; |
| 519 | 502 |
| 520 #endif // ENABLE_LOGGING_AND_PROFILING | 503 #endif // ENABLE_LOGGING_AND_PROFILING |
| 521 | 504 |
| 522 } } // namespace v8::internal | 505 } } // namespace v8::internal |
| 523 | 506 |
| 524 #endif // V8_PLATFORM_H_ | 507 #endif // V8_PLATFORM_H_ |
| OLD | NEW |