#pragma once
#include "JSDestructibleObject.h"
#include "StackFrame.h"
#include <wtf/Vector.h>
namespace JSC {
class Exception final : public JSCell {
public:
using Base = JSCell;
static constexpr unsigned StructureFlags = Base::StructureFlags | StructureIsImmortal;
static constexpr bool needsDestruction = true;
template<typename CellType, SubspaceAccess mode>
static IsoSubspace* subspaceFor(VM& vm)
{
return &vm.exceptionSpace;
}
enum StackCaptureAction {
CaptureStack,
DoNotCaptureStack
};
JS_EXPORT_PRIVATE static Exception* create(VM&, JSValue thrownValue, StackCaptureAction = CaptureStack);
static Structure* createStructure(VM&, JSGlobalObject*, JSValue prototype);
static void visitChildren(JSCell*, SlotVisitor&);
DECLARE_EXPORT_INFO;
static ptrdiff_t valueOffset()
{
return OBJECT_OFFSETOF(Exception, m_value);
}
JSValue value() const { return m_value.get(); }
const Vector<StackFrame>& stack() const { return m_stack; }
bool didNotifyInspectorOfThrow() const { return m_didNotifyInspectorOfThrow; }
void setDidNotifyInspectorOfThrow() { m_didNotifyInspectorOfThrow = true; }
~Exception();
private:
Exception(VM&);
void finishCreation(VM&, JSValue thrownValue, StackCaptureAction);
static void destroy(JSCell*);
WriteBarrier<Unknown> m_value;
Vector<StackFrame> m_stack;
bool m_didNotifyInspectorOfThrow { false };
friend class LLIntOffsetsExtractor;
};
}