Commit e26aa58b authored by mstarzinger's avatar mstarzinger Committed by Commit bot

[interpreter] Add field for handler table to bytecode array.

This adds a handler table field to the header of our BytecodeArray
objects. The field will eventually hold a range-based handler table
similar to full-codegen code, to support exception handlong within
interpreted code.

R=oth@chromium.org
BUG=v8:4674
LOG=n

Review URL: https://codereview.chromium.org/1606493002

Cr-Commit-Position: refs/heads/master@{#33373}
parent 60d9733a
...@@ -3056,6 +3056,7 @@ AllocationResult Heap::AllocateBytecodeArray(int length, ...@@ -3056,6 +3056,7 @@ AllocationResult Heap::AllocateBytecodeArray(int length,
instance->set_frame_size(frame_size); instance->set_frame_size(frame_size);
instance->set_parameter_count(parameter_count); instance->set_parameter_count(parameter_count);
instance->set_constant_pool(constant_pool); instance->set_constant_pool(constant_pool);
instance->set_handler_table(empty_fixed_array());
CopyBytes(instance->GetFirstBytecodeAddress(), raw_bytecodes, length); CopyBytes(instance->GetFirstBytecodeAddress(), raw_bytecodes, length);
return result; return result;
......
...@@ -193,19 +193,21 @@ class JSArrayBuffer::BodyDescriptor final : public BodyDescriptorBase { ...@@ -193,19 +193,21 @@ class JSArrayBuffer::BodyDescriptor final : public BodyDescriptorBase {
class BytecodeArray::BodyDescriptor final : public BodyDescriptorBase { class BytecodeArray::BodyDescriptor final : public BodyDescriptorBase {
public: public:
static bool IsValidSlot(HeapObject* obj, int offset) { static bool IsValidSlot(HeapObject* obj, int offset) {
return offset == kConstantPoolOffset; return offset == kConstantPoolOffset || offset == kHandlerTableOffset;
} }
template <typename ObjectVisitor> template <typename ObjectVisitor>
static inline void IterateBody(HeapObject* obj, int object_size, static inline void IterateBody(HeapObject* obj, int object_size,
ObjectVisitor* v) { ObjectVisitor* v) {
IteratePointer(obj, kConstantPoolOffset, v); IteratePointer(obj, kConstantPoolOffset, v);
IteratePointer(obj, kHandlerTableOffset, v);
} }
template <typename StaticVisitor> template <typename StaticVisitor>
static inline void IterateBody(HeapObject* obj, int object_size) { static inline void IterateBody(HeapObject* obj, int object_size) {
Heap* heap = obj->GetHeap(); Heap* heap = obj->GetHeap();
IteratePointer<StaticVisitor>(heap, obj, kConstantPoolOffset); IteratePointer<StaticVisitor>(heap, obj, kConstantPoolOffset);
IteratePointer<StaticVisitor>(heap, obj, kHandlerTableOffset);
} }
static inline int SizeOf(Map* map, HeapObject* obj) { static inline int SizeOf(Map* map, HeapObject* obj) {
......
...@@ -4050,6 +4050,7 @@ int BytecodeArray::parameter_count() const { ...@@ -4050,6 +4050,7 @@ int BytecodeArray::parameter_count() const {
ACCESSORS(BytecodeArray, constant_pool, FixedArray, kConstantPoolOffset) ACCESSORS(BytecodeArray, constant_pool, FixedArray, kConstantPoolOffset)
ACCESSORS(BytecodeArray, handler_table, FixedArray, kHandlerTableOffset)
Address BytecodeArray::GetFirstBytecodeAddress() { Address BytecodeArray::GetFirstBytecodeAddress() {
......
...@@ -4373,6 +4373,9 @@ class BytecodeArray : public FixedArrayBase { ...@@ -4373,6 +4373,9 @@ class BytecodeArray : public FixedArrayBase {
// Accessors for the constant pool. // Accessors for the constant pool.
DECL_ACCESSORS(constant_pool, FixedArray) DECL_ACCESSORS(constant_pool, FixedArray)
// Accessors for handler table containing offsets of exception handlers.
DECL_ACCESSORS(handler_table, FixedArray)
DECLARE_CAST(BytecodeArray) DECLARE_CAST(BytecodeArray)
// Dispatched behavior. // Dispatched behavior.
...@@ -4387,7 +4390,8 @@ class BytecodeArray : public FixedArrayBase { ...@@ -4387,7 +4390,8 @@ class BytecodeArray : public FixedArrayBase {
static const int kFrameSizeOffset = FixedArrayBase::kHeaderSize; static const int kFrameSizeOffset = FixedArrayBase::kHeaderSize;
static const int kParameterSizeOffset = kFrameSizeOffset + kIntSize; static const int kParameterSizeOffset = kFrameSizeOffset + kIntSize;
static const int kConstantPoolOffset = kParameterSizeOffset + kIntSize; static const int kConstantPoolOffset = kParameterSizeOffset + kIntSize;
static const int kHeaderSize = kConstantPoolOffset + kPointerSize; static const int kHandlerTableOffset = kConstantPoolOffset + kPointerSize;
static const int kHeaderSize = kHandlerTableOffset + kPointerSize;
static const int kAlignedSize = OBJECT_POINTER_ALIGN(kHeaderSize); static const int kAlignedSize = OBJECT_POINTER_ALIGN(kHeaderSize);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment