Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(193)

Side by Side Diff: src/inspector/v8-heap-profiler-agent-impl.cc

Issue 2558913004: [inspector] Store interger in context embedder data instead of a string. (Closed)
Patch Set: review comments Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/inspector/v8-function-call.cc ('k') | src/inspector/v8-inspector-impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/inspector/v8-heap-profiler-agent-impl.h" 5 #include "src/inspector/v8-heap-profiler-agent-impl.h"
6 6
7 #include "src/inspector/injected-script.h" 7 #include "src/inspector/injected-script.h"
8 #include "src/inspector/inspected-context.h"
8 #include "src/inspector/protocol/Protocol.h" 9 #include "src/inspector/protocol/Protocol.h"
9 #include "src/inspector/string-util.h" 10 #include "src/inspector/string-util.h"
10 #include "src/inspector/v8-debugger.h" 11 #include "src/inspector/v8-debugger.h"
11 #include "src/inspector/v8-inspector-impl.h" 12 #include "src/inspector/v8-inspector-impl.h"
12 #include "src/inspector/v8-inspector-session-impl.h" 13 #include "src/inspector/v8-inspector-session-impl.h"
13 14
14 #include "include/v8-inspector.h" 15 #include "include/v8-inspector.h"
15 #include "include/v8-profiler.h" 16 #include "include/v8-profiler.h"
16 #include "include/v8-version.h" 17 #include "include/v8-version.h"
17 18
(...skipping 30 matching lines...) Expand all
48 49
49 class GlobalObjectNameResolver final 50 class GlobalObjectNameResolver final
50 : public v8::HeapProfiler::ObjectNameResolver { 51 : public v8::HeapProfiler::ObjectNameResolver {
51 public: 52 public:
52 explicit GlobalObjectNameResolver(V8InspectorSessionImpl* session) 53 explicit GlobalObjectNameResolver(V8InspectorSessionImpl* session)
53 : m_offset(0), m_strings(10000), m_session(session) {} 54 : m_offset(0), m_strings(10000), m_session(session) {}
54 55
55 const char* GetName(v8::Local<v8::Object> object) override { 56 const char* GetName(v8::Local<v8::Object> object) override {
56 InspectedContext* context = m_session->inspector()->getContext( 57 InspectedContext* context = m_session->inspector()->getContext(
57 m_session->contextGroupId(), 58 m_session->contextGroupId(),
58 V8Debugger::contextId(object->CreationContext())); 59 InspectedContext::contextId(object->CreationContext()));
59 if (!context) return ""; 60 if (!context) return "";
60 String16 name = context->origin(); 61 String16 name = context->origin();
61 size_t length = name.length(); 62 size_t length = name.length();
62 if (m_offset + length + 1 >= m_strings.size()) return ""; 63 if (m_offset + length + 1 >= m_strings.size()) return "";
63 for (size_t i = 0; i < length; ++i) { 64 for (size_t i = 0; i < length; ++i) {
64 UChar ch = name[i]; 65 UChar ch = name[i];
65 m_strings[m_offset + i] = ch > 0xff ? '?' : static_cast<char>(ch); 66 m_strings[m_offset + i] = ch > 0xff ? '?' : static_cast<char>(ch);
66 } 67 }
67 m_strings[m_offset + length] = '\0'; 68 m_strings[m_offset + length] = '\0';
68 char* result = &*m_strings.begin() + m_offset; 69 char* result = &*m_strings.begin() + m_offset;
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 if (!v8Profile) 375 if (!v8Profile)
375 return Response::Error("Cannot access v8 sampled heap profile."); 376 return Response::Error("Cannot access v8 sampled heap profile.");
376 v8::AllocationProfile::Node* root = v8Profile->GetRootNode(); 377 v8::AllocationProfile::Node* root = v8Profile->GetRootNode();
377 *profile = protocol::HeapProfiler::SamplingHeapProfile::create() 378 *profile = protocol::HeapProfiler::SamplingHeapProfile::create()
378 .setHead(buildSampingHeapProfileNode(root)) 379 .setHead(buildSampingHeapProfileNode(root))
379 .build(); 380 .build();
380 return Response::OK(); 381 return Response::OK();
381 } 382 }
382 383
383 } // namespace v8_inspector 384 } // namespace v8_inspector
OLDNEW
« no previous file with comments | « src/inspector/v8-function-call.cc ('k') | src/inspector/v8-inspector-impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698