Bug 1865597 - Add error checking when initializing parallel marking and disable on...
[gecko.git] / js / src / vm / StringObject-inl.h
blobbaa430ceeab198fe1cb0069ef1124ef9b27cd559
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/. */
7 #ifndef vm_StringObject_inl_h
8 #define vm_StringObject_inl_h
10 #include "vm/StringObject.h"
12 #include "vm/JSObject-inl.h"
13 #include "vm/Shape-inl.h"
15 namespace js {
17 /* static */ inline bool StringObject::init(JSContext* cx,
18 Handle<StringObject*> obj,
19 HandleString str) {
20 MOZ_ASSERT(obj->numFixedSlots() == 2);
22 if (!SharedShape::ensureInitialCustomShape<StringObject>(cx, obj)) {
23 return false;
26 MOZ_ASSERT(obj->lookup(cx, NameToId(cx->names().length))->slot() ==
27 LENGTH_SLOT);
29 obj->setStringThis(str);
31 return true;
34 /* static */ inline StringObject* StringObject::create(JSContext* cx,
35 HandleString str,
36 HandleObject proto,
37 NewObjectKind newKind) {
38 Rooted<StringObject*> obj(
39 cx, NewObjectWithClassProtoAndKind<StringObject>(
40 cx, proto, newKind,
41 ObjectFlags({ObjectFlag::NeedsProxyGetSetResultValidation})));
42 if (!obj) {
43 return nullptr;
45 if (!StringObject::init(cx, obj, str)) {
46 return nullptr;
48 return obj;
51 } // namespace js
53 #endif /* vm_StringObject_inl_h */