2012-10-26 22:17:24 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
|
|
|
*/
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef js_heap_api_h___
|
|
|
|
#define js_heap_api_h___
|
|
|
|
|
2012-10-26 22:18:50 +04:00
|
|
|
/* These values are private to the JS engine. */
|
2012-10-26 22:17:24 +04:00
|
|
|
namespace js {
|
2012-10-26 22:18:50 +04:00
|
|
|
namespace gc {
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Page size must be static to support our arena pointer optimizations, so we
|
|
|
|
* are forced to support each platform with non-4096 pages as a special case.
|
|
|
|
* Note: The freelist supports a maximum arena shift of 15.
|
|
|
|
* Note: Do not use JS_CPU_SPARC here, this header is used outside JS.
|
|
|
|
*/
|
|
|
|
#if (defined(SOLARIS) || defined(__FreeBSD__)) && \
|
|
|
|
(defined(__sparc) || defined(__sparcv9) || defined(__ia64))
|
|
|
|
const size_t PageShift = 13;
|
|
|
|
const size_t ArenaShift = PageShift;
|
|
|
|
#elif defined(__powerpc__)
|
|
|
|
const size_t PageShift = 16;
|
|
|
|
const size_t ArenaShift = 12;
|
|
|
|
#else
|
|
|
|
const size_t PageShift = 12;
|
|
|
|
const size_t ArenaShift = PageShift;
|
|
|
|
#endif
|
|
|
|
const size_t PageSize = size_t(1) << PageShift;
|
|
|
|
const size_t ArenaSize = size_t(1) << ArenaShift;
|
|
|
|
const size_t ArenaMask = ArenaSize - 1;
|
|
|
|
|
|
|
|
const size_t ChunkShift = 20;
|
|
|
|
const size_t ChunkSize = size_t(1) << ChunkShift;
|
|
|
|
const size_t ChunkMask = ChunkSize - 1;
|
|
|
|
|
|
|
|
} /* namespace gc */
|
|
|
|
} /* namespace js */
|
|
|
|
|
|
|
|
namespace JS {
|
|
|
|
|
|
|
|
namespace shadow {
|
|
|
|
|
|
|
|
struct ArenaHeader
|
|
|
|
{
|
|
|
|
JSCompartment *compartment;
|
|
|
|
};
|
|
|
|
|
|
|
|
} /* namespace shadow */
|
|
|
|
|
|
|
|
static inline shadow::ArenaHeader *
|
|
|
|
GetGCThingArena(void *thing)
|
|
|
|
{
|
|
|
|
uintptr_t addr = uintptr_t(thing);
|
|
|
|
addr &= ~js::gc::ArenaMask;
|
|
|
|
return reinterpret_cast<shadow::ArenaHeader *>(addr);
|
|
|
|
}
|
2012-10-26 22:17:24 +04:00
|
|
|
|
|
|
|
static inline JSCompartment *
|
|
|
|
GetGCThingCompartment(void *thing)
|
|
|
|
{
|
|
|
|
JS_ASSERT(thing);
|
2012-10-26 22:18:50 +04:00
|
|
|
return GetGCThingArena(thing)->compartment;
|
2012-10-26 22:17:24 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline JSCompartment *
|
|
|
|
GetObjectCompartment(JSObject *obj)
|
|
|
|
{
|
|
|
|
return GetGCThingCompartment(obj);
|
|
|
|
}
|
|
|
|
|
2012-10-26 22:18:50 +04:00
|
|
|
} /* namespace JS */
|
2012-10-26 22:17:24 +04:00
|
|
|
|
|
|
|
#endif /* js_heap_api_h___ */
|