@@ -17,47 +17,52 @@ namespace js {
1717
1818struct Class ;
1919
20- // Allocate a new GC thing. After a successful allocation the caller must
21- // fully initialize the thing before calling any function that can potentially
22- // trigger GC. This will ensure that GC tracing never sees junk values stored
23- // in the partially initialized thing.
24-
20+ // Allocate a new GC thing that's not a JSObject or a string.
21+ //
22+ // After a successful allocation the caller must fully initialize the thing
23+ // before calling any function that can potentially trigger GC. This will ensure
24+ // that GC tracing never sees junk values stored in the partially initialized
25+ // thing.
2526template <typename T, AllowGC allowGC = CanGC>
2627T* Allocate (JSContext* cx);
2728
28- // Use for JSObject. A longer signature that includes additional information in
29- // support of various optimizations. If dynamic slots are requested they will be
30- // allocated and the pointer stored directly in |NativeObject::slots_|.
31- template <typename , AllowGC allowGC = CanGC>
32- JSObject* Allocate (JSContext* cx, gc::AllocKind kind, size_t nDynamicSlots,
33- gc::InitialHeap heap, const Class* clasp);
29+ // Allocate a JSObject.
30+ //
31+ // A longer signature that includes additional information in support of various
32+ // optimizations. If dynamic slots are requested they will be allocated and the
33+ // pointer stored directly in |NativeObject::slots_|.
34+ template <AllowGC allowGC = CanGC>
35+ JSObject* AllocateObject (JSContext* cx, gc::AllocKind kind, size_t nDynamicSlots,
36+ gc::InitialHeap heap, const Class* clasp);
3437
3538// Internal function used for nursery-allocatable strings.
3639template <typename StringAllocT, AllowGC allowGC = CanGC>
37- StringAllocT* AllocateString (JSContext* cx, gc::InitialHeap heap);
40+ StringAllocT* AllocateStringImpl (JSContext* cx, gc::InitialHeap heap);
3841
42+ // Allocate a string.
43+ //
3944// Use for nursery-allocatable strings. Returns a value cast to the correct
4045// type.
4146template <typename StringT, AllowGC allowGC = CanGC>
42- StringT* Allocate (JSContext* cx, gc::InitialHeap heap) {
43- return static_cast <StringT*>(js::AllocateString <JSString, allowGC>(cx, heap));
47+ StringT* AllocateString (JSContext* cx, gc::InitialHeap heap) {
48+ return static_cast <StringT*>(AllocateStringImpl <JSString, allowGC>(cx, heap));
4449}
4550
4651// Specialization for JSFatInlineString that must use a different allocation
4752// type. Note that we have to explicitly specialize for both values of AllowGC
4853// because partial function specialization is not allowed.
4954template <>
50- inline JSFatInlineString* Allocate <JSFatInlineString, CanGC>(
55+ inline JSFatInlineString* AllocateString <JSFatInlineString, CanGC>(
5156 JSContext* cx, gc::InitialHeap heap) {
5257 return static_cast <JSFatInlineString*>(
53- js::AllocateString <JSFatInlineString, CanGC>(cx, heap));
58+ js::AllocateStringImpl <JSFatInlineString, CanGC>(cx, heap));
5459}
5560
5661template <>
57- inline JSFatInlineString* Allocate <JSFatInlineString, NoGC>(
62+ inline JSFatInlineString* AllocateString <JSFatInlineString, NoGC>(
5863 JSContext* cx, gc::InitialHeap heap) {
5964 return static_cast <JSFatInlineString*>(
60- js::AllocateString <JSFatInlineString, NoGC>(cx, heap));
65+ js::AllocateStringImpl <JSFatInlineString, NoGC>(cx, heap));
6166}
6267
6368} // namespace js
0 commit comments