// Copyright 2018 the V8 project authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef V8_OBJECTS_STACK_FRAME_INFO_H_ #define V8_OBJECTS_STACK_FRAME_INFO_H_ #include "src/objects/struct.h" #include "torque-generated/bit-fields-tq.h" // Has to be the last include (doesn't have include guards): #include "src/objects/object-macros.h" namespace v8 { namespace internal { class FrameArray; class WasmInstanceObject; class StackFrameInfo : public TorqueGeneratedStackFrameInfo { public: NEVER_READ_ONLY_SPACE // Wasm frames only: function_offset instead of promise_combinator_index. DECL_INT_ACCESSORS(function_offset) DECL_BOOLEAN_ACCESSORS(is_eval) DECL_BOOLEAN_ACCESSORS(is_constructor) DECL_BOOLEAN_ACCESSORS(is_wasm) DECL_BOOLEAN_ACCESSORS(is_asmjs_wasm) DECL_BOOLEAN_ACCESSORS(is_user_java_script) DECL_BOOLEAN_ACCESSORS(is_toplevel) DECL_BOOLEAN_ACCESSORS(is_async) DECL_BOOLEAN_ACCESSORS(is_promise_all) DECL_BOOLEAN_ACCESSORS(is_promise_any) // Dispatched behavior. DECL_PRINTER(StackFrameInfo) private: // Bit position in the flag, from least significant bit position. DEFINE_TORQUE_GENERATED_STACK_FRAME_INFO_FLAGS() TQ_OBJECT_CONSTRUCTORS(StackFrameInfo) }; // This class is used to lazily initialize a StackFrameInfo object from // a FrameArray plus an index. // The first time any of the Get* or Is* methods is called, a // StackFrameInfo object is allocated and all necessary information // retrieved. class StackTraceFrame : public TorqueGeneratedStackTraceFrame { public: NEVER_READ_ONLY_SPACE // Dispatched behavior. DECL_PRINTER(StackTraceFrame) static int GetLineNumber(Handle frame); static int GetOneBasedLineNumber(Handle frame); static int GetColumnNumber(Handle frame); static int GetOneBasedColumnNumber(Handle frame); static int GetScriptId(Handle frame); static int GetPromiseCombinatorIndex(Handle frame); static int GetFunctionOffset(Handle frame); static int GetWasmFunctionIndex(Handle frame); static Handle GetFileName(Handle frame); static Handle GetScriptNameOrSourceUrl(Handle frame); static Handle GetFunctionName(Handle frame); static Handle GetMethodName(Handle frame); static Handle GetTypeName(Handle frame); static Handle GetEvalOrigin(Handle frame); static Handle GetWasmModuleName(Handle frame); static Handle GetWasmInstance( Handle frame); static bool IsEval(Handle frame); static bool IsConstructor(Handle frame); static bool IsWasm(Handle frame); static bool IsAsmJsWasm(Handle frame); static bool IsUserJavaScript(Handle frame); static bool IsToplevel(Handle frame); static bool IsAsync(Handle frame); static bool IsPromiseAll(Handle frame); static bool IsPromiseAny(Handle frame); private: static Handle GetFrameInfo(Handle frame); static void InitializeFrameInfo(Handle frame); TQ_OBJECT_CONSTRUCTORS(StackTraceFrame) }; // Small helper that retrieves the FrameArray from a stack-trace // consisting of a FixedArray of StackTraceFrame objects. // This helper is only temporary until all FrameArray use-sites have // been converted to use StackTraceFrame and StackFrameInfo objects. V8_EXPORT_PRIVATE Handle GetFrameArrayFromStackTrace(Isolate* isolate, Handle stack_trace); class IncrementalStringBuilder; void SerializeStackTraceFrame(Isolate* isolate, Handle frame, IncrementalStringBuilder* builder); V8_EXPORT_PRIVATE MaybeHandle SerializeStackTraceFrame(Isolate* isolate, Handle frame); } // namespace internal } // namespace v8 #include "src/objects/object-macros-undef.h" #endif // V8_OBJECTS_STACK_FRAME_INFO_H_