Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/js/src/vm/ReceiverGuard-inl.h
Line
Count
Source (jump to first uncovered line)
1
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2
 * vim: set ts=8 sts=4 et sw=4 tw=99:
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 vm_ReceiverGuard_inl_h
8
#define vm_ReceiverGuard_inl_h
9
10
#include "vm/ReceiverGuard.h"
11
12
#include "builtin/TypedObject.h"
13
#include "vm/JSObject.h"
14
#include "vm/ShapedObject.h"
15
#include "vm/UnboxedObject.h"
16
17
namespace js {
18
19
MOZ_ALWAYS_INLINE
20
ReceiverGuard::ReceiverGuard(JSObject* obj)
21
  : group(nullptr), shape(nullptr)
22
0
{
23
0
    if (!obj->isNative()) {
24
0
        if (obj->is<UnboxedPlainObject>()) {
25
0
            group = obj->group();
26
0
            if (UnboxedExpandoObject* expando = obj->as<UnboxedPlainObject>().maybeExpando()) {
27
0
                shape = expando->lastProperty();
28
0
            }
29
0
            return;
30
0
        }
31
0
        if (obj->is<TypedObject>()) {
32
0
            group = obj->group();
33
0
            return;
34
0
        }
35
0
    }
36
0
    shape = obj->as<ShapedObject>().shape();
37
0
}
38
39
MOZ_ALWAYS_INLINE
40
ReceiverGuard::ReceiverGuard(ObjectGroup* group, Shape* shape)
41
  : group(group), shape(shape)
42
0
{
43
0
    if (group) {
44
0
        const Class* clasp = group->clasp();
45
0
        if (clasp == &UnboxedPlainObject::class_) {
46
0
            // Keep both group and shape.
47
0
        } else if (IsTypedObjectClass(clasp)) {
48
0
            this->shape = nullptr;
49
0
        } else {
50
0
            this->group = nullptr;
51
0
        }
52
0
    }
53
0
}
54
55
} // namespace js
56
57
#endif /* vm_ReceiverGuard_inl_h */