Line data Source code
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 : #include "vm/Caches-inl.h"
8 :
9 : #include "mozilla/PodOperations.h"
10 :
11 : using namespace js;
12 :
13 : using mozilla::PodZero;
14 :
15 : MathCache*
16 0 : RuntimeCaches::createMathCache(JSContext* cx)
17 : {
18 0 : MOZ_ASSERT(!mathCache_);
19 :
20 0 : UniquePtr<MathCache> newMathCache(js_new<MathCache>());
21 0 : if (!newMathCache) {
22 0 : ReportOutOfMemory(cx);
23 0 : return nullptr;
24 : }
25 :
26 0 : mathCache_ = Move(newMathCache);
27 0 : return mathCache_.get();
28 : }
29 :
30 : bool
31 4 : RuntimeCaches::init()
32 : {
33 4 : if (!evalCache.init())
34 0 : return false;
35 :
36 4 : return true;
37 : }
38 :
39 : void
40 21 : NewObjectCache::clearNurseryObjects(JSRuntime* rt)
41 : {
42 882 : for (unsigned i = 0; i < mozilla::ArrayLength(entries); ++i) {
43 861 : Entry& e = entries[i];
44 861 : NativeObject* obj = reinterpret_cast<NativeObject*>(&e.templateObject);
45 2562 : if (IsInsideNursery(e.key) ||
46 1701 : rt->gc.nursery().isInside(obj->slots_) ||
47 840 : rt->gc.nursery().isInside(obj->elements_))
48 : {
49 114 : PodZero(&e);
50 : }
51 : }
52 21 : }
|