OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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 |
11 // with the distribution. | 11 // with the distribution. |
12 // * Neither the name of Google Inc. nor the names of its | 12 // * Neither the name of Google Inc. nor the names of its |
13 // contributors may be used to endorse or promote products derived | 13 // contributors may be used to endorse or promote products derived |
14 // from this software without specific prior written permission. | 14 // from this software without specific prior written permission. |
15 // | 15 // |
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 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. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
28 #include "src/perf-jit.h" | 28 #include "src/perf-jit.h" |
29 | 29 |
| 30 #include <memory> |
| 31 |
30 #include "src/assembler.h" | 32 #include "src/assembler.h" |
31 #include "src/eh-frame.h" | 33 #include "src/eh-frame.h" |
32 #include "src/objects-inl.h" | 34 #include "src/objects-inl.h" |
33 #include "src/source-position-table.h" | 35 #include "src/source-position-table.h" |
34 | 36 |
35 #if V8_OS_LINUX | 37 #if V8_OS_LINUX |
36 #include <fcntl.h> | 38 #include <fcntl.h> |
37 #include <sys/mman.h> | 39 #include <sys/mman.h> |
38 #include <unistd.h> | 40 #include <unistd.h> |
39 #endif // V8_OS_LINUX | 41 #endif // V8_OS_LINUX |
(...skipping 209 matching lines...) Loading... |
249 uint32_t entry_count = 0; | 251 uint32_t entry_count = 0; |
250 for (SourcePositionTableIterator iterator(code->source_position_table()); | 252 for (SourcePositionTableIterator iterator(code->source_position_table()); |
251 !iterator.done(); iterator.Advance()) { | 253 !iterator.done(); iterator.Advance()) { |
252 entry_count++; | 254 entry_count++; |
253 } | 255 } |
254 if (entry_count == 0) return; | 256 if (entry_count == 0) return; |
255 Handle<Script> script(Script::cast(shared->script())); | 257 Handle<Script> script(Script::cast(shared->script())); |
256 Handle<Object> name_or_url(Script::GetNameOrSourceURL(script)); | 258 Handle<Object> name_or_url(Script::GetNameOrSourceURL(script)); |
257 | 259 |
258 int name_length = 0; | 260 int name_length = 0; |
259 base::SmartArrayPointer<char> name_string; | 261 std::unique_ptr<char[]> name_string; |
260 if (name_or_url->IsString()) { | 262 if (name_or_url->IsString()) { |
261 name_string = | 263 name_string = |
262 Handle<String>::cast(name_or_url) | 264 Handle<String>::cast(name_or_url) |
263 ->ToCString(DISALLOW_NULLS, FAST_STRING_TRAVERSAL, &name_length); | 265 ->ToCString(DISALLOW_NULLS, FAST_STRING_TRAVERSAL, &name_length); |
264 DCHECK_EQ(0, name_string.get()[name_length]); | 266 DCHECK_EQ(0, name_string.get()[name_length]); |
265 } else { | 267 } else { |
266 const char unknown[] = "<unknown>"; | 268 const char unknown[] = "<unknown>"; |
267 name_length = static_cast<int>(strlen(unknown)); | 269 name_length = static_cast<int>(strlen(unknown)); |
268 char* buffer = NewArray<char>(name_length); | 270 char* buffer = NewArray<char>(name_length); |
269 base::OS::StrNCpy(buffer, name_length + 1, unknown, | 271 base::OS::StrNCpy(buffer, name_length + 1, unknown, |
270 static_cast<size_t>(name_length)); | 272 static_cast<size_t>(name_length)); |
271 name_string = base::SmartArrayPointer<char>(buffer); | 273 name_string = std::unique_ptr<char[]>(buffer); |
272 } | 274 } |
273 DCHECK_EQ(name_length, strlen(name_string.get())); | 275 DCHECK_EQ(name_length, strlen(name_string.get())); |
274 | 276 |
275 PerfJitCodeDebugInfo debug_info; | 277 PerfJitCodeDebugInfo debug_info; |
276 | 278 |
277 debug_info.event_ = PerfJitCodeLoad::kDebugInfo; | 279 debug_info.event_ = PerfJitCodeLoad::kDebugInfo; |
278 debug_info.time_stamp_ = GetTimestamp(); | 280 debug_info.time_stamp_ = GetTimestamp(); |
279 debug_info.address_ = reinterpret_cast<uint64_t>(code->instruction_start()); | 281 debug_info.address_ = reinterpret_cast<uint64_t>(code->instruction_start()); |
280 debug_info.entry_count_ = entry_count; | 282 debug_info.entry_count_ = entry_count; |
281 | 283 |
(...skipping 100 matching lines...) Loading... |
382 header.time_stamp_ = | 384 header.time_stamp_ = |
383 static_cast<uint64_t>(base::OS::TimeCurrentMillis() * 1000.0); | 385 static_cast<uint64_t>(base::OS::TimeCurrentMillis() * 1000.0); |
384 header.flags_ = 0; | 386 header.flags_ = 0; |
385 | 387 |
386 LogWriteBytes(reinterpret_cast<const char*>(&header), sizeof(header)); | 388 LogWriteBytes(reinterpret_cast<const char*>(&header), sizeof(header)); |
387 } | 389 } |
388 | 390 |
389 #endif // V8_OS_LINUX | 391 #endif // V8_OS_LINUX |
390 } // namespace internal | 392 } // namespace internal |
391 } // namespace v8 | 393 } // namespace v8 |
OLD | NEW |