ShapeList.h (1779B)
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- 2 * vim: set ts=8 sts=2 et sw=2 tw=80: 3 * This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #ifndef jit_ShapeList_h 8 #define jit_ShapeList_h 9 10 #include <stddef.h> 11 #include <stdint.h> 12 13 #include "jstypes.h" 14 15 #include "js/Class.h" 16 #include "vm/List.h" 17 18 namespace js::jit { 19 20 // Special object used for storing a list of shapes to guard against. These are 21 // only used in the fields of CacheIR stubs and do not escape. 22 class ShapeListObject : public ListObject { 23 public: 24 static const JSClass class_; 25 static const JSClassOps classOps_; 26 27 static constexpr size_t MaxLength = 16; 28 29 static ShapeListObject* create(JSContext* cx); 30 static void trace(JSTracer* trc, JSObject* obj); 31 32 Shape* get(uint32_t index) const; 33 Shape* getUnbarriered(uint32_t index) const; 34 35 bool traceWeak(JSTracer* trc); 36 }; 37 38 // Similar to ShapeListObject. But here we keep a list of the shape and the 39 // corresponding offset of a particular access (e.g. obj.a). 40 // The values are saved as: [shape1, offset1, shape2, offset2 ...]. 41 class ShapeListWithOffsetsObject : public ListObject { 42 public: 43 static const JSClass class_; 44 static const JSClassOps classOps_; 45 46 static constexpr size_t MaxLength = 16; 47 48 static ShapeListWithOffsetsObject* create(JSContext* cx); 49 static void trace(JSTracer* trc, JSObject* obj); 50 51 uint32_t numShapes() const; 52 Shape* getShape(uint32_t index) const; 53 Shape* getShapeUnbarriered(uint32_t index) const; 54 55 uint32_t getOffset(uint32_t index) const; 56 57 bool traceWeak(JSTracer* trc); 58 }; 59 60 } // namespace js::jit 61 62 #endif // jit_ShapeList_h