Chromium Code Reviews| Index: tracing/tracing/extras/importer/trace_code_entry.html |
| diff --git a/tracing/tracing/extras/importer/trace_code_entry.html b/tracing/tracing/extras/importer/trace_code_entry.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..1a989580a1aa721c48277f230c271c8787016898 |
| --- /dev/null |
| +++ b/tracing/tracing/extras/importer/trace_code_entry.html |
| @@ -0,0 +1,72 @@ |
| +<!DOCTYPE html> |
| +<!-- |
| +Copyright 2015 The Chromium Authors. All rights reserved. |
| +Use of this source code is governed by a BSD-style license that can be |
| +found in the LICENSE file. |
| +--> |
| + |
| +<link rel="import" href="/tracing/extras/importer/v8/codemap.html"> |
| +<link rel="import" href="/tracing/model/source_info/js_source_info.html"> |
| + |
| +<script> |
| +'use strict'; |
| + |
| +/** |
| + * @fileoverview TraceCodeEntry is a wrapper around the V8 CodeEntry to extract |
|
petrcermak
2015/08/12 10:53:24
nit: s/to extract/which extracts/ ?
dsinclair
2015/08/13 14:55:32
I think to was also correct, but changed to that f
|
| + * extra context information for each item. This includes things like the |
| + * source file, line and if the function is a native method or not. |
| + */ |
| +tr.exportTo('tr.e.importer', function() { |
| + function TraceCodeEntry(size, name, script_id) { |
|
petrcermak
2015/08/12 10:53:24
It seems that we generally use camel case for func
dsinclair
2015/08/13 14:55:32
Done.
|
| + var method_name = undefined; |
| + var script = undefined; |
| + var line_num = -1; |
| + var is_native = false; |
| + |
| + if (name.startsWith('LazyCompile:')) { |
| + var clean_name = name.replace(/LazyCompile:~?/, ''); |
| + var idx = clean_name.lastIndexOf(' '); |
| + if (idx < 0) { |
| + method_name = clean_name; |
| + } else { |
| + method_name = clean_name.substring(0, idx); |
| + script = clean_name.substring(idx + 1); |
| + |
| + var matches = script.match(/(.*):(\d+)$/); |
| + if (matches !== null) { |
| + script = matches[1]; |
| + line_num = parseInt(matches[2]); |
| + } |
| + } |
| + |
| + if (method_name.endsWith(' native')) { |
| + is_native = true; |
| + method_name = method_name.replace(/\s+native\s*$/, ''); |
|
petrcermak
2015/08/12 10:53:24
nit: No need for '\s*' in the regex as you check t
dsinclair
2015/08/13 14:55:32
Done.
|
| + } |
| + |
| + if (method_name === '') |
| + method_name = 'unknown'; |
| + } else { |
| + method_name = name; |
| + } |
| + |
| + tr.e.importer.v8.CodeMap.CodeEntry.call(this, size, method_name); |
| + |
| + this.sourceInfo_ = new tr.model.source_info.JSSourceInfo( |
| + script, line_num, is_native, script_id); |
| + }; |
| + |
| + TraceCodeEntry.prototype = { |
| + __proto__: tr.e.importer.v8.CodeMap.CodeEntry.prototype, |
| + |
| + get sourceInfo() { |
| + return this.sourceInfo_; |
| + } |
| + }; |
| + |
| + return { |
| + TraceCodeEntry: TraceCodeEntry |
| + }; |
| +}); |
| +</script> |
| + |