whesse@chromium.org | cec079d | 2010-03-22 14:44:04 +0000 | [diff] [blame] | 1 | // Copyright 2010 the V8 project authors. All rights reserved. |
| 2 | // Redistribution and use in source and binary forms, with or without |
| 3 | // modification, are permitted provided that the following conditions are |
| 4 | // met: |
| 5 | // |
| 6 | // * Redistributions of source code must retain the above copyright |
| 7 | // notice, this list of conditions and the following disclaimer. |
| 8 | // * Redistributions in binary form must reproduce the above |
| 9 | // copyright notice, this list of conditions and the following |
| 10 | // disclaimer in the documentation and/or other materials provided |
| 11 | // with the distribution. |
| 12 | // * Neither the name of Google Inc. nor the names of its |
| 13 | // contributors may be used to endorse or promote products derived |
| 14 | // from this software without specific prior written permission. |
| 15 | // |
| 16 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 19 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 20 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 21 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | |
| 28 | #ifndef V8_CPU_PROFILER_INL_H_ |
| 29 | #define V8_CPU_PROFILER_INL_H_ |
| 30 | |
lrn@chromium.org | 25156de | 2010-04-06 13:10:27 +0000 | [diff] [blame] | 31 | #include "cpu-profiler.h" |
| 32 | |
ricow@chromium.org | c9c8082 | 2010-04-21 08:22:37 +0000 | [diff] [blame] | 33 | #ifdef ENABLE_LOGGING_AND_PROFILING |
lrn@chromium.org | 25156de | 2010-04-06 13:10:27 +0000 | [diff] [blame] | 34 | |
whesse@chromium.org | cec079d | 2010-03-22 14:44:04 +0000 | [diff] [blame] | 35 | #include "circular-queue-inl.h" |
| 36 | #include "profile-generator-inl.h" |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 37 | #include "unbound-queue-inl.h" |
whesse@chromium.org | cec079d | 2010-03-22 14:44:04 +0000 | [diff] [blame] | 38 | |
whesse@chromium.org | cec079d | 2010-03-22 14:44:04 +0000 | [diff] [blame] | 39 | namespace v8 { |
| 40 | namespace internal { |
| 41 | |
lrn@chromium.org | 25156de | 2010-04-06 13:10:27 +0000 | [diff] [blame] | 42 | void CodeCreateEventRecord::UpdateCodeMap(CodeMap* code_map) { |
ager@chromium.org | 357bf65 | 2010-04-12 11:30:10 +0000 | [diff] [blame] | 43 | code_map->AddCode(start, entry, size); |
lrn@chromium.org | 25156de | 2010-04-06 13:10:27 +0000 | [diff] [blame] | 44 | } |
| 45 | |
| 46 | |
| 47 | void CodeMoveEventRecord::UpdateCodeMap(CodeMap* code_map) { |
ager@chromium.org | 357bf65 | 2010-04-12 11:30:10 +0000 | [diff] [blame] | 48 | code_map->MoveCode(from, to); |
lrn@chromium.org | 25156de | 2010-04-06 13:10:27 +0000 | [diff] [blame] | 49 | } |
| 50 | |
| 51 | |
| 52 | void CodeDeleteEventRecord::UpdateCodeMap(CodeMap* code_map) { |
ager@chromium.org | 357bf65 | 2010-04-12 11:30:10 +0000 | [diff] [blame] | 53 | code_map->DeleteCode(start); |
lrn@chromium.org | 25156de | 2010-04-06 13:10:27 +0000 | [diff] [blame] | 54 | } |
| 55 | |
| 56 | |
| 57 | void CodeAliasEventRecord::UpdateCodeMap(CodeMap* code_map) { |
erik.corry@gmail.com | 9dfbea4 | 2010-05-21 12:58:28 +0000 | [diff] [blame] | 58 | code_map->AddAlias(start, entry, code_start); |
ager@chromium.org | 357bf65 | 2010-04-12 11:30:10 +0000 | [diff] [blame] | 59 | } |
| 60 | |
| 61 | |
| 62 | TickSampleEventRecord* TickSampleEventRecord::init(void* value) { |
| 63 | TickSampleEventRecord* result = |
| 64 | reinterpret_cast<TickSampleEventRecord*>(value); |
| 65 | result->filler = 1; |
| 66 | ASSERT(result->filler != SamplingCircularQueue::kClear); |
| 67 | // Init the required fields only. |
| 68 | result->sample.pc = NULL; |
| 69 | result->sample.frames_count = 0; |
| 70 | return result; |
lrn@chromium.org | 25156de | 2010-04-06 13:10:27 +0000 | [diff] [blame] | 71 | } |
| 72 | |
whesse@chromium.org | cec079d | 2010-03-22 14:44:04 +0000 | [diff] [blame] | 73 | |
| 74 | TickSample* ProfilerEventsProcessor::TickSampleEvent() { |
ricow@chromium.org | c9c8082 | 2010-04-21 08:22:37 +0000 | [diff] [blame] | 75 | generator_->Tick(); |
whesse@chromium.org | cec079d | 2010-03-22 14:44:04 +0000 | [diff] [blame] | 76 | TickSampleEventRecord* evt = |
ager@chromium.org | 357bf65 | 2010-04-12 11:30:10 +0000 | [diff] [blame] | 77 | TickSampleEventRecord::init(ticks_buffer_.Enqueue()); |
whesse@chromium.org | cec079d | 2010-03-22 14:44:04 +0000 | [diff] [blame] | 78 | evt->order = enqueue_order_; // No increment! |
| 79 | return &evt->sample; |
| 80 | } |
| 81 | |
ager@chromium.org | 357bf65 | 2010-04-12 11:30:10 +0000 | [diff] [blame] | 82 | |
| 83 | bool ProfilerEventsProcessor::FilterOutCodeCreateEvent( |
| 84 | Logger::LogEventsAndTags tag) { |
ager@chromium.org | 357bf65 | 2010-04-12 11:30:10 +0000 | [diff] [blame] | 85 | return FLAG_prof_browser_mode |
| 86 | && (tag != Logger::CALLBACK_TAG |
| 87 | && tag != Logger::FUNCTION_TAG |
| 88 | && tag != Logger::LAZY_COMPILE_TAG |
fschneider@chromium.org | c20610a | 2010-09-22 09:44:58 +0000 | [diff] [blame] | 89 | && tag != Logger::REG_EXP_TAG |
ager@chromium.org | 357bf65 | 2010-04-12 11:30:10 +0000 | [diff] [blame] | 90 | && tag != Logger::SCRIPT_TAG); |
| 91 | } |
| 92 | |
whesse@chromium.org | cec079d | 2010-03-22 14:44:04 +0000 | [diff] [blame] | 93 | } } // namespace v8::internal |
| 94 | |
ricow@chromium.org | c9c8082 | 2010-04-21 08:22:37 +0000 | [diff] [blame] | 95 | #endif // ENABLE_LOGGING_AND_PROFILING |
lrn@chromium.org | 25156de | 2010-04-06 13:10:27 +0000 | [diff] [blame] | 96 | |
whesse@chromium.org | cec079d | 2010-03-22 14:44:04 +0000 | [diff] [blame] | 97 | #endif // V8_CPU_PROFILER_INL_H_ |