1 // Copyright 2017 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef V8_OBJECTS_FRAME_ARRAY_INL_H_
6 #define V8_OBJECTS_FRAME_ARRAY_INL_H_
7 
8 #include "src/objects/frame-array.h"
9 #include "src/wasm/wasm-objects-inl.h"
10 
11 // Has to be the last include (doesn't have include guards):
12 #include "src/objects/object-macros.h"
13 
14 namespace v8 {
15 namespace internal {
16 
17 CAST_ACCESSOR(FrameArray)
18 
19 #define DEFINE_FRAME_ARRAY_ACCESSORS(name, type)                              \
20   type* FrameArray::name(int frame_ix) const {                                \
21     Object* obj =                                                             \
22         get(kFirstIndex + frame_ix * kElementsPerFrame + k##name##Offset);    \
23     return type::cast(obj);                                                   \
24   }                                                                           \
25                                                                               \
26   void FrameArray::Set##name(int frame_ix, type* value) {                     \
27     set(kFirstIndex + frame_ix * kElementsPerFrame + k##name##Offset, value); \
28   }
FRAME_ARRAY_FIELD_LIST(DEFINE_FRAME_ARRAY_ACCESSORS)29 FRAME_ARRAY_FIELD_LIST(DEFINE_FRAME_ARRAY_ACCESSORS)
30 #undef DEFINE_FRAME_ARRAY_ACCESSORS
31 
32 bool FrameArray::IsWasmFrame(int frame_ix) const {
33   const int flags = Flags(frame_ix)->value();
34   return (flags & kIsWasmFrame) != 0;
35 }
36 
IsWasmInterpretedFrame(int frame_ix)37 bool FrameArray::IsWasmInterpretedFrame(int frame_ix) const {
38   const int flags = Flags(frame_ix)->value();
39   return (flags & kIsWasmInterpretedFrame) != 0;
40 }
41 
IsAsmJsWasmFrame(int frame_ix)42 bool FrameArray::IsAsmJsWasmFrame(int frame_ix) const {
43   const int flags = Flags(frame_ix)->value();
44   return (flags & kIsAsmJsWasmFrame) != 0;
45 }
46 
FrameCount()47 int FrameArray::FrameCount() const {
48   const int frame_count = Smi::ToInt(get(kFrameCountIndex));
49   DCHECK_LE(0, frame_count);
50   return frame_count;
51 }
52 
53 }  // namespace internal
54 }  // namespace v8
55 
56 #include "src/objects/object-macros-undef.h"
57 
58 #endif  // V8_OBJECTS_FRAME_ARRAY_INL_H_
59