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

Unified Diff: src/inspector/v8-stack-trace-impl.h

Issue 2816043006: [inspector] avoid cloning of async call chains (Closed)
Patch Set: StackTrace -> back to V8StacktraceImpl Created 3 years, 8 months 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 side-by-side diff with in-line comments
Download patch
Index: src/inspector/v8-stack-trace-impl.h
diff --git a/src/inspector/v8-stack-trace-impl.h b/src/inspector/v8-stack-trace-impl.h
index 4721fcf9bf4a7df2904bb128207587b27a7d744d..80ed32a42ed2245d6c7d00e5fa6ee9735f76585f 100644
--- a/src/inspector/v8-stack-trace-impl.h
+++ b/src/inspector/v8-stack-trace-impl.h
@@ -5,70 +5,46 @@
#ifndef V8_INSPECTOR_V8STACKTRACEIMPL_H_
#define V8_INSPECTOR_V8STACKTRACEIMPL_H_
+#include <memory>
#include <vector>
+#include "include/v8-inspector.h"
+#include "include/v8.h"
#include "src/base/macros.h"
-#include "src/inspector/protocol/Forward.h"
#include "src/inspector/protocol/Runtime.h"
-
-#include "include/v8-inspector.h"
+#include "src/inspector/string-16.h"
namespace v8_inspector {
+class AsyncStackTrace;
class V8Debugger;
+class WasmTranslation;
-// Note: async stack trace may have empty top stack with non-empty tail to
-// indicate that current native-only state had some async story.
-// On the other hand, any non-top async stack is guaranteed to be non-empty.
-class V8StackTraceImpl final : public V8StackTrace {
+class V8StackTraceImpl : public V8StackTrace {
public:
- static const size_t maxCallStackSizeToCapture = 200;
-
- class Frame {
- public:
- Frame(const String16& functionName, const String16& scriptId,
- const String16& scriptName, int lineNumber, int column = 0);
- ~Frame() = default;
-
- const String16& functionName() const { return m_functionName; }
- const String16& scriptId() const { return m_scriptId; }
- const String16& sourceURL() const { return m_scriptName; }
- int lineNumber() const { return m_lineNumber; }
- int columnNumber() const { return m_columnNumber; }
-
- private:
- friend class V8StackTraceImpl;
- std::unique_ptr<protocol::Runtime::CallFrame> buildInspectorObject() const;
-
- String16 m_functionName;
- String16 m_scriptId;
- String16 m_scriptName;
- int m_lineNumber;
- int m_columnNumber;
- };
-
static void setCaptureStackTraceForUncaughtExceptions(v8::Isolate*,
bool capture);
- static std::unique_ptr<V8StackTraceImpl> create(
- V8Debugger*, int contextGroupId, v8::Local<v8::StackTrace>,
- size_t maxStackSize, const String16& description = String16());
- static std::unique_ptr<V8StackTraceImpl> capture(
- V8Debugger*, int contextGroupId, size_t maxStackSize,
- const String16& description = String16());
-
- // This method drops the async chain. Use cloneImpl() instead.
- std::unique_ptr<V8StackTrace> clone() override;
- std::unique_ptr<V8StackTraceImpl> cloneImpl();
- static std::unique_ptr<protocol::Runtime::StackTrace>
- buildInspectorObjectForTail(V8Debugger*);
+ static const int maxCallStackSizeToCapture = 200;
+ static std::unique_ptr<V8StackTraceImpl> create(V8Debugger*,
+ int contextGroupId,
+ v8::Local<v8::StackTrace>,
+ int maxStackSize);
+ static std::unique_ptr<V8StackTraceImpl> capture(V8Debugger*,
+ int contextGroupId,
dgozman 2017/04/17 17:49:08 Isn't contextGroupId === debugger->CurrentContextG
kozy 2017/04/17 21:34:17 Not always, I think someone can call captureStackt
dgozman 2017/04/17 23:03:15 We should fix that in a follow-up!
+ int maxStackSize);
+
+ ~V8StackTraceImpl() override;
std::unique_ptr<protocol::Runtime::StackTrace> buildInspectorObjectImpl()
const;
- ~V8StackTraceImpl() override;
// V8StackTrace implementation.
- bool isEmpty() const override { return !m_frames.size(); };
+ // This method drops the async stack trace.
+ std::unique_ptr<V8StackTrace> clone() override;
+ bool isEmpty() const override;
StringView topSourceURL() const override;
+ // 1-based.
int topLineNumber() const override;
+ // 1-based.
int topColumnNumber() const override;
StringView topScriptId() const override;
StringView topFunctionName() const override;
@@ -76,22 +52,73 @@ class V8StackTraceImpl final : public V8StackTrace {
const override;
std::unique_ptr<StringBuffer> toString() const override;
+ class Frame {
+ public:
+ explicit Frame(v8::Local<v8::StackFrame> frame);
+ ~Frame() = default;
+
+ void translate(WasmTranslation* wasmTranslation);
+
+ const String16& functionName() const;
+ const String16& scriptId() const;
+ const String16& sourceURL() const;
+ // 0-based.
+ int lineNumber() const;
+ // 0-based.
+ int columnNumber() const;
+ std::unique_ptr<protocol::Runtime::CallFrame> buildInspectorObject() const;
+
+ private:
+ String16 m_functionName;
+ String16 m_scriptId;
+ String16 m_sourceURL;
+ // 0-based.
+ int m_lineNumber;
+ int m_columnNumber;
+ };
+
private:
- V8StackTraceImpl(int contextGroupId, const String16& description,
- std::vector<Frame>& frames,
- std::unique_ptr<V8StackTraceImpl> parent,
- std::unique_ptr<V8StackTraceImpl> creation);
+ V8StackTraceImpl(const std::vector<Frame> frames, int maxAsyncDepth,
+ std::shared_ptr<AsyncStackTrace> asyncParent,
+ std::shared_ptr<AsyncStackTrace> asyncCreation);
- std::unique_ptr<protocol::Runtime::StackTrace> buildInspectorObjectImpl(
- V8StackTraceImpl* creation) const;
+ std::vector<Frame> m_frames;
+ int m_maxAsyncDepth;
+ std::weak_ptr<AsyncStackTrace> m_asyncParent;
+ std::weak_ptr<AsyncStackTrace> m_asyncCreation;
+
+ DISALLOW_COPY_AND_ASSIGN(V8StackTraceImpl);
+};
+
+class AsyncStackTrace {
+ public:
+ static std::shared_ptr<AsyncStackTrace> capture(V8Debugger*,
+ int contextGroupId,
+ const String16& description,
+ int maxStackSize);
+
+ std::unique_ptr<protocol::Runtime::StackTrace> buildInspectorObject(
+ AsyncStackTrace* asyncCreation, int maxAsyncDepth) const;
+
+ int contextGroupId() const;
+ std::weak_ptr<AsyncStackTrace> parent() const;
+ std::weak_ptr<AsyncStackTrace> creation() const;
+ bool isEmpty() const;
+
+ private:
+ AsyncStackTrace(int contextGroupId, const String16& description,
+ const std::vector<V8StackTraceImpl::Frame>& frames,
+ std::shared_ptr<AsyncStackTrace> asyncParent,
+ std::shared_ptr<AsyncStackTrace> asyncCreation);
int m_contextGroupId;
String16 m_description;
- std::vector<Frame> m_frames;
- std::unique_ptr<V8StackTraceImpl> m_parent;
- std::unique_ptr<V8StackTraceImpl> m_creation;
- DISALLOW_COPY_AND_ASSIGN(V8StackTraceImpl);
+ std::vector<V8StackTraceImpl::Frame> m_frames;
+ std::weak_ptr<AsyncStackTrace> m_asyncParent;
+ std::weak_ptr<AsyncStackTrace> m_asyncCreation;
+
+ DISALLOW_COPY_AND_ASSIGN(AsyncStackTrace);
};
} // namespace v8_inspector

Powered by Google App Engine
This is Rietveld 408576698