fschneider@chromium.org | 086aac6 | 2010-03-17 13:18:24 +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_PROFILE_GENERATOR_INL_H_ |
| 29 | #define V8_PROFILE_GENERATOR_INL_H_ |
| 30 | |
| 31 | #include "profile-generator.h" |
| 32 | |
| 33 | namespace v8 { |
| 34 | namespace internal { |
| 35 | |
erik.corry@gmail.com | 145eff5 | 2010-08-23 11:36:18 +0000 | [diff] [blame] | 36 | const char* StringsStorage::GetFunctionName(String* name) { |
| 37 | return GetFunctionName(GetName(name)); |
| 38 | } |
| 39 | |
| 40 | |
| 41 | const char* StringsStorage::GetFunctionName(const char* name) { |
| 42 | return strlen(name) > 0 ? name : ProfileGenerator::kAnonymousFunctionName; |
| 43 | } |
| 44 | |
| 45 | |
whesse@chromium.org | cec079d | 2010-03-22 14:44:04 +0000 | [diff] [blame] | 46 | CodeEntry::CodeEntry(Logger::LogEventsAndTags tag, |
lrn@chromium.org | 25156de | 2010-04-06 13:10:27 +0000 | [diff] [blame] | 47 | const char* name_prefix, |
whesse@chromium.org | cec079d | 2010-03-22 14:44:04 +0000 | [diff] [blame] | 48 | const char* name, |
| 49 | const char* resource_name, |
erik.corry@gmail.com | 9dfbea4 | 2010-05-21 12:58:28 +0000 | [diff] [blame] | 50 | int line_number, |
| 51 | int security_token_id) |
fschneider@chromium.org | c20610a | 2010-09-22 09:44:58 +0000 | [diff] [blame] | 52 | : tag_(tag), |
lrn@chromium.org | 25156de | 2010-04-06 13:10:27 +0000 | [diff] [blame] | 53 | name_prefix_(name_prefix), |
whesse@chromium.org | cec079d | 2010-03-22 14:44:04 +0000 | [diff] [blame] | 54 | name_(name), |
| 55 | resource_name_(resource_name), |
erik.corry@gmail.com | 9dfbea4 | 2010-05-21 12:58:28 +0000 | [diff] [blame] | 56 | line_number_(line_number), |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 57 | shared_id_(0), |
erik.corry@gmail.com | 9dfbea4 | 2010-05-21 12:58:28 +0000 | [diff] [blame] | 58 | security_token_id_(security_token_id) { |
whesse@chromium.org | cec079d | 2010-03-22 14:44:04 +0000 | [diff] [blame] | 59 | } |
| 60 | |
| 61 | |
ager@chromium.org | 357bf65 | 2010-04-12 11:30:10 +0000 | [diff] [blame] | 62 | bool CodeEntry::is_js_function_tag(Logger::LogEventsAndTags tag) { |
| 63 | return tag == Logger::FUNCTION_TAG |
| 64 | || tag == Logger::LAZY_COMPILE_TAG |
| 65 | || tag == Logger::SCRIPT_TAG |
| 66 | || tag == Logger::NATIVE_FUNCTION_TAG |
| 67 | || tag == Logger::NATIVE_LAZY_COMPILE_TAG |
| 68 | || tag == Logger::NATIVE_SCRIPT_TAG; |
fschneider@chromium.org | 086aac6 | 2010-03-17 13:18:24 +0000 | [diff] [blame] | 69 | } |
| 70 | |
| 71 | |
ricow@chromium.org | c9c8082 | 2010-04-21 08:22:37 +0000 | [diff] [blame] | 72 | ProfileNode::ProfileNode(ProfileTree* tree, CodeEntry* entry) |
| 73 | : tree_(tree), |
| 74 | entry_(entry), |
fschneider@chromium.org | 086aac6 | 2010-03-17 13:18:24 +0000 | [diff] [blame] | 75 | total_ticks_(0), |
| 76 | self_ticks_(0), |
| 77 | children_(CodeEntriesMatch) { |
| 78 | } |
| 79 | |
| 80 | |
| 81 | void CodeMap::AddCode(Address addr, CodeEntry* entry, unsigned size) { |
| 82 | CodeTree::Locator locator; |
| 83 | tree_.Insert(addr, &locator); |
| 84 | locator.set_value(CodeEntryInfo(entry, size)); |
| 85 | } |
| 86 | |
| 87 | |
| 88 | void CodeMap::MoveCode(Address from, Address to) { |
| 89 | tree_.Move(from, to); |
| 90 | } |
| 91 | |
| 92 | void CodeMap::DeleteCode(Address addr) { |
| 93 | tree_.Remove(addr); |
| 94 | } |
| 95 | |
| 96 | |
ager@chromium.org | 357bf65 | 2010-04-12 11:30:10 +0000 | [diff] [blame] | 97 | CodeEntry* ProfileGenerator::EntryForVMState(StateTag tag) { |
| 98 | switch (tag) { |
| 99 | case GC: |
| 100 | return gc_entry_; |
| 101 | case JS: |
| 102 | case COMPILER: |
| 103 | // DOM events handlers are reported as OTHER / EXTERNAL entries. |
| 104 | // To avoid confusing people, let's put all these entries into |
| 105 | // one bucket. |
| 106 | case OTHER: |
| 107 | case EXTERNAL: |
| 108 | return program_entry_; |
| 109 | default: return NULL; |
| 110 | } |
| 111 | } |
| 112 | |
vegorov@chromium.org | 21b5e95 | 2010-11-23 10:24:40 +0000 | [diff] [blame] | 113 | |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 114 | uint64_t HeapEntry::id() { |
vegorov@chromium.org | 21b5e95 | 2010-11-23 10:24:40 +0000 | [diff] [blame] | 115 | union { |
| 116 | Id stored_id; |
| 117 | uint64_t returned_id; |
| 118 | } id_adaptor = {id_}; |
| 119 | return id_adaptor.returned_id; |
| 120 | } |
| 121 | |
fschneider@chromium.org | 086aac6 | 2010-03-17 13:18:24 +0000 | [diff] [blame] | 122 | } } // namespace v8::internal |
| 123 | |
fschneider@chromium.org | 086aac6 | 2010-03-17 13:18:24 +0000 | [diff] [blame] | 124 | #endif // V8_PROFILE_GENERATOR_INL_H_ |