From c0c1d760283a52918ac0cbf5237e010930ffb734 Mon Sep 17 00:00:00 2001 From: kozyatinskiy Date: Sat, 8 Apr 2017 15:26:22 -0700 Subject: [PATCH] [inspector] introduced StackFrame::IsWasm flag We don't need to do any kind of translation for non-wasm frames. And we need this knowledge for lazy symbolization. Capturing stack trace is ~7% faster. BUG=v8:6189 R=dgozman@chromium.org,yangguo@chromium.org Review-Url: https://codereview.chromium.org/2795103004 Cr-Commit-Position: refs/heads/master@{#44502} --- include/v8.h | 5 +++++ src/api.cc | 1 + src/inspector/v8-stack-trace-impl.cc | 6 ++++-- src/isolate.cc | 2 ++ src/objects-inl.h | 1 + src/objects.h | 2 ++ 6 files changed, 15 insertions(+), 2 deletions(-) diff --git a/include/v8.h b/include/v8.h index 43274d360b..ae84f389ab 100644 --- a/include/v8.h +++ b/include/v8.h @@ -1646,6 +1646,11 @@ class V8_EXPORT StackFrame { * constructor via "new". */ bool IsConstructor() const; + + /** + * Returns whether or not the associated functions is defined in wasm. + */ + bool IsWasm() const; }; diff --git a/src/api.cc b/src/api.cc index 5c27b69135..a0990efd76 100644 --- a/src/api.cc +++ b/src/api.cc @@ -2930,6 +2930,7 @@ bool StackFrame::IsConstructor() const { return Utils::OpenHandle(this)->is_constructor(); } +bool StackFrame::IsWasm() const { return Utils::OpenHandle(this)->is_wasm(); } // --- N a t i v e W e a k M a p --- diff --git a/src/inspector/v8-stack-trace-impl.cc b/src/inspector/v8-stack-trace-impl.cc index ccf0fd9765..dddad36202 100644 --- a/src/inspector/v8-stack-trace-impl.cc +++ b/src/inspector/v8-stack-trace-impl.cc @@ -40,8 +40,10 @@ V8StackTraceImpl::Frame toFrame(v8::Local frame, int sourceColumn = frame->GetColumn() - 1; // TODO(clemensh): Figure out a way to do this translation only right before // sending the stack trace over wire. - wasmTranslation->TranslateWasmScriptLocationToProtocolLocation( - &scriptId, &sourceLineNumber, &sourceColumn); + if (frame->IsWasm()) { + wasmTranslation->TranslateWasmScriptLocationToProtocolLocation( + &scriptId, &sourceLineNumber, &sourceColumn); + } return V8StackTraceImpl::Frame(functionName, scriptId, sourceName, sourceLineNumber + 1, sourceColumn + 1); } diff --git a/src/isolate.cc b/src/isolate.cc index c2674baa18..82ea67a0a9 100644 --- a/src/isolate.cc +++ b/src/isolate.cc @@ -679,6 +679,7 @@ class CaptureStackTraceHelper { if (options_ & StackTrace::kIsConstructor) { frame->set_is_constructor(summ.is_constructor()); } + frame->set_is_wasm(false); return frame; } @@ -707,6 +708,7 @@ class CaptureStackTraceHelper { if (options_ & StackTrace::kScriptId) { info->set_script_id(summ.script()->id()); } + info->set_is_wasm(true); return info; } diff --git a/src/objects-inl.h b/src/objects-inl.h index 7339693815..04e0511a57 100644 --- a/src/objects-inl.h +++ b/src/objects-inl.h @@ -5819,6 +5819,7 @@ ACCESSORS(StackFrameInfo, function_name, Object, kFunctionNameIndex) SMI_ACCESSORS(StackFrameInfo, flag, kFlagIndex) BOOL_ACCESSORS(StackFrameInfo, flag, is_eval, kIsEvalBit) BOOL_ACCESSORS(StackFrameInfo, flag, is_constructor, kIsConstructorBit) +BOOL_ACCESSORS(StackFrameInfo, flag, is_wasm, kIsWasmBit) ACCESSORS(SharedFunctionInfo, name, Object, kNameOffset) ACCESSORS(SharedFunctionInfo, optimized_code_map, FixedArray, diff --git a/src/objects.h b/src/objects.h index b69c620c46..d5461a7fd4 100644 --- a/src/objects.h +++ b/src/objects.h @@ -10112,6 +10112,7 @@ class StackFrameInfo : public Struct { DECL_ACCESSORS(function_name, Object) DECL_BOOLEAN_ACCESSORS(is_eval) DECL_BOOLEAN_ACCESSORS(is_constructor) + DECL_BOOLEAN_ACCESSORS(is_wasm) DECL_INT_ACCESSORS(flag) DECLARE_CAST(StackFrameInfo) @@ -10135,6 +10136,7 @@ class StackFrameInfo : public Struct { // Bit position in the flag, from least significant bit position. static const int kIsEvalBit = 0; static const int kIsConstructorBit = 1; + static const int kIsWasmBit = 2; DISALLOW_IMPLICIT_CONSTRUCTORS(StackFrameInfo); };