Commit 09050c8a authored by Marja Hölttä's avatar Marja Hölttä Committed by Commit Bot

[objects.h splitting] Move out FrameArray.

BUG=v8:5402
R=mstarzinger@chromium.org

Change-Id: I4220cd1d7907f9c353265aeab38ee53dcf6f56b6
Reviewed-on: https://chromium-review.googlesource.com/459541Reviewed-by: 's avatarMichael Starzinger <mstarzinger@chromium.org>
Commit-Queue: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#44112}
parent dae6e43d
...@@ -1702,6 +1702,8 @@ v8_source_set("v8_base") { ...@@ -1702,6 +1702,8 @@ v8_source_set("v8_base") {
"src/objects.cc", "src/objects.cc",
"src/objects.h", "src/objects.h",
"src/objects/descriptor-array.h", "src/objects/descriptor-array.h",
"src/objects/frame-array-inl.h",
"src/objects/frame-array.h",
"src/objects/literal-objects.cc", "src/objects/literal-objects.cc",
"src/objects/literal-objects.h", "src/objects/literal-objects.h",
"src/objects/module-info.h", "src/objects/module-info.h",
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "src/counters.h" #include "src/counters.h"
#include "src/objects-inl.h" #include "src/objects-inl.h"
#include "src/objects/frame-array-inl.h"
#include "src/string-builder.h" #include "src/string-builder.h"
#include "src/wasm/wasm-module.h" #include "src/wasm/wasm-module.h"
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "src/conversions.h" #include "src/conversions.h"
#include "src/isolate-inl.h" #include "src/isolate-inl.h"
#include "src/macro-assembler.h" #include "src/macro-assembler.h"
#include "src/objects/frame-array-inl.h"
#include "src/objects/module-info.h" #include "src/objects/module-info.h"
#include "src/objects/scope-info.h" #include "src/objects/scope-info.h"
......
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
#include "src/libsampler/sampler.h" #include "src/libsampler/sampler.h"
#include "src/log.h" #include "src/log.h"
#include "src/messages.h" #include "src/messages.h"
#include "src/objects/frame-array-inl.h"
#include "src/profiler/cpu-profiler.h" #include "src/profiler/cpu-profiler.h"
#include "src/prototype.h" #include "src/prototype.h"
#include "src/regexp/regexp-stack.h" #include "src/regexp/regexp-stack.h"
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "src/execution.h" #include "src/execution.h"
#include "src/isolate-inl.h" #include "src/isolate-inl.h"
#include "src/keys.h" #include "src/keys.h"
#include "src/objects/frame-array-inl.h"
#include "src/string-builder.h" #include "src/string-builder.h"
#include "src/wasm/wasm-module.h" #include "src/wasm/wasm-module.h"
#include "src/wasm/wasm-objects.h" #include "src/wasm/wasm-objects.h"
......
...@@ -40,6 +40,9 @@ ...@@ -40,6 +40,9 @@
#include "src/transitions-inl.h" #include "src/transitions-inl.h"
#include "src/v8memory.h" #include "src/v8memory.h"
// Has to be the last include (doesn't have include guards):
#include "src/objects/object-macros.h"
namespace v8 { namespace v8 {
namespace internal { namespace internal {
...@@ -599,16 +602,6 @@ bool Object::IsMinusZero() const { ...@@ -599,16 +602,6 @@ bool Object::IsMinusZero() const {
// ------------------------------------ // ------------------------------------
// Cast operations // Cast operations
#define CAST_ACCESSOR(type) \
type* type::cast(Object* object) { \
SLOW_DCHECK(object->Is##type()); \
return reinterpret_cast<type*>(object); \
} \
const type* type::cast(const Object* object) { \
SLOW_DCHECK(object->Is##type()); \
return reinterpret_cast<const type*>(object); \
}
CAST_ACCESSOR(AbstractCode) CAST_ACCESSOR(AbstractCode)
CAST_ACCESSOR(ArrayList) CAST_ACCESSOR(ArrayList)
CAST_ACCESSOR(BoilerplateDescription) CAST_ACCESSOR(BoilerplateDescription)
...@@ -631,7 +624,6 @@ CAST_ACCESSOR(FixedArrayBase) ...@@ -631,7 +624,6 @@ CAST_ACCESSOR(FixedArrayBase)
CAST_ACCESSOR(FixedDoubleArray) CAST_ACCESSOR(FixedDoubleArray)
CAST_ACCESSOR(FixedTypedArrayBase) CAST_ACCESSOR(FixedTypedArrayBase)
CAST_ACCESSOR(Foreign) CAST_ACCESSOR(Foreign)
CAST_ACCESSOR(FrameArray)
CAST_ACCESSOR(GlobalDictionary) CAST_ACCESSOR(GlobalDictionary)
CAST_ACCESSOR(HandlerTable) CAST_ACCESSOR(HandlerTable)
CAST_ACCESSOR(HeapObject) CAST_ACCESSOR(HeapObject)
...@@ -2663,40 +2655,6 @@ Object** FixedArray::RawFieldOfElementAt(int index) { ...@@ -2663,40 +2655,6 @@ Object** FixedArray::RawFieldOfElementAt(int index) {
return HeapObject::RawField(this, OffsetOfElementAt(index)); return HeapObject::RawField(this, OffsetOfElementAt(index));
} }
#define DEFINE_FRAME_ARRAY_ACCESSORS(name, type) \
type* FrameArray::name(int frame_ix) const { \
Object* obj = \
get(kFirstIndex + frame_ix * kElementsPerFrame + k##name##Offset); \
return type::cast(obj); \
} \
\
void FrameArray::Set##name(int frame_ix, type* value) { \
set(kFirstIndex + frame_ix * kElementsPerFrame + k##name##Offset, value); \
}
FRAME_ARRAY_FIELD_LIST(DEFINE_FRAME_ARRAY_ACCESSORS)
#undef DEFINE_FRAME_ARRAY_ACCESSORS
bool FrameArray::IsWasmFrame(int frame_ix) const {
const int flags = Flags(frame_ix)->value();
return (flags & kIsWasmFrame) != 0;
}
bool FrameArray::IsWasmInterpretedFrame(int frame_ix) const {
const int flags = Flags(frame_ix)->value();
return (flags & kIsWasmInterpretedFrame) != 0;
}
bool FrameArray::IsAsmJsWasmFrame(int frame_ix) const {
const int flags = Flags(frame_ix)->value();
return (flags & kIsAsmJsWasmFrame) != 0;
}
int FrameArray::FrameCount() const {
const int frame_count = Smi::cast(get(kFrameCountIndex))->value();
DCHECK_LE(0, frame_count);
return frame_count;
}
bool DescriptorArray::IsEmpty() { bool DescriptorArray::IsEmpty() {
DCHECK(length() >= kFirstIndex || DCHECK(length() >= kFirstIndex ||
this == GetHeap()->empty_descriptor_array()); this == GetHeap()->empty_descriptor_array());
...@@ -8284,4 +8242,6 @@ SMI_ACCESSORS(JSStringIterator, index, kNextIndexOffset) ...@@ -8284,4 +8242,6 @@ SMI_ACCESSORS(JSStringIterator, index, kNextIndexOffset)
} // namespace internal } // namespace internal
} // namespace v8 } // namespace v8
#include "src/objects/object-macros-undef.h"
#endif // V8_OBJECTS_INL_H_ #endif // V8_OBJECTS_INL_H_
...@@ -54,6 +54,7 @@ ...@@ -54,6 +54,7 @@
#include "src/map-updater.h" #include "src/map-updater.h"
#include "src/messages.h" #include "src/messages.h"
#include "src/objects-body-descriptors-inl.h" #include "src/objects-body-descriptors-inl.h"
#include "src/objects/frame-array-inl.h"
#include "src/property-descriptor.h" #include "src/property-descriptor.h"
#include "src/prototype.h" #include "src/prototype.h"
#include "src/regexp/jsregexp.h" #include "src/regexp/jsregexp.h"
......
...@@ -2965,90 +2965,6 @@ class ArrayList : public FixedArray { ...@@ -2965,90 +2965,6 @@ class ArrayList : public FixedArray {
DISALLOW_IMPLICIT_CONSTRUCTORS(ArrayList); DISALLOW_IMPLICIT_CONSTRUCTORS(ArrayList);
}; };
#define FRAME_ARRAY_FIELD_LIST(V) \
V(WasmInstance, Object) \
V(WasmFunctionIndex, Smi) \
V(Receiver, Object) \
V(Function, JSFunction) \
V(Code, AbstractCode) \
V(Offset, Smi) \
V(Flags, Smi)
// Container object for data collected during simple stack trace captures.
class FrameArray : public FixedArray {
public:
#define DECLARE_FRAME_ARRAY_ACCESSORS(name, type) \
inline type* name(int frame_ix) const; \
inline void Set##name(int frame_ix, type* value);
FRAME_ARRAY_FIELD_LIST(DECLARE_FRAME_ARRAY_ACCESSORS)
#undef DECLARE_FRAME_ARRAY_ACCESSORS
inline bool IsWasmFrame(int frame_ix) const;
inline bool IsWasmInterpretedFrame(int frame_ix) const;
inline bool IsAsmJsWasmFrame(int frame_ix) const;
inline int FrameCount() const;
void ShrinkToFit();
// Flags.
enum Flag {
kIsWasmFrame = 1 << 0,
kIsWasmInterpretedFrame = 1 << 1,
kIsAsmJsWasmFrame = 1 << 2,
kIsStrict = 1 << 3,
kForceConstructor = 1 << 4,
kAsmJsAtNumberConversion = 1 << 5
};
static Handle<FrameArray> AppendJSFrame(Handle<FrameArray> in,
Handle<Object> receiver,
Handle<JSFunction> function,
Handle<AbstractCode> code, int offset,
int flags);
static Handle<FrameArray> AppendWasmFrame(Handle<FrameArray> in,
Handle<Object> wasm_instance,
int wasm_function_index,
Handle<AbstractCode> code,
int offset, int flags);
DECLARE_CAST(FrameArray)
private:
// The underlying fixed array embodies a captured stack trace. Frame i
// occupies indices
//
// kFirstIndex + 1 + [i * kElementsPerFrame, (i + 1) * kElementsPerFrame[,
//
// with internal offsets as below:
static const int kWasmInstanceOffset = 0;
static const int kWasmFunctionIndexOffset = 1;
static const int kReceiverOffset = 0;
static const int kFunctionOffset = 1;
static const int kCodeOffset = 2;
static const int kOffsetOffset = 3;
static const int kFlagsOffset = 4;
static const int kElementsPerFrame = 5;
// Array layout indices.
static const int kFrameCountIndex = 0;
static const int kFirstIndex = 1;
static int LengthFor(int frame_count) {
return kFirstIndex + frame_count * kElementsPerFrame;
}
static Handle<FrameArray> EnsureSpace(Handle<FrameArray> array, int length);
friend class Factory;
DISALLOW_IMPLICIT_CONSTRUCTORS(FrameArray);
};
enum SearchMode { ALL_ENTRIES, VALID_ENTRIES }; enum SearchMode { ALL_ENTRIES, VALID_ENTRIES };
template <SearchMode search_mode, typename T> template <SearchMode search_mode, typename T>
......
// Copyright 2017 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_FRAME_ARRAY_INL_H_
#define V8_OBJECTS_FRAME_ARRAY_INL_H_
#include "src/objects/frame-array.h"
// Has to be the last include (doesn't have include guards):
#include "src/objects/object-macros.h"
namespace v8 {
namespace internal {
CAST_ACCESSOR(FrameArray)
#define DEFINE_FRAME_ARRAY_ACCESSORS(name, type) \
type* FrameArray::name(int frame_ix) const { \
Object* obj = \
get(kFirstIndex + frame_ix * kElementsPerFrame + k##name##Offset); \
return type::cast(obj); \
} \
\
void FrameArray::Set##name(int frame_ix, type* value) { \
set(kFirstIndex + frame_ix * kElementsPerFrame + k##name##Offset, value); \
}
FRAME_ARRAY_FIELD_LIST(DEFINE_FRAME_ARRAY_ACCESSORS)
#undef DEFINE_FRAME_ARRAY_ACCESSORS
bool FrameArray::IsWasmFrame(int frame_ix) const {
const int flags = Flags(frame_ix)->value();
return (flags & kIsWasmFrame) != 0;
}
bool FrameArray::IsWasmInterpretedFrame(int frame_ix) const {
const int flags = Flags(frame_ix)->value();
return (flags & kIsWasmInterpretedFrame) != 0;
}
bool FrameArray::IsAsmJsWasmFrame(int frame_ix) const {
const int flags = Flags(frame_ix)->value();
return (flags & kIsAsmJsWasmFrame) != 0;
}
int FrameArray::FrameCount() const {
const int frame_count = Smi::cast(get(kFrameCountIndex))->value();
DCHECK_LE(0, frame_count);
return frame_count;
}
} // namespace internal
} // namespace v8
#include "src/objects/object-macros-undef.h"
#endif // V8_OBJECTS_FRAME_ARRAY_INL_H_
// Copyright 2017 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_FRAME_ARRAY_H_
#define V8_OBJECTS_FRAME_ARRAY_H_
#include "src/objects.h"
// Has to be the last include (doesn't have include guards):
#include "src/objects/object-macros.h"
namespace v8 {
namespace internal {
template <typename T>
class Handle;
#define FRAME_ARRAY_FIELD_LIST(V) \
V(WasmInstance, Object) \
V(WasmFunctionIndex, Smi) \
V(Receiver, Object) \
V(Function, JSFunction) \
V(Code, AbstractCode) \
V(Offset, Smi) \
V(Flags, Smi)
// Container object for data collected during simple stack trace captures.
class FrameArray : public FixedArray {
public:
#define DECLARE_FRAME_ARRAY_ACCESSORS(name, type) \
inline type* name(int frame_ix) const; \
inline void Set##name(int frame_ix, type* value);
FRAME_ARRAY_FIELD_LIST(DECLARE_FRAME_ARRAY_ACCESSORS)
#undef DECLARE_FRAME_ARRAY_ACCESSORS
inline bool IsWasmFrame(int frame_ix) const;
inline bool IsWasmInterpretedFrame(int frame_ix) const;
inline bool IsAsmJsWasmFrame(int frame_ix) const;
inline int FrameCount() const;
void ShrinkToFit();
// Flags.
enum Flag {
kIsWasmFrame = 1 << 0,
kIsWasmInterpretedFrame = 1 << 1,
kIsAsmJsWasmFrame = 1 << 2,
kIsStrict = 1 << 3,
kForceConstructor = 1 << 4,
kAsmJsAtNumberConversion = 1 << 5
};
static Handle<FrameArray> AppendJSFrame(Handle<FrameArray> in,
Handle<Object> receiver,
Handle<JSFunction> function,
Handle<AbstractCode> code, int offset,
int flags);
static Handle<FrameArray> AppendWasmFrame(Handle<FrameArray> in,
Handle<Object> wasm_instance,
int wasm_function_index,
Handle<AbstractCode> code,
int offset, int flags);
DECLARE_CAST(FrameArray)
private:
// The underlying fixed array embodies a captured stack trace. Frame i
// occupies indices
//
// kFirstIndex + 1 + [i * kElementsPerFrame, (i + 1) * kElementsPerFrame[,
//
// with internal offsets as below:
static const int kWasmInstanceOffset = 0;
static const int kWasmFunctionIndexOffset = 1;
static const int kReceiverOffset = 0;
static const int kFunctionOffset = 1;
static const int kCodeOffset = 2;
static const int kOffsetOffset = 3;
static const int kFlagsOffset = 4;
static const int kElementsPerFrame = 5;
// Array layout indices.
static const int kFrameCountIndex = 0;
static const int kFirstIndex = 1;
static int LengthFor(int frame_count) {
return kFirstIndex + frame_count * kElementsPerFrame;
}
static Handle<FrameArray> EnsureSpace(Handle<FrameArray> array, int length);
friend class Factory;
DISALLOW_IMPLICIT_CONSTRUCTORS(FrameArray);
};
} // namespace internal
} // namespace v8
#include "src/objects/object-macros-undef.h"
#endif // V8_OBJECTS_FRAME_ARRAY_H_
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#undef CAST_ACCESSOR
#undef DECL_BOOLEAN_ACCESSORS #undef DECL_BOOLEAN_ACCESSORS
#undef DECL_INT_ACCESSORS #undef DECL_INT_ACCESSORS
#undef DECL_ACCESSORS #undef DECL_ACCESSORS
......
...@@ -25,6 +25,16 @@ ...@@ -25,6 +25,16 @@
INLINE(static type* cast(Object* object)); \ INLINE(static type* cast(Object* object)); \
INLINE(static const type* cast(const Object* object)); INLINE(static const type* cast(const Object* object));
#define CAST_ACCESSOR(type) \
type* type::cast(Object* object) { \
SLOW_DCHECK(object->Is##type()); \
return reinterpret_cast<type*>(object); \
} \
const type* type::cast(const Object* object) { \
SLOW_DCHECK(object->Is##type()); \
return reinterpret_cast<const type*>(object); \
}
#ifdef VERIFY_HEAP #ifdef VERIFY_HEAP
#define DECLARE_VERIFIER(Name) void Name##Verify(); #define DECLARE_VERIFIER(Name) void Name##Verify();
#else #else
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "src/factory.h" #include "src/factory.h"
#include "src/frames-inl.h" #include "src/frames-inl.h"
#include "src/objects-inl.h" #include "src/objects-inl.h"
#include "src/objects/frame-array-inl.h"
#include "src/trap-handler/trap-handler.h" #include "src/trap-handler/trap-handler.h"
#include "src/v8memory.h" #include "src/v8memory.h"
#include "src/wasm/wasm-module.h" #include "src/wasm/wasm-module.h"
......
...@@ -1118,6 +1118,8 @@ ...@@ -1118,6 +1118,8 @@
'objects.cc', 'objects.cc',
'objects.h', 'objects.h',
'objects/descriptor-array.h', 'objects/descriptor-array.h',
'objects/frame-array.h',
'objects/frame-array-inl.h',
'objects/literal-objects.cc', 'objects/literal-objects.cc',
'objects/literal-objects.h', 'objects/literal-objects.h',
'objects/module-info.h', 'objects/module-info.h',
......
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