aboutsummaryrefslogtreecommitdiff
path: root/deps/v8/src/api.cc
diff options
context:
space:
mode:
authorMatheus Marchini <matheus@sthima.com>2018-06-04 09:33:17 -0700
committerMatheus Marchini <matheus@sthima.com>2018-06-22 09:42:46 -0700
commitb3627560a94eaf51262cc041aebc9ef150b5fcbc (patch)
tree6f8cdb5e15f0bc7e686b018f952b21556cc6b91b /deps/v8/src/api.cc
parent8689c785379293adc04ec2a3d47ed08a580fe521 (diff)
downloadandroid-node-v8-b3627560a94eaf51262cc041aebc9ef150b5fcbc.tar.gz
android-node-v8-b3627560a94eaf51262cc041aebc9ef150b5fcbc.tar.bz2
android-node-v8-b3627560a94eaf51262cc041aebc9ef150b5fcbc.zip
deps: backport aa6ce3e from upstream V8
Original commit message: [log][api] introduce public CodeEventListener API Introduce a new public API called CodeEventListener to allow embedders to better support external profilers and other diagnostic tools without relying on unsupported methods like --perf-basic-prof. Bug: v8:7694 Cq-Include-Trybots: luci.chromium.try:linux_chromium_rel_ng Change-Id: I063cc965394d59401358757634c9ea84c11517e9 Co-authored-by: Daniel Beckert <daniel@sthima.com.br> Reviewed-on: https://chromium-review.googlesource.com/1028770 Commit-Queue: Yang Guo <yangguo@chromium.org> Reviewed-by: Hannes Payer <hpayer@chromium.org> Reviewed-by: Yang Guo <yangguo@chromium.org> Reviewed-by: Andreas Haas <ahaas@chromium.org> Cr-Commit-Position: refs/heads/master@{#53382} Refs: https://github.com/v8/v8/commit/aa6ce3ee617b2f324bea3a5d8e3263aee PR-URL: https://github.com/nodejs/node/pull/21126 Reviewed-By: Michaƫl Zasso <targos@protonmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'deps/v8/src/api.cc')
-rw-r--r--deps/v8/src/api.cc64
1 files changed, 64 insertions, 0 deletions
diff --git a/deps/v8/src/api.cc b/deps/v8/src/api.cc
index e9a5ec69ec..d101bc419a 100644
--- a/deps/v8/src/api.cc
+++ b/deps/v8/src/api.cc
@@ -10211,6 +10211,70 @@ void CpuProfiler::SetIdle(bool is_idle) {
isolate->SetIdle(is_idle);
}
+uintptr_t CodeEvent::GetCodeStartAddress() {
+ return reinterpret_cast<i::CodeEvent*>(this)->code_start_address;
+}
+
+size_t CodeEvent::GetCodeSize() {
+ return reinterpret_cast<i::CodeEvent*>(this)->code_size;
+}
+
+Local<String> CodeEvent::GetFunctionName() {
+ return ToApiHandle<String>(
+ reinterpret_cast<i::CodeEvent*>(this)->function_name);
+}
+
+Local<String> CodeEvent::GetScriptName() {
+ return ToApiHandle<String>(
+ reinterpret_cast<i::CodeEvent*>(this)->script_name);
+}
+
+int CodeEvent::GetScriptLine() {
+ return reinterpret_cast<i::CodeEvent*>(this)->script_line;
+}
+
+int CodeEvent::GetScriptColumn() {
+ return reinterpret_cast<i::CodeEvent*>(this)->script_column;
+}
+
+CodeEventType CodeEvent::GetCodeType() {
+ return reinterpret_cast<i::CodeEvent*>(this)->code_type;
+}
+
+const char* CodeEvent::GetComment() {
+ return reinterpret_cast<i::CodeEvent*>(this)->comment;
+}
+
+const char* CodeEvent::GetCodeEventTypeName(CodeEventType code_event_type) {
+ switch (code_event_type) {
+ case kUnknownType:
+ return "Unknown";
+#define V(Name) \
+ case k##Name##Type: \
+ return #Name;
+ CODE_EVENTS_LIST(V)
+#undef V
+ }
+}
+
+CodeEventHandler::CodeEventHandler(Isolate* isolate) {
+ internal_listener_ =
+ new i::ExternalCodeEventListener(reinterpret_cast<i::Isolate*>(isolate));
+}
+
+CodeEventHandler::~CodeEventHandler() {
+ delete reinterpret_cast<i::ExternalCodeEventListener*>(internal_listener_);
+}
+
+void CodeEventHandler::Enable() {
+ reinterpret_cast<i::ExternalCodeEventListener*>(internal_listener_)
+ ->StartListening(this);
+}
+
+void CodeEventHandler::Disable() {
+ reinterpret_cast<i::ExternalCodeEventListener*>(internal_listener_)
+ ->StopListening();
+}
static i::HeapGraphEdge* ToInternal(const HeapGraphEdge* edge) {
return const_cast<i::HeapGraphEdge*>(