Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/js/src/jsfriendapi.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 jsfriendapi_h
8
#define jsfriendapi_h
9
10
#include "mozilla/Atomics.h"
11
#include "mozilla/Casting.h"
12
#include "mozilla/Maybe.h"
13
#include "mozilla/MemoryReporting.h"
14
#include "mozilla/UniquePtr.h"
15
16
#include "jspubtd.h"
17
18
#include "js/CallArgs.h"
19
#include "js/CallNonGenericMethod.h"
20
#include "js/CharacterEncoding.h"
21
#include "js/Class.h"
22
#include "js/ErrorReport.h"
23
#include "js/HeapAPI.h"
24
#include "js/StableStringChars.h"
25
#include "js/TypeDecls.h"
26
#include "js/Utility.h"
27
28
#ifndef JS_STACK_GROWTH_DIRECTION
29
# ifdef __hppa
30
#  define JS_STACK_GROWTH_DIRECTION (1)
31
# else
32
#  define JS_STACK_GROWTH_DIRECTION (-1)
33
# endif
34
#endif
35
36
#if JS_STACK_GROWTH_DIRECTION > 0
37
# define JS_CHECK_STACK_SIZE(limit, sp) (MOZ_LIKELY((uintptr_t)(sp) < (limit)))
38
#else
39
48
# define JS_CHECK_STACK_SIZE(limit, sp) (MOZ_LIKELY((uintptr_t)(sp) > (limit)))
40
#endif
41
42
struct JSErrorFormatString;
43
struct JSJitInfo;
44
45
namespace JS {
46
template <class T>
47
class Heap;
48
} /* namespace JS */
49
50
namespace js {
51
class JS_FRIEND_API(BaseProxyHandler);
52
class InterpreterFrame;
53
} /* namespace js */
54
55
extern JS_FRIEND_API(void)
56
JS_SetGrayGCRootsTracer(JSContext* cx, JSTraceDataOp traceOp, void* data);
57
58
extern JS_FRIEND_API(JSObject*)
59
JS_FindCompilationScope(JSContext* cx, JS::HandleObject obj);
60
61
extern JS_FRIEND_API(JSFunction*)
62
JS_GetObjectFunction(JSObject* obj);
63
64
extern JS_FRIEND_API(bool)
65
JS_SplicePrototype(JSContext* cx, JS::HandleObject obj, JS::HandleObject proto);
66
67
extern JS_FRIEND_API(JSObject*)
68
JS_NewObjectWithUniqueType(JSContext* cx, const JSClass* clasp, JS::HandleObject proto);
69
70
/**
71
 * Allocate an object in exactly the same way as JS_NewObjectWithGivenProto, but
72
 * without invoking the metadata callback on it.  This allows creation of
73
 * internal bookkeeping objects that are guaranteed to not have metadata
74
 * attached to them.
75
 */
76
extern JS_FRIEND_API(JSObject*)
77
JS_NewObjectWithoutMetadata(JSContext* cx, const JSClass* clasp, JS::Handle<JSObject*> proto);
78
79
extern JS_FRIEND_API(bool)
80
JS_NondeterministicGetWeakMapKeys(JSContext* cx, JS::HandleObject obj, JS::MutableHandleObject ret);
81
82
extern JS_FRIEND_API(bool)
83
JS_NondeterministicGetWeakSetKeys(JSContext* cx, JS::HandleObject obj, JS::MutableHandleObject ret);
84
85
// Raw JSScript* because this needs to be callable from a signal handler.
86
extern JS_FRIEND_API(unsigned)
87
JS_PCToLineNumber(JSScript* script, jsbytecode* pc, unsigned* columnp = nullptr);
88
89
/**
90
 * Determine whether the given object is backed by a DeadObjectProxy.
91
 *
92
 * Such objects hold no other objects (they have no outgoing reference edges)
93
 * and will throw if you touch them (e.g. by reading/writing a property).
94
 */
95
extern JS_FRIEND_API(bool)
96
JS_IsDeadWrapper(JSObject* obj);
97
98
/**
99
 * Creates a new dead wrapper object in the given scope. To be used when
100
 * attempting to wrap objects from scopes which are already dead.
101
 *
102
 * If origObject is passed, it must be an proxy object, and will be
103
 * used to determine the characteristics of the new dead wrapper.
104
 */
105
extern JS_FRIEND_API(JSObject*)
106
JS_NewDeadWrapper(JSContext* cx, JSObject* origObject = nullptr);
107
108
/**
109
 * Determine whether the given object is a ScriptSourceObject.
110
 */
111
extern JS_FRIEND_API(bool)
112
JS_IsScriptSourceObject(JSObject* obj);
113
114
/*
115
 * Used by the cycle collector to trace through a shape or object group and
116
 * all cycle-participating data it reaches, using bounded stack space.
117
 */
118
extern JS_FRIEND_API(void)
119
JS_TraceShapeCycleCollectorChildren(JS::CallbackTracer* trc, JS::GCCellPtr shape);
120
extern JS_FRIEND_API(void)
121
JS_TraceObjectGroupCycleCollectorChildren(JS::CallbackTracer* trc, JS::GCCellPtr group);
122
123
/*
124
 * Telemetry reasons passed to the accumulate telemetry callback.
125
 *
126
 * It's OK for these enum values to change as they will be mapped to a fixed
127
 * member of the mozilla::Telemetry::HistogramID enum by the callback.
128
 */
129
enum {
130
    JS_TELEMETRY_GC_REASON,
131
    JS_TELEMETRY_GC_IS_ZONE_GC,
132
    JS_TELEMETRY_GC_MS,
133
    JS_TELEMETRY_GC_BUDGET_MS,
134
    JS_TELEMETRY_GC_BUDGET_OVERRUN,
135
    JS_TELEMETRY_GC_ANIMATION_MS,
136
    JS_TELEMETRY_GC_MAX_PAUSE_MS_2,
137
    JS_TELEMETRY_GC_MARK_MS,
138
    JS_TELEMETRY_GC_SWEEP_MS,
139
    JS_TELEMETRY_GC_COMPACT_MS,
140
    JS_TELEMETRY_GC_MARK_ROOTS_MS,
141
    JS_TELEMETRY_GC_MARK_GRAY_MS,
142
    JS_TELEMETRY_GC_SLICE_MS,
143
    JS_TELEMETRY_GC_SLOW_PHASE,
144
    JS_TELEMETRY_GC_SLOW_TASK,
145
    JS_TELEMETRY_GC_MMU_50,
146
    JS_TELEMETRY_GC_RESET,
147
    JS_TELEMETRY_GC_RESET_REASON,
148
    JS_TELEMETRY_GC_INCREMENTAL_DISABLED,
149
    JS_TELEMETRY_GC_NON_INCREMENTAL,
150
    JS_TELEMETRY_GC_NON_INCREMENTAL_REASON,
151
    JS_TELEMETRY_GC_SCC_SWEEP_TOTAL_MS,
152
    JS_TELEMETRY_GC_SCC_SWEEP_MAX_PAUSE_MS,
153
    JS_TELEMETRY_GC_MINOR_REASON,
154
    JS_TELEMETRY_GC_MINOR_REASON_LONG,
155
    JS_TELEMETRY_GC_MINOR_US,
156
    JS_TELEMETRY_GC_NURSERY_BYTES,
157
    JS_TELEMETRY_GC_PRETENURE_COUNT,
158
    JS_TELEMETRY_PRIVILEGED_PARSER_COMPILE_LAZY_AFTER_MS,
159
    JS_TELEMETRY_WEB_PARSER_COMPILE_LAZY_AFTER_MS,
160
    JS_TELEMETRY_END
161
};
162
163
typedef void
164
(*JSAccumulateTelemetryDataCallback)(int id, uint32_t sample, const char* key);
165
166
extern JS_FRIEND_API(void)
167
JS_SetAccumulateTelemetryCallback(JSContext* cx, JSAccumulateTelemetryDataCallback callback);
168
169
/*
170
 * Use counter names passed to the accumulate use counter callback.
171
 *
172
 * It's OK to for these enum values to change as they will be mapped to a
173
 * fixed member of the mozilla::UseCounter enum by the callback.
174
 */
175
176
enum class JSUseCounter {
177
    ASMJS,
178
    WASM
179
};
180
181
typedef void
182
(*JSSetUseCounterCallback)(JSObject* obj, JSUseCounter counter);
183
184
extern JS_FRIEND_API(void)
185
JS_SetSetUseCounterCallback(JSContext* cx, JSSetUseCounterCallback callback);
186
187
extern JS_FRIEND_API(JSPrincipals*)
188
JS_GetCompartmentPrincipals(JS::Compartment* compartment);
189
190
extern JS_FRIEND_API(JSPrincipals*)
191
JS_GetScriptPrincipals(JSScript* script);
192
193
namespace js {
194
extern JS_FRIEND_API(JS::Realm*)
195
GetScriptRealm(JSScript* script);
196
} /* namespace js */
197
198
extern JS_FRIEND_API(bool)
199
JS_ScriptHasMutedErrors(JSScript* script);
200
201
extern JS_FRIEND_API(JSObject*)
202
JS_CloneObject(JSContext* cx, JS::HandleObject obj, JS::HandleObject proto);
203
204
/**
205
 * Copy the own properties of src to dst in a fast way.  src and dst must both
206
 * be native and must be in the compartment of cx.  They must have the same
207
 * class, the same parent, and the same prototype.  Class reserved slots will
208
 * NOT be copied.
209
 *
210
 * dst must not have any properties on it before this function is called.
211
 *
212
 * src must have been allocated via JS_NewObjectWithoutMetadata so that we can
213
 * be sure it has no metadata that needs copying to dst.  This also means that
214
 * dst needs to have the compartment global as its parent.  This function will
215
 * preserve the existing metadata on dst, if any.
216
 */
217
extern JS_FRIEND_API(bool)
218
JS_InitializePropertiesFromCompatibleNativeObject(JSContext* cx,
219
                                                  JS::HandleObject dst,
220
                                                  JS::HandleObject src);
221
222
namespace js {
223
224
JS_FRIEND_API(bool)
225
GetBuiltinClass(JSContext* cx, JS::HandleObject obj, ESClass* cls);
226
227
JS_FRIEND_API(bool)
228
IsArgumentsObject(JS::HandleObject obj);
229
230
JS_FRIEND_API(const char*)
231
ObjectClassName(JSContext* cx, JS::HandleObject obj);
232
233
JS_FRIEND_API(void)
234
ReportOverRecursed(JSContext* maybecx);
235
236
JS_FRIEND_API(bool)
237
AddRawValueRoot(JSContext* cx, JS::Value* vp, const char* name);
238
239
JS_FRIEND_API(void)
240
RemoveRawValueRoot(JSContext* cx, JS::Value* vp);
241
242
JS_FRIEND_API(JSAtom*)
243
GetPropertyNameFromPC(JSScript* script, jsbytecode* pc);
244
245
#if defined(DEBUG) || defined(JS_JITSPEW)
246
247
/*
248
 * Routines to print out values during debugging. These are FRIEND_API to help
249
 * the debugger find them and to support temporarily hacking js::Dump* calls
250
 * into other code. Note that there are overloads that do not require the FILE*
251
 * parameter, which will default to stderr.
252
 */
253
254
extern JS_FRIEND_API(void)
255
DumpString(JSString* str, FILE* fp);
256
257
extern JS_FRIEND_API(void)
258
DumpAtom(JSAtom* atom, FILE* fp);
259
260
extern JS_FRIEND_API(void)
261
DumpObject(JSObject* obj, FILE* fp);
262
263
extern JS_FRIEND_API(void)
264
DumpChars(const char16_t* s, size_t n, FILE* fp);
265
266
extern JS_FRIEND_API(void)
267
DumpValue(const JS::Value& val, FILE* fp);
268
269
extern JS_FRIEND_API(void)
270
DumpId(jsid id, FILE* fp);
271
272
extern JS_FRIEND_API(void)
273
DumpInterpreterFrame(JSContext* cx, FILE* fp, InterpreterFrame* start = nullptr);
274
275
extern JS_FRIEND_API(bool)
276
DumpPC(JSContext* cx, FILE* fp);
277
278
extern JS_FRIEND_API(bool)
279
DumpScript(JSContext* cx, JSScript* scriptArg, FILE* fp);
280
281
// Versions for use directly in a debugger (default parameters are not handled
282
// well in gdb; built-in handles like stderr are not handled well in lldb.)
283
extern JS_FRIEND_API(void) DumpString(JSString* str);
284
extern JS_FRIEND_API(void) DumpAtom(JSAtom* atom);
285
extern JS_FRIEND_API(void) DumpObject(JSObject* obj);
286
extern JS_FRIEND_API(void) DumpChars(const char16_t* s, size_t n);
287
extern JS_FRIEND_API(void) DumpValue(const JS::Value& val);
288
extern JS_FRIEND_API(void) DumpId(jsid id);
289
extern JS_FRIEND_API(void) DumpInterpreterFrame(JSContext* cx, InterpreterFrame* start = nullptr);
290
extern JS_FRIEND_API(bool) DumpPC(JSContext* cx);
291
extern JS_FRIEND_API(bool) DumpScript(JSContext* cx, JSScript* scriptArg);
292
293
#endif
294
295
extern JS_FRIEND_API(void)
296
DumpBacktrace(JSContext* cx, FILE* fp);
297
298
extern JS_FRIEND_API(void)
299
DumpBacktrace(JSContext* cx);
300
301
} // namespace js
302
303
namespace JS {
304
305
/** Exposed for DumpJSStack */
306
extern JS_FRIEND_API(JS::UniqueChars)
307
FormatStackDump(JSContext* cx, bool showArgs, bool showLocals, bool showThisProps);
308
309
/**
310
 * Set all of the uninitialized lexicals on an object to undefined. Return
311
 * true if any lexicals were initialized and false otherwise.
312
 * */
313
extern JS_FRIEND_API(bool)
314
ForceLexicalInitialization(JSContext *cx, HandleObject obj);
315
316
/**
317
 * Whether we are poisoning unused/released data for error detection. Governed
318
 * by the JS_GC_POISONING #ifdef as well as the $JSGC_DISABLE_POISONING
319
 * environment variable.
320
 */
321
extern JS_FRIEND_API(int)
322
IsGCPoisoning();
323
324
extern JS_FRIEND_API(JSPrincipals*)
325
GetRealmPrincipals(JS::Realm* realm);
326
327
extern JS_FRIEND_API(void)
328
SetRealmPrincipals(JS::Realm* realm, JSPrincipals* principals);
329
330
extern JS_FRIEND_API(bool)
331
GetIsSecureContext(JS::Realm* realm);
332
333
} // namespace JS
334
335
/**
336
 * Copies all own properties from |obj| to |target|. Both |obj| and |target|
337
 * must not be cross-compartment wrappers because we have to enter their realms.
338
 *
339
 * This function immediately enters a realm, and does not impose any
340
 * restrictions on the realm of |cx|.
341
 */
342
extern JS_FRIEND_API(bool)
343
JS_CopyPropertiesFrom(JSContext* cx, JS::HandleObject target, JS::HandleObject obj);
344
345
/*
346
 * Single-property version of the above. This function asserts that an |own|
347
 * property of the given name exists on |obj|.
348
 *
349
 * On entry, |cx| must be same-compartment with |obj|. |target| must not be a
350
 * cross-compartment wrapper because we have to enter its realm.
351
 *
352
 * The copyBehavior argument controls what happens with
353
 * non-configurable properties.
354
 */
355
typedef enum  {
356
    MakeNonConfigurableIntoConfigurable,
357
    CopyNonConfigurableAsIs
358
} PropertyCopyBehavior;
359
360
extern JS_FRIEND_API(bool)
361
JS_CopyPropertyFrom(JSContext* cx, JS::HandleId id, JS::HandleObject target,
362
                    JS::HandleObject obj,
363
                    PropertyCopyBehavior copyBehavior = CopyNonConfigurableAsIs);
364
365
extern JS_FRIEND_API(bool)
366
JS_WrapPropertyDescriptor(JSContext* cx, JS::MutableHandle<JS::PropertyDescriptor> desc);
367
368
struct JSFunctionSpecWithHelp {
369
    const char*     name;
370
    JSNative        call;
371
    uint16_t        nargs;
372
    uint16_t        flags;
373
    const JSJitInfo* jitInfo;
374
    const char*     usage;
375
    const char*     help;
376
};
377
378
#define JS_FN_HELP(name,call,nargs,flags,usage,help)                          \
379
    {name, call, nargs, (flags) | JSPROP_ENUMERATE, nullptr, usage, help}
380
#define JS_INLINABLE_FN_HELP(name,call,nargs,flags,native,usage,help)         \
381
    {name, call, nargs, (flags) | JSPROP_ENUMERATE, &js::jit::JitInfo_##native,\
382
     usage, help}
383
#define JS_FS_HELP_END                                                        \
384
    {nullptr, nullptr, 0, 0, nullptr, nullptr}
385
386
extern JS_FRIEND_API(bool)
387
JS_DefineFunctionsWithHelp(JSContext* cx, JS::HandleObject obj, const JSFunctionSpecWithHelp* fs);
388
389
namespace js {
390
391
/**
392
 * A class of objects that return source code on demand.
393
 *
394
 * When code is compiled with setSourceIsLazy(true), SpiderMonkey doesn't
395
 * retain the source code (and doesn't do lazy bytecode generation). If we ever
396
 * need the source code, say, in response to a call to Function.prototype.
397
 * toSource or Debugger.Source.prototype.text, then we call the 'load' member
398
 * function of the instance of this class that has hopefully been registered
399
 * with the runtime, passing the code's URL, and hope that it will be able to
400
 * find the source.
401
 */
402
class SourceHook {
403
  public:
404
    virtual ~SourceHook() { }
405
406
    /**
407
     * Set |*src| and |*length| to refer to the source code for |filename|.
408
     * On success, the caller owns the buffer to which |*src| points, and
409
     * should use JS_free to free it.
410
     */
411
    virtual bool load(JSContext* cx, const char* filename, char16_t** src, size_t* length) = 0;
412
};
413
414
/**
415
 * Have |cx| use |hook| to retrieve lazily-retrieved source code. See the
416
 * comments for SourceHook. The context takes ownership of the hook, and
417
 * will delete it when the context itself is deleted, or when a new hook is
418
 * set.
419
 */
420
extern JS_FRIEND_API(void)
421
SetSourceHook(JSContext* cx, mozilla::UniquePtr<SourceHook> hook);
422
423
/** Remove |cx|'s source hook, and return it. The caller now owns the hook. */
424
extern JS_FRIEND_API(mozilla::UniquePtr<SourceHook>)
425
ForgetSourceHook(JSContext* cx);
426
427
/**
428
 * Use the runtime's internal handling of job queues for Promise jobs.
429
 *
430
 * Most embeddings, notably web browsers, will have their own task scheduling
431
 * systems and need to integrate handling of Promise jobs into that, so they
432
 * will want to manage job queues themselves. For basic embeddings such as the
433
 * JS shell that don't have an event loop of their own, it's easier to have
434
 * SpiderMonkey handle job queues internally.
435
 *
436
 * Note that the embedding still has to trigger processing of job queues at
437
 * right time(s), such as after evaluation of a script has run to completion.
438
 */
439
extern JS_FRIEND_API(bool)
440
UseInternalJobQueues(JSContext* cx);
441
442
/**
443
 * Enqueue |job| on the internal job queue.
444
 *
445
 * This is useful in tests for creating situations where a call occurs with no
446
 * other JavaScript on the stack.
447
 */
448
extern JS_FRIEND_API(bool)
449
EnqueueJob(JSContext* cx, JS::HandleObject job);
450
451
/**
452
 * Instruct the runtime to stop draining the internal job queue.
453
 *
454
 * Useful if the embedding is in the process of quitting in reaction to a
455
 * builtin being called, or if it wants to resume executing jobs later on.
456
 */
457
extern JS_FRIEND_API(void)
458
StopDrainingJobQueue(JSContext* cx);
459
460
extern JS_FRIEND_API(void)
461
RunJobs(JSContext* cx);
462
463
extern JS_FRIEND_API(JS::Zone*)
464
GetRealmZone(JS::Realm* realm);
465
466
typedef bool
467
(* PreserveWrapperCallback)(JSContext* cx, JS::HandleObject obj);
468
469
typedef enum  {
470
    CollectNurseryBeforeDump,
471
    IgnoreNurseryObjects
472
} DumpHeapNurseryBehaviour;
473
474
 /**
475
  * Dump the complete object graph of heap-allocated things.
476
  * fp is the file for the dump output.
477
  */
478
extern JS_FRIEND_API(void)
479
DumpHeap(JSContext* cx, FILE* fp, DumpHeapNurseryBehaviour nurseryBehaviour);
480
481
#ifdef JS_OLD_GETTER_SETTER_METHODS
482
JS_FRIEND_API(bool) obj_defineGetter(JSContext* cx, unsigned argc, JS::Value* vp);
483
JS_FRIEND_API(bool) obj_defineSetter(JSContext* cx, unsigned argc, JS::Value* vp);
484
#endif
485
486
extern JS_FRIEND_API(bool)
487
IsSystemRealm(JS::Realm* realm);
488
489
extern JS_FRIEND_API(bool)
490
IsSystemCompartment(JS::Compartment* comp);
491
492
extern JS_FRIEND_API(bool)
493
IsSystemZone(JS::Zone* zone);
494
495
extern JS_FRIEND_API(bool)
496
IsAtomsZone(JS::Zone* zone);
497
498
struct WeakMapTracer
499
{
500
    JSRuntime* runtime;
501
502
    explicit WeakMapTracer(JSRuntime* rt) : runtime(rt) {}
503
504
    // Weak map tracer callback, called once for every binding of every
505
    // weak map that was live at the time of the last garbage collection.
506
    //
507
    // m will be nullptr if the weak map is not contained in a JS Object.
508
    //
509
    // The callback should not GC (and will assert in a debug build if it does so.)
510
    virtual void trace(JSObject* m, JS::GCCellPtr key, JS::GCCellPtr value) = 0;
511
};
512
513
extern JS_FRIEND_API(void)
514
TraceWeakMaps(WeakMapTracer* trc);
515
516
extern JS_FRIEND_API(bool)
517
AreGCGrayBitsValid(JSRuntime* rt);
518
519
extern JS_FRIEND_API(bool)
520
ZoneGlobalsAreAllGray(JS::Zone* zone);
521
522
extern JS_FRIEND_API(bool)
523
IsObjectZoneSweepingOrCompacting(JSObject* obj);
524
525
typedef void
526
(*GCThingCallback)(void* closure, JS::GCCellPtr thing);
527
528
extern JS_FRIEND_API(void)
529
VisitGrayWrapperTargets(JS::Zone* zone, GCThingCallback callback, void* closure);
530
531
extern JS_FRIEND_API(JSObject*)
532
GetWeakmapKeyDelegate(JSObject* key);
533
534
/**
535
 * Invoke cellCallback on every gray JSObject in the given zone.
536
 */
537
extern JS_FRIEND_API(void)
538
IterateGrayObjects(JS::Zone* zone, GCThingCallback cellCallback, void* data);
539
540
/**
541
 * Invoke cellCallback on every gray JSObject in the given zone while cycle
542
 * collection is in progress.
543
 */
544
extern JS_FRIEND_API(void)
545
IterateGrayObjectsUnderCC(JS::Zone* zone, GCThingCallback cellCallback, void* data);
546
547
#if defined(JS_GC_ZEAL) || defined(DEBUG)
548
// Trace the heap and check there are no black to gray edges. These are
549
// not allowed since the cycle collector could throw away the gray thing and
550
// leave a dangling pointer.
551
//
552
// This doesn't trace weak maps as these are handled separately.
553
extern JS_FRIEND_API(bool)
554
CheckGrayMarkingState(JSRuntime* rt);
555
#endif
556
557
#ifdef JS_HAS_CTYPES
558
extern JS_FRIEND_API(size_t)
559
SizeOfDataIfCDataObject(mozilla::MallocSizeOf mallocSizeOf, JSObject* obj);
560
#endif
561
562
// Note: this returns nullptr iff |zone| is the atoms zone.
563
extern JS_FRIEND_API(JS::Realm*)
564
GetAnyRealmInZone(JS::Zone* zone);
565
566
/*
567
 * Shadow declarations of JS internal structures, for access by inline access
568
 * functions below. Do not use these structures in any other way. When adding
569
 * new fields for access by inline methods, make sure to add static asserts to
570
 * the original header file to ensure that offsets are consistent.
571
 */
572
namespace shadow {
573
574
struct ObjectGroup {
575
    const Class* clasp;
576
    JSObject* proto;
577
    JS::Realm* realm;
578
};
579
580
struct BaseShape {
581
    const js::Class* clasp_;
582
    JSObject* parent;
583
};
584
585
class Shape {
586
public:
587
    shadow::BaseShape* base;
588
    jsid              _1;
589
    uint32_t          immutableFlags;
590
591
    static const uint32_t FIXED_SLOTS_SHIFT = 24;
592
    static const uint32_t FIXED_SLOTS_MASK = 0x1f << FIXED_SLOTS_SHIFT;
593
};
594
595
/**
596
 * This layout is shared by all native objects. For non-native objects, the
597
 * group may always be accessed safely, and other members may be as well,
598
 * depending on the object's specific layout.
599
 */
600
struct Object {
601
    shadow::ObjectGroup* group;
602
    shadow::Shape*      shape;
603
    JS::Value*          slots;
604
    void*               _1;
605
606
    static const size_t MAX_FIXED_SLOTS = 16;
607
608
    size_t numFixedSlots() const {
609
        return (shape->immutableFlags & Shape::FIXED_SLOTS_MASK) >> Shape::FIXED_SLOTS_SHIFT;
610
    }
611
612
    JS::Value* fixedSlots() const {
613
        return (JS::Value*)(uintptr_t(this) + sizeof(shadow::Object));
614
    }
615
616
    JS::Value& slotRef(size_t slot) const {
617
        size_t nfixed = numFixedSlots();
618
        if (slot < nfixed) {
619
            return fixedSlots()[slot];
620
        }
621
        return slots[slot - nfixed];
622
    }
623
};
624
625
struct Function {
626
    Object base;
627
    uint16_t nargs;
628
    uint16_t flags;
629
    /* Used only for natives */
630
    JSNative native;
631
    const JSJitInfo* jitinfo;
632
    void* _1;
633
};
634
635
} /* namespace shadow */
636
637
// This is equal to |&JSObject::class_|.  Use it in places where you don't want
638
// to #include vm/JSObject.h.
639
extern JS_FRIEND_DATA(const js::Class* const) ObjectClassPtr;
640
641
inline const js::Class*
642
GetObjectClass(const JSObject* obj)
643
{
644
    return reinterpret_cast<const shadow::Object*>(obj)->group->clasp;
645
}
646
647
inline const JSClass*
648
GetObjectJSClass(JSObject* obj)
649
{
650
    return js::Jsvalify(GetObjectClass(obj));
651
}
652
653
JS_FRIEND_API(const Class*)
654
ProtoKeyToClass(JSProtoKey key);
655
656
// Returns the key for the class inherited by a given standard class (that
657
// is to say, the prototype of this standard class's prototype).
658
//
659
// You must be sure that this corresponds to a standard class with a cached
660
// JSProtoKey before calling this function. In general |key| will match the
661
// cached proto key, except in cases where multiple JSProtoKeys share a
662
// JSClass.
663
inline JSProtoKey
664
InheritanceProtoKeyForStandardClass(JSProtoKey key)
665
{
666
    // [Object] has nothing to inherit from.
667
    if (key == JSProto_Object) {
668
        return JSProto_Null;
669
    }
670
671
    // If we're ClassSpec defined return the proto key from that
672
    if (ProtoKeyToClass(key)->specDefined()) {
673
        return ProtoKeyToClass(key)->specInheritanceProtoKey();
674
    }
675
676
    // Otherwise, we inherit [Object].
677
    return JSProto_Object;
678
}
679
680
JS_FRIEND_API(bool)
681
IsFunctionObject(JSObject* obj);
682
683
JS_FRIEND_API(bool)
684
UninlinedIsCrossCompartmentWrapper(const JSObject* obj);
685
686
static MOZ_ALWAYS_INLINE JS::Compartment*
687
GetObjectCompartment(JSObject* obj)
688
9
{
689
9
    JS::Realm* realm = reinterpret_cast<shadow::Object*>(obj)->group->realm;
690
9
    return JS::GetCompartmentForRealm(realm);
691
9
}
Unified_cpp_js_ipc0.cpp:js::GetObjectCompartment(JSObject*)
Line
Count
Source
688
9
{
689
9
    JS::Realm* realm = reinterpret_cast<shadow::Object*>(obj)->group->realm;
690
9
    return JS::GetCompartmentForRealm(realm);
691
9
}
Unexecuted instantiation: CTypes.cpp:js::GetObjectCompartment(JSObject*)
Unexecuted instantiation: Library.cpp:js::GetObjectCompartment(JSObject*)
Unexecuted instantiation: StoreBuffer.cpp:js::GetObjectCompartment(JSObject*)
Unexecuted instantiation: jsutil.cpp:js::GetObjectCompartment(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src0.cpp:js::GetObjectCompartment(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src1.cpp:js::GetObjectCompartment(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src10.cpp:js::GetObjectCompartment(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src11.cpp:js::GetObjectCompartment(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src12.cpp:js::GetObjectCompartment(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src14.cpp:js::GetObjectCompartment(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src15.cpp:js::GetObjectCompartment(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src17.cpp:js::GetObjectCompartment(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src18.cpp:js::GetObjectCompartment(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src19.cpp:js::GetObjectCompartment(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src2.cpp:js::GetObjectCompartment(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src20.cpp:js::GetObjectCompartment(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src21.cpp:js::GetObjectCompartment(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src22.cpp:js::GetObjectCompartment(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src23.cpp:js::GetObjectCompartment(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src24.cpp:js::GetObjectCompartment(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src25.cpp:js::GetObjectCompartment(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src26.cpp:js::GetObjectCompartment(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src27.cpp:js::GetObjectCompartment(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src28.cpp:js::GetObjectCompartment(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src29.cpp:js::GetObjectCompartment(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src3.cpp:js::GetObjectCompartment(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src30.cpp:js::GetObjectCompartment(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src31.cpp:js::GetObjectCompartment(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src32.cpp:js::GetObjectCompartment(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src33.cpp:js::GetObjectCompartment(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src34.cpp:js::GetObjectCompartment(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src35.cpp:js::GetObjectCompartment(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src36.cpp:js::GetObjectCompartment(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src37.cpp:js::GetObjectCompartment(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src38.cpp:js::GetObjectCompartment(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src39.cpp:js::GetObjectCompartment(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src4.cpp:js::GetObjectCompartment(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src40.cpp:js::GetObjectCompartment(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src41.cpp:js::GetObjectCompartment(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src42.cpp:js::GetObjectCompartment(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src43.cpp:js::GetObjectCompartment(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src44.cpp:js::GetObjectCompartment(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src45.cpp:js::GetObjectCompartment(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src5.cpp:js::GetObjectCompartment(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src6.cpp:js::GetObjectCompartment(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src7.cpp:js::GetObjectCompartment(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src8.cpp:js::GetObjectCompartment(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src9.cpp:js::GetObjectCompartment(JSObject*)
Unexecuted instantiation: RegExp.cpp:js::GetObjectCompartment(JSObject*)
Unexecuted instantiation: BinSource-auto.cpp:js::GetObjectCompartment(JSObject*)
Unexecuted instantiation: BinSource.cpp:js::GetObjectCompartment(JSObject*)
Unexecuted instantiation: BinToken.cpp:js::GetObjectCompartment(JSObject*)
Unexecuted instantiation: BinTokenReaderBase.cpp:js::GetObjectCompartment(JSObject*)
Unexecuted instantiation: BinTokenReaderMultipart.cpp:js::GetObjectCompartment(JSObject*)
Unexecuted instantiation: BinTokenReaderTester.cpp:js::GetObjectCompartment(JSObject*)
Unexecuted instantiation: Parser.cpp:js::GetObjectCompartment(JSObject*)
Unexecuted instantiation: Disassembler-x86-shared.cpp:js::GetObjectCompartment(JSObject*)
Unexecuted instantiation: jsmath.cpp:js::GetObjectCompartment(JSObject*)
Unexecuted instantiation: Interpreter.cpp:js::GetObjectCompartment(JSObject*)
Unexecuted instantiation: VTuneWrapper.cpp:js::GetObjectCompartment(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src13.cpp:js::GetObjectCompartment(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src16.cpp:js::GetObjectCompartment(JSObject*)
692
693
// CrossCompartmentWrappers are shared by all realms within the compartment, so
694
// getting a wrapper's realm usually doesn't make sense.
695
static MOZ_ALWAYS_INLINE JS::Realm*
696
GetNonCCWObjectRealm(JSObject* obj)
697
0
{
698
0
    MOZ_ASSERT(!js::UninlinedIsCrossCompartmentWrapper(obj));
699
0
    return reinterpret_cast<shadow::Object*>(obj)->group->realm;
700
0
}
Unexecuted instantiation: Unified_cpp_js_ipc0.cpp:js::GetNonCCWObjectRealm(JSObject*)
Unexecuted instantiation: CTypes.cpp:js::GetNonCCWObjectRealm(JSObject*)
Unexecuted instantiation: Library.cpp:js::GetNonCCWObjectRealm(JSObject*)
Unexecuted instantiation: StoreBuffer.cpp:js::GetNonCCWObjectRealm(JSObject*)
Unexecuted instantiation: jsutil.cpp:js::GetNonCCWObjectRealm(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src0.cpp:js::GetNonCCWObjectRealm(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src1.cpp:js::GetNonCCWObjectRealm(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src10.cpp:js::GetNonCCWObjectRealm(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src11.cpp:js::GetNonCCWObjectRealm(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src12.cpp:js::GetNonCCWObjectRealm(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src14.cpp:js::GetNonCCWObjectRealm(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src15.cpp:js::GetNonCCWObjectRealm(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src17.cpp:js::GetNonCCWObjectRealm(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src18.cpp:js::GetNonCCWObjectRealm(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src19.cpp:js::GetNonCCWObjectRealm(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src2.cpp:js::GetNonCCWObjectRealm(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src20.cpp:js::GetNonCCWObjectRealm(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src21.cpp:js::GetNonCCWObjectRealm(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src22.cpp:js::GetNonCCWObjectRealm(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src23.cpp:js::GetNonCCWObjectRealm(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src24.cpp:js::GetNonCCWObjectRealm(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src25.cpp:js::GetNonCCWObjectRealm(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src26.cpp:js::GetNonCCWObjectRealm(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src27.cpp:js::GetNonCCWObjectRealm(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src28.cpp:js::GetNonCCWObjectRealm(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src29.cpp:js::GetNonCCWObjectRealm(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src3.cpp:js::GetNonCCWObjectRealm(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src30.cpp:js::GetNonCCWObjectRealm(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src31.cpp:js::GetNonCCWObjectRealm(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src32.cpp:js::GetNonCCWObjectRealm(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src33.cpp:js::GetNonCCWObjectRealm(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src34.cpp:js::GetNonCCWObjectRealm(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src35.cpp:js::GetNonCCWObjectRealm(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src36.cpp:js::GetNonCCWObjectRealm(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src37.cpp:js::GetNonCCWObjectRealm(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src38.cpp:js::GetNonCCWObjectRealm(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src39.cpp:js::GetNonCCWObjectRealm(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src4.cpp:js::GetNonCCWObjectRealm(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src40.cpp:js::GetNonCCWObjectRealm(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src41.cpp:js::GetNonCCWObjectRealm(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src42.cpp:js::GetNonCCWObjectRealm(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src43.cpp:js::GetNonCCWObjectRealm(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src44.cpp:js::GetNonCCWObjectRealm(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src45.cpp:js::GetNonCCWObjectRealm(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src5.cpp:js::GetNonCCWObjectRealm(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src6.cpp:js::GetNonCCWObjectRealm(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src7.cpp:js::GetNonCCWObjectRealm(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src8.cpp:js::GetNonCCWObjectRealm(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src9.cpp:js::GetNonCCWObjectRealm(JSObject*)
Unexecuted instantiation: RegExp.cpp:js::GetNonCCWObjectRealm(JSObject*)
Unexecuted instantiation: BinSource-auto.cpp:js::GetNonCCWObjectRealm(JSObject*)
Unexecuted instantiation: BinSource.cpp:js::GetNonCCWObjectRealm(JSObject*)
Unexecuted instantiation: BinToken.cpp:js::GetNonCCWObjectRealm(JSObject*)
Unexecuted instantiation: BinTokenReaderBase.cpp:js::GetNonCCWObjectRealm(JSObject*)
Unexecuted instantiation: BinTokenReaderMultipart.cpp:js::GetNonCCWObjectRealm(JSObject*)
Unexecuted instantiation: BinTokenReaderTester.cpp:js::GetNonCCWObjectRealm(JSObject*)
Unexecuted instantiation: Parser.cpp:js::GetNonCCWObjectRealm(JSObject*)
Unexecuted instantiation: Disassembler-x86-shared.cpp:js::GetNonCCWObjectRealm(JSObject*)
Unexecuted instantiation: jsmath.cpp:js::GetNonCCWObjectRealm(JSObject*)
Unexecuted instantiation: Interpreter.cpp:js::GetNonCCWObjectRealm(JSObject*)
Unexecuted instantiation: VTuneWrapper.cpp:js::GetNonCCWObjectRealm(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src13.cpp:js::GetNonCCWObjectRealm(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src16.cpp:js::GetNonCCWObjectRealm(JSObject*)
701
702
JS_FRIEND_API(JSObject*)
703
GetPrototypeNoProxy(JSObject* obj);
704
705
JS_FRIEND_API(void)
706
AssertSameCompartment(JSContext* cx, JSObject* obj);
707
708
JS_FRIEND_API(void)
709
AssertSameCompartment(JSContext* cx, JS::HandleValue v);
710
711
#ifdef JS_DEBUG
712
JS_FRIEND_API(void)
713
AssertSameCompartment(JSObject* objA, JSObject* objB);
714
#else
715
inline void AssertSameCompartment(JSObject* objA, JSObject* objB) {}
716
#endif
717
718
JS_FRIEND_API(void)
719
NotifyAnimationActivity(JSObject* obj);
720
721
JS_FRIEND_API(JSFunction*)
722
DefineFunctionWithReserved(JSContext* cx, JSObject* obj, const char* name, JSNative call,
723
                           unsigned nargs, unsigned attrs);
724
725
JS_FRIEND_API(JSFunction*)
726
NewFunctionWithReserved(JSContext* cx, JSNative call, unsigned nargs, unsigned flags,
727
                        const char* name);
728
729
JS_FRIEND_API(JSFunction*)
730
NewFunctionByIdWithReserved(JSContext* cx, JSNative native, unsigned nargs, unsigned flags,
731
                            jsid id);
732
733
JS_FRIEND_API(const JS::Value&)
734
GetFunctionNativeReserved(JSObject* fun, size_t which);
735
736
JS_FRIEND_API(void)
737
SetFunctionNativeReserved(JSObject* fun, size_t which, const JS::Value& val);
738
739
JS_FRIEND_API(bool)
740
FunctionHasNativeReserved(JSObject* fun);
741
742
JS_FRIEND_API(bool)
743
GetObjectProto(JSContext* cx, JS::HandleObject obj, JS::MutableHandleObject proto);
744
745
extern JS_FRIEND_API(JSObject*)
746
GetStaticPrototype(JSObject* obj);
747
748
JS_FRIEND_API(bool)
749
GetRealmOriginalEval(JSContext* cx, JS::MutableHandleObject eval);
750
751
inline void*
752
GetObjectPrivate(JSObject* obj)
753
{
754
    MOZ_ASSERT(GetObjectClass(obj)->flags & JSCLASS_HAS_PRIVATE);
755
    const shadow::Object* nobj = reinterpret_cast<const shadow::Object*>(obj);
756
    void** addr = reinterpret_cast<void**>(&nobj->fixedSlots()[nobj->numFixedSlots()]);
757
    return *addr;
758
}
759
760
/**
761
 * Get the value stored in an object's reserved slot. This can be used with
762
 * both native objects and proxies, but if |obj| is known to be a proxy
763
 * GetProxyReservedSlot is a bit more efficient.
764
 */
765
inline const JS::Value&
766
GetReservedSlot(JSObject* obj, size_t slot)
767
{
768
    MOZ_ASSERT(slot < JSCLASS_RESERVED_SLOTS(GetObjectClass(obj)));
769
    return reinterpret_cast<const shadow::Object*>(obj)->slotRef(slot);
770
}
771
772
JS_FRIEND_API(void)
773
SetReservedSlotWithBarrier(JSObject* obj, size_t slot, const JS::Value& value);
774
775
/**
776
 * Store a value in an object's reserved slot. This can be used with
777
 * both native objects and proxies, but if |obj| is known to be a proxy
778
 * SetProxyReservedSlot is a bit more efficient.
779
 */
780
inline void
781
SetReservedSlot(JSObject* obj, size_t slot, const JS::Value& value)
782
{
783
    MOZ_ASSERT(slot < JSCLASS_RESERVED_SLOTS(GetObjectClass(obj)));
784
    shadow::Object* sobj = reinterpret_cast<shadow::Object*>(obj);
785
    if (sobj->slotRef(slot).isGCThing() || value.isGCThing()) {
786
        SetReservedSlotWithBarrier(obj, slot, value);
787
    } else {
788
        sobj->slotRef(slot) = value;
789
    }
790
}
791
792
JS_FRIEND_API(uint32_t)
793
GetObjectSlotSpan(JSObject* obj);
794
795
inline const JS::Value&
796
GetObjectSlot(JSObject* obj, size_t slot)
797
{
798
    MOZ_ASSERT(slot < GetObjectSlotSpan(obj));
799
    return reinterpret_cast<const shadow::Object*>(obj)->slotRef(slot);
800
}
801
802
MOZ_ALWAYS_INLINE size_t
803
GetAtomLength(JSAtom* atom)
804
{
805
    return reinterpret_cast<JS::shadow::String*>(atom)->length();
806
}
807
808
static const uint32_t MaxStringLength = (1 << 28) - 1;
809
810
MOZ_ALWAYS_INLINE size_t
811
GetFlatStringLength(JSFlatString* s)
812
{
813
    return reinterpret_cast<JS::shadow::String*>(s)->length();
814
}
815
816
MOZ_ALWAYS_INLINE size_t
817
GetLinearStringLength(JSLinearString* s)
818
0
{
819
0
    return reinterpret_cast<JS::shadow::String*>(s)->length();
820
0
}
821
822
MOZ_ALWAYS_INLINE bool
823
LinearStringHasLatin1Chars(JSLinearString* s)
824
{
825
    return reinterpret_cast<JS::shadow::String*>(s)->flags() & JS::shadow::String::LATIN1_CHARS_BIT;
826
}
827
828
MOZ_ALWAYS_INLINE bool
829
AtomHasLatin1Chars(JSAtom* atom)
830
{
831
    return reinterpret_cast<JS::shadow::String*>(atom)->flags() & JS::shadow::String::LATIN1_CHARS_BIT;
832
}
833
834
MOZ_ALWAYS_INLINE bool
835
StringHasLatin1Chars(JSString* s)
836
{
837
    return reinterpret_cast<JS::shadow::String*>(s)->flags() & JS::shadow::String::LATIN1_CHARS_BIT;
838
}
839
840
MOZ_ALWAYS_INLINE const JS::Latin1Char*
841
GetLatin1LinearStringChars(const JS::AutoRequireNoGC& nogc, JSLinearString* linear)
842
{
843
    MOZ_ASSERT(LinearStringHasLatin1Chars(linear));
844
845
    using JS::shadow::String;
846
    String* s = reinterpret_cast<String*>(linear);
847
    if (s->flags() & String::INLINE_CHARS_BIT) {
848
        return s->inlineStorageLatin1;
849
    }
850
    return s->nonInlineCharsLatin1;
851
}
852
853
MOZ_ALWAYS_INLINE const char16_t*
854
GetTwoByteLinearStringChars(const JS::AutoRequireNoGC& nogc, JSLinearString* linear)
855
{
856
    MOZ_ASSERT(!LinearStringHasLatin1Chars(linear));
857
858
    using JS::shadow::String;
859
    String* s = reinterpret_cast<String*>(linear);
860
    if (s->flags() & String::INLINE_CHARS_BIT) {
861
        return s->inlineStorageTwoByte;
862
    }
863
    return s->nonInlineCharsTwoByte;
864
}
865
866
MOZ_ALWAYS_INLINE JSLinearString*
867
AtomToLinearString(JSAtom* atom)
868
{
869
    return reinterpret_cast<JSLinearString*>(atom);
870
}
871
872
MOZ_ALWAYS_INLINE JSFlatString*
873
AtomToFlatString(JSAtom* atom)
874
{
875
    return reinterpret_cast<JSFlatString*>(atom);
876
}
877
878
MOZ_ALWAYS_INLINE JSLinearString*
879
FlatStringToLinearString(JSFlatString* s)
880
{
881
    return reinterpret_cast<JSLinearString*>(s);
882
}
883
884
MOZ_ALWAYS_INLINE const JS::Latin1Char*
885
GetLatin1AtomChars(const JS::AutoRequireNoGC& nogc, JSAtom* atom)
886
{
887
    return GetLatin1LinearStringChars(nogc, AtomToLinearString(atom));
888
}
889
890
MOZ_ALWAYS_INLINE const char16_t*
891
GetTwoByteAtomChars(const JS::AutoRequireNoGC& nogc, JSAtom* atom)
892
{
893
    return GetTwoByteLinearStringChars(nogc, AtomToLinearString(atom));
894
}
895
896
MOZ_ALWAYS_INLINE bool
897
IsExternalString(JSString* str, const JSStringFinalizer** fin, const char16_t** chars)
898
{
899
    using JS::shadow::String;
900
    String* s = reinterpret_cast<String*>(str);
901
902
    if ((s->flags() & String::TYPE_FLAGS_MASK) != String::EXTERNAL_FLAGS) {
903
        return false;
904
    }
905
906
    MOZ_ASSERT(JS_IsExternalString(str));
907
    *fin = s->externalFinalizer;
908
    *chars = s->nonInlineCharsTwoByte;
909
    return true;
910
}
911
912
JS_FRIEND_API(JSLinearString*)
913
StringToLinearStringSlow(JSContext* cx, JSString* str);
914
915
MOZ_ALWAYS_INLINE JSLinearString*
916
StringToLinearString(JSContext* cx, JSString* str)
917
{
918
    using JS::shadow::String;
919
    String* s = reinterpret_cast<String*>(str);
920
    if (MOZ_UNLIKELY(!(s->flags() & String::LINEAR_BIT))) {
921
        return StringToLinearStringSlow(cx, str);
922
    }
923
    return reinterpret_cast<JSLinearString*>(str);
924
}
925
926
template<typename CharType>
927
MOZ_ALWAYS_INLINE void
928
CopyLinearStringChars(CharType* dest, JSLinearString* s, size_t len, size_t start = 0);
929
930
MOZ_ALWAYS_INLINE void
931
CopyLinearStringChars(char16_t* dest, JSLinearString* s, size_t len, size_t start = 0)
932
{
933
    MOZ_ASSERT(start + len <= GetLinearStringLength(s));
934
    JS::AutoCheckCannotGC nogc;
935
    if (LinearStringHasLatin1Chars(s)) {
936
        const JS::Latin1Char* src = GetLatin1LinearStringChars(nogc, s);
937
        for (size_t i = 0; i < len; i++) {
938
            dest[i] = src[start + i];
939
        }
940
    } else {
941
        const char16_t* src = GetTwoByteLinearStringChars(nogc, s);
942
        mozilla::PodCopy(dest, src + start, len);
943
    }
944
}
945
946
MOZ_ALWAYS_INLINE void
947
CopyLinearStringChars(char* dest, JSLinearString* s, size_t len, size_t start = 0)
948
{
949
    MOZ_ASSERT(start + len <= GetLinearStringLength(s));
950
    JS::AutoCheckCannotGC nogc;
951
    if (LinearStringHasLatin1Chars(s)) {
952
        const JS::Latin1Char* src = GetLatin1LinearStringChars(nogc, s);
953
        for (size_t i = 0; i < len; i++) {
954
           dest[i] = char(src[start + i]);
955
        }
956
    } else {
957
      const char16_t* src = GetTwoByteLinearStringChars(nogc, s);
958
      for (size_t i = 0; i < len; i++) {
959
          dest[i] = char(src[start + i]);
960
      }
961
    }
962
}
963
964
template<typename CharType>
965
inline bool
966
CopyStringChars(JSContext* cx, CharType* dest, JSString* s, size_t len, size_t start = 0)
967
{
968
    JSLinearString* linear = StringToLinearString(cx, s);
969
    if (!linear) {
970
        return false;
971
    }
972
973
    CopyLinearStringChars(dest, linear, len, start);
974
    return true;
975
}
976
977
inline void
978
CopyFlatStringChars(char16_t* dest, JSFlatString* s, size_t len)
979
{
980
    CopyLinearStringChars(dest, FlatStringToLinearString(s), len);
981
}
982
983
/**
984
 * Add some or all property keys of obj to the id vector *props.
985
 *
986
 * The flags parameter controls which property keys are added. Pass a
987
 * combination of the following bits:
988
 *
989
 *     JSITER_OWNONLY - Don't also search the prototype chain; only consider
990
 *       obj's own properties.
991
 *
992
 *     JSITER_HIDDEN - Include nonenumerable properties.
993
 *
994
 *     JSITER_SYMBOLS - Include property keys that are symbols. The default
995
 *       behavior is to filter out symbols.
996
 *
997
 *     JSITER_SYMBOLSONLY - Exclude non-symbol property keys.
998
 *
999
 * This is the closest C++ API we have to `Reflect.ownKeys(obj)`, or
1000
 * equivalently, the ES6 [[OwnPropertyKeys]] internal method. Pass
1001
 * `JSITER_OWNONLY | JSITER_HIDDEN | JSITER_SYMBOLS` as flags to get
1002
 * results that match the output of Reflect.ownKeys.
1003
 */
1004
JS_FRIEND_API(bool)
1005
GetPropertyKeys(JSContext* cx, JS::HandleObject obj, unsigned flags, JS::AutoIdVector* props);
1006
1007
JS_FRIEND_API(bool)
1008
AppendUnique(JSContext* cx, JS::AutoIdVector& base, JS::AutoIdVector& others);
1009
1010
JS_FRIEND_API(bool)
1011
StringIsArrayIndex(JSLinearString* str, uint32_t* indexp);
1012
1013
JS_FRIEND_API(void)
1014
SetPreserveWrapperCallback(JSContext* cx, PreserveWrapperCallback callback);
1015
1016
JS_FRIEND_API(bool)
1017
IsObjectInContextCompartment(JSObject* obj, const JSContext* cx);
1018
1019
/*
1020
 * NB: keep these in sync with the copy in builtin/SelfHostingDefines.h.
1021
 */
1022
/* 0x1 is no longer used */
1023
/* 0x2 is no longer used */
1024
/* 0x4 is no longer used */
1025
32
#define JSITER_OWNONLY    0x8   /* iterate over obj's own properties only */
1026
8
#define JSITER_HIDDEN     0x10  /* also enumerate non-enumerable properties */
1027
8
#define JSITER_SYMBOLS    0x20  /* also include symbol property keys */
1028
24
#define JSITER_SYMBOLSONLY 0x40 /* exclude string property keys */
1029
22
#define JSITER_FORAWAITOF 0x80  /* for-await-of */
1030
1031
JS_FRIEND_API(bool)
1032
RunningWithTrustedPrincipals(JSContext* cx);
1033
1034
MOZ_ALWAYS_INLINE uintptr_t
1035
GetNativeStackLimit(JSContext* cx, JS::StackKind kind, int extraAllowance = 0)
1036
{
1037
    uintptr_t limit = JS::RootingContext::get(cx)->nativeStackLimit[kind];
1038
#if JS_STACK_GROWTH_DIRECTION > 0
1039
    limit += extraAllowance;
1040
#else
1041
    limit -= extraAllowance;
1042
#endif
1043
    return limit;
1044
}
1045
1046
MOZ_ALWAYS_INLINE uintptr_t
1047
GetNativeStackLimit(JSContext* cx, int extraAllowance = 0)
1048
{
1049
    JS::StackKind kind = RunningWithTrustedPrincipals(cx) ? JS::StackForTrustedScript
1050
                                                          : JS::StackForUntrustedScript;
1051
    return GetNativeStackLimit(cx, kind, extraAllowance);
1052
}
1053
1054
/*
1055
 * These functions return |false| if we are close to using up the C++ stack.
1056
 * They also report an overrecursion error, except for the DontReport variants.
1057
 * The CheckSystemRecursionLimit variant gives us a little extra space so we
1058
 * can ensure that crucial code is able to run. CheckRecursionLimitConservative
1059
 * allows less space than any other check, including a safety buffer (as in, it
1060
 * uses the untrusted limit and subtracts a little more from it).
1061
 */
1062
1063
MOZ_ALWAYS_INLINE bool
1064
CheckRecursionLimit(JSContext* cx, uintptr_t limit)
1065
{
1066
    int stackDummy;
1067
1068
    JS_STACK_OOM_POSSIBLY_FAIL_REPORT();
1069
1070
    if (!JS_CHECK_STACK_SIZE(limit, &stackDummy)) {
1071
        ReportOverRecursed(cx);
1072
        return false;
1073
    }
1074
    return true;
1075
}
1076
1077
MOZ_ALWAYS_INLINE bool
1078
CheckRecursionLimitDontReport(uintptr_t limit)
1079
{
1080
    int stackDummy;
1081
1082
    JS_STACK_OOM_POSSIBLY_FAIL();
1083
1084
    return JS_CHECK_STACK_SIZE(limit, &stackDummy);
1085
}
1086
1087
MOZ_ALWAYS_INLINE bool
1088
CheckRecursionLimit(JSContext* cx)
1089
{
1090
    JS_STACK_OOM_POSSIBLY_FAIL_REPORT();
1091
1092
    // GetNativeStackLimit(cx) is pretty slow because it has to do an uninlined
1093
    // call to RunningWithTrustedPrincipals to determine which stack limit to
1094
    // use. To work around this, check the untrusted limit first to avoid the
1095
    // overhead in most cases.
1096
    uintptr_t untrustedLimit = GetNativeStackLimit(cx, JS::StackForUntrustedScript);
1097
    if (MOZ_LIKELY(CheckRecursionLimitDontReport(untrustedLimit))) {
1098
        return true;
1099
    }
1100
    return CheckRecursionLimit(cx, GetNativeStackLimit(cx));
1101
}
1102
1103
MOZ_ALWAYS_INLINE bool
1104
CheckRecursionLimitDontReport(JSContext* cx)
1105
0
{
1106
0
    return CheckRecursionLimitDontReport(GetNativeStackLimit(cx));
1107
0
}
1108
1109
MOZ_ALWAYS_INLINE bool
1110
CheckRecursionLimitWithStackPointerDontReport(JSContext* cx, void* sp)
1111
8
{
1112
8
    JS_STACK_OOM_POSSIBLY_FAIL();
1113
8
1114
8
    return JS_CHECK_STACK_SIZE(GetNativeStackLimit(cx), sp);
1115
8
}
1116
1117
MOZ_ALWAYS_INLINE bool
1118
CheckRecursionLimitWithStackPointer(JSContext* cx, void* sp)
1119
22
{
1120
22
    JS_STACK_OOM_POSSIBLY_FAIL_REPORT();
1121
22
1122
22
    if (!JS_CHECK_STACK_SIZE(GetNativeStackLimit(cx), sp)) {
1123
0
        ReportOverRecursed(cx);
1124
0
        return false;
1125
0
    }
1126
22
    return true;
1127
22
}
1128
1129
MOZ_ALWAYS_INLINE bool
1130
CheckSystemRecursionLimit(JSContext* cx)
1131
0
{
1132
0
    return CheckRecursionLimit(cx, GetNativeStackLimit(cx, JS::StackForSystemCode));
1133
0
}
1134
1135
MOZ_ALWAYS_INLINE bool
1136
CheckRecursionLimitConservative(JSContext* cx)
1137
{
1138
    return CheckRecursionLimit(cx, GetNativeStackLimit(cx, JS::StackForUntrustedScript,
1139
                                                       -1024 * int(sizeof(size_t))));
1140
}
1141
1142
MOZ_ALWAYS_INLINE bool
1143
CheckRecursionLimitConservativeDontReport(JSContext* cx)
1144
{
1145
    return CheckRecursionLimitDontReport(GetNativeStackLimit(cx, JS::StackForUntrustedScript,
1146
                                                             -1024 * int(sizeof(size_t))));
1147
}
1148
1149
JS_FRIEND_API(void)
1150
StartPCCountProfiling(JSContext* cx);
1151
1152
JS_FRIEND_API(void)
1153
StopPCCountProfiling(JSContext* cx);
1154
1155
JS_FRIEND_API(void)
1156
PurgePCCounts(JSContext* cx);
1157
1158
JS_FRIEND_API(size_t)
1159
GetPCCountScriptCount(JSContext* cx);
1160
1161
JS_FRIEND_API(JSString*)
1162
GetPCCountScriptSummary(JSContext* cx, size_t script);
1163
1164
JS_FRIEND_API(JSString*)
1165
GetPCCountScriptContents(JSContext* cx, size_t script);
1166
1167
/**
1168
 * Generate lcov trace file content for the current compartment, and allocate a
1169
 * new buffer and return the content in it, the size of the newly allocated
1170
 * content within the buffer would be set to the length out-param.
1171
 *
1172
 * In case of out-of-memory, this function returns nullptr and does not set any
1173
 * value to the length out-param.
1174
 */
1175
JS_FRIEND_API(char*)
1176
GetCodeCoverageSummary(JSContext* cx, size_t* length);
1177
1178
typedef bool
1179
(* DOMInstanceClassHasProtoAtDepth)(const Class* instanceClass,
1180
                                    uint32_t protoID, uint32_t depth);
1181
struct JSDOMCallbacks {
1182
    DOMInstanceClassHasProtoAtDepth instanceClassMatchesProto;
1183
};
1184
typedef struct JSDOMCallbacks DOMCallbacks;
1185
1186
extern JS_FRIEND_API(void)
1187
SetDOMCallbacks(JSContext* cx, const DOMCallbacks* callbacks);
1188
1189
extern JS_FRIEND_API(const DOMCallbacks*)
1190
GetDOMCallbacks(JSContext* cx);
1191
1192
extern JS_FRIEND_API(JSObject*)
1193
GetTestingFunctions(JSContext* cx);
1194
1195
/**
1196
 * Helper to convert FreeOp to JSFreeOp when the definition of FreeOp is not
1197
 * available and the compiler does not know that FreeOp inherits from
1198
 * JSFreeOp.
1199
 */
1200
inline JSFreeOp*
1201
CastToJSFreeOp(FreeOp* fop)
1202
{
1203
    return reinterpret_cast<JSFreeOp*>(fop);
1204
}
1205
1206
/* Implemented in jsexn.cpp. */
1207
1208
/**
1209
 * Get an error type name from a JSExnType constant.
1210
 * Returns nullptr for invalid arguments and JSEXN_INTERNALERR
1211
 */
1212
extern JS_FRIEND_API(JSFlatString*)
1213
GetErrorTypeName(JSContext* cx, int16_t exnType);
1214
1215
extern JS_FRIEND_API(RegExpShared*)
1216
RegExpToSharedNonInline(JSContext* cx, JS::HandleObject regexp);
1217
1218
/* Implemented in CrossCompartmentWrapper.cpp. */
1219
typedef enum NukeReferencesToWindow {
1220
    NukeWindowReferences,
1221
    DontNukeWindowReferences
1222
} NukeReferencesToWindow;
1223
1224
typedef enum NukeReferencesFromTarget {
1225
    NukeAllReferences,
1226
    NukeIncomingReferences,
1227
} NukeReferencesFromTarget;
1228
1229
/*
1230
 * These filters are designed to be ephemeral stack classes, and thus don't
1231
 * do any rooting or holding of their members.
1232
 */
1233
struct CompartmentFilter {
1234
    virtual bool match(JS::Compartment* c) const = 0;
1235
};
1236
1237
struct AllCompartments : public CompartmentFilter {
1238
    virtual bool match(JS::Compartment* c) const override { return true; }
1239
};
1240
1241
struct ContentCompartmentsOnly : public CompartmentFilter {
1242
    virtual bool match(JS::Compartment* c) const override {
1243
        return !IsSystemCompartment(c);
1244
    }
1245
};
1246
1247
struct ChromeCompartmentsOnly : public CompartmentFilter {
1248
    virtual bool match(JS::Compartment* c) const override {
1249
        return IsSystemCompartment(c);
1250
    }
1251
};
1252
1253
struct SingleCompartment : public CompartmentFilter {
1254
    JS::Compartment* ours;
1255
    explicit SingleCompartment(JS::Compartment* c) : ours(c) {}
1256
    virtual bool match(JS::Compartment* c) const override { return c == ours; }
1257
};
1258
1259
struct CompartmentsWithPrincipals : public CompartmentFilter {
1260
    JSPrincipals* principals;
1261
    explicit CompartmentsWithPrincipals(JSPrincipals* p) : principals(p) {}
1262
    virtual bool match(JS::Compartment* c) const override {
1263
        return JS_GetCompartmentPrincipals(c) == principals;
1264
    }
1265
};
1266
1267
extern JS_FRIEND_API(bool)
1268
NukeCrossCompartmentWrappers(JSContext* cx,
1269
                             const CompartmentFilter& sourceFilter,
1270
                             JS::Compartment* target,
1271
                             NukeReferencesToWindow nukeReferencesToWindow,
1272
                             NukeReferencesFromTarget nukeReferencesFromTarget);
1273
1274
/* Specify information about DOMProxy proxies in the DOM, for use by ICs. */
1275
1276
/*
1277
 * The DOMProxyShadowsCheck function will be called to check if the property for
1278
 * id should be gotten from the prototype, or if there is an own property that
1279
 * shadows it.
1280
 * * If ShadowsViaDirectExpando is returned, then the slot at
1281
 *   listBaseExpandoSlot contains an expando object which has the property in
1282
 *   question.
1283
 * * If ShadowsViaIndirectExpando is returned, then the slot at
1284
 *   listBaseExpandoSlot contains a private pointer to an ExpandoAndGeneration
1285
 *   and the expando object in the ExpandoAndGeneration has the property in
1286
 *   question.
1287
 * * If DoesntShadow is returned then the slot at listBaseExpandoSlot should
1288
 *   either be undefined or point to an expando object that would contain the
1289
 *   own property.
1290
 * * If DoesntShadowUnique is returned then the slot at listBaseExpandoSlot
1291
 *   should contain a private pointer to a ExpandoAndGeneration, which contains
1292
 *   a JS::Value that should either be undefined or point to an expando object,
1293
 *   and a uint64 value. If that value changes then the IC for getting a
1294
 *   property will be invalidated.
1295
 * * If Shadows is returned, that means the property is an own property of the
1296
 *   proxy but doesn't live on the expando object.
1297
 */
1298
1299
struct ExpandoAndGeneration {
1300
  ExpandoAndGeneration()
1301
    : expando(JS::UndefinedValue()),
1302
      generation(0)
1303
  {}
1304
1305
  void OwnerUnlinked()
1306
  {
1307
      ++generation;
1308
  }
1309
1310
  static size_t offsetOfExpando()
1311
0
  {
1312
0
      return offsetof(ExpandoAndGeneration, expando);
1313
0
  }
1314
1315
  static size_t offsetOfGeneration()
1316
0
  {
1317
0
      return offsetof(ExpandoAndGeneration, generation);
1318
0
  }
1319
1320
  JS::Heap<JS::Value> expando;
1321
  uint64_t generation;
1322
};
1323
1324
typedef enum DOMProxyShadowsResult {
1325
  ShadowCheckFailed,
1326
  Shadows,
1327
  DoesntShadow,
1328
  DoesntShadowUnique,
1329
  ShadowsViaDirectExpando,
1330
  ShadowsViaIndirectExpando
1331
} DOMProxyShadowsResult;
1332
typedef DOMProxyShadowsResult
1333
(* DOMProxyShadowsCheck)(JSContext* cx, JS::HandleObject object, JS::HandleId id);
1334
JS_FRIEND_API(void)
1335
SetDOMProxyInformation(const void* domProxyHandlerFamily,
1336
                       DOMProxyShadowsCheck domProxyShadowsCheck);
1337
1338
const void* GetDOMProxyHandlerFamily();
1339
DOMProxyShadowsCheck GetDOMProxyShadowsCheck();
1340
0
inline bool DOMProxyIsShadowing(DOMProxyShadowsResult result) {
1341
0
    return result == Shadows ||
1342
0
           result == ShadowsViaDirectExpando ||
1343
0
           result == ShadowsViaIndirectExpando;
1344
0
}
1345
1346
// Callbacks and other information for use by the JITs when optimizing accesses
1347
// on xray wrappers.
1348
struct XrayJitInfo {
1349
    // Test whether a proxy handler is a cross compartment xray with no
1350
    // security checks.
1351
    bool (*isCrossCompartmentXray)(const BaseProxyHandler* handler);
1352
1353
    // Test whether xrays in |obj|'s compartment have expandos of their own,
1354
    // instead of sharing them with Xrays from other compartments.
1355
    bool (*compartmentHasExclusiveExpandos)(JSObject* obj);
1356
1357
    // Proxy reserved slot used by xrays in sandboxes to store their holder
1358
    // object.
1359
    size_t xrayHolderSlot;
1360
1361
    // Reserved slot used by xray holders to store the xray's expando object.
1362
    size_t holderExpandoSlot;
1363
1364
    // Reserved slot used by xray expandos to store a custom prototype.
1365
    size_t expandoProtoSlot;
1366
};
1367
1368
JS_FRIEND_API(void)
1369
SetXrayJitInfo(XrayJitInfo* info);
1370
1371
XrayJitInfo*
1372
GetXrayJitInfo();
1373
1374
/* Implemented in jsdate.cpp. */
1375
1376
/** Detect whether the internal date value is NaN. */
1377
extern JS_FRIEND_API(bool)
1378
DateIsValid(JSContext* cx, JS::HandleObject obj, bool* isValid);
1379
1380
extern JS_FRIEND_API(bool)
1381
DateGetMsecSinceEpoch(JSContext* cx, JS::HandleObject obj, double* msecSinceEpoch);
1382
1383
} /* namespace js */
1384
1385
typedef enum JSErrNum {
1386
#define MSG_DEF(name, count, exception, format) \
1387
    name,
1388
#include "js.msg"
1389
#undef MSG_DEF
1390
    JSErr_Limit
1391
} JSErrNum;
1392
1393
namespace js {
1394
1395
/* Implemented in vm/JSContext.cpp. */
1396
1397
extern JS_FRIEND_API(const JSErrorFormatString*)
1398
GetErrorMessage(void* userRef, const unsigned errorNumber);
1399
1400
struct MOZ_STACK_CLASS JS_FRIEND_API(ErrorReport)
1401
{
1402
    explicit ErrorReport(JSContext* cx);
1403
    ~ErrorReport();
1404
1405
    enum SniffingBehavior {
1406
        WithSideEffects,
1407
        NoSideEffects
1408
    };
1409
1410
    /**
1411
     * Generate a JSErrorReport from the provided thrown value.
1412
     *
1413
     * If the value is a (possibly wrapped) Error object, the JSErrorReport will
1414
     * be exactly initialized from the Error object's information, without
1415
     * observable side effects. (The Error object's JSErrorReport is reused, if
1416
     * it has one.)
1417
     *
1418
     * Otherwise various attempts are made to derive JSErrorReport information
1419
     * from |exn| and from the current execution state.  This process is
1420
     * *definitely* inconsistent with any standard, and particulars of the
1421
     * behavior implemented here generally shouldn't be relied upon.
1422
     *
1423
     * If the value of |sniffingBehavior| is |WithSideEffects|, some of these
1424
     * attempts *may* invoke user-configurable behavior when |exn| is an object:
1425
     * converting |exn| to a string, detecting and getting properties on |exn|,
1426
     * accessing |exn|'s prototype chain, and others are possible.  Users *must*
1427
     * tolerate |ErrorReport::init| potentially having arbitrary effects.  Any
1428
     * exceptions thrown by these operations will be caught and silently
1429
     * ignored, and "default" values will be substituted into the JSErrorReport.
1430
     *
1431
     * But if the value of |sniffingBehavior| is |NoSideEffects|, these attempts
1432
     * *will not* invoke any observable side effects.  The JSErrorReport will
1433
     * simply contain fewer, less precise details.
1434
     *
1435
     * Unlike some functions involved in error handling, this function adheres
1436
     * to the usual JSAPI return value error behavior.
1437
     */
1438
    bool init(JSContext* cx, JS::HandleValue exn,
1439
              SniffingBehavior sniffingBehavior);
1440
1441
    JSErrorReport* report()
1442
    {
1443
        return reportp;
1444
    }
1445
1446
    const JS::ConstUTF8CharsZ toStringResult()
1447
    {
1448
        return toStringResult_;
1449
    }
1450
1451
  private:
1452
    // More or less an equivalent of JS_ReportErrorNumber/js::ReportErrorNumberVA
1453
    // but fills in an ErrorReport instead of reporting it.  Uses varargs to
1454
    // make it simpler to call js::ExpandErrorArgumentsVA.
1455
    //
1456
    // Returns false if we fail to actually populate the ErrorReport
1457
    // for some reason (probably out of memory).
1458
    bool populateUncaughtExceptionReportUTF8(JSContext* cx, ...);
1459
    bool populateUncaughtExceptionReportUTF8VA(JSContext* cx, va_list ap);
1460
1461
    // Reports exceptions from add-on scopes to telemetry.
1462
    void ReportAddonExceptionToTelemetry(JSContext* cx);
1463
1464
    // We may have a provided JSErrorReport, so need a way to represent that.
1465
    JSErrorReport* reportp;
1466
1467
    // Or we may need to synthesize a JSErrorReport one of our own.
1468
    JSErrorReport ownedReport;
1469
1470
    // And we have a string to maybe keep alive that has pointers into
1471
    // it from ownedReport.
1472
    JS::RootedString str;
1473
1474
    // And keep its chars alive too.
1475
    JS::AutoStableStringChars strChars;
1476
1477
    // And we need to root our exception value.
1478
    JS::RootedObject exnObject;
1479
1480
    // And for our filename.
1481
    JS::UniqueChars filename;
1482
1483
    // We may have a result of error.toString().
1484
    // FIXME: We should not call error.toString(), since it could have side
1485
    //        effect (see bug 633623).
1486
    JS::ConstUTF8CharsZ toStringResult_;
1487
    JS::UniqueChars toStringResultBytesStorage;
1488
};
1489
1490
/* Implemented in vm/StructuredClone.cpp. */
1491
extern JS_FRIEND_API(uint64_t)
1492
GetSCOffset(JSStructuredCloneWriter* writer);
1493
1494
namespace Scalar {
1495
1496
/**
1497
 * Scalar types that can appear in typed arrays and typed objects.  The enum
1498
 * values must to be kept in sync with the JS_SCALARTYPEREPR_ constants, as
1499
 * well as the TypedArrayObject::classes and TypedArrayObject::protoClasses
1500
 * definitions.
1501
 */
1502
enum Type {
1503
    Int8 = 0,
1504
    Uint8,
1505
    Int16,
1506
    Uint16,
1507
    Int32,
1508
    Uint32,
1509
    Float32,
1510
    Float64,
1511
1512
    /**
1513
     * Special type that is a uint8_t, but assignments are clamped to [0, 256).
1514
     * Treat the raw data type as a uint8_t.
1515
     */
1516
    Uint8Clamped,
1517
1518
    /**
1519
     * Types that don't have their own TypedArray equivalent, for now.
1520
     */
1521
    MaxTypedArrayViewType,
1522
1523
    Int64,
1524
};
1525
1526
static inline size_t
1527
byteSize(Type atype)
1528
0
{
1529
0
    switch (atype) {
1530
0
      case Int8:
1531
0
      case Uint8:
1532
0
      case Uint8Clamped:
1533
0
        return 1;
1534
0
      case Int16:
1535
0
      case Uint16:
1536
0
        return 2;
1537
0
      case Int32:
1538
0
      case Uint32:
1539
0
      case Float32:
1540
0
        return 4;
1541
0
      case Int64:
1542
0
      case Float64:
1543
0
        return 8;
1544
0
        return 16;
1545
0
      default:
1546
0
        MOZ_CRASH("invalid scalar type");
1547
0
    }
1548
0
}
Unexecuted instantiation: Unified_cpp_js_ipc0.cpp:js::Scalar::byteSize(js::Scalar::Type)
Unexecuted instantiation: CTypes.cpp:js::Scalar::byteSize(js::Scalar::Type)
Unexecuted instantiation: Library.cpp:js::Scalar::byteSize(js::Scalar::Type)
Unexecuted instantiation: StoreBuffer.cpp:js::Scalar::byteSize(js::Scalar::Type)
Unexecuted instantiation: jsutil.cpp:js::Scalar::byteSize(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src0.cpp:js::Scalar::byteSize(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src1.cpp:js::Scalar::byteSize(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src10.cpp:js::Scalar::byteSize(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src11.cpp:js::Scalar::byteSize(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src12.cpp:js::Scalar::byteSize(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src14.cpp:js::Scalar::byteSize(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src15.cpp:js::Scalar::byteSize(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src17.cpp:js::Scalar::byteSize(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src18.cpp:js::Scalar::byteSize(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src19.cpp:js::Scalar::byteSize(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src2.cpp:js::Scalar::byteSize(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src20.cpp:js::Scalar::byteSize(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src21.cpp:js::Scalar::byteSize(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src22.cpp:js::Scalar::byteSize(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src23.cpp:js::Scalar::byteSize(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src24.cpp:js::Scalar::byteSize(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src25.cpp:js::Scalar::byteSize(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src26.cpp:js::Scalar::byteSize(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src27.cpp:js::Scalar::byteSize(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src28.cpp:js::Scalar::byteSize(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src29.cpp:js::Scalar::byteSize(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src3.cpp:js::Scalar::byteSize(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src30.cpp:js::Scalar::byteSize(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src31.cpp:js::Scalar::byteSize(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src32.cpp:js::Scalar::byteSize(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src33.cpp:js::Scalar::byteSize(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src34.cpp:js::Scalar::byteSize(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src35.cpp:js::Scalar::byteSize(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src36.cpp:js::Scalar::byteSize(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src37.cpp:js::Scalar::byteSize(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src38.cpp:js::Scalar::byteSize(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src39.cpp:js::Scalar::byteSize(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src4.cpp:js::Scalar::byteSize(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src40.cpp:js::Scalar::byteSize(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src41.cpp:js::Scalar::byteSize(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src42.cpp:js::Scalar::byteSize(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src43.cpp:js::Scalar::byteSize(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src44.cpp:js::Scalar::byteSize(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src45.cpp:js::Scalar::byteSize(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src5.cpp:js::Scalar::byteSize(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src6.cpp:js::Scalar::byteSize(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src7.cpp:js::Scalar::byteSize(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src8.cpp:js::Scalar::byteSize(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src9.cpp:js::Scalar::byteSize(js::Scalar::Type)
Unexecuted instantiation: RegExp.cpp:js::Scalar::byteSize(js::Scalar::Type)
Unexecuted instantiation: BinSource-auto.cpp:js::Scalar::byteSize(js::Scalar::Type)
Unexecuted instantiation: BinSource.cpp:js::Scalar::byteSize(js::Scalar::Type)
Unexecuted instantiation: BinToken.cpp:js::Scalar::byteSize(js::Scalar::Type)
Unexecuted instantiation: BinTokenReaderBase.cpp:js::Scalar::byteSize(js::Scalar::Type)
Unexecuted instantiation: BinTokenReaderMultipart.cpp:js::Scalar::byteSize(js::Scalar::Type)
Unexecuted instantiation: BinTokenReaderTester.cpp:js::Scalar::byteSize(js::Scalar::Type)
Unexecuted instantiation: Parser.cpp:js::Scalar::byteSize(js::Scalar::Type)
Unexecuted instantiation: Disassembler-x86-shared.cpp:js::Scalar::byteSize(js::Scalar::Type)
Unexecuted instantiation: jsmath.cpp:js::Scalar::byteSize(js::Scalar::Type)
Unexecuted instantiation: Interpreter.cpp:js::Scalar::byteSize(js::Scalar::Type)
Unexecuted instantiation: VTuneWrapper.cpp:js::Scalar::byteSize(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src13.cpp:js::Scalar::byteSize(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src16.cpp:js::Scalar::byteSize(js::Scalar::Type)
1549
1550
static inline bool
1551
0
isSignedIntType(Type atype) {
1552
0
    switch (atype) {
1553
0
      case Int8:
1554
0
      case Int16:
1555
0
      case Int32:
1556
0
      case Int64:
1557
0
        return true;
1558
0
      case Uint8:
1559
0
      case Uint8Clamped:
1560
0
      case Uint16:
1561
0
      case Uint32:
1562
0
      case Float32:
1563
0
      case Float64:
1564
0
        return false;
1565
0
      default:
1566
0
        MOZ_CRASH("invalid scalar type");
1567
0
    }
1568
0
}
Unexecuted instantiation: Unified_cpp_js_ipc0.cpp:js::Scalar::isSignedIntType(js::Scalar::Type)
Unexecuted instantiation: CTypes.cpp:js::Scalar::isSignedIntType(js::Scalar::Type)
Unexecuted instantiation: Library.cpp:js::Scalar::isSignedIntType(js::Scalar::Type)
Unexecuted instantiation: StoreBuffer.cpp:js::Scalar::isSignedIntType(js::Scalar::Type)
Unexecuted instantiation: jsutil.cpp:js::Scalar::isSignedIntType(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src0.cpp:js::Scalar::isSignedIntType(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src1.cpp:js::Scalar::isSignedIntType(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src10.cpp:js::Scalar::isSignedIntType(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src11.cpp:js::Scalar::isSignedIntType(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src12.cpp:js::Scalar::isSignedIntType(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src14.cpp:js::Scalar::isSignedIntType(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src15.cpp:js::Scalar::isSignedIntType(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src17.cpp:js::Scalar::isSignedIntType(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src18.cpp:js::Scalar::isSignedIntType(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src19.cpp:js::Scalar::isSignedIntType(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src2.cpp:js::Scalar::isSignedIntType(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src20.cpp:js::Scalar::isSignedIntType(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src21.cpp:js::Scalar::isSignedIntType(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src22.cpp:js::Scalar::isSignedIntType(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src23.cpp:js::Scalar::isSignedIntType(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src24.cpp:js::Scalar::isSignedIntType(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src25.cpp:js::Scalar::isSignedIntType(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src26.cpp:js::Scalar::isSignedIntType(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src27.cpp:js::Scalar::isSignedIntType(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src28.cpp:js::Scalar::isSignedIntType(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src29.cpp:js::Scalar::isSignedIntType(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src3.cpp:js::Scalar::isSignedIntType(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src30.cpp:js::Scalar::isSignedIntType(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src31.cpp:js::Scalar::isSignedIntType(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src32.cpp:js::Scalar::isSignedIntType(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src33.cpp:js::Scalar::isSignedIntType(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src34.cpp:js::Scalar::isSignedIntType(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src35.cpp:js::Scalar::isSignedIntType(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src36.cpp:js::Scalar::isSignedIntType(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src37.cpp:js::Scalar::isSignedIntType(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src38.cpp:js::Scalar::isSignedIntType(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src39.cpp:js::Scalar::isSignedIntType(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src4.cpp:js::Scalar::isSignedIntType(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src40.cpp:js::Scalar::isSignedIntType(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src41.cpp:js::Scalar::isSignedIntType(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src42.cpp:js::Scalar::isSignedIntType(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src43.cpp:js::Scalar::isSignedIntType(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src44.cpp:js::Scalar::isSignedIntType(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src45.cpp:js::Scalar::isSignedIntType(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src5.cpp:js::Scalar::isSignedIntType(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src6.cpp:js::Scalar::isSignedIntType(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src7.cpp:js::Scalar::isSignedIntType(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src8.cpp:js::Scalar::isSignedIntType(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src9.cpp:js::Scalar::isSignedIntType(js::Scalar::Type)
Unexecuted instantiation: RegExp.cpp:js::Scalar::isSignedIntType(js::Scalar::Type)
Unexecuted instantiation: BinSource-auto.cpp:js::Scalar::isSignedIntType(js::Scalar::Type)
Unexecuted instantiation: BinSource.cpp:js::Scalar::isSignedIntType(js::Scalar::Type)
Unexecuted instantiation: BinToken.cpp:js::Scalar::isSignedIntType(js::Scalar::Type)
Unexecuted instantiation: BinTokenReaderBase.cpp:js::Scalar::isSignedIntType(js::Scalar::Type)
Unexecuted instantiation: BinTokenReaderMultipart.cpp:js::Scalar::isSignedIntType(js::Scalar::Type)
Unexecuted instantiation: BinTokenReaderTester.cpp:js::Scalar::isSignedIntType(js::Scalar::Type)
Unexecuted instantiation: Parser.cpp:js::Scalar::isSignedIntType(js::Scalar::Type)
Unexecuted instantiation: Disassembler-x86-shared.cpp:js::Scalar::isSignedIntType(js::Scalar::Type)
Unexecuted instantiation: jsmath.cpp:js::Scalar::isSignedIntType(js::Scalar::Type)
Unexecuted instantiation: Interpreter.cpp:js::Scalar::isSignedIntType(js::Scalar::Type)
Unexecuted instantiation: VTuneWrapper.cpp:js::Scalar::isSignedIntType(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src13.cpp:js::Scalar::isSignedIntType(js::Scalar::Type)
Unexecuted instantiation: Unified_cpp_js_src16.cpp:js::Scalar::isSignedIntType(js::Scalar::Type)
1569
1570
} /* namespace Scalar */
1571
} /* namespace js */
1572
1573
/*
1574
 * Create a new typed array with nelements elements.
1575
 *
1576
 * These functions (except the WithBuffer variants) fill in the array with zeros.
1577
 */
1578
1579
extern JS_FRIEND_API(JSObject*)
1580
JS_NewInt8Array(JSContext* cx, uint32_t nelements);
1581
extern JS_FRIEND_API(JSObject*)
1582
JS_NewUint8Array(JSContext* cx, uint32_t nelements);
1583
extern JS_FRIEND_API(JSObject*)
1584
JS_NewUint8ClampedArray(JSContext* cx, uint32_t nelements);
1585
extern JS_FRIEND_API(JSObject*)
1586
JS_NewInt16Array(JSContext* cx, uint32_t nelements);
1587
extern JS_FRIEND_API(JSObject*)
1588
JS_NewUint16Array(JSContext* cx, uint32_t nelements);
1589
extern JS_FRIEND_API(JSObject*)
1590
JS_NewInt32Array(JSContext* cx, uint32_t nelements);
1591
extern JS_FRIEND_API(JSObject*)
1592
JS_NewUint32Array(JSContext* cx, uint32_t nelements);
1593
extern JS_FRIEND_API(JSObject*)
1594
JS_NewFloat32Array(JSContext* cx, uint32_t nelements);
1595
extern JS_FRIEND_API(JSObject*)
1596
JS_NewFloat64Array(JSContext* cx, uint32_t nelements);
1597
1598
/*
1599
 * Create a new typed array and copy in values from the given object. The
1600
 * object is used as if it were an array; that is, the new array (if
1601
 * successfully created) will have length given by array.length, and its
1602
 * elements will be those specified by array[0], array[1], and so on, after
1603
 * conversion to the typed array element type.
1604
 */
1605
1606
extern JS_FRIEND_API(JSObject*)
1607
JS_NewInt8ArrayFromArray(JSContext* cx, JS::HandleObject array);
1608
extern JS_FRIEND_API(JSObject*)
1609
JS_NewUint8ArrayFromArray(JSContext* cx, JS::HandleObject array);
1610
extern JS_FRIEND_API(JSObject*)
1611
JS_NewUint8ClampedArrayFromArray(JSContext* cx, JS::HandleObject array);
1612
extern JS_FRIEND_API(JSObject*)
1613
JS_NewInt16ArrayFromArray(JSContext* cx, JS::HandleObject array);
1614
extern JS_FRIEND_API(JSObject*)
1615
JS_NewUint16ArrayFromArray(JSContext* cx, JS::HandleObject array);
1616
extern JS_FRIEND_API(JSObject*)
1617
JS_NewInt32ArrayFromArray(JSContext* cx, JS::HandleObject array);
1618
extern JS_FRIEND_API(JSObject*)
1619
JS_NewUint32ArrayFromArray(JSContext* cx, JS::HandleObject array);
1620
extern JS_FRIEND_API(JSObject*)
1621
JS_NewFloat32ArrayFromArray(JSContext* cx, JS::HandleObject array);
1622
extern JS_FRIEND_API(JSObject*)
1623
JS_NewFloat64ArrayFromArray(JSContext* cx, JS::HandleObject array);
1624
1625
/*
1626
 * Create a new typed array using the given ArrayBuffer or
1627
 * SharedArrayBuffer for storage.  The length value is optional; if -1
1628
 * is passed, enough elements to use up the remainder of the byte
1629
 * array is used as the default value.
1630
 */
1631
1632
extern JS_FRIEND_API(JSObject*)
1633
JS_NewInt8ArrayWithBuffer(JSContext* cx, JS::HandleObject arrayBuffer,
1634
                          uint32_t byteOffset, int32_t length);
1635
extern JS_FRIEND_API(JSObject*)
1636
JS_NewUint8ArrayWithBuffer(JSContext* cx, JS::HandleObject arrayBuffer,
1637
                           uint32_t byteOffset, int32_t length);
1638
extern JS_FRIEND_API(JSObject*)
1639
JS_NewUint8ClampedArrayWithBuffer(JSContext* cx, JS::HandleObject arrayBuffer,
1640
                                  uint32_t byteOffset, int32_t length);
1641
extern JS_FRIEND_API(JSObject*)
1642
JS_NewInt16ArrayWithBuffer(JSContext* cx, JS::HandleObject arrayBuffer,
1643
                           uint32_t byteOffset, int32_t length);
1644
extern JS_FRIEND_API(JSObject*)
1645
JS_NewUint16ArrayWithBuffer(JSContext* cx, JS::HandleObject arrayBuffer,
1646
                            uint32_t byteOffset, int32_t length);
1647
extern JS_FRIEND_API(JSObject*)
1648
JS_NewInt32ArrayWithBuffer(JSContext* cx, JS::HandleObject arrayBuffer,
1649
                           uint32_t byteOffset, int32_t length);
1650
extern JS_FRIEND_API(JSObject*)
1651
JS_NewUint32ArrayWithBuffer(JSContext* cx, JS::HandleObject arrayBuffer,
1652
                            uint32_t byteOffset, int32_t length);
1653
extern JS_FRIEND_API(JSObject*)
1654
JS_NewFloat32ArrayWithBuffer(JSContext* cx, JS::HandleObject arrayBuffer,
1655
                             uint32_t byteOffset, int32_t length);
1656
extern JS_FRIEND_API(JSObject*)
1657
JS_NewFloat64ArrayWithBuffer(JSContext* cx, JS::HandleObject arrayBuffer,
1658
                             uint32_t byteOffset, int32_t length);
1659
1660
/**
1661
 * Create a new SharedArrayBuffer with the given byte length.  This
1662
 * may only be called if
1663
 * JS::RealmCreationOptionsRef(cx).getSharedMemoryAndAtomicsEnabled() is
1664
 * true.
1665
 */
1666
extern JS_FRIEND_API(JSObject*)
1667
JS_NewSharedArrayBuffer(JSContext* cx, uint32_t nbytes);
1668
1669
/**
1670
 * Create a new ArrayBuffer with the given byte length.
1671
 */
1672
extern JS_FRIEND_API(JSObject*)
1673
JS_NewArrayBuffer(JSContext* cx, uint32_t nbytes);
1674
1675
/**
1676
 * Check whether obj supports JS_GetTypedArray* APIs. Note that this may return
1677
 * false if a security wrapper is encountered that denies the unwrapping. If
1678
 * this test or one of the JS_Is*Array tests succeeds, then it is safe to call
1679
 * the various accessor JSAPI calls defined below.
1680
 */
1681
extern JS_FRIEND_API(bool)
1682
JS_IsTypedArrayObject(JSObject* obj);
1683
1684
/**
1685
 * Check whether obj supports JS_GetArrayBufferView* APIs. Note that this may
1686
 * return false if a security wrapper is encountered that denies the
1687
 * unwrapping. If this test or one of the more specific tests succeeds, then it
1688
 * is safe to call the various ArrayBufferView accessor JSAPI calls defined
1689
 * below.
1690
 */
1691
extern JS_FRIEND_API(bool)
1692
JS_IsArrayBufferViewObject(JSObject* obj);
1693
1694
/*
1695
 * Test for specific typed array types (ArrayBufferView subtypes)
1696
 */
1697
1698
extern JS_FRIEND_API(bool)
1699
JS_IsInt8Array(JSObject* obj);
1700
extern JS_FRIEND_API(bool)
1701
JS_IsUint8Array(JSObject* obj);
1702
extern JS_FRIEND_API(bool)
1703
JS_IsUint8ClampedArray(JSObject* obj);
1704
extern JS_FRIEND_API(bool)
1705
JS_IsInt16Array(JSObject* obj);
1706
extern JS_FRIEND_API(bool)
1707
JS_IsUint16Array(JSObject* obj);
1708
extern JS_FRIEND_API(bool)
1709
JS_IsInt32Array(JSObject* obj);
1710
extern JS_FRIEND_API(bool)
1711
JS_IsUint32Array(JSObject* obj);
1712
extern JS_FRIEND_API(bool)
1713
JS_IsFloat32Array(JSObject* obj);
1714
extern JS_FRIEND_API(bool)
1715
JS_IsFloat64Array(JSObject* obj);
1716
1717
/**
1718
 * Return the isShared flag of a typed array, which denotes whether
1719
 * the underlying buffer is a SharedArrayBuffer.
1720
 *
1721
 * |obj| must have passed a JS_IsTypedArrayObject/JS_Is*Array test, or somehow
1722
 * be known that it would pass such a test: it is a typed array or a wrapper of
1723
 * a typed array, and the unwrapping will succeed.
1724
 */
1725
extern JS_FRIEND_API(bool)
1726
JS_GetTypedArraySharedness(JSObject* obj);
1727
1728
/*
1729
 * Test for specific typed array types (ArrayBufferView subtypes) and return
1730
 * the unwrapped object if so, else nullptr.  Never throws.
1731
 */
1732
1733
namespace js {
1734
1735
extern JS_FRIEND_API(JSObject*)
1736
UnwrapInt8Array(JSObject* obj);
1737
extern JS_FRIEND_API(JSObject*)
1738
UnwrapUint8Array(JSObject* obj);
1739
extern JS_FRIEND_API(JSObject*)
1740
UnwrapUint8ClampedArray(JSObject* obj);
1741
extern JS_FRIEND_API(JSObject*)
1742
UnwrapInt16Array(JSObject* obj);
1743
extern JS_FRIEND_API(JSObject*)
1744
UnwrapUint16Array(JSObject* obj);
1745
extern JS_FRIEND_API(JSObject*)
1746
UnwrapInt32Array(JSObject* obj);
1747
extern JS_FRIEND_API(JSObject*)
1748
UnwrapUint32Array(JSObject* obj);
1749
extern JS_FRIEND_API(JSObject*)
1750
UnwrapFloat32Array(JSObject* obj);
1751
extern JS_FRIEND_API(JSObject*)
1752
UnwrapFloat64Array(JSObject* obj);
1753
1754
extern JS_FRIEND_API(JSObject*)
1755
UnwrapArrayBuffer(JSObject* obj);
1756
1757
extern JS_FRIEND_API(JSObject*)
1758
UnwrapArrayBufferView(JSObject* obj);
1759
1760
extern JS_FRIEND_API(JSObject*)
1761
UnwrapSharedArrayBuffer(JSObject* obj);
1762
1763
extern JS_FRIEND_API(JSObject*)
1764
UnwrapReadableStream(JSObject* obj);
1765
1766
1767
namespace detail {
1768
1769
extern JS_FRIEND_DATA(const Class* const) Int8ArrayClassPtr;
1770
extern JS_FRIEND_DATA(const Class* const) Uint8ArrayClassPtr;
1771
extern JS_FRIEND_DATA(const Class* const) Uint8ClampedArrayClassPtr;
1772
extern JS_FRIEND_DATA(const Class* const) Int16ArrayClassPtr;
1773
extern JS_FRIEND_DATA(const Class* const) Uint16ArrayClassPtr;
1774
extern JS_FRIEND_DATA(const Class* const) Int32ArrayClassPtr;
1775
extern JS_FRIEND_DATA(const Class* const) Uint32ArrayClassPtr;
1776
extern JS_FRIEND_DATA(const Class* const) Float32ArrayClassPtr;
1777
extern JS_FRIEND_DATA(const Class* const) Float64ArrayClassPtr;
1778
1779
const size_t TypedArrayLengthSlot = 1;
1780
1781
} // namespace detail
1782
1783
#define JS_DEFINE_DATA_AND_LENGTH_ACCESSOR(Type, type) \
1784
inline void \
1785
Get ## Type ## ArrayLengthAndData(JSObject* obj, uint32_t* length, bool* isSharedMemory, type** data) \
1786
{ \
1787
    MOZ_ASSERT(GetObjectClass(obj) == detail::Type ## ArrayClassPtr); \
1788
    const JS::Value& lenSlot = GetReservedSlot(obj, detail::TypedArrayLengthSlot); \
1789
    *length = mozilla::AssertedCast<uint32_t>(lenSlot.toInt32()); \
1790
    *isSharedMemory = JS_GetTypedArraySharedness(obj); \
1791
    *data = static_cast<type*>(GetObjectPrivate(obj)); \
1792
}
1793
1794
JS_DEFINE_DATA_AND_LENGTH_ACCESSOR(Int8, int8_t)
1795
JS_DEFINE_DATA_AND_LENGTH_ACCESSOR(Uint8, uint8_t)
1796
JS_DEFINE_DATA_AND_LENGTH_ACCESSOR(Uint8Clamped, uint8_t)
1797
JS_DEFINE_DATA_AND_LENGTH_ACCESSOR(Int16, int16_t)
1798
JS_DEFINE_DATA_AND_LENGTH_ACCESSOR(Uint16, uint16_t)
1799
JS_DEFINE_DATA_AND_LENGTH_ACCESSOR(Int32, int32_t)
1800
JS_DEFINE_DATA_AND_LENGTH_ACCESSOR(Uint32, uint32_t)
1801
JS_DEFINE_DATA_AND_LENGTH_ACCESSOR(Float32, float)
1802
JS_DEFINE_DATA_AND_LENGTH_ACCESSOR(Float64, double)
1803
1804
#undef JS_DEFINE_DATA_AND_LENGTH_ACCESSOR
1805
1806
// This one isn't inlined because it's rather tricky (by dint of having to deal
1807
// with a dozen-plus classes and varying slot layouts.
1808
extern JS_FRIEND_API(void)
1809
GetArrayBufferViewLengthAndData(JSObject* obj, uint32_t* length, bool* isSharedMemory, uint8_t** data);
1810
1811
// This one isn't inlined because there are a bunch of different ArrayBuffer
1812
// classes that would have to be individually handled here.
1813
//
1814
// There is an isShared out argument for API consistency (eases use from DOM).
1815
// It will always be set to false.
1816
extern JS_FRIEND_API(void)
1817
GetArrayBufferLengthAndData(JSObject* obj, uint32_t* length, bool* isSharedMemory, uint8_t** data);
1818
1819
// Ditto for SharedArrayBuffer.
1820
//
1821
// There is an isShared out argument for API consistency (eases use from DOM).
1822
// It will always be set to true.
1823
extern JS_FRIEND_API(void)
1824
GetSharedArrayBufferLengthAndData(JSObject* obj, uint32_t* length, bool* isSharedMemory, uint8_t** data);
1825
1826
} // namespace js
1827
1828
JS_FRIEND_API(uint8_t*)
1829
JS_GetSharedArrayBufferData(JSObject* obj, bool* isSharedMemory, const JS::AutoRequireNoGC&);
1830
1831
/*
1832
 * Unwrap Typed arrays all at once. Return nullptr without throwing if the
1833
 * object cannot be viewed as the correct typed array, or the typed array
1834
 * object on success, filling both outparameters.
1835
 */
1836
extern JS_FRIEND_API(JSObject*)
1837
JS_GetObjectAsInt8Array(JSObject* obj, uint32_t* length, bool* isSharedMemory, int8_t** data);
1838
extern JS_FRIEND_API(JSObject*)
1839
JS_GetObjectAsUint8Array(JSObject* obj, uint32_t* length, bool* isSharedMemory, uint8_t** data);
1840
extern JS_FRIEND_API(JSObject*)
1841
JS_GetObjectAsUint8ClampedArray(JSObject* obj, uint32_t* length, bool* isSharedMemory, uint8_t** data);
1842
extern JS_FRIEND_API(JSObject*)
1843
JS_GetObjectAsInt16Array(JSObject* obj, uint32_t* length, bool* isSharedMemory, int16_t** data);
1844
extern JS_FRIEND_API(JSObject*)
1845
JS_GetObjectAsUint16Array(JSObject* obj, uint32_t* length, bool* isSharedMemory, uint16_t** data);
1846
extern JS_FRIEND_API(JSObject*)
1847
JS_GetObjectAsInt32Array(JSObject* obj, uint32_t* length, bool* isSharedMemory, int32_t** data);
1848
extern JS_FRIEND_API(JSObject*)
1849
JS_GetObjectAsUint32Array(JSObject* obj, uint32_t* length, bool* isSharedMemory, uint32_t** data);
1850
extern JS_FRIEND_API(JSObject*)
1851
JS_GetObjectAsFloat32Array(JSObject* obj, uint32_t* length, bool* isSharedMemory, float** data);
1852
extern JS_FRIEND_API(JSObject*)
1853
JS_GetObjectAsFloat64Array(JSObject* obj, uint32_t* length, bool* isSharedMemory, double** data);
1854
extern JS_FRIEND_API(JSObject*)
1855
JS_GetObjectAsArrayBufferView(JSObject* obj, uint32_t* length, bool* isSharedMemory, uint8_t** data);
1856
1857
/*
1858
 * Unwrap an ArrayBuffer, return nullptr if it's a different type.
1859
 */
1860
extern JS_FRIEND_API(JSObject*)
1861
JS_GetObjectAsArrayBuffer(JSObject* obj, uint32_t* length, uint8_t** data);
1862
1863
/*
1864
 * Get the type of elements in a typed array, or MaxTypedArrayViewType if a DataView.
1865
 *
1866
 * |obj| must have passed a JS_IsArrayBufferView/JS_Is*Array test, or somehow
1867
 * be known that it would pass such a test: it is an ArrayBufferView or a
1868
 * wrapper of an ArrayBufferView, and the unwrapping will succeed.
1869
 */
1870
extern JS_FRIEND_API(js::Scalar::Type)
1871
JS_GetArrayBufferViewType(JSObject* obj);
1872
1873
extern JS_FRIEND_API(js::Scalar::Type)
1874
JS_GetSharedArrayBufferViewType(JSObject* obj);
1875
1876
/*
1877
 * Check whether obj supports the JS_GetArrayBuffer* APIs. Note that this may
1878
 * return false if a security wrapper is encountered that denies the
1879
 * unwrapping. If this test succeeds, then it is safe to call the various
1880
 * accessor JSAPI calls defined below.
1881
 */
1882
extern JS_FRIEND_API(bool)
1883
JS_IsArrayBufferObject(JSObject* obj);
1884
1885
extern JS_FRIEND_API(bool)
1886
JS_IsSharedArrayBufferObject(JSObject* obj);
1887
1888
/**
1889
 * Return the available byte length of an array buffer.
1890
 *
1891
 * |obj| must have passed a JS_IsArrayBufferObject test, or somehow be known
1892
 * that it would pass such a test: it is an ArrayBuffer or a wrapper of an
1893
 * ArrayBuffer, and the unwrapping will succeed.
1894
 */
1895
extern JS_FRIEND_API(uint32_t)
1896
JS_GetArrayBufferByteLength(JSObject* obj);
1897
1898
extern JS_FRIEND_API(uint32_t)
1899
JS_GetSharedArrayBufferByteLength(JSObject* obj);
1900
1901
/**
1902
 * Return true if the arrayBuffer contains any data. This will return false for
1903
 * ArrayBuffer.prototype and detached ArrayBuffers.
1904
 *
1905
 * |obj| must have passed a JS_IsArrayBufferObject test, or somehow be known
1906
 * that it would pass such a test: it is an ArrayBuffer or a wrapper of an
1907
 * ArrayBuffer, and the unwrapping will succeed.
1908
 */
1909
extern JS_FRIEND_API(bool)
1910
JS_ArrayBufferHasData(JSObject* obj);
1911
1912
/**
1913
 * Return a pointer to the start of the data referenced by a typed array. The
1914
 * data is still owned by the typed array, and should not be modified on
1915
 * another thread. Furthermore, the pointer can become invalid on GC (if the
1916
 * data is small and fits inside the array's GC header), so callers must take
1917
 * care not to hold on across anything that could GC.
1918
 *
1919
 * |obj| must have passed a JS_IsArrayBufferObject test, or somehow be known
1920
 * that it would pass such a test: it is an ArrayBuffer or a wrapper of an
1921
 * ArrayBuffer, and the unwrapping will succeed.
1922
 *
1923
 * |*isSharedMemory| will be set to false, the argument is present to simplify
1924
 * its use from code that also interacts with SharedArrayBuffer.
1925
 */
1926
extern JS_FRIEND_API(uint8_t*)
1927
JS_GetArrayBufferData(JSObject* obj, bool* isSharedMemory, const JS::AutoRequireNoGC&);
1928
1929
/**
1930
 * Check whether the obj is ArrayBufferObject and memory mapped. Note that this
1931
 * may return false if a security wrapper is encountered that denies the
1932
 * unwrapping.
1933
 */
1934
extern JS_FRIEND_API(bool)
1935
JS_IsMappedArrayBufferObject(JSObject* obj);
1936
1937
/**
1938
 * Return the number of elements in a typed array.
1939
 *
1940
 * |obj| must have passed a JS_IsTypedArrayObject/JS_Is*Array test, or somehow
1941
 * be known that it would pass such a test: it is a typed array or a wrapper of
1942
 * a typed array, and the unwrapping will succeed.
1943
 */
1944
extern JS_FRIEND_API(uint32_t)
1945
JS_GetTypedArrayLength(JSObject* obj);
1946
1947
/**
1948
 * Return the byte offset from the start of an array buffer to the start of a
1949
 * typed array view.
1950
 *
1951
 * |obj| must have passed a JS_IsTypedArrayObject/JS_Is*Array test, or somehow
1952
 * be known that it would pass such a test: it is a typed array or a wrapper of
1953
 * a typed array, and the unwrapping will succeed.
1954
 */
1955
extern JS_FRIEND_API(uint32_t)
1956
JS_GetTypedArrayByteOffset(JSObject* obj);
1957
1958
/**
1959
 * Return the byte length of a typed array.
1960
 *
1961
 * |obj| must have passed a JS_IsTypedArrayObject/JS_Is*Array test, or somehow
1962
 * be known that it would pass such a test: it is a typed array or a wrapper of
1963
 * a typed array, and the unwrapping will succeed.
1964
 */
1965
extern JS_FRIEND_API(uint32_t)
1966
JS_GetTypedArrayByteLength(JSObject* obj);
1967
1968
/**
1969
 * Check whether obj supports JS_ArrayBufferView* APIs. Note that this may
1970
 * return false if a security wrapper is encountered that denies the
1971
 * unwrapping.
1972
 */
1973
extern JS_FRIEND_API(bool)
1974
JS_IsArrayBufferViewObject(JSObject* obj);
1975
1976
/**
1977
 * More generic name for JS_GetTypedArrayByteLength to cover DataViews as well
1978
 */
1979
extern JS_FRIEND_API(uint32_t)
1980
JS_GetArrayBufferViewByteLength(JSObject* obj);
1981
1982
/**
1983
 * More generic name for JS_GetTypedArrayByteOffset to cover DataViews as well
1984
 */
1985
extern JS_FRIEND_API(uint32_t)
1986
JS_GetArrayBufferViewByteOffset(JSObject* obj);
1987
1988
/*
1989
 * Return a pointer to the start of the data referenced by a typed array. The
1990
 * data is still owned by the typed array, and should not be modified on
1991
 * another thread. Furthermore, the pointer can become invalid on GC (if the
1992
 * data is small and fits inside the array's GC header), so callers must take
1993
 * care not to hold on across anything that could GC.
1994
 *
1995
 * |obj| must have passed a JS_Is*Array test, or somehow be known that it would
1996
 * pass such a test: it is a typed array or a wrapper of a typed array, and the
1997
 * unwrapping will succeed.
1998
 *
1999
 * |*isSharedMemory| will be set to true if the typed array maps a
2000
 * SharedArrayBuffer, otherwise to false.
2001
 */
2002
2003
extern JS_FRIEND_API(int8_t*)
2004
JS_GetInt8ArrayData(JSObject* obj, bool* isSharedMemory, const JS::AutoRequireNoGC&);
2005
extern JS_FRIEND_API(uint8_t*)
2006
JS_GetUint8ArrayData(JSObject* obj, bool* isSharedMemory, const JS::AutoRequireNoGC&);
2007
extern JS_FRIEND_API(uint8_t*)
2008
JS_GetUint8ClampedArrayData(JSObject* obj, bool* isSharedMemory, const JS::AutoRequireNoGC&);
2009
extern JS_FRIEND_API(int16_t*)
2010
JS_GetInt16ArrayData(JSObject* obj, bool* isSharedMemory, const JS::AutoRequireNoGC&);
2011
extern JS_FRIEND_API(uint16_t*)
2012
JS_GetUint16ArrayData(JSObject* obj, bool* isSharedMemory, const JS::AutoRequireNoGC&);
2013
extern JS_FRIEND_API(int32_t*)
2014
JS_GetInt32ArrayData(JSObject* obj, bool* isSharedMemory, const JS::AutoRequireNoGC&);
2015
extern JS_FRIEND_API(uint32_t*)
2016
JS_GetUint32ArrayData(JSObject* obj, bool* isSharedMemory, const JS::AutoRequireNoGC&);
2017
extern JS_FRIEND_API(float*)
2018
JS_GetFloat32ArrayData(JSObject* obj, bool* isSharedMemory, const JS::AutoRequireNoGC&);
2019
extern JS_FRIEND_API(double*)
2020
JS_GetFloat64ArrayData(JSObject* obj, bool* isSharedMemory, const JS::AutoRequireNoGC&);
2021
2022
/**
2023
 * Same as above, but for any kind of ArrayBufferView. Prefer the type-specific
2024
 * versions when possible.
2025
 */
2026
extern JS_FRIEND_API(void*)
2027
JS_GetArrayBufferViewData(JSObject* obj, bool* isSharedMemory, const JS::AutoRequireNoGC&);
2028
2029
/**
2030
 * Return the ArrayBuffer or SharedArrayBuffer underlying an ArrayBufferView.
2031
 * This may return a detached buffer.  |obj| must be an object that would
2032
 * return true for JS_IsArrayBufferViewObject().
2033
 */
2034
extern JS_FRIEND_API(JSObject*)
2035
JS_GetArrayBufferViewBuffer(JSContext* cx, JS::HandleObject obj, bool* isSharedMemory);
2036
2037
/**
2038
 * Detach an ArrayBuffer, causing all associated views to no longer refer to
2039
 * the ArrayBuffer's original attached memory.
2040
 *
2041
 * The |changeData| argument is obsolete and ignored.
2042
 */
2043
extern JS_FRIEND_API(bool)
2044
JS_DetachArrayBuffer(JSContext* cx, JS::HandleObject obj);
2045
2046
/**
2047
 * Check whether the obj is a detached ArrayBufferObject. Note that this may
2048
 * return false if a security wrapper is encountered that denies the
2049
 * unwrapping.
2050
 */
2051
extern JS_FRIEND_API(bool)
2052
JS_IsDetachedArrayBufferObject(JSObject* obj);
2053
2054
/**
2055
 * Check whether obj supports JS_GetDataView* APIs.
2056
 */
2057
JS_FRIEND_API(bool)
2058
JS_IsDataViewObject(JSObject* obj);
2059
2060
/**
2061
 * Create a new DataView using the given buffer for storage. The given buffer
2062
 * must be an ArrayBuffer or SharedArrayBuffer (or a cross-compartment wrapper
2063
 * of either type), and the offset and length must fit within the bounds of the
2064
 * buffer. Currently, nullptr will be returned and an exception will be thrown
2065
 * if these conditions do not hold, but do not depend on that behavior.
2066
 */
2067
JS_FRIEND_API(JSObject*)
2068
JS_NewDataView(JSContext* cx, JS::HandleObject buffer, uint32_t byteOffset, int32_t byteLength);
2069
2070
/**
2071
 * Return the byte offset of a data view into its array buffer. |obj| must be a
2072
 * DataView.
2073
 *
2074
 * |obj| must have passed a JS_IsDataViewObject test, or somehow be known that
2075
 * it would pass such a test: it is a data view or a wrapper of a data view,
2076
 * and the unwrapping will succeed.
2077
 */
2078
JS_FRIEND_API(uint32_t)
2079
JS_GetDataViewByteOffset(JSObject* obj);
2080
2081
/**
2082
 * Return the byte length of a data view.
2083
 *
2084
 * |obj| must have passed a JS_IsDataViewObject test, or somehow be known that
2085
 * it would pass such a test: it is a data view or a wrapper of a data view,
2086
 * and the unwrapping will succeed. If cx is nullptr, then DEBUG builds may be
2087
 * unable to assert when unwrapping should be disallowed.
2088
 */
2089
JS_FRIEND_API(uint32_t)
2090
JS_GetDataViewByteLength(JSObject* obj);
2091
2092
/**
2093
 * Return a pointer to the beginning of the data referenced by a DataView.
2094
 *
2095
 * |obj| must have passed a JS_IsDataViewObject test, or somehow be known that
2096
 * it would pass such a test: it is a data view or a wrapper of a data view,
2097
 * and the unwrapping will succeed. If cx is nullptr, then DEBUG builds may be
2098
 * unable to assert when unwrapping should be disallowed.
2099
 *
2100
 * |*isSharedMemory| will be set to true if the DataView maps a SharedArrayBuffer,
2101
 * otherwise to false.
2102
 */
2103
JS_FRIEND_API(void*)
2104
JS_GetDataViewData(JSObject* obj, bool* isSharedMemory, const JS::AutoRequireNoGC&);
2105
2106
namespace js {
2107
namespace jit {
2108
2109
enum class InlinableNative : uint16_t;
2110
2111
} // namespace jit
2112
} // namespace js
2113
2114
/**
2115
 * A class, expected to be passed by value, which represents the CallArgs for a
2116
 * JSJitGetterOp.
2117
 */
2118
class JSJitGetterCallArgs : protected JS::MutableHandleValue
2119
{
2120
  public:
2121
    explicit JSJitGetterCallArgs(const JS::CallArgs& args)
2122
      : JS::MutableHandleValue(args.rval())
2123
    {}
2124
2125
    explicit JSJitGetterCallArgs(JS::RootedValue* rooted)
2126
      : JS::MutableHandleValue(rooted)
2127
    {}
2128
2129
    JS::MutableHandleValue rval() {
2130
        return *this;
2131
    }
2132
};
2133
2134
/**
2135
 * A class, expected to be passed by value, which represents the CallArgs for a
2136
 * JSJitSetterOp.
2137
 */
2138
class JSJitSetterCallArgs : protected JS::MutableHandleValue
2139
{
2140
  public:
2141
    explicit JSJitSetterCallArgs(const JS::CallArgs& args)
2142
      : JS::MutableHandleValue(args[0])
2143
    {}
2144
2145
    JS::MutableHandleValue operator[](unsigned i) {
2146
        MOZ_ASSERT(i == 0);
2147
        return *this;
2148
    }
2149
2150
    unsigned length() const { return 1; }
2151
2152
    // Add get() or maybe hasDefined() as needed
2153
};
2154
2155
struct JSJitMethodCallArgsTraits;
2156
2157
/**
2158
 * A class, expected to be passed by reference, which represents the CallArgs
2159
 * for a JSJitMethodOp.
2160
 */
2161
class JSJitMethodCallArgs : protected JS::detail::CallArgsBase<JS::detail::NoUsedRval>
2162
{
2163
  private:
2164
    typedef JS::detail::CallArgsBase<JS::detail::NoUsedRval> Base;
2165
    friend struct JSJitMethodCallArgsTraits;
2166
2167
  public:
2168
    explicit JSJitMethodCallArgs(const JS::CallArgs& args) {
2169
        argv_ = args.array();
2170
        argc_ = args.length();
2171
    }
2172
2173
    JS::MutableHandleValue rval() const {
2174
        return Base::rval();
2175
    }
2176
2177
    unsigned length() const { return Base::length(); }
2178
2179
    JS::MutableHandleValue operator[](unsigned i) const {
2180
        return Base::operator[](i);
2181
    }
2182
2183
    bool hasDefined(unsigned i) const {
2184
        return Base::hasDefined(i);
2185
    }
2186
2187
    JSObject& callee() const {
2188
        // We can't use Base::callee() because that will try to poke at
2189
        // this->usedRval_, which we don't have.
2190
        return argv_[-2].toObject();
2191
    }
2192
2193
    JS::HandleValue get(unsigned i) const {
2194
        return Base::get(i);
2195
    }
2196
};
2197
2198
struct JSJitMethodCallArgsTraits
2199
{
2200
    static const size_t offsetOfArgv = offsetof(JSJitMethodCallArgs, argv_);
2201
    static const size_t offsetOfArgc = offsetof(JSJitMethodCallArgs, argc_);
2202
};
2203
2204
typedef bool
2205
(* JSJitGetterOp)(JSContext* cx, JS::HandleObject thisObj,
2206
                  void* specializedThis, JSJitGetterCallArgs args);
2207
typedef bool
2208
(* JSJitSetterOp)(JSContext* cx, JS::HandleObject thisObj,
2209
                  void* specializedThis, JSJitSetterCallArgs args);
2210
typedef bool
2211
(* JSJitMethodOp)(JSContext* cx, JS::HandleObject thisObj,
2212
                  void* specializedThis, const JSJitMethodCallArgs& args);
2213
2214
/**
2215
 * This struct contains metadata passed from the DOM to the JS Engine for JIT
2216
 * optimizations on DOM property accessors. Eventually, this should be made
2217
 * available to general JSAPI users, but we are not currently ready to do so.
2218
 */
2219
struct JSJitInfo {
2220
    enum OpType {
2221
        Getter,
2222
        Setter,
2223
        Method,
2224
        StaticMethod,
2225
        InlinableNative,
2226
        IgnoresReturnValueNative,
2227
        // Must be last
2228
        OpTypeCount
2229
    };
2230
2231
    enum ArgType {
2232
        // Basic types
2233
        String = (1 << 0),
2234
        Integer = (1 << 1), // Only 32-bit or less
2235
        Double = (1 << 2), // Maybe we want to add Float sometime too
2236
        Boolean = (1 << 3),
2237
        Object = (1 << 4),
2238
        Null = (1 << 5),
2239
2240
        // And derived types
2241
        Numeric = Integer | Double,
2242
        // Should "Primitive" use the WebIDL definition, which
2243
        // excludes string and null, or the typical JS one that includes them?
2244
        Primitive = Numeric | Boolean | Null | String,
2245
        ObjectOrNull = Object | Null,
2246
        Any = ObjectOrNull | Primitive,
2247
2248
        // Our sentinel value.
2249
        ArgTypeListEnd = (1 << 31)
2250
    };
2251
2252
    static_assert(Any & String, "Any must include String.");
2253
    static_assert(Any & Integer, "Any must include Integer.");
2254
    static_assert(Any & Double, "Any must include Double.");
2255
    static_assert(Any & Boolean, "Any must include Boolean.");
2256
    static_assert(Any & Object, "Any must include Object.");
2257
    static_assert(Any & Null, "Any must include Null.");
2258
2259
    /**
2260
     * An enum that describes what this getter/setter/method aliases.  This
2261
     * determines what things can be hoisted past this call, and if this
2262
     * call is movable what it can be hoisted past.
2263
     */
2264
    enum AliasSet {
2265
        /**
2266
         * Alias nothing: a constant value, getting it can't affect any other
2267
         * values, nothing can affect it.
2268
         */
2269
        AliasNone,
2270
2271
        /**
2272
         * Alias things that can modify the DOM but nothing else.  Doing the
2273
         * call can't affect the behavior of any other function.
2274
         */
2275
        AliasDOMSets,
2276
2277
        /**
2278
         * Alias the world.  Calling this can change arbitrary values anywhere
2279
         * in the system.  Most things fall in this bucket.
2280
         */
2281
        AliasEverything,
2282
2283
        /** Must be last. */
2284
        AliasSetCount
2285
    };
2286
2287
    bool needsOuterizedThisObject() const
2288
0
    {
2289
0
        return type() != Getter && type() != Setter;
2290
0
    }
2291
2292
    bool isTypedMethodJitInfo() const
2293
0
    {
2294
0
        return isTypedMethod;
2295
0
    }
2296
2297
    OpType type() const
2298
50
    {
2299
50
        return OpType(type_);
2300
50
    }
2301
2302
    AliasSet aliasSet() const
2303
0
    {
2304
0
        return AliasSet(aliasSet_);
2305
0
    }
2306
2307
    JSValueType returnType() const
2308
0
    {
2309
0
        return JSValueType(returnType_);
2310
0
    }
2311
2312
    union {
2313
        JSJitGetterOp getter;
2314
        JSJitSetterOp setter;
2315
        JSJitMethodOp method;
2316
        /** A DOM static method, used for Promise wrappers */
2317
        JSNative staticMethod;
2318
        JSNative ignoresReturnValueMethod;
2319
    };
2320
2321
0
    static unsigned offsetOfIgnoresReturnValueNative() {
2322
0
        return offsetof(JSJitInfo, ignoresReturnValueMethod);
2323
0
    }
2324
2325
    union {
2326
        uint16_t protoID;
2327
        js::jit::InlinableNative inlinableNative;
2328
    };
2329
2330
    union {
2331
        uint16_t depth;
2332
2333
        // Additional opcode for some InlinableNative functions.
2334
        uint16_t nativeOp;
2335
    };
2336
2337
    // These fields are carefully packed to take up 4 bytes.  If you need more
2338
    // bits for whatever reason, please see if you can steal bits from existing
2339
    // fields before adding more members to this structure.
2340
2341
#define JITINFO_OP_TYPE_BITS 4
2342
#define JITINFO_ALIAS_SET_BITS 4
2343
#define JITINFO_RETURN_TYPE_BITS 8
2344
#define JITINFO_SLOT_INDEX_BITS 10
2345
2346
    /** The OpType that says what sort of function we are. */
2347
    uint32_t type_ : JITINFO_OP_TYPE_BITS;
2348
2349
    /**
2350
     * The alias set for this op.  This is a _minimal_ alias set; in
2351
     * particular for a method it does not include whatever argument
2352
     * conversions might do.  That's covered by argTypes and runtime
2353
     * analysis of the actual argument types being passed in.
2354
     */
2355
    uint32_t aliasSet_ : JITINFO_ALIAS_SET_BITS;
2356
2357
    /** The return type tag.  Might be JSVAL_TYPE_UNKNOWN. */
2358
    uint32_t returnType_ : JITINFO_RETURN_TYPE_BITS;
2359
2360
    static_assert(OpTypeCount <= (1 << JITINFO_OP_TYPE_BITS),
2361
                  "Not enough space for OpType");
2362
    static_assert(AliasSetCount <= (1 << JITINFO_ALIAS_SET_BITS),
2363
                  "Not enough space for AliasSet");
2364
    static_assert((sizeof(JSValueType) * 8) <= JITINFO_RETURN_TYPE_BITS,
2365
                  "Not enough space for JSValueType");
2366
2367
#undef JITINFO_RETURN_TYPE_BITS
2368
#undef JITINFO_ALIAS_SET_BITS
2369
#undef JITINFO_OP_TYPE_BITS
2370
2371
    /** Is op fallible? False in setters. */
2372
    uint32_t isInfallible : 1;
2373
2374
    /**
2375
     * Is op movable?  To be movable the op must
2376
     * not AliasEverything, but even that might
2377
     * not be enough (e.g. in cases when it can
2378
     * throw or is explicitly not movable).
2379
     */
2380
    uint32_t isMovable : 1;
2381
2382
    /**
2383
     * Can op be dead-code eliminated? Again, this
2384
     * depends on whether the op can throw, in
2385
     * addition to the alias set.
2386
     */
2387
    uint32_t isEliminatable : 1;
2388
2389
    // XXXbz should we have a JSValueType for the type of the member?
2390
    /**
2391
     * True if this is a getter that can always
2392
     * get the value from a slot of the "this" object.
2393
     */
2394
    uint32_t isAlwaysInSlot : 1;
2395
2396
    /**
2397
     * True if this is a getter that can sometimes (if the slot doesn't contain
2398
     * UndefinedValue()) get the value from a slot of the "this" object.
2399
     */
2400
    uint32_t isLazilyCachedInSlot : 1;
2401
2402
    /** True if this is an instance of JSTypedMethodJitInfo. */
2403
    uint32_t isTypedMethod : 1;
2404
2405
    /**
2406
     * If isAlwaysInSlot or isSometimesInSlot is true,
2407
     * the index of the slot to get the value from.
2408
     * Otherwise 0.
2409
     */
2410
    uint32_t slotIndex : JITINFO_SLOT_INDEX_BITS;
2411
2412
    static const size_t maxSlotIndex = (1 << JITINFO_SLOT_INDEX_BITS) - 1;
2413
2414
#undef JITINFO_SLOT_INDEX_BITS
2415
};
2416
2417
static_assert(sizeof(JSJitInfo) == (sizeof(void*) + 2 * sizeof(uint32_t)),
2418
              "There are several thousand instances of JSJitInfo stored in "
2419
              "a binary. Please don't increase its space requirements without "
2420
              "verifying that there is no other way forward (better packing, "
2421
              "smaller datatypes for fields, subclassing, etc.).");
2422
2423
struct JSTypedMethodJitInfo
2424
{
2425
    // We use C-style inheritance here, rather than C++ style inheritance
2426
    // because not all compilers support brace-initialization for non-aggregate
2427
    // classes. Using C++ style inheritance and constructors instead of
2428
    // brace-initialization would also force the creation of static
2429
    // constructors (on some compilers) when JSJitInfo and JSTypedMethodJitInfo
2430
    // structures are declared. Since there can be several thousand of these
2431
    // structures present and we want to have roughly equivalent performance
2432
    // across a range of compilers, we do things manually.
2433
    JSJitInfo base;
2434
2435
    const JSJitInfo::ArgType* const argTypes; /* For a method, a list of sets of
2436
                                                 types that the function
2437
                                                 expects.  This can be used,
2438
                                                 for example, to figure out
2439
                                                 when argument coercions can
2440
                                                 have side-effects. */
2441
};
2442
2443
namespace js {
2444
2445
static MOZ_ALWAYS_INLINE shadow::Function*
2446
FunctionObjectToShadowFunction(JSObject* fun)
2447
0
{
2448
0
    MOZ_ASSERT(GetObjectClass(fun) == FunctionClassPtr);
2449
0
    return reinterpret_cast<shadow::Function*>(fun);
2450
0
}
Unexecuted instantiation: Unified_cpp_js_ipc0.cpp:js::FunctionObjectToShadowFunction(JSObject*)
Unexecuted instantiation: CTypes.cpp:js::FunctionObjectToShadowFunction(JSObject*)
Unexecuted instantiation: Library.cpp:js::FunctionObjectToShadowFunction(JSObject*)
Unexecuted instantiation: StoreBuffer.cpp:js::FunctionObjectToShadowFunction(JSObject*)
Unexecuted instantiation: jsutil.cpp:js::FunctionObjectToShadowFunction(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src0.cpp:js::FunctionObjectToShadowFunction(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src1.cpp:js::FunctionObjectToShadowFunction(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src10.cpp:js::FunctionObjectToShadowFunction(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src11.cpp:js::FunctionObjectToShadowFunction(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src12.cpp:js::FunctionObjectToShadowFunction(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src14.cpp:js::FunctionObjectToShadowFunction(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src15.cpp:js::FunctionObjectToShadowFunction(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src17.cpp:js::FunctionObjectToShadowFunction(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src18.cpp:js::FunctionObjectToShadowFunction(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src19.cpp:js::FunctionObjectToShadowFunction(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src2.cpp:js::FunctionObjectToShadowFunction(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src20.cpp:js::FunctionObjectToShadowFunction(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src21.cpp:js::FunctionObjectToShadowFunction(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src22.cpp:js::FunctionObjectToShadowFunction(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src23.cpp:js::FunctionObjectToShadowFunction(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src24.cpp:js::FunctionObjectToShadowFunction(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src25.cpp:js::FunctionObjectToShadowFunction(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src26.cpp:js::FunctionObjectToShadowFunction(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src27.cpp:js::FunctionObjectToShadowFunction(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src28.cpp:js::FunctionObjectToShadowFunction(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src29.cpp:js::FunctionObjectToShadowFunction(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src3.cpp:js::FunctionObjectToShadowFunction(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src30.cpp:js::FunctionObjectToShadowFunction(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src31.cpp:js::FunctionObjectToShadowFunction(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src32.cpp:js::FunctionObjectToShadowFunction(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src33.cpp:js::FunctionObjectToShadowFunction(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src34.cpp:js::FunctionObjectToShadowFunction(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src35.cpp:js::FunctionObjectToShadowFunction(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src36.cpp:js::FunctionObjectToShadowFunction(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src37.cpp:js::FunctionObjectToShadowFunction(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src38.cpp:js::FunctionObjectToShadowFunction(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src39.cpp:js::FunctionObjectToShadowFunction(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src4.cpp:js::FunctionObjectToShadowFunction(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src40.cpp:js::FunctionObjectToShadowFunction(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src41.cpp:js::FunctionObjectToShadowFunction(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src42.cpp:js::FunctionObjectToShadowFunction(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src43.cpp:js::FunctionObjectToShadowFunction(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src44.cpp:js::FunctionObjectToShadowFunction(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src45.cpp:js::FunctionObjectToShadowFunction(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src5.cpp:js::FunctionObjectToShadowFunction(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src6.cpp:js::FunctionObjectToShadowFunction(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src7.cpp:js::FunctionObjectToShadowFunction(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src8.cpp:js::FunctionObjectToShadowFunction(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src9.cpp:js::FunctionObjectToShadowFunction(JSObject*)
Unexecuted instantiation: RegExp.cpp:js::FunctionObjectToShadowFunction(JSObject*)
Unexecuted instantiation: BinSource-auto.cpp:js::FunctionObjectToShadowFunction(JSObject*)
Unexecuted instantiation: BinSource.cpp:js::FunctionObjectToShadowFunction(JSObject*)
Unexecuted instantiation: BinToken.cpp:js::FunctionObjectToShadowFunction(JSObject*)
Unexecuted instantiation: BinTokenReaderBase.cpp:js::FunctionObjectToShadowFunction(JSObject*)
Unexecuted instantiation: BinTokenReaderMultipart.cpp:js::FunctionObjectToShadowFunction(JSObject*)
Unexecuted instantiation: BinTokenReaderTester.cpp:js::FunctionObjectToShadowFunction(JSObject*)
Unexecuted instantiation: Parser.cpp:js::FunctionObjectToShadowFunction(JSObject*)
Unexecuted instantiation: Disassembler-x86-shared.cpp:js::FunctionObjectToShadowFunction(JSObject*)
Unexecuted instantiation: jsmath.cpp:js::FunctionObjectToShadowFunction(JSObject*)
Unexecuted instantiation: Interpreter.cpp:js::FunctionObjectToShadowFunction(JSObject*)
Unexecuted instantiation: VTuneWrapper.cpp:js::FunctionObjectToShadowFunction(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src13.cpp:js::FunctionObjectToShadowFunction(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src16.cpp:js::FunctionObjectToShadowFunction(JSObject*)
2451
2452
/* Statically asserted in JSFunction.h. */
2453
static const unsigned JS_FUNCTION_INTERPRETED_BITS = 0x0201;
2454
2455
// Return whether the given function object is native.
2456
static MOZ_ALWAYS_INLINE bool
2457
FunctionObjectIsNative(JSObject* fun)
2458
0
{
2459
0
    return !(FunctionObjectToShadowFunction(fun)->flags & JS_FUNCTION_INTERPRETED_BITS);
2460
0
}
Unexecuted instantiation: Unified_cpp_js_ipc0.cpp:js::FunctionObjectIsNative(JSObject*)
Unexecuted instantiation: CTypes.cpp:js::FunctionObjectIsNative(JSObject*)
Unexecuted instantiation: Library.cpp:js::FunctionObjectIsNative(JSObject*)
Unexecuted instantiation: StoreBuffer.cpp:js::FunctionObjectIsNative(JSObject*)
Unexecuted instantiation: jsutil.cpp:js::FunctionObjectIsNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src0.cpp:js::FunctionObjectIsNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src1.cpp:js::FunctionObjectIsNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src10.cpp:js::FunctionObjectIsNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src11.cpp:js::FunctionObjectIsNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src12.cpp:js::FunctionObjectIsNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src14.cpp:js::FunctionObjectIsNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src15.cpp:js::FunctionObjectIsNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src17.cpp:js::FunctionObjectIsNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src18.cpp:js::FunctionObjectIsNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src19.cpp:js::FunctionObjectIsNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src2.cpp:js::FunctionObjectIsNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src20.cpp:js::FunctionObjectIsNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src21.cpp:js::FunctionObjectIsNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src22.cpp:js::FunctionObjectIsNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src23.cpp:js::FunctionObjectIsNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src24.cpp:js::FunctionObjectIsNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src25.cpp:js::FunctionObjectIsNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src26.cpp:js::FunctionObjectIsNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src27.cpp:js::FunctionObjectIsNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src28.cpp:js::FunctionObjectIsNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src29.cpp:js::FunctionObjectIsNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src3.cpp:js::FunctionObjectIsNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src30.cpp:js::FunctionObjectIsNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src31.cpp:js::FunctionObjectIsNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src32.cpp:js::FunctionObjectIsNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src33.cpp:js::FunctionObjectIsNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src34.cpp:js::FunctionObjectIsNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src35.cpp:js::FunctionObjectIsNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src36.cpp:js::FunctionObjectIsNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src37.cpp:js::FunctionObjectIsNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src38.cpp:js::FunctionObjectIsNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src39.cpp:js::FunctionObjectIsNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src4.cpp:js::FunctionObjectIsNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src40.cpp:js::FunctionObjectIsNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src41.cpp:js::FunctionObjectIsNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src42.cpp:js::FunctionObjectIsNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src43.cpp:js::FunctionObjectIsNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src44.cpp:js::FunctionObjectIsNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src45.cpp:js::FunctionObjectIsNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src5.cpp:js::FunctionObjectIsNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src6.cpp:js::FunctionObjectIsNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src7.cpp:js::FunctionObjectIsNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src8.cpp:js::FunctionObjectIsNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src9.cpp:js::FunctionObjectIsNative(JSObject*)
Unexecuted instantiation: RegExp.cpp:js::FunctionObjectIsNative(JSObject*)
Unexecuted instantiation: BinSource-auto.cpp:js::FunctionObjectIsNative(JSObject*)
Unexecuted instantiation: BinSource.cpp:js::FunctionObjectIsNative(JSObject*)
Unexecuted instantiation: BinToken.cpp:js::FunctionObjectIsNative(JSObject*)
Unexecuted instantiation: BinTokenReaderBase.cpp:js::FunctionObjectIsNative(JSObject*)
Unexecuted instantiation: BinTokenReaderMultipart.cpp:js::FunctionObjectIsNative(JSObject*)
Unexecuted instantiation: BinTokenReaderTester.cpp:js::FunctionObjectIsNative(JSObject*)
Unexecuted instantiation: Parser.cpp:js::FunctionObjectIsNative(JSObject*)
Unexecuted instantiation: Disassembler-x86-shared.cpp:js::FunctionObjectIsNative(JSObject*)
Unexecuted instantiation: jsmath.cpp:js::FunctionObjectIsNative(JSObject*)
Unexecuted instantiation: Interpreter.cpp:js::FunctionObjectIsNative(JSObject*)
Unexecuted instantiation: VTuneWrapper.cpp:js::FunctionObjectIsNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src13.cpp:js::FunctionObjectIsNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src16.cpp:js::FunctionObjectIsNative(JSObject*)
2461
2462
static MOZ_ALWAYS_INLINE JSNative
2463
GetFunctionObjectNative(JSObject* fun)
2464
0
{
2465
0
    MOZ_ASSERT(FunctionObjectIsNative(fun));
2466
0
    return FunctionObjectToShadowFunction(fun)->native;
2467
0
}
Unexecuted instantiation: Unified_cpp_js_ipc0.cpp:js::GetFunctionObjectNative(JSObject*)
Unexecuted instantiation: CTypes.cpp:js::GetFunctionObjectNative(JSObject*)
Unexecuted instantiation: Library.cpp:js::GetFunctionObjectNative(JSObject*)
Unexecuted instantiation: StoreBuffer.cpp:js::GetFunctionObjectNative(JSObject*)
Unexecuted instantiation: jsutil.cpp:js::GetFunctionObjectNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src0.cpp:js::GetFunctionObjectNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src1.cpp:js::GetFunctionObjectNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src10.cpp:js::GetFunctionObjectNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src11.cpp:js::GetFunctionObjectNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src12.cpp:js::GetFunctionObjectNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src14.cpp:js::GetFunctionObjectNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src15.cpp:js::GetFunctionObjectNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src17.cpp:js::GetFunctionObjectNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src18.cpp:js::GetFunctionObjectNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src19.cpp:js::GetFunctionObjectNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src2.cpp:js::GetFunctionObjectNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src20.cpp:js::GetFunctionObjectNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src21.cpp:js::GetFunctionObjectNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src22.cpp:js::GetFunctionObjectNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src23.cpp:js::GetFunctionObjectNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src24.cpp:js::GetFunctionObjectNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src25.cpp:js::GetFunctionObjectNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src26.cpp:js::GetFunctionObjectNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src27.cpp:js::GetFunctionObjectNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src28.cpp:js::GetFunctionObjectNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src29.cpp:js::GetFunctionObjectNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src3.cpp:js::GetFunctionObjectNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src30.cpp:js::GetFunctionObjectNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src31.cpp:js::GetFunctionObjectNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src32.cpp:js::GetFunctionObjectNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src33.cpp:js::GetFunctionObjectNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src34.cpp:js::GetFunctionObjectNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src35.cpp:js::GetFunctionObjectNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src36.cpp:js::GetFunctionObjectNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src37.cpp:js::GetFunctionObjectNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src38.cpp:js::GetFunctionObjectNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src39.cpp:js::GetFunctionObjectNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src4.cpp:js::GetFunctionObjectNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src40.cpp:js::GetFunctionObjectNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src41.cpp:js::GetFunctionObjectNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src42.cpp:js::GetFunctionObjectNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src43.cpp:js::GetFunctionObjectNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src44.cpp:js::GetFunctionObjectNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src45.cpp:js::GetFunctionObjectNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src5.cpp:js::GetFunctionObjectNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src6.cpp:js::GetFunctionObjectNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src7.cpp:js::GetFunctionObjectNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src8.cpp:js::GetFunctionObjectNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src9.cpp:js::GetFunctionObjectNative(JSObject*)
Unexecuted instantiation: RegExp.cpp:js::GetFunctionObjectNative(JSObject*)
Unexecuted instantiation: BinSource-auto.cpp:js::GetFunctionObjectNative(JSObject*)
Unexecuted instantiation: BinSource.cpp:js::GetFunctionObjectNative(JSObject*)
Unexecuted instantiation: BinToken.cpp:js::GetFunctionObjectNative(JSObject*)
Unexecuted instantiation: BinTokenReaderBase.cpp:js::GetFunctionObjectNative(JSObject*)
Unexecuted instantiation: BinTokenReaderMultipart.cpp:js::GetFunctionObjectNative(JSObject*)
Unexecuted instantiation: BinTokenReaderTester.cpp:js::GetFunctionObjectNative(JSObject*)
Unexecuted instantiation: Parser.cpp:js::GetFunctionObjectNative(JSObject*)
Unexecuted instantiation: Disassembler-x86-shared.cpp:js::GetFunctionObjectNative(JSObject*)
Unexecuted instantiation: jsmath.cpp:js::GetFunctionObjectNative(JSObject*)
Unexecuted instantiation: Interpreter.cpp:js::GetFunctionObjectNative(JSObject*)
Unexecuted instantiation: VTuneWrapper.cpp:js::GetFunctionObjectNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src13.cpp:js::GetFunctionObjectNative(JSObject*)
Unexecuted instantiation: Unified_cpp_js_src16.cpp:js::GetFunctionObjectNative(JSObject*)
2468
2469
} // namespace js
2470
2471
static MOZ_ALWAYS_INLINE const JSJitInfo*
2472
FUNCTION_VALUE_TO_JITINFO(const JS::Value& v)
2473
0
{
2474
0
    MOZ_ASSERT(js::FunctionObjectIsNative(&v.toObject()));
2475
0
    return js::FunctionObjectToShadowFunction(&v.toObject())->jitinfo;
2476
0
}
Unexecuted instantiation: Unified_cpp_js_ipc0.cpp:FUNCTION_VALUE_TO_JITINFO(JS::Value const&)
Unexecuted instantiation: CTypes.cpp:FUNCTION_VALUE_TO_JITINFO(JS::Value const&)
Unexecuted instantiation: Library.cpp:FUNCTION_VALUE_TO_JITINFO(JS::Value const&)
Unexecuted instantiation: StoreBuffer.cpp:FUNCTION_VALUE_TO_JITINFO(JS::Value const&)
Unexecuted instantiation: jsutil.cpp:FUNCTION_VALUE_TO_JITINFO(JS::Value const&)
Unexecuted instantiation: Unified_cpp_js_src0.cpp:FUNCTION_VALUE_TO_JITINFO(JS::Value const&)
Unexecuted instantiation: Unified_cpp_js_src1.cpp:FUNCTION_VALUE_TO_JITINFO(JS::Value const&)
Unexecuted instantiation: Unified_cpp_js_src10.cpp:FUNCTION_VALUE_TO_JITINFO(JS::Value const&)
Unexecuted instantiation: Unified_cpp_js_src11.cpp:FUNCTION_VALUE_TO_JITINFO(JS::Value const&)
Unexecuted instantiation: Unified_cpp_js_src12.cpp:FUNCTION_VALUE_TO_JITINFO(JS::Value const&)
Unexecuted instantiation: Unified_cpp_js_src14.cpp:FUNCTION_VALUE_TO_JITINFO(JS::Value const&)
Unexecuted instantiation: Unified_cpp_js_src15.cpp:FUNCTION_VALUE_TO_JITINFO(JS::Value const&)
Unexecuted instantiation: Unified_cpp_js_src17.cpp:FUNCTION_VALUE_TO_JITINFO(JS::Value const&)
Unexecuted instantiation: Unified_cpp_js_src18.cpp:FUNCTION_VALUE_TO_JITINFO(JS::Value const&)
Unexecuted instantiation: Unified_cpp_js_src19.cpp:FUNCTION_VALUE_TO_JITINFO(JS::Value const&)
Unexecuted instantiation: Unified_cpp_js_src2.cpp:FUNCTION_VALUE_TO_JITINFO(JS::Value const&)
Unexecuted instantiation: Unified_cpp_js_src20.cpp:FUNCTION_VALUE_TO_JITINFO(JS::Value const&)
Unexecuted instantiation: Unified_cpp_js_src21.cpp:FUNCTION_VALUE_TO_JITINFO(JS::Value const&)
Unexecuted instantiation: Unified_cpp_js_src22.cpp:FUNCTION_VALUE_TO_JITINFO(JS::Value const&)
Unexecuted instantiation: Unified_cpp_js_src23.cpp:FUNCTION_VALUE_TO_JITINFO(JS::Value const&)
Unexecuted instantiation: Unified_cpp_js_src24.cpp:FUNCTION_VALUE_TO_JITINFO(JS::Value const&)
Unexecuted instantiation: Unified_cpp_js_src25.cpp:FUNCTION_VALUE_TO_JITINFO(JS::Value const&)
Unexecuted instantiation: Unified_cpp_js_src26.cpp:FUNCTION_VALUE_TO_JITINFO(JS::Value const&)
Unexecuted instantiation: Unified_cpp_js_src27.cpp:FUNCTION_VALUE_TO_JITINFO(JS::Value const&)
Unexecuted instantiation: Unified_cpp_js_src28.cpp:FUNCTION_VALUE_TO_JITINFO(JS::Value const&)
Unexecuted instantiation: Unified_cpp_js_src29.cpp:FUNCTION_VALUE_TO_JITINFO(JS::Value const&)
Unexecuted instantiation: Unified_cpp_js_src3.cpp:FUNCTION_VALUE_TO_JITINFO(JS::Value const&)
Unexecuted instantiation: Unified_cpp_js_src30.cpp:FUNCTION_VALUE_TO_JITINFO(JS::Value const&)
Unexecuted instantiation: Unified_cpp_js_src31.cpp:FUNCTION_VALUE_TO_JITINFO(JS::Value const&)
Unexecuted instantiation: Unified_cpp_js_src32.cpp:FUNCTION_VALUE_TO_JITINFO(JS::Value const&)
Unexecuted instantiation: Unified_cpp_js_src33.cpp:FUNCTION_VALUE_TO_JITINFO(JS::Value const&)
Unexecuted instantiation: Unified_cpp_js_src34.cpp:FUNCTION_VALUE_TO_JITINFO(JS::Value const&)
Unexecuted instantiation: Unified_cpp_js_src35.cpp:FUNCTION_VALUE_TO_JITINFO(JS::Value const&)
Unexecuted instantiation: Unified_cpp_js_src36.cpp:FUNCTION_VALUE_TO_JITINFO(JS::Value const&)
Unexecuted instantiation: Unified_cpp_js_src37.cpp:FUNCTION_VALUE_TO_JITINFO(JS::Value const&)
Unexecuted instantiation: Unified_cpp_js_src38.cpp:FUNCTION_VALUE_TO_JITINFO(JS::Value const&)
Unexecuted instantiation: Unified_cpp_js_src39.cpp:FUNCTION_VALUE_TO_JITINFO(JS::Value const&)
Unexecuted instantiation: Unified_cpp_js_src4.cpp:FUNCTION_VALUE_TO_JITINFO(JS::Value const&)
Unexecuted instantiation: Unified_cpp_js_src40.cpp:FUNCTION_VALUE_TO_JITINFO(JS::Value const&)
Unexecuted instantiation: Unified_cpp_js_src41.cpp:FUNCTION_VALUE_TO_JITINFO(JS::Value const&)
Unexecuted instantiation: Unified_cpp_js_src42.cpp:FUNCTION_VALUE_TO_JITINFO(JS::Value const&)
Unexecuted instantiation: Unified_cpp_js_src43.cpp:FUNCTION_VALUE_TO_JITINFO(JS::Value const&)
Unexecuted instantiation: Unified_cpp_js_src44.cpp:FUNCTION_VALUE_TO_JITINFO(JS::Value const&)
Unexecuted instantiation: Unified_cpp_js_src45.cpp:FUNCTION_VALUE_TO_JITINFO(JS::Value const&)
Unexecuted instantiation: Unified_cpp_js_src5.cpp:FUNCTION_VALUE_TO_JITINFO(JS::Value const&)
Unexecuted instantiation: Unified_cpp_js_src6.cpp:FUNCTION_VALUE_TO_JITINFO(JS::Value const&)
Unexecuted instantiation: Unified_cpp_js_src7.cpp:FUNCTION_VALUE_TO_JITINFO(JS::Value const&)
Unexecuted instantiation: Unified_cpp_js_src8.cpp:FUNCTION_VALUE_TO_JITINFO(JS::Value const&)
Unexecuted instantiation: Unified_cpp_js_src9.cpp:FUNCTION_VALUE_TO_JITINFO(JS::Value const&)
Unexecuted instantiation: RegExp.cpp:FUNCTION_VALUE_TO_JITINFO(JS::Value const&)
Unexecuted instantiation: BinSource-auto.cpp:FUNCTION_VALUE_TO_JITINFO(JS::Value const&)
Unexecuted instantiation: BinSource.cpp:FUNCTION_VALUE_TO_JITINFO(JS::Value const&)
Unexecuted instantiation: BinToken.cpp:FUNCTION_VALUE_TO_JITINFO(JS::Value const&)
Unexecuted instantiation: BinTokenReaderBase.cpp:FUNCTION_VALUE_TO_JITINFO(JS::Value const&)
Unexecuted instantiation: BinTokenReaderMultipart.cpp:FUNCTION_VALUE_TO_JITINFO(JS::Value const&)
Unexecuted instantiation: BinTokenReaderTester.cpp:FUNCTION_VALUE_TO_JITINFO(JS::Value const&)
Unexecuted instantiation: Parser.cpp:FUNCTION_VALUE_TO_JITINFO(JS::Value const&)
Unexecuted instantiation: Disassembler-x86-shared.cpp:FUNCTION_VALUE_TO_JITINFO(JS::Value const&)
Unexecuted instantiation: jsmath.cpp:FUNCTION_VALUE_TO_JITINFO(JS::Value const&)
Unexecuted instantiation: Interpreter.cpp:FUNCTION_VALUE_TO_JITINFO(JS::Value const&)
Unexecuted instantiation: VTuneWrapper.cpp:FUNCTION_VALUE_TO_JITINFO(JS::Value const&)
Unexecuted instantiation: Unified_cpp_js_src13.cpp:FUNCTION_VALUE_TO_JITINFO(JS::Value const&)
Unexecuted instantiation: Unified_cpp_js_src16.cpp:FUNCTION_VALUE_TO_JITINFO(JS::Value const&)
2477
2478
static MOZ_ALWAYS_INLINE void
2479
SET_JITINFO(JSFunction * func, const JSJitInfo* info)
2480
0
{
2481
0
    js::shadow::Function* fun = reinterpret_cast<js::shadow::Function*>(func);
2482
0
    MOZ_ASSERT(!(fun->flags & js::JS_FUNCTION_INTERPRETED_BITS));
2483
0
    fun->jitinfo = info;
2484
0
}
Unexecuted instantiation: Unified_cpp_js_ipc0.cpp:SET_JITINFO(JSFunction*, JSJitInfo const*)
Unexecuted instantiation: CTypes.cpp:SET_JITINFO(JSFunction*, JSJitInfo const*)
Unexecuted instantiation: Library.cpp:SET_JITINFO(JSFunction*, JSJitInfo const*)
Unexecuted instantiation: StoreBuffer.cpp:SET_JITINFO(JSFunction*, JSJitInfo const*)
Unexecuted instantiation: jsutil.cpp:SET_JITINFO(JSFunction*, JSJitInfo const*)
Unexecuted instantiation: Unified_cpp_js_src0.cpp:SET_JITINFO(JSFunction*, JSJitInfo const*)
Unexecuted instantiation: Unified_cpp_js_src1.cpp:SET_JITINFO(JSFunction*, JSJitInfo const*)
Unexecuted instantiation: Unified_cpp_js_src10.cpp:SET_JITINFO(JSFunction*, JSJitInfo const*)
Unexecuted instantiation: Unified_cpp_js_src11.cpp:SET_JITINFO(JSFunction*, JSJitInfo const*)
Unexecuted instantiation: Unified_cpp_js_src12.cpp:SET_JITINFO(JSFunction*, JSJitInfo const*)
Unexecuted instantiation: Unified_cpp_js_src14.cpp:SET_JITINFO(JSFunction*, JSJitInfo const*)
Unexecuted instantiation: Unified_cpp_js_src15.cpp:SET_JITINFO(JSFunction*, JSJitInfo const*)
Unexecuted instantiation: Unified_cpp_js_src17.cpp:SET_JITINFO(JSFunction*, JSJitInfo const*)
Unexecuted instantiation: Unified_cpp_js_src18.cpp:SET_JITINFO(JSFunction*, JSJitInfo const*)
Unexecuted instantiation: Unified_cpp_js_src19.cpp:SET_JITINFO(JSFunction*, JSJitInfo const*)
Unexecuted instantiation: Unified_cpp_js_src2.cpp:SET_JITINFO(JSFunction*, JSJitInfo const*)
Unexecuted instantiation: Unified_cpp_js_src20.cpp:SET_JITINFO(JSFunction*, JSJitInfo const*)
Unexecuted instantiation: Unified_cpp_js_src21.cpp:SET_JITINFO(JSFunction*, JSJitInfo const*)
Unexecuted instantiation: Unified_cpp_js_src22.cpp:SET_JITINFO(JSFunction*, JSJitInfo const*)
Unexecuted instantiation: Unified_cpp_js_src23.cpp:SET_JITINFO(JSFunction*, JSJitInfo const*)
Unexecuted instantiation: Unified_cpp_js_src24.cpp:SET_JITINFO(JSFunction*, JSJitInfo const*)
Unexecuted instantiation: Unified_cpp_js_src25.cpp:SET_JITINFO(JSFunction*, JSJitInfo const*)
Unexecuted instantiation: Unified_cpp_js_src26.cpp:SET_JITINFO(JSFunction*, JSJitInfo const*)
Unexecuted instantiation: Unified_cpp_js_src27.cpp:SET_JITINFO(JSFunction*, JSJitInfo const*)
Unexecuted instantiation: Unified_cpp_js_src28.cpp:SET_JITINFO(JSFunction*, JSJitInfo const*)
Unexecuted instantiation: Unified_cpp_js_src29.cpp:SET_JITINFO(JSFunction*, JSJitInfo const*)
Unexecuted instantiation: Unified_cpp_js_src3.cpp:SET_JITINFO(JSFunction*, JSJitInfo const*)
Unexecuted instantiation: Unified_cpp_js_src30.cpp:SET_JITINFO(JSFunction*, JSJitInfo const*)
Unexecuted instantiation: Unified_cpp_js_src31.cpp:SET_JITINFO(JSFunction*, JSJitInfo const*)
Unexecuted instantiation: Unified_cpp_js_src32.cpp:SET_JITINFO(JSFunction*, JSJitInfo const*)
Unexecuted instantiation: Unified_cpp_js_src33.cpp:SET_JITINFO(JSFunction*, JSJitInfo const*)
Unexecuted instantiation: Unified_cpp_js_src34.cpp:SET_JITINFO(JSFunction*, JSJitInfo const*)
Unexecuted instantiation: Unified_cpp_js_src35.cpp:SET_JITINFO(JSFunction*, JSJitInfo const*)
Unexecuted instantiation: Unified_cpp_js_src36.cpp:SET_JITINFO(JSFunction*, JSJitInfo const*)
Unexecuted instantiation: Unified_cpp_js_src37.cpp:SET_JITINFO(JSFunction*, JSJitInfo const*)
Unexecuted instantiation: Unified_cpp_js_src38.cpp:SET_JITINFO(JSFunction*, JSJitInfo const*)
Unexecuted instantiation: Unified_cpp_js_src39.cpp:SET_JITINFO(JSFunction*, JSJitInfo const*)
Unexecuted instantiation: Unified_cpp_js_src4.cpp:SET_JITINFO(JSFunction*, JSJitInfo const*)
Unexecuted instantiation: Unified_cpp_js_src40.cpp:SET_JITINFO(JSFunction*, JSJitInfo const*)
Unexecuted instantiation: Unified_cpp_js_src41.cpp:SET_JITINFO(JSFunction*, JSJitInfo const*)
Unexecuted instantiation: Unified_cpp_js_src42.cpp:SET_JITINFO(JSFunction*, JSJitInfo const*)
Unexecuted instantiation: Unified_cpp_js_src43.cpp:SET_JITINFO(JSFunction*, JSJitInfo const*)
Unexecuted instantiation: Unified_cpp_js_src44.cpp:SET_JITINFO(JSFunction*, JSJitInfo const*)
Unexecuted instantiation: Unified_cpp_js_src45.cpp:SET_JITINFO(JSFunction*, JSJitInfo const*)
Unexecuted instantiation: Unified_cpp_js_src5.cpp:SET_JITINFO(JSFunction*, JSJitInfo const*)
Unexecuted instantiation: Unified_cpp_js_src6.cpp:SET_JITINFO(JSFunction*, JSJitInfo const*)
Unexecuted instantiation: Unified_cpp_js_src7.cpp:SET_JITINFO(JSFunction*, JSJitInfo const*)
Unexecuted instantiation: Unified_cpp_js_src8.cpp:SET_JITINFO(JSFunction*, JSJitInfo const*)
Unexecuted instantiation: Unified_cpp_js_src9.cpp:SET_JITINFO(JSFunction*, JSJitInfo const*)
Unexecuted instantiation: RegExp.cpp:SET_JITINFO(JSFunction*, JSJitInfo const*)
Unexecuted instantiation: BinSource-auto.cpp:SET_JITINFO(JSFunction*, JSJitInfo const*)
Unexecuted instantiation: BinSource.cpp:SET_JITINFO(JSFunction*, JSJitInfo const*)
Unexecuted instantiation: BinToken.cpp:SET_JITINFO(JSFunction*, JSJitInfo const*)
Unexecuted instantiation: BinTokenReaderBase.cpp:SET_JITINFO(JSFunction*, JSJitInfo const*)
Unexecuted instantiation: BinTokenReaderMultipart.cpp:SET_JITINFO(JSFunction*, JSJitInfo const*)
Unexecuted instantiation: BinTokenReaderTester.cpp:SET_JITINFO(JSFunction*, JSJitInfo const*)
Unexecuted instantiation: Parser.cpp:SET_JITINFO(JSFunction*, JSJitInfo const*)
Unexecuted instantiation: Disassembler-x86-shared.cpp:SET_JITINFO(JSFunction*, JSJitInfo const*)
Unexecuted instantiation: jsmath.cpp:SET_JITINFO(JSFunction*, JSJitInfo const*)
Unexecuted instantiation: Interpreter.cpp:SET_JITINFO(JSFunction*, JSJitInfo const*)
Unexecuted instantiation: VTuneWrapper.cpp:SET_JITINFO(JSFunction*, JSJitInfo const*)
Unexecuted instantiation: Unified_cpp_js_src13.cpp:SET_JITINFO(JSFunction*, JSJitInfo const*)
Unexecuted instantiation: Unified_cpp_js_src16.cpp:SET_JITINFO(JSFunction*, JSJitInfo const*)
2485
2486
/*
2487
 * Engine-internal extensions of jsid.  This code is here only until we
2488
 * eliminate Gecko's dependencies on it!
2489
 */
2490
2491
static MOZ_ALWAYS_INLINE jsid
2492
JSID_FROM_BITS(size_t bits)
2493
11.1M
{
2494
11.1M
    jsid id;
2495
11.1M
    JSID_BITS(id) = bits;
2496
11.1M
    return id;
2497
11.1M
}
Unexecuted instantiation: Unified_cpp_js_ipc0.cpp:JSID_FROM_BITS(unsigned long)
StructuredClone.cpp:JSID_FROM_BITS(unsigned long)
Line
Count
Source
2493
1.62M
{
2494
1.62M
    jsid id;
2495
1.62M
    JSID_BITS(id) = bits;
2496
1.62M
    return id;
2497
1.62M
}
Unexecuted instantiation: CTypes.cpp:JSID_FROM_BITS(unsigned long)
Unexecuted instantiation: Library.cpp:JSID_FROM_BITS(unsigned long)
Unexecuted instantiation: StoreBuffer.cpp:JSID_FROM_BITS(unsigned long)
Unexecuted instantiation: jsutil.cpp:JSID_FROM_BITS(unsigned long)
Unified_cpp_js_src0.cpp:JSID_FROM_BITS(unsigned long)
Line
Count
Source
2493
5.46M
{
2494
5.46M
    jsid id;
2495
5.46M
    JSID_BITS(id) = bits;
2496
5.46M
    return id;
2497
5.46M
}
Unified_cpp_js_src1.cpp:JSID_FROM_BITS(unsigned long)
Line
Count
Source
2493
623
{
2494
623
    jsid id;
2495
623
    JSID_BITS(id) = bits;
2496
623
    return id;
2497
623
}
Unified_cpp_js_src10.cpp:JSID_FROM_BITS(unsigned long)
Line
Count
Source
2493
37
{
2494
37
    jsid id;
2495
37
    JSID_BITS(id) = bits;
2496
37
    return id;
2497
37
}
Unexecuted instantiation: Unified_cpp_js_src11.cpp:JSID_FROM_BITS(unsigned long)
Unexecuted instantiation: Unified_cpp_js_src12.cpp:JSID_FROM_BITS(unsigned long)
Unified_cpp_js_src14.cpp:JSID_FROM_BITS(unsigned long)
Line
Count
Source
2493
33
{
2494
33
    jsid id;
2495
33
    JSID_BITS(id) = bits;
2496
33
    return id;
2497
33
}
Unified_cpp_js_src15.cpp:JSID_FROM_BITS(unsigned long)
Line
Count
Source
2493
767
{
2494
767
    jsid id;
2495
767
    JSID_BITS(id) = bits;
2496
767
    return id;
2497
767
}
Unified_cpp_js_src17.cpp:JSID_FROM_BITS(unsigned long)
Line
Count
Source
2493
371
{
2494
371
    jsid id;
2495
371
    JSID_BITS(id) = bits;
2496
371
    return id;
2497
371
}
Unexecuted instantiation: Unified_cpp_js_src18.cpp:JSID_FROM_BITS(unsigned long)
Unexecuted instantiation: Unified_cpp_js_src19.cpp:JSID_FROM_BITS(unsigned long)
Unexecuted instantiation: Unified_cpp_js_src2.cpp:JSID_FROM_BITS(unsigned long)
Unified_cpp_js_src20.cpp:JSID_FROM_BITS(unsigned long)
Line
Count
Source
2493
72
{
2494
72
    jsid id;
2495
72
    JSID_BITS(id) = bits;
2496
72
    return id;
2497
72
}
Unexecuted instantiation: Unified_cpp_js_src21.cpp:JSID_FROM_BITS(unsigned long)
Unexecuted instantiation: Unified_cpp_js_src22.cpp:JSID_FROM_BITS(unsigned long)
Unified_cpp_js_src23.cpp:JSID_FROM_BITS(unsigned long)
Line
Count
Source
2493
758k
{
2494
758k
    jsid id;
2495
758k
    JSID_BITS(id) = bits;
2496
758k
    return id;
2497
758k
}
Unexecuted instantiation: Unified_cpp_js_src24.cpp:JSID_FROM_BITS(unsigned long)
Unexecuted instantiation: Unified_cpp_js_src25.cpp:JSID_FROM_BITS(unsigned long)
Unexecuted instantiation: Unified_cpp_js_src26.cpp:JSID_FROM_BITS(unsigned long)
Unexecuted instantiation: Unified_cpp_js_src27.cpp:JSID_FROM_BITS(unsigned long)
Unexecuted instantiation: Unified_cpp_js_src28.cpp:JSID_FROM_BITS(unsigned long)
Unexecuted instantiation: Unified_cpp_js_src29.cpp:JSID_FROM_BITS(unsigned long)
Unexecuted instantiation: Unified_cpp_js_src3.cpp:JSID_FROM_BITS(unsigned long)
Unexecuted instantiation: Unified_cpp_js_src30.cpp:JSID_FROM_BITS(unsigned long)
Unexecuted instantiation: Unified_cpp_js_src31.cpp:JSID_FROM_BITS(unsigned long)
Unexecuted instantiation: Unified_cpp_js_src32.cpp:JSID_FROM_BITS(unsigned long)
Unexecuted instantiation: Unified_cpp_js_src33.cpp:JSID_FROM_BITS(unsigned long)
Unified_cpp_js_src34.cpp:JSID_FROM_BITS(unsigned long)
Line
Count
Source
2493
5
{
2494
5
    jsid id;
2495
5
    JSID_BITS(id) = bits;
2496
5
    return id;
2497
5
}
Unified_cpp_js_src35.cpp:JSID_FROM_BITS(unsigned long)
Line
Count
Source
2493
180
{
2494
180
    jsid id;
2495
180
    JSID_BITS(id) = bits;
2496
180
    return id;
2497
180
}
Unified_cpp_js_src36.cpp:JSID_FROM_BITS(unsigned long)
Line
Count
Source
2493
3.33M
{
2494
3.33M
    jsid id;
2495
3.33M
    JSID_BITS(id) = bits;
2496
3.33M
    return id;
2497
3.33M
}
Unified_cpp_js_src37.cpp:JSID_FROM_BITS(unsigned long)
Line
Count
Source
2493
428
{
2494
428
    jsid id;
2495
428
    JSID_BITS(id) = bits;
2496
428
    return id;
2497
428
}
Unexecuted instantiation: Unified_cpp_js_src38.cpp:JSID_FROM_BITS(unsigned long)
Unified_cpp_js_src39.cpp:JSID_FROM_BITS(unsigned long)
Line
Count
Source
2493
322
{
2494
322
    jsid id;
2495
322
    JSID_BITS(id) = bits;
2496
322
    return id;
2497
322
}
Unexecuted instantiation: Unified_cpp_js_src4.cpp:JSID_FROM_BITS(unsigned long)
Unexecuted instantiation: Unified_cpp_js_src40.cpp:JSID_FROM_BITS(unsigned long)
Unexecuted instantiation: Unified_cpp_js_src41.cpp:JSID_FROM_BITS(unsigned long)
Unified_cpp_js_src42.cpp:JSID_FROM_BITS(unsigned long)
Line
Count
Source
2493
63
{
2494
63
    jsid id;
2495
63
    JSID_BITS(id) = bits;
2496
63
    return id;
2497
63
}
Unexecuted instantiation: Unified_cpp_js_src43.cpp:JSID_FROM_BITS(unsigned long)
Unexecuted instantiation: Unified_cpp_js_src44.cpp:JSID_FROM_BITS(unsigned long)
Unexecuted instantiation: Unified_cpp_js_src45.cpp:JSID_FROM_BITS(unsigned long)
Unexecuted instantiation: Unified_cpp_js_src5.cpp:JSID_FROM_BITS(unsigned long)
Unexecuted instantiation: Unified_cpp_js_src6.cpp:JSID_FROM_BITS(unsigned long)
Unexecuted instantiation: Unified_cpp_js_src7.cpp:JSID_FROM_BITS(unsigned long)
Unexecuted instantiation: Unified_cpp_js_src8.cpp:JSID_FROM_BITS(unsigned long)
Unexecuted instantiation: Unified_cpp_js_src9.cpp:JSID_FROM_BITS(unsigned long)
Unexecuted instantiation: RegExp.cpp:JSID_FROM_BITS(unsigned long)
Unexecuted instantiation: BinSource-auto.cpp:JSID_FROM_BITS(unsigned long)
Unexecuted instantiation: BinSource.cpp:JSID_FROM_BITS(unsigned long)
Unexecuted instantiation: BinToken.cpp:JSID_FROM_BITS(unsigned long)
Unexecuted instantiation: BinTokenReaderBase.cpp:JSID_FROM_BITS(unsigned long)
Unexecuted instantiation: BinTokenReaderMultipart.cpp:JSID_FROM_BITS(unsigned long)
Unexecuted instantiation: BinTokenReaderTester.cpp:JSID_FROM_BITS(unsigned long)
Unexecuted instantiation: Parser.cpp:JSID_FROM_BITS(unsigned long)
Unexecuted instantiation: Disassembler-x86-shared.cpp:JSID_FROM_BITS(unsigned long)
Unexecuted instantiation: jsmath.cpp:JSID_FROM_BITS(unsigned long)
Interpreter.cpp:JSID_FROM_BITS(unsigned long)
Line
Count
Source
2493
18
{
2494
18
    jsid id;
2495
18
    JSID_BITS(id) = bits;
2496
18
    return id;
2497
18
}
Unexecuted instantiation: VTuneWrapper.cpp:JSID_FROM_BITS(unsigned long)
Unexecuted instantiation: Unified_cpp_js_src13.cpp:JSID_FROM_BITS(unsigned long)
Unexecuted instantiation: Unified_cpp_js_src16.cpp:JSID_FROM_BITS(unsigned long)
2498
2499
namespace js {
2500
namespace detail {
2501
bool IdMatchesAtom(jsid id, JSAtom* atom);
2502
bool IdMatchesAtom(jsid id, JSString* atom);
2503
} // namespace detail
2504
} // namespace js
2505
2506
/**
2507
 * Must not be used on atoms that are representable as integer jsids.
2508
 * Prefer NameToId or AtomToId over this function:
2509
 *
2510
 * A PropertyName is an atom that does not contain an integer in the range
2511
 * [0, UINT32_MAX]. However, jsid can only hold an integer in the range
2512
 * [0, JSID_INT_MAX] (where JSID_INT_MAX == 2^31-1).  Thus, for the range of
2513
 * integers (JSID_INT_MAX, UINT32_MAX], to represent as a jsid 'id', it must be
2514
 * the case JSID_IS_ATOM(id) and !JSID_TO_ATOM(id)->isPropertyName().  In most
2515
 * cases when creating a jsid, code does not have to care about this corner
2516
 * case because:
2517
 *
2518
 * - When given an arbitrary JSAtom*, AtomToId must be used, which checks for
2519
 *   integer atoms representable as integer jsids, and does this conversion.
2520
 *
2521
 * - When given a PropertyName*, NameToId can be used which which does not need
2522
 *   to do any dynamic checks.
2523
 *
2524
 * Thus, it is only the rare third case which needs this function, which
2525
 * handles any JSAtom* that is known not to be representable with an int jsid.
2526
 */
2527
static MOZ_ALWAYS_INLINE jsid
2528
NON_INTEGER_ATOM_TO_JSID(JSAtom* atom)
2529
9.56M
{
2530
9.56M
    MOZ_ASSERT(((size_t)atom & JSID_TYPE_MASK) == 0);
2531
9.56M
    jsid id = JSID_FROM_BITS((size_t)atom | JSID_TYPE_STRING);
2532
9.56M
    MOZ_ASSERT(js::detail::IdMatchesAtom(id, atom));
2533
9.56M
    return id;
2534
9.56M
}
Unexecuted instantiation: Unified_cpp_js_ipc0.cpp:NON_INTEGER_ATOM_TO_JSID(JSAtom*)
Unexecuted instantiation: CTypes.cpp:NON_INTEGER_ATOM_TO_JSID(JSAtom*)
Unexecuted instantiation: Library.cpp:NON_INTEGER_ATOM_TO_JSID(JSAtom*)
Unexecuted instantiation: StoreBuffer.cpp:NON_INTEGER_ATOM_TO_JSID(JSAtom*)
Unexecuted instantiation: jsutil.cpp:NON_INTEGER_ATOM_TO_JSID(JSAtom*)
Unified_cpp_js_src0.cpp:NON_INTEGER_ATOM_TO_JSID(JSAtom*)
Line
Count
Source
2529
5.46M
{
2530
5.46M
    MOZ_ASSERT(((size_t)atom & JSID_TYPE_MASK) == 0);
2531
5.46M
    jsid id = JSID_FROM_BITS((size_t)atom | JSID_TYPE_STRING);
2532
5.46M
    MOZ_ASSERT(js::detail::IdMatchesAtom(id, atom));
2533
5.46M
    return id;
2534
5.46M
}
Unified_cpp_js_src1.cpp:NON_INTEGER_ATOM_TO_JSID(JSAtom*)
Line
Count
Source
2529
623
{
2530
623
    MOZ_ASSERT(((size_t)atom & JSID_TYPE_MASK) == 0);
2531
623
    jsid id = JSID_FROM_BITS((size_t)atom | JSID_TYPE_STRING);
2532
623
    MOZ_ASSERT(js::detail::IdMatchesAtom(id, atom));
2533
623
    return id;
2534
623
}
Unified_cpp_js_src10.cpp:NON_INTEGER_ATOM_TO_JSID(JSAtom*)
Line
Count
Source
2529
37
{
2530
37
    MOZ_ASSERT(((size_t)atom & JSID_TYPE_MASK) == 0);
2531
37
    jsid id = JSID_FROM_BITS((size_t)atom | JSID_TYPE_STRING);
2532
37
    MOZ_ASSERT(js::detail::IdMatchesAtom(id, atom));
2533
37
    return id;
2534
37
}
Unexecuted instantiation: Unified_cpp_js_src11.cpp:NON_INTEGER_ATOM_TO_JSID(JSAtom*)
Unexecuted instantiation: Unified_cpp_js_src12.cpp:NON_INTEGER_ATOM_TO_JSID(JSAtom*)
Unified_cpp_js_src14.cpp:NON_INTEGER_ATOM_TO_JSID(JSAtom*)
Line
Count
Source
2529
33
{
2530
33
    MOZ_ASSERT(((size_t)atom & JSID_TYPE_MASK) == 0);
2531
33
    jsid id = JSID_FROM_BITS((size_t)atom | JSID_TYPE_STRING);
2532
33
    MOZ_ASSERT(js::detail::IdMatchesAtom(id, atom));
2533
33
    return id;
2534
33
}
Unified_cpp_js_src15.cpp:NON_INTEGER_ATOM_TO_JSID(JSAtom*)
Line
Count
Source
2529
767
{
2530
767
    MOZ_ASSERT(((size_t)atom & JSID_TYPE_MASK) == 0);
2531
767
    jsid id = JSID_FROM_BITS((size_t)atom | JSID_TYPE_STRING);
2532
767
    MOZ_ASSERT(js::detail::IdMatchesAtom(id, atom));
2533
767
    return id;
2534
767
}
Unified_cpp_js_src17.cpp:NON_INTEGER_ATOM_TO_JSID(JSAtom*)
Line
Count
Source
2529
371
{
2530
371
    MOZ_ASSERT(((size_t)atom & JSID_TYPE_MASK) == 0);
2531
371
    jsid id = JSID_FROM_BITS((size_t)atom | JSID_TYPE_STRING);
2532
371
    MOZ_ASSERT(js::detail::IdMatchesAtom(id, atom));
2533
371
    return id;
2534
371
}
Unexecuted instantiation: Unified_cpp_js_src18.cpp:NON_INTEGER_ATOM_TO_JSID(JSAtom*)
Unexecuted instantiation: Unified_cpp_js_src19.cpp:NON_INTEGER_ATOM_TO_JSID(JSAtom*)
Unexecuted instantiation: Unified_cpp_js_src2.cpp:NON_INTEGER_ATOM_TO_JSID(JSAtom*)
Unified_cpp_js_src20.cpp:NON_INTEGER_ATOM_TO_JSID(JSAtom*)
Line
Count
Source
2529
72
{
2530
72
    MOZ_ASSERT(((size_t)atom & JSID_TYPE_MASK) == 0);
2531
72
    jsid id = JSID_FROM_BITS((size_t)atom | JSID_TYPE_STRING);
2532
72
    MOZ_ASSERT(js::detail::IdMatchesAtom(id, atom));
2533
72
    return id;
2534
72
}
Unexecuted instantiation: Unified_cpp_js_src21.cpp:NON_INTEGER_ATOM_TO_JSID(JSAtom*)
Unexecuted instantiation: Unified_cpp_js_src22.cpp:NON_INTEGER_ATOM_TO_JSID(JSAtom*)
Unified_cpp_js_src23.cpp:NON_INTEGER_ATOM_TO_JSID(JSAtom*)
Line
Count
Source
2529
758k
{
2530
758k
    MOZ_ASSERT(((size_t)atom & JSID_TYPE_MASK) == 0);
2531
758k
    jsid id = JSID_FROM_BITS((size_t)atom | JSID_TYPE_STRING);
2532
758k
    MOZ_ASSERT(js::detail::IdMatchesAtom(id, atom));
2533
758k
    return id;
2534
758k
}
Unexecuted instantiation: Unified_cpp_js_src24.cpp:NON_INTEGER_ATOM_TO_JSID(JSAtom*)
Unexecuted instantiation: Unified_cpp_js_src25.cpp:NON_INTEGER_ATOM_TO_JSID(JSAtom*)
Unexecuted instantiation: Unified_cpp_js_src26.cpp:NON_INTEGER_ATOM_TO_JSID(JSAtom*)
Unexecuted instantiation: Unified_cpp_js_src27.cpp:NON_INTEGER_ATOM_TO_JSID(JSAtom*)
Unexecuted instantiation: Unified_cpp_js_src28.cpp:NON_INTEGER_ATOM_TO_JSID(JSAtom*)
Unexecuted instantiation: Unified_cpp_js_src29.cpp:NON_INTEGER_ATOM_TO_JSID(JSAtom*)
Unexecuted instantiation: Unified_cpp_js_src3.cpp:NON_INTEGER_ATOM_TO_JSID(JSAtom*)
Unexecuted instantiation: Unified_cpp_js_src30.cpp:NON_INTEGER_ATOM_TO_JSID(JSAtom*)
Unexecuted instantiation: Unified_cpp_js_src31.cpp:NON_INTEGER_ATOM_TO_JSID(JSAtom*)
Unexecuted instantiation: Unified_cpp_js_src32.cpp:NON_INTEGER_ATOM_TO_JSID(JSAtom*)
Unexecuted instantiation: Unified_cpp_js_src33.cpp:NON_INTEGER_ATOM_TO_JSID(JSAtom*)
Unified_cpp_js_src34.cpp:NON_INTEGER_ATOM_TO_JSID(JSAtom*)
Line
Count
Source
2529
5
{
2530
5
    MOZ_ASSERT(((size_t)atom & JSID_TYPE_MASK) == 0);
2531
5
    jsid id = JSID_FROM_BITS((size_t)atom | JSID_TYPE_STRING);
2532
5
    MOZ_ASSERT(js::detail::IdMatchesAtom(id, atom));
2533
5
    return id;
2534
5
}
Unified_cpp_js_src35.cpp:NON_INTEGER_ATOM_TO_JSID(JSAtom*)
Line
Count
Source
2529
180
{
2530
180
    MOZ_ASSERT(((size_t)atom & JSID_TYPE_MASK) == 0);
2531
180
    jsid id = JSID_FROM_BITS((size_t)atom | JSID_TYPE_STRING);
2532
180
    MOZ_ASSERT(js::detail::IdMatchesAtom(id, atom));
2533
180
    return id;
2534
180
}
Unified_cpp_js_src36.cpp:NON_INTEGER_ATOM_TO_JSID(JSAtom*)
Line
Count
Source
2529
3.33M
{
2530
3.33M
    MOZ_ASSERT(((size_t)atom & JSID_TYPE_MASK) == 0);
2531
3.33M
    jsid id = JSID_FROM_BITS((size_t)atom | JSID_TYPE_STRING);
2532
3.33M
    MOZ_ASSERT(js::detail::IdMatchesAtom(id, atom));
2533
3.33M
    return id;
2534
3.33M
}
Unified_cpp_js_src37.cpp:NON_INTEGER_ATOM_TO_JSID(JSAtom*)
Line
Count
Source
2529
428
{
2530
428
    MOZ_ASSERT(((size_t)atom & JSID_TYPE_MASK) == 0);
2531
428
    jsid id = JSID_FROM_BITS((size_t)atom | JSID_TYPE_STRING);
2532
428
    MOZ_ASSERT(js::detail::IdMatchesAtom(id, atom));
2533
428
    return id;
2534
428
}
Unexecuted instantiation: Unified_cpp_js_src38.cpp:NON_INTEGER_ATOM_TO_JSID(JSAtom*)
Unified_cpp_js_src39.cpp:NON_INTEGER_ATOM_TO_JSID(JSAtom*)
Line
Count
Source
2529
322
{
2530
322
    MOZ_ASSERT(((size_t)atom & JSID_TYPE_MASK) == 0);
2531
322
    jsid id = JSID_FROM_BITS((size_t)atom | JSID_TYPE_STRING);
2532
322
    MOZ_ASSERT(js::detail::IdMatchesAtom(id, atom));
2533
322
    return id;
2534
322
}
Unexecuted instantiation: Unified_cpp_js_src4.cpp:NON_INTEGER_ATOM_TO_JSID(JSAtom*)
Unexecuted instantiation: Unified_cpp_js_src40.cpp:NON_INTEGER_ATOM_TO_JSID(JSAtom*)
Unexecuted instantiation: Unified_cpp_js_src41.cpp:NON_INTEGER_ATOM_TO_JSID(JSAtom*)
Unified_cpp_js_src42.cpp:NON_INTEGER_ATOM_TO_JSID(JSAtom*)
Line
Count
Source
2529
63
{
2530
63
    MOZ_ASSERT(((size_t)atom & JSID_TYPE_MASK) == 0);
2531
63
    jsid id = JSID_FROM_BITS((size_t)atom | JSID_TYPE_STRING);
2532
63
    MOZ_ASSERT(js::detail::IdMatchesAtom(id, atom));
2533
63
    return id;
2534
63
}
Unexecuted instantiation: Unified_cpp_js_src43.cpp:NON_INTEGER_ATOM_TO_JSID(JSAtom*)
Unexecuted instantiation: Unified_cpp_js_src44.cpp:NON_INTEGER_ATOM_TO_JSID(JSAtom*)
Unexecuted instantiation: Unified_cpp_js_src45.cpp:NON_INTEGER_ATOM_TO_JSID(JSAtom*)
Unexecuted instantiation: Unified_cpp_js_src5.cpp:NON_INTEGER_ATOM_TO_JSID(JSAtom*)
Unexecuted instantiation: Unified_cpp_js_src6.cpp:NON_INTEGER_ATOM_TO_JSID(JSAtom*)
Unexecuted instantiation: Unified_cpp_js_src7.cpp:NON_INTEGER_ATOM_TO_JSID(JSAtom*)
Unexecuted instantiation: Unified_cpp_js_src8.cpp:NON_INTEGER_ATOM_TO_JSID(JSAtom*)
Unexecuted instantiation: Unified_cpp_js_src9.cpp:NON_INTEGER_ATOM_TO_JSID(JSAtom*)
Unexecuted instantiation: RegExp.cpp:NON_INTEGER_ATOM_TO_JSID(JSAtom*)
Unexecuted instantiation: BinSource-auto.cpp:NON_INTEGER_ATOM_TO_JSID(JSAtom*)
Unexecuted instantiation: BinSource.cpp:NON_INTEGER_ATOM_TO_JSID(JSAtom*)
Unexecuted instantiation: BinToken.cpp:NON_INTEGER_ATOM_TO_JSID(JSAtom*)
Unexecuted instantiation: BinTokenReaderBase.cpp:NON_INTEGER_ATOM_TO_JSID(JSAtom*)
Unexecuted instantiation: BinTokenReaderMultipart.cpp:NON_INTEGER_ATOM_TO_JSID(JSAtom*)
Unexecuted instantiation: BinTokenReaderTester.cpp:NON_INTEGER_ATOM_TO_JSID(JSAtom*)
Unexecuted instantiation: Parser.cpp:NON_INTEGER_ATOM_TO_JSID(JSAtom*)
Unexecuted instantiation: Disassembler-x86-shared.cpp:NON_INTEGER_ATOM_TO_JSID(JSAtom*)
Unexecuted instantiation: jsmath.cpp:NON_INTEGER_ATOM_TO_JSID(JSAtom*)
Interpreter.cpp:NON_INTEGER_ATOM_TO_JSID(JSAtom*)
Line
Count
Source
2529
18
{
2530
18
    MOZ_ASSERT(((size_t)atom & JSID_TYPE_MASK) == 0);
2531
18
    jsid id = JSID_FROM_BITS((size_t)atom | JSID_TYPE_STRING);
2532
18
    MOZ_ASSERT(js::detail::IdMatchesAtom(id, atom));
2533
18
    return id;
2534
18
}
Unexecuted instantiation: VTuneWrapper.cpp:NON_INTEGER_ATOM_TO_JSID(JSAtom*)
Unexecuted instantiation: Unified_cpp_js_src13.cpp:NON_INTEGER_ATOM_TO_JSID(JSAtom*)
Unexecuted instantiation: Unified_cpp_js_src16.cpp:NON_INTEGER_ATOM_TO_JSID(JSAtom*)
2535
2536
static MOZ_ALWAYS_INLINE jsid
2537
NON_INTEGER_ATOM_TO_JSID(JSString* atom)
2538
0
{
2539
0
    MOZ_ASSERT(((size_t)atom & JSID_TYPE_MASK) == 0);
2540
0
    jsid id = JSID_FROM_BITS((size_t)atom | JSID_TYPE_STRING);
2541
0
    MOZ_ASSERT(js::detail::IdMatchesAtom(id, atom));
2542
0
    return id;
2543
0
}
Unexecuted instantiation: Unified_cpp_js_ipc0.cpp:NON_INTEGER_ATOM_TO_JSID(JSString*)
Unexecuted instantiation: CTypes.cpp:NON_INTEGER_ATOM_TO_JSID(JSString*)
Unexecuted instantiation: Library.cpp:NON_INTEGER_ATOM_TO_JSID(JSString*)
Unexecuted instantiation: StoreBuffer.cpp:NON_INTEGER_ATOM_TO_JSID(JSString*)
Unexecuted instantiation: jsutil.cpp:NON_INTEGER_ATOM_TO_JSID(JSString*)
Unexecuted instantiation: Unified_cpp_js_src0.cpp:NON_INTEGER_ATOM_TO_JSID(JSString*)
Unexecuted instantiation: Unified_cpp_js_src1.cpp:NON_INTEGER_ATOM_TO_JSID(JSString*)
Unexecuted instantiation: Unified_cpp_js_src10.cpp:NON_INTEGER_ATOM_TO_JSID(JSString*)
Unexecuted instantiation: Unified_cpp_js_src11.cpp:NON_INTEGER_ATOM_TO_JSID(JSString*)
Unexecuted instantiation: Unified_cpp_js_src12.cpp:NON_INTEGER_ATOM_TO_JSID(JSString*)
Unexecuted instantiation: Unified_cpp_js_src14.cpp:NON_INTEGER_ATOM_TO_JSID(JSString*)
Unexecuted instantiation: Unified_cpp_js_src15.cpp:NON_INTEGER_ATOM_TO_JSID(JSString*)
Unexecuted instantiation: Unified_cpp_js_src17.cpp:NON_INTEGER_ATOM_TO_JSID(JSString*)
Unexecuted instantiation: Unified_cpp_js_src18.cpp:NON_INTEGER_ATOM_TO_JSID(JSString*)
Unexecuted instantiation: Unified_cpp_js_src19.cpp:NON_INTEGER_ATOM_TO_JSID(JSString*)
Unexecuted instantiation: Unified_cpp_js_src2.cpp:NON_INTEGER_ATOM_TO_JSID(JSString*)
Unexecuted instantiation: Unified_cpp_js_src20.cpp:NON_INTEGER_ATOM_TO_JSID(JSString*)
Unexecuted instantiation: Unified_cpp_js_src21.cpp:NON_INTEGER_ATOM_TO_JSID(JSString*)
Unexecuted instantiation: Unified_cpp_js_src22.cpp:NON_INTEGER_ATOM_TO_JSID(JSString*)
Unexecuted instantiation: Unified_cpp_js_src23.cpp:NON_INTEGER_ATOM_TO_JSID(JSString*)
Unexecuted instantiation: Unified_cpp_js_src24.cpp:NON_INTEGER_ATOM_TO_JSID(JSString*)
Unexecuted instantiation: Unified_cpp_js_src25.cpp:NON_INTEGER_ATOM_TO_JSID(JSString*)
Unexecuted instantiation: Unified_cpp_js_src26.cpp:NON_INTEGER_ATOM_TO_JSID(JSString*)
Unexecuted instantiation: Unified_cpp_js_src27.cpp:NON_INTEGER_ATOM_TO_JSID(JSString*)
Unexecuted instantiation: Unified_cpp_js_src28.cpp:NON_INTEGER_ATOM_TO_JSID(JSString*)
Unexecuted instantiation: Unified_cpp_js_src29.cpp:NON_INTEGER_ATOM_TO_JSID(JSString*)
Unexecuted instantiation: Unified_cpp_js_src3.cpp:NON_INTEGER_ATOM_TO_JSID(JSString*)
Unexecuted instantiation: Unified_cpp_js_src30.cpp:NON_INTEGER_ATOM_TO_JSID(JSString*)
Unexecuted instantiation: Unified_cpp_js_src31.cpp:NON_INTEGER_ATOM_TO_JSID(JSString*)
Unexecuted instantiation: Unified_cpp_js_src32.cpp:NON_INTEGER_ATOM_TO_JSID(JSString*)
Unexecuted instantiation: Unified_cpp_js_src33.cpp:NON_INTEGER_ATOM_TO_JSID(JSString*)
Unexecuted instantiation: Unified_cpp_js_src34.cpp:NON_INTEGER_ATOM_TO_JSID(JSString*)
Unexecuted instantiation: Unified_cpp_js_src35.cpp:NON_INTEGER_ATOM_TO_JSID(JSString*)
Unexecuted instantiation: Unified_cpp_js_src36.cpp:NON_INTEGER_ATOM_TO_JSID(JSString*)
Unexecuted instantiation: Unified_cpp_js_src37.cpp:NON_INTEGER_ATOM_TO_JSID(JSString*)
Unexecuted instantiation: Unified_cpp_js_src38.cpp:NON_INTEGER_ATOM_TO_JSID(JSString*)
Unexecuted instantiation: Unified_cpp_js_src39.cpp:NON_INTEGER_ATOM_TO_JSID(JSString*)
Unexecuted instantiation: Unified_cpp_js_src4.cpp:NON_INTEGER_ATOM_TO_JSID(JSString*)
Unexecuted instantiation: Unified_cpp_js_src40.cpp:NON_INTEGER_ATOM_TO_JSID(JSString*)
Unexecuted instantiation: Unified_cpp_js_src41.cpp:NON_INTEGER_ATOM_TO_JSID(JSString*)
Unexecuted instantiation: Unified_cpp_js_src42.cpp:NON_INTEGER_ATOM_TO_JSID(JSString*)
Unexecuted instantiation: Unified_cpp_js_src43.cpp:NON_INTEGER_ATOM_TO_JSID(JSString*)
Unexecuted instantiation: Unified_cpp_js_src44.cpp:NON_INTEGER_ATOM_TO_JSID(JSString*)
Unexecuted instantiation: Unified_cpp_js_src45.cpp:NON_INTEGER_ATOM_TO_JSID(JSString*)
Unexecuted instantiation: Unified_cpp_js_src5.cpp:NON_INTEGER_ATOM_TO_JSID(JSString*)
Unexecuted instantiation: Unified_cpp_js_src6.cpp:NON_INTEGER_ATOM_TO_JSID(JSString*)
Unexecuted instantiation: Unified_cpp_js_src7.cpp:NON_INTEGER_ATOM_TO_JSID(JSString*)
Unexecuted instantiation: Unified_cpp_js_src8.cpp:NON_INTEGER_ATOM_TO_JSID(JSString*)
Unexecuted instantiation: Unified_cpp_js_src9.cpp:NON_INTEGER_ATOM_TO_JSID(JSString*)
Unexecuted instantiation: RegExp.cpp:NON_INTEGER_ATOM_TO_JSID(JSString*)
Unexecuted instantiation: BinSource-auto.cpp:NON_INTEGER_ATOM_TO_JSID(JSString*)
Unexecuted instantiation: BinSource.cpp:NON_INTEGER_ATOM_TO_JSID(JSString*)
Unexecuted instantiation: BinToken.cpp:NON_INTEGER_ATOM_TO_JSID(JSString*)
Unexecuted instantiation: BinTokenReaderBase.cpp:NON_INTEGER_ATOM_TO_JSID(JSString*)
Unexecuted instantiation: BinTokenReaderMultipart.cpp:NON_INTEGER_ATOM_TO_JSID(JSString*)
Unexecuted instantiation: BinTokenReaderTester.cpp:NON_INTEGER_ATOM_TO_JSID(JSString*)
Unexecuted instantiation: Parser.cpp:NON_INTEGER_ATOM_TO_JSID(JSString*)
Unexecuted instantiation: Disassembler-x86-shared.cpp:NON_INTEGER_ATOM_TO_JSID(JSString*)
Unexecuted instantiation: jsmath.cpp:NON_INTEGER_ATOM_TO_JSID(JSString*)
Unexecuted instantiation: Interpreter.cpp:NON_INTEGER_ATOM_TO_JSID(JSString*)
Unexecuted instantiation: VTuneWrapper.cpp:NON_INTEGER_ATOM_TO_JSID(JSString*)
Unexecuted instantiation: Unified_cpp_js_src13.cpp:NON_INTEGER_ATOM_TO_JSID(JSString*)
Unexecuted instantiation: Unified_cpp_js_src16.cpp:NON_INTEGER_ATOM_TO_JSID(JSString*)
2544
2545
/* All strings stored in jsids are atomized, but are not necessarily property names. */
2546
static MOZ_ALWAYS_INLINE bool
2547
JSID_IS_ATOM(jsid id)
2548
14.6M
{
2549
14.6M
    return JSID_IS_STRING(id);
2550
14.6M
}
Unexecuted instantiation: Unified_cpp_js_ipc0.cpp:JSID_IS_ATOM(jsid)
Unexecuted instantiation: CTypes.cpp:JSID_IS_ATOM(jsid)
Unexecuted instantiation: Library.cpp:JSID_IS_ATOM(jsid)
Unexecuted instantiation: StoreBuffer.cpp:JSID_IS_ATOM(jsid)
Unexecuted instantiation: jsutil.cpp:JSID_IS_ATOM(jsid)
Unexecuted instantiation: Unified_cpp_js_src0.cpp:JSID_IS_ATOM(jsid)
Unexecuted instantiation: Unified_cpp_js_src1.cpp:JSID_IS_ATOM(jsid)
Unexecuted instantiation: Unified_cpp_js_src10.cpp:JSID_IS_ATOM(jsid)
Unexecuted instantiation: Unified_cpp_js_src11.cpp:JSID_IS_ATOM(jsid)
Unexecuted instantiation: Unified_cpp_js_src12.cpp:JSID_IS_ATOM(jsid)
Unexecuted instantiation: Unified_cpp_js_src14.cpp:JSID_IS_ATOM(jsid)
Unexecuted instantiation: Unified_cpp_js_src15.cpp:JSID_IS_ATOM(jsid)
Unexecuted instantiation: Unified_cpp_js_src17.cpp:JSID_IS_ATOM(jsid)
Unexecuted instantiation: Unified_cpp_js_src18.cpp:JSID_IS_ATOM(jsid)
Unexecuted instantiation: Unified_cpp_js_src19.cpp:JSID_IS_ATOM(jsid)
Unexecuted instantiation: Unified_cpp_js_src2.cpp:JSID_IS_ATOM(jsid)
Unexecuted instantiation: Unified_cpp_js_src20.cpp:JSID_IS_ATOM(jsid)
Unexecuted instantiation: Unified_cpp_js_src21.cpp:JSID_IS_ATOM(jsid)
Unexecuted instantiation: Unified_cpp_js_src22.cpp:JSID_IS_ATOM(jsid)
Unexecuted instantiation: Unified_cpp_js_src23.cpp:JSID_IS_ATOM(jsid)
Unexecuted instantiation: Unified_cpp_js_src24.cpp:JSID_IS_ATOM(jsid)
Unexecuted instantiation: Unified_cpp_js_src25.cpp:JSID_IS_ATOM(jsid)
Unexecuted instantiation: Unified_cpp_js_src26.cpp:JSID_IS_ATOM(jsid)
Unified_cpp_js_src27.cpp:JSID_IS_ATOM(jsid)
Line
Count
Source
2548
11.3M
{
2549
11.3M
    return JSID_IS_STRING(id);
2550
11.3M
}
Unexecuted instantiation: Unified_cpp_js_src28.cpp:JSID_IS_ATOM(jsid)
Unexecuted instantiation: Unified_cpp_js_src29.cpp:JSID_IS_ATOM(jsid)
Unexecuted instantiation: Unified_cpp_js_src3.cpp:JSID_IS_ATOM(jsid)
Unexecuted instantiation: Unified_cpp_js_src30.cpp:JSID_IS_ATOM(jsid)
Unexecuted instantiation: Unified_cpp_js_src31.cpp:JSID_IS_ATOM(jsid)
Unexecuted instantiation: Unified_cpp_js_src32.cpp:JSID_IS_ATOM(jsid)
Unexecuted instantiation: Unified_cpp_js_src33.cpp:JSID_IS_ATOM(jsid)
Unexecuted instantiation: Unified_cpp_js_src34.cpp:JSID_IS_ATOM(jsid)
Unexecuted instantiation: Unified_cpp_js_src35.cpp:JSID_IS_ATOM(jsid)
Unified_cpp_js_src36.cpp:JSID_IS_ATOM(jsid)
Line
Count
Source
2548
3.25M
{
2549
3.25M
    return JSID_IS_STRING(id);
2550
3.25M
}
Unified_cpp_js_src37.cpp:JSID_IS_ATOM(jsid)
Line
Count
Source
2548
4.23k
{
2549
4.23k
    return JSID_IS_STRING(id);
2550
4.23k
}
Unexecuted instantiation: Unified_cpp_js_src38.cpp:JSID_IS_ATOM(jsid)
Unified_cpp_js_src39.cpp:JSID_IS_ATOM(jsid)
Line
Count
Source
2548
2.46k
{
2549
2.46k
    return JSID_IS_STRING(id);
2550
2.46k
}
Unexecuted instantiation: Unified_cpp_js_src4.cpp:JSID_IS_ATOM(jsid)
Unexecuted instantiation: Unified_cpp_js_src40.cpp:JSID_IS_ATOM(jsid)
Unexecuted instantiation: Unified_cpp_js_src41.cpp:JSID_IS_ATOM(jsid)
Unified_cpp_js_src42.cpp:JSID_IS_ATOM(jsid)
Line
Count
Source
2548
3
{
2549
3
    return JSID_IS_STRING(id);
2550
3
}
Unexecuted instantiation: Unified_cpp_js_src43.cpp:JSID_IS_ATOM(jsid)
Unexecuted instantiation: Unified_cpp_js_src44.cpp:JSID_IS_ATOM(jsid)
Unexecuted instantiation: Unified_cpp_js_src45.cpp:JSID_IS_ATOM(jsid)
Unexecuted instantiation: Unified_cpp_js_src5.cpp:JSID_IS_ATOM(jsid)
Unexecuted instantiation: Unified_cpp_js_src6.cpp:JSID_IS_ATOM(jsid)
Unexecuted instantiation: Unified_cpp_js_src7.cpp:JSID_IS_ATOM(jsid)
Unified_cpp_js_src8.cpp:JSID_IS_ATOM(jsid)
Line
Count
Source
2548
2
{
2549
2
    return JSID_IS_STRING(id);
2550
2
}
Unexecuted instantiation: Unified_cpp_js_src9.cpp:JSID_IS_ATOM(jsid)
Unexecuted instantiation: RegExp.cpp:JSID_IS_ATOM(jsid)
Unexecuted instantiation: BinSource-auto.cpp:JSID_IS_ATOM(jsid)
Unexecuted instantiation: BinSource.cpp:JSID_IS_ATOM(jsid)
Unexecuted instantiation: BinToken.cpp:JSID_IS_ATOM(jsid)
Unexecuted instantiation: BinTokenReaderBase.cpp:JSID_IS_ATOM(jsid)
Unexecuted instantiation: BinTokenReaderMultipart.cpp:JSID_IS_ATOM(jsid)
Unexecuted instantiation: BinTokenReaderTester.cpp:JSID_IS_ATOM(jsid)
Unexecuted instantiation: Parser.cpp:JSID_IS_ATOM(jsid)
Unexecuted instantiation: Disassembler-x86-shared.cpp:JSID_IS_ATOM(jsid)
Unexecuted instantiation: jsmath.cpp:JSID_IS_ATOM(jsid)
Interpreter.cpp:JSID_IS_ATOM(jsid)
Line
Count
Source
2548
1
{
2549
1
    return JSID_IS_STRING(id);
2550
1
}
Unexecuted instantiation: VTuneWrapper.cpp:JSID_IS_ATOM(jsid)
Unexecuted instantiation: Unified_cpp_js_src13.cpp:JSID_IS_ATOM(jsid)
Unexecuted instantiation: Unified_cpp_js_src16.cpp:JSID_IS_ATOM(jsid)
2551
2552
static MOZ_ALWAYS_INLINE bool
2553
JSID_IS_ATOM(jsid id, JSAtom* atom)
2554
1.24k
{
2555
1.24k
    return id == NON_INTEGER_ATOM_TO_JSID(atom);
2556
1.24k
}
Unexecuted instantiation: Unified_cpp_js_ipc0.cpp:JSID_IS_ATOM(jsid, JSAtom*)
Unexecuted instantiation: CTypes.cpp:JSID_IS_ATOM(jsid, JSAtom*)
Unexecuted instantiation: Library.cpp:JSID_IS_ATOM(jsid, JSAtom*)
Unexecuted instantiation: StoreBuffer.cpp:JSID_IS_ATOM(jsid, JSAtom*)
Unexecuted instantiation: jsutil.cpp:JSID_IS_ATOM(jsid, JSAtom*)
Unexecuted instantiation: Unified_cpp_js_src0.cpp:JSID_IS_ATOM(jsid, JSAtom*)
Unexecuted instantiation: Unified_cpp_js_src1.cpp:JSID_IS_ATOM(jsid, JSAtom*)
Unexecuted instantiation: Unified_cpp_js_src10.cpp:JSID_IS_ATOM(jsid, JSAtom*)
Unexecuted instantiation: Unified_cpp_js_src11.cpp:JSID_IS_ATOM(jsid, JSAtom*)
Unexecuted instantiation: Unified_cpp_js_src12.cpp:JSID_IS_ATOM(jsid, JSAtom*)
Unexecuted instantiation: Unified_cpp_js_src14.cpp:JSID_IS_ATOM(jsid, JSAtom*)
Unified_cpp_js_src15.cpp:JSID_IS_ATOM(jsid, JSAtom*)
Line
Count
Source
2554
590
{
2555
590
    return id == NON_INTEGER_ATOM_TO_JSID(atom);
2556
590
}
Unexecuted instantiation: Unified_cpp_js_src17.cpp:JSID_IS_ATOM(jsid, JSAtom*)
Unexecuted instantiation: Unified_cpp_js_src18.cpp:JSID_IS_ATOM(jsid, JSAtom*)
Unexecuted instantiation: Unified_cpp_js_src19.cpp:JSID_IS_ATOM(jsid, JSAtom*)
Unexecuted instantiation: Unified_cpp_js_src2.cpp:JSID_IS_ATOM(jsid, JSAtom*)
Unexecuted instantiation: Unified_cpp_js_src20.cpp:JSID_IS_ATOM(jsid, JSAtom*)
Unexecuted instantiation: Unified_cpp_js_src21.cpp:JSID_IS_ATOM(jsid, JSAtom*)
Unexecuted instantiation: Unified_cpp_js_src22.cpp:JSID_IS_ATOM(jsid, JSAtom*)
Unexecuted instantiation: Unified_cpp_js_src23.cpp:JSID_IS_ATOM(jsid, JSAtom*)
Unexecuted instantiation: Unified_cpp_js_src24.cpp:JSID_IS_ATOM(jsid, JSAtom*)
Unexecuted instantiation: Unified_cpp_js_src25.cpp:JSID_IS_ATOM(jsid, JSAtom*)
Unexecuted instantiation: Unified_cpp_js_src26.cpp:JSID_IS_ATOM(jsid, JSAtom*)
Unexecuted instantiation: Unified_cpp_js_src27.cpp:JSID_IS_ATOM(jsid, JSAtom*)
Unexecuted instantiation: Unified_cpp_js_src28.cpp:JSID_IS_ATOM(jsid, JSAtom*)
Unexecuted instantiation: Unified_cpp_js_src29.cpp:JSID_IS_ATOM(jsid, JSAtom*)
Unexecuted instantiation: Unified_cpp_js_src3.cpp:JSID_IS_ATOM(jsid, JSAtom*)
Unexecuted instantiation: Unified_cpp_js_src30.cpp:JSID_IS_ATOM(jsid, JSAtom*)
Unexecuted instantiation: Unified_cpp_js_src31.cpp:JSID_IS_ATOM(jsid, JSAtom*)
Unexecuted instantiation: Unified_cpp_js_src32.cpp:JSID_IS_ATOM(jsid, JSAtom*)
Unexecuted instantiation: Unified_cpp_js_src33.cpp:JSID_IS_ATOM(jsid, JSAtom*)
Unexecuted instantiation: Unified_cpp_js_src34.cpp:JSID_IS_ATOM(jsid, JSAtom*)
Unexecuted instantiation: Unified_cpp_js_src35.cpp:JSID_IS_ATOM(jsid, JSAtom*)
Unified_cpp_js_src36.cpp:JSID_IS_ATOM(jsid, JSAtom*)
Line
Count
Source
2554
657
{
2555
657
    return id == NON_INTEGER_ATOM_TO_JSID(atom);
2556
657
}
Unexecuted instantiation: Unified_cpp_js_src37.cpp:JSID_IS_ATOM(jsid, JSAtom*)
Unexecuted instantiation: Unified_cpp_js_src38.cpp:JSID_IS_ATOM(jsid, JSAtom*)
Unexecuted instantiation: Unified_cpp_js_src39.cpp:JSID_IS_ATOM(jsid, JSAtom*)
Unexecuted instantiation: Unified_cpp_js_src4.cpp:JSID_IS_ATOM(jsid, JSAtom*)
Unexecuted instantiation: Unified_cpp_js_src40.cpp:JSID_IS_ATOM(jsid, JSAtom*)
Unexecuted instantiation: Unified_cpp_js_src41.cpp:JSID_IS_ATOM(jsid, JSAtom*)
Unexecuted instantiation: Unified_cpp_js_src42.cpp:JSID_IS_ATOM(jsid, JSAtom*)
Unexecuted instantiation: Unified_cpp_js_src43.cpp:JSID_IS_ATOM(jsid, JSAtom*)
Unexecuted instantiation: Unified_cpp_js_src44.cpp:JSID_IS_ATOM(jsid, JSAtom*)
Unexecuted instantiation: Unified_cpp_js_src45.cpp:JSID_IS_ATOM(jsid, JSAtom*)
Unexecuted instantiation: Unified_cpp_js_src5.cpp:JSID_IS_ATOM(jsid, JSAtom*)
Unexecuted instantiation: Unified_cpp_js_src6.cpp:JSID_IS_ATOM(jsid, JSAtom*)
Unexecuted instantiation: Unified_cpp_js_src7.cpp:JSID_IS_ATOM(jsid, JSAtom*)
Unexecuted instantiation: Unified_cpp_js_src8.cpp:JSID_IS_ATOM(jsid, JSAtom*)
Unexecuted instantiation: Unified_cpp_js_src9.cpp:JSID_IS_ATOM(jsid, JSAtom*)
Unexecuted instantiation: RegExp.cpp:JSID_IS_ATOM(jsid, JSAtom*)
Unexecuted instantiation: BinSource-auto.cpp:JSID_IS_ATOM(jsid, JSAtom*)
Unexecuted instantiation: BinSource.cpp:JSID_IS_ATOM(jsid, JSAtom*)
Unexecuted instantiation: BinToken.cpp:JSID_IS_ATOM(jsid, JSAtom*)
Unexecuted instantiation: BinTokenReaderBase.cpp:JSID_IS_ATOM(jsid, JSAtom*)
Unexecuted instantiation: BinTokenReaderMultipart.cpp:JSID_IS_ATOM(jsid, JSAtom*)
Unexecuted instantiation: BinTokenReaderTester.cpp:JSID_IS_ATOM(jsid, JSAtom*)
Unexecuted instantiation: Parser.cpp:JSID_IS_ATOM(jsid, JSAtom*)
Unexecuted instantiation: Disassembler-x86-shared.cpp:JSID_IS_ATOM(jsid, JSAtom*)
Unexecuted instantiation: jsmath.cpp:JSID_IS_ATOM(jsid, JSAtom*)
Unexecuted instantiation: Interpreter.cpp:JSID_IS_ATOM(jsid, JSAtom*)
Unexecuted instantiation: VTuneWrapper.cpp:JSID_IS_ATOM(jsid, JSAtom*)
Unexecuted instantiation: Unified_cpp_js_src13.cpp:JSID_IS_ATOM(jsid, JSAtom*)
Unexecuted instantiation: Unified_cpp_js_src16.cpp:JSID_IS_ATOM(jsid, JSAtom*)
2557
2558
static MOZ_ALWAYS_INLINE JSAtom*
2559
JSID_TO_ATOM(jsid id)
2560
21.1M
{
2561
21.1M
    return (JSAtom*)JSID_TO_STRING(id);
2562
21.1M
}
Unexecuted instantiation: Unified_cpp_js_ipc0.cpp:JSID_TO_ATOM(jsid)
Unexecuted instantiation: CTypes.cpp:JSID_TO_ATOM(jsid)
Unexecuted instantiation: Library.cpp:JSID_TO_ATOM(jsid)
Unexecuted instantiation: StoreBuffer.cpp:JSID_TO_ATOM(jsid)
Unexecuted instantiation: jsutil.cpp:JSID_TO_ATOM(jsid)
Unified_cpp_js_src0.cpp:JSID_TO_ATOM(jsid)
Line
Count
Source
2560
33
{
2561
33
    return (JSAtom*)JSID_TO_STRING(id);
2562
33
}
Unexecuted instantiation: Unified_cpp_js_src1.cpp:JSID_TO_ATOM(jsid)
Unexecuted instantiation: Unified_cpp_js_src10.cpp:JSID_TO_ATOM(jsid)
Unexecuted instantiation: Unified_cpp_js_src11.cpp:JSID_TO_ATOM(jsid)
Unexecuted instantiation: Unified_cpp_js_src12.cpp:JSID_TO_ATOM(jsid)
Unexecuted instantiation: Unified_cpp_js_src14.cpp:JSID_TO_ATOM(jsid)
Unified_cpp_js_src15.cpp:JSID_TO_ATOM(jsid)
Line
Count
Source
2560
673
{
2561
673
    return (JSAtom*)JSID_TO_STRING(id);
2562
673
}
Unexecuted instantiation: Unified_cpp_js_src17.cpp:JSID_TO_ATOM(jsid)
Unexecuted instantiation: Unified_cpp_js_src18.cpp:JSID_TO_ATOM(jsid)
Unexecuted instantiation: Unified_cpp_js_src19.cpp:JSID_TO_ATOM(jsid)
Unexecuted instantiation: Unified_cpp_js_src2.cpp:JSID_TO_ATOM(jsid)
Unexecuted instantiation: Unified_cpp_js_src20.cpp:JSID_TO_ATOM(jsid)
Unexecuted instantiation: Unified_cpp_js_src21.cpp:JSID_TO_ATOM(jsid)
Unexecuted instantiation: Unified_cpp_js_src22.cpp:JSID_TO_ATOM(jsid)
Unexecuted instantiation: Unified_cpp_js_src23.cpp:JSID_TO_ATOM(jsid)
Unexecuted instantiation: Unified_cpp_js_src24.cpp:JSID_TO_ATOM(jsid)
Unexecuted instantiation: Unified_cpp_js_src25.cpp:JSID_TO_ATOM(jsid)
Unexecuted instantiation: Unified_cpp_js_src26.cpp:JSID_TO_ATOM(jsid)
Unified_cpp_js_src27.cpp:JSID_TO_ATOM(jsid)
Line
Count
Source
2560
14.6M
{
2561
14.6M
    return (JSAtom*)JSID_TO_STRING(id);
2562
14.6M
}
Unexecuted instantiation: Unified_cpp_js_src28.cpp:JSID_TO_ATOM(jsid)
Unexecuted instantiation: Unified_cpp_js_src29.cpp:JSID_TO_ATOM(jsid)
Unexecuted instantiation: Unified_cpp_js_src3.cpp:JSID_TO_ATOM(jsid)
Unexecuted instantiation: Unified_cpp_js_src30.cpp:JSID_TO_ATOM(jsid)
Unexecuted instantiation: Unified_cpp_js_src31.cpp:JSID_TO_ATOM(jsid)
Unexecuted instantiation: Unified_cpp_js_src32.cpp:JSID_TO_ATOM(jsid)
Unexecuted instantiation: Unified_cpp_js_src33.cpp:JSID_TO_ATOM(jsid)
Unexecuted instantiation: Unified_cpp_js_src34.cpp:JSID_TO_ATOM(jsid)
Unexecuted instantiation: Unified_cpp_js_src35.cpp:JSID_TO_ATOM(jsid)
Unified_cpp_js_src36.cpp:JSID_TO_ATOM(jsid)
Line
Count
Source
2560
3.25M
{
2561
3.25M
    return (JSAtom*)JSID_TO_STRING(id);
2562
3.25M
}
Unified_cpp_js_src37.cpp:JSID_TO_ATOM(jsid)
Line
Count
Source
2560
4.25k
{
2561
4.25k
    return (JSAtom*)JSID_TO_STRING(id);
2562
4.25k
}
Unexecuted instantiation: Unified_cpp_js_src38.cpp:JSID_TO_ATOM(jsid)
Unified_cpp_js_src39.cpp:JSID_TO_ATOM(jsid)
Line
Count
Source
2560
3.25M
{
2561
3.25M
    return (JSAtom*)JSID_TO_STRING(id);
2562
3.25M
}
Unexecuted instantiation: Unified_cpp_js_src4.cpp:JSID_TO_ATOM(jsid)
Unexecuted instantiation: Unified_cpp_js_src40.cpp:JSID_TO_ATOM(jsid)
Unexecuted instantiation: Unified_cpp_js_src41.cpp:JSID_TO_ATOM(jsid)
Unified_cpp_js_src42.cpp:JSID_TO_ATOM(jsid)
Line
Count
Source
2560
6
{
2561
6
    return (JSAtom*)JSID_TO_STRING(id);
2562
6
}
Unexecuted instantiation: Unified_cpp_js_src43.cpp:JSID_TO_ATOM(jsid)
Unexecuted instantiation: Unified_cpp_js_src44.cpp:JSID_TO_ATOM(jsid)
Unexecuted instantiation: Unified_cpp_js_src45.cpp:JSID_TO_ATOM(jsid)
Unexecuted instantiation: Unified_cpp_js_src5.cpp:JSID_TO_ATOM(jsid)
Unexecuted instantiation: Unified_cpp_js_src6.cpp:JSID_TO_ATOM(jsid)
Unexecuted instantiation: Unified_cpp_js_src7.cpp:JSID_TO_ATOM(jsid)
Unified_cpp_js_src8.cpp:JSID_TO_ATOM(jsid)
Line
Count
Source
2560
2
{
2561
2
    return (JSAtom*)JSID_TO_STRING(id);
2562
2
}
Unexecuted instantiation: Unified_cpp_js_src9.cpp:JSID_TO_ATOM(jsid)
Unexecuted instantiation: RegExp.cpp:JSID_TO_ATOM(jsid)
Unexecuted instantiation: BinSource-auto.cpp:JSID_TO_ATOM(jsid)
Unexecuted instantiation: BinSource.cpp:JSID_TO_ATOM(jsid)
Unexecuted instantiation: BinToken.cpp:JSID_TO_ATOM(jsid)
Unexecuted instantiation: BinTokenReaderBase.cpp:JSID_TO_ATOM(jsid)
Unexecuted instantiation: BinTokenReaderMultipart.cpp:JSID_TO_ATOM(jsid)
Unexecuted instantiation: BinTokenReaderTester.cpp:JSID_TO_ATOM(jsid)
Unexecuted instantiation: Parser.cpp:JSID_TO_ATOM(jsid)
Unexecuted instantiation: Disassembler-x86-shared.cpp:JSID_TO_ATOM(jsid)
Unexecuted instantiation: jsmath.cpp:JSID_TO_ATOM(jsid)
Interpreter.cpp:JSID_TO_ATOM(jsid)
Line
Count
Source
2560
1
{
2561
1
    return (JSAtom*)JSID_TO_STRING(id);
2562
1
}
Unexecuted instantiation: VTuneWrapper.cpp:JSID_TO_ATOM(jsid)
Unexecuted instantiation: Unified_cpp_js_src13.cpp:JSID_TO_ATOM(jsid)
Unexecuted instantiation: Unified_cpp_js_src16.cpp:JSID_TO_ATOM(jsid)
2563
2564
JS_STATIC_ASSERT(sizeof(jsid) == sizeof(void*));
2565
2566
namespace js {
2567
2568
static MOZ_ALWAYS_INLINE JS::Value
2569
IdToValue(jsid id)
2570
131
{
2571
131
    if (JSID_IS_STRING(id)) {
2572
131
        return JS::StringValue(JSID_TO_STRING(id));
2573
131
    }
2574
0
    if (JSID_IS_INT(id)) {
2575
0
        return JS::Int32Value(JSID_TO_INT(id));
2576
0
    }
2577
0
    if (JSID_IS_SYMBOL(id)) {
2578
0
        return JS::SymbolValue(JSID_TO_SYMBOL(id));
2579
0
    }
2580
0
    MOZ_ASSERT(JSID_IS_VOID(id));
2581
0
    return JS::UndefinedValue();
2582
0
}
Unexecuted instantiation: Unified_cpp_js_ipc0.cpp:js::IdToValue(jsid)
Unexecuted instantiation: StructuredClone.cpp:js::IdToValue(jsid)
Unexecuted instantiation: CTypes.cpp:js::IdToValue(jsid)
Unexecuted instantiation: Library.cpp:js::IdToValue(jsid)
Unexecuted instantiation: StoreBuffer.cpp:js::IdToValue(jsid)
Unexecuted instantiation: jsutil.cpp:js::IdToValue(jsid)
Unexecuted instantiation: Unified_cpp_js_src0.cpp:js::IdToValue(jsid)
Unexecuted instantiation: Unified_cpp_js_src1.cpp:js::IdToValue(jsid)
Unexecuted instantiation: Unified_cpp_js_src10.cpp:js::IdToValue(jsid)
Unexecuted instantiation: Unified_cpp_js_src11.cpp:js::IdToValue(jsid)
Unexecuted instantiation: Unified_cpp_js_src12.cpp:js::IdToValue(jsid)
Unexecuted instantiation: Unified_cpp_js_src14.cpp:js::IdToValue(jsid)
Unexecuted instantiation: Unified_cpp_js_src15.cpp:js::IdToValue(jsid)
Unexecuted instantiation: Unified_cpp_js_src17.cpp:js::IdToValue(jsid)
Unexecuted instantiation: Unified_cpp_js_src18.cpp:js::IdToValue(jsid)
Unexecuted instantiation: Unified_cpp_js_src19.cpp:js::IdToValue(jsid)
Unexecuted instantiation: Unified_cpp_js_src2.cpp:js::IdToValue(jsid)
Unexecuted instantiation: Unified_cpp_js_src20.cpp:js::IdToValue(jsid)
Unexecuted instantiation: Unified_cpp_js_src21.cpp:js::IdToValue(jsid)
Unexecuted instantiation: Unified_cpp_js_src22.cpp:js::IdToValue(jsid)
Unexecuted instantiation: Unified_cpp_js_src23.cpp:js::IdToValue(jsid)
Unexecuted instantiation: Unified_cpp_js_src24.cpp:js::IdToValue(jsid)
Unexecuted instantiation: Unified_cpp_js_src25.cpp:js::IdToValue(jsid)
Unexecuted instantiation: Unified_cpp_js_src26.cpp:js::IdToValue(jsid)
Unexecuted instantiation: Unified_cpp_js_src27.cpp:js::IdToValue(jsid)
Unexecuted instantiation: Unified_cpp_js_src28.cpp:js::IdToValue(jsid)
Unexecuted instantiation: Unified_cpp_js_src29.cpp:js::IdToValue(jsid)
Unexecuted instantiation: Unified_cpp_js_src3.cpp:js::IdToValue(jsid)
Unexecuted instantiation: Unified_cpp_js_src30.cpp:js::IdToValue(jsid)
Unexecuted instantiation: Unified_cpp_js_src31.cpp:js::IdToValue(jsid)
Unexecuted instantiation: Unified_cpp_js_src32.cpp:js::IdToValue(jsid)
Unexecuted instantiation: Unified_cpp_js_src33.cpp:js::IdToValue(jsid)
Unexecuted instantiation: Unified_cpp_js_src34.cpp:js::IdToValue(jsid)
Unexecuted instantiation: Unified_cpp_js_src35.cpp:js::IdToValue(jsid)
Unified_cpp_js_src36.cpp:js::IdToValue(jsid)
Line
Count
Source
2570
131
{
2571
131
    if (JSID_IS_STRING(id)) {
2572
131
        return JS::StringValue(JSID_TO_STRING(id));
2573
131
    }
2574
0
    if (JSID_IS_INT(id)) {
2575
0
        return JS::Int32Value(JSID_TO_INT(id));
2576
0
    }
2577
0
    if (JSID_IS_SYMBOL(id)) {
2578
0
        return JS::SymbolValue(JSID_TO_SYMBOL(id));
2579
0
    }
2580
0
    MOZ_ASSERT(JSID_IS_VOID(id));
2581
0
    return JS::UndefinedValue();
2582
0
}
Unexecuted instantiation: Unified_cpp_js_src37.cpp:js::IdToValue(jsid)
Unexecuted instantiation: Unified_cpp_js_src38.cpp:js::IdToValue(jsid)
Unexecuted instantiation: Unified_cpp_js_src39.cpp:js::IdToValue(jsid)
Unexecuted instantiation: Unified_cpp_js_src4.cpp:js::IdToValue(jsid)
Unexecuted instantiation: Unified_cpp_js_src40.cpp:js::IdToValue(jsid)
Unexecuted instantiation: Unified_cpp_js_src41.cpp:js::IdToValue(jsid)
Unexecuted instantiation: Unified_cpp_js_src42.cpp:js::IdToValue(jsid)
Unexecuted instantiation: Unified_cpp_js_src43.cpp:js::IdToValue(jsid)
Unexecuted instantiation: Unified_cpp_js_src44.cpp:js::IdToValue(jsid)
Unexecuted instantiation: Unified_cpp_js_src45.cpp:js::IdToValue(jsid)
Unexecuted instantiation: Unified_cpp_js_src5.cpp:js::IdToValue(jsid)
Unexecuted instantiation: Unified_cpp_js_src6.cpp:js::IdToValue(jsid)
Unexecuted instantiation: Unified_cpp_js_src7.cpp:js::IdToValue(jsid)
Unexecuted instantiation: Unified_cpp_js_src8.cpp:js::IdToValue(jsid)
Unexecuted instantiation: Unified_cpp_js_src9.cpp:js::IdToValue(jsid)
Unexecuted instantiation: RegExp.cpp:js::IdToValue(jsid)
Unexecuted instantiation: BinSource-auto.cpp:js::IdToValue(jsid)
Unexecuted instantiation: BinSource.cpp:js::IdToValue(jsid)
Unexecuted instantiation: BinToken.cpp:js::IdToValue(jsid)
Unexecuted instantiation: BinTokenReaderBase.cpp:js::IdToValue(jsid)
Unexecuted instantiation: BinTokenReaderMultipart.cpp:js::IdToValue(jsid)
Unexecuted instantiation: BinTokenReaderTester.cpp:js::IdToValue(jsid)
Unexecuted instantiation: Parser.cpp:js::IdToValue(jsid)
Unexecuted instantiation: Disassembler-x86-shared.cpp:js::IdToValue(jsid)
Unexecuted instantiation: jsmath.cpp:js::IdToValue(jsid)
Unexecuted instantiation: Interpreter.cpp:js::IdToValue(jsid)
Unexecuted instantiation: VTuneWrapper.cpp:js::IdToValue(jsid)
Unexecuted instantiation: Unified_cpp_js_src13.cpp:js::IdToValue(jsid)
Unexecuted instantiation: Unified_cpp_js_src16.cpp:js::IdToValue(jsid)
2583
2584
/**
2585
 * PrepareScriptEnvironmentAndInvoke asserts the embedder has registered a
2586
 * ScriptEnvironmentPreparer and then it calls the preparer's 'invoke' method
2587
 * with the given |closure|, with the assumption that the preparer will set up
2588
 * any state necessary to run script in |global|, invoke |closure| with a valid
2589
 * JSContext*, report any exceptions thrown from the closure, and return.
2590
 *
2591
 * PrepareScriptEnvironmentAndInvoke will report any exceptions that are thrown
2592
 * by the closure.  Consumers who want to propagate back whether the closure
2593
 * succeeded should do so via members of the closure itself.
2594
 */
2595
2596
struct ScriptEnvironmentPreparer {
2597
    struct Closure {
2598
        virtual bool operator()(JSContext* cx) = 0;
2599
    };
2600
2601
    virtual void invoke(JS::HandleObject global, Closure& closure) = 0;
2602
};
2603
2604
extern JS_FRIEND_API(void)
2605
PrepareScriptEnvironmentAndInvoke(JSContext* cx, JS::HandleObject global,
2606
                                  ScriptEnvironmentPreparer::Closure& closure);
2607
2608
JS_FRIEND_API(void)
2609
SetScriptEnvironmentPreparer(JSContext* cx, ScriptEnvironmentPreparer* preparer);
2610
2611
enum CTypesActivityType {
2612
    CTYPES_CALL_BEGIN,
2613
    CTYPES_CALL_END,
2614
    CTYPES_CALLBACK_BEGIN,
2615
    CTYPES_CALLBACK_END
2616
};
2617
2618
typedef void
2619
(* CTypesActivityCallback)(JSContext* cx, CTypesActivityType type);
2620
2621
/**
2622
 * Sets a callback that is run whenever js-ctypes is about to be used when
2623
 * calling into C.
2624
 */
2625
JS_FRIEND_API(void)
2626
SetCTypesActivityCallback(JSContext* cx, CTypesActivityCallback cb);
2627
2628
class MOZ_RAII JS_FRIEND_API(AutoCTypesActivityCallback) {
2629
  private:
2630
    JSContext* cx;
2631
    CTypesActivityCallback callback;
2632
    CTypesActivityType endType;
2633
    MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
2634
2635
  public:
2636
    AutoCTypesActivityCallback(JSContext* cx, CTypesActivityType beginType,
2637
                               CTypesActivityType endType
2638
                               MOZ_GUARD_OBJECT_NOTIFIER_PARAM);
2639
0
    ~AutoCTypesActivityCallback() {
2640
0
        DoEndCallback();
2641
0
    }
2642
0
    void DoEndCallback() {
2643
0
        if (callback) {
2644
0
            callback(cx, endType);
2645
0
            callback = nullptr;
2646
0
        }
2647
0
    }
2648
};
2649
2650
// Abstract base class for objects that build allocation metadata for JavaScript
2651
// values.
2652
struct AllocationMetadataBuilder {
2653
6
    AllocationMetadataBuilder() { }
2654
2655
    // Return a metadata object for the newly constructed object |obj|, or
2656
    // nullptr if there's no metadata to attach.
2657
    //
2658
    // Implementations should treat all errors as fatal; there is no way to
2659
    // report errors from this callback. In particular, the caller provides an
2660
    // oomUnsafe for overriding implementations to use.
2661
    virtual JSObject* build(JSContext* cx, JS::HandleObject obj,
2662
                            AutoEnterOOMUnsafeRegion& oomUnsafe) const
2663
0
    {
2664
0
        return nullptr;
2665
0
    }
2666
};
2667
2668
/**
2669
 * Specify a callback to invoke when creating each JS object in the current
2670
 * compartment, which may return a metadata object to associate with the
2671
 * object.
2672
 */
2673
JS_FRIEND_API(void)
2674
SetAllocationMetadataBuilder(JSContext* cx, const AllocationMetadataBuilder *callback);
2675
2676
/** Get the metadata associated with an object. */
2677
JS_FRIEND_API(JSObject*)
2678
GetAllocationMetadata(JSObject* obj);
2679
2680
JS_FRIEND_API(bool)
2681
GetElementsWithAdder(JSContext* cx, JS::HandleObject obj, JS::HandleObject receiver,
2682
                     uint32_t begin, uint32_t end, js::ElementAdder* adder);
2683
2684
JS_FRIEND_API(bool)
2685
ForwardToNative(JSContext* cx, JSNative native, const JS::CallArgs& args);
2686
2687
/**
2688
 * Helper function for HTMLDocument and HTMLFormElement.
2689
 *
2690
 * These are the only two interfaces that have [OverrideBuiltins], a named
2691
 * getter, and no named setter. They're implemented as proxies with a custom
2692
 * getOwnPropertyDescriptor() method. Unfortunately, overriding
2693
 * getOwnPropertyDescriptor() automatically affects the behavior of set(),
2694
 * which normally is just common sense but is *not* desired for these two
2695
 * interfaces.
2696
 *
2697
 * The fix is for these two interfaces to override set() to ignore the
2698
 * getOwnPropertyDescriptor() override.
2699
 *
2700
 * SetPropertyIgnoringNamedGetter is exposed to make it easier to override
2701
 * set() in this way.  It carries out all the steps of BaseProxyHandler::set()
2702
 * except the initial getOwnPropertyDescriptor() call.  The caller must supply
2703
 * that descriptor as the 'ownDesc' parameter.
2704
 *
2705
 * Implemented in proxy/BaseProxyHandler.cpp.
2706
 */
2707
JS_FRIEND_API(bool)
2708
SetPropertyIgnoringNamedGetter(JSContext* cx, JS::HandleObject obj, JS::HandleId id,
2709
                               JS::HandleValue v, JS::HandleValue receiver,
2710
                               JS::Handle<JS::PropertyDescriptor> ownDesc,
2711
                               JS::ObjectOpResult& result);
2712
2713
// This function is for one specific use case, please don't use this for anything else!
2714
extern JS_FRIEND_API(bool)
2715
ExecuteInFrameScriptEnvironment(JSContext* cx, JS::HandleObject obj,
2716
                                JS::HandleScript script,
2717
                                JS::MutableHandleObject scope);
2718
2719
// These functions are provided for the JSM component loader in Gecko.
2720
//
2721
// A 'JSMEnvironment' refers to an environment chain constructed for JSM loading
2722
// in a shared global. Internally it is a NonSyntacticVariablesObject with a
2723
// corresponding extensible LexicalEnvironmentObject that is accessible by
2724
// JS_ExtensibleLexicalEnvironment. The |this| value of that lexical environment
2725
// is the NSVO itself.
2726
//
2727
// Normal global environment (ES6):     JSM "global" environment:
2728
//
2729
//                                      * - extensible lexical environment
2730
//                                      |   (code runs in this environment;
2731
//                                      |    `let/const` bindings go here)
2732
//                                      |
2733
//                                      * - JSMEnvironment (=== `this`)
2734
//                                      |   (`var` bindings go here)
2735
//                                      |
2736
// * - extensible lexical environment   * - extensible lexical environment
2737
// |   (code runs in this environment;  |   (empty)
2738
// |    `let/const` bindings go here)   |
2739
// |                                    |
2740
// * - actual global (=== `this`)       * - shared JSM global
2741
//     (var bindings go here; and           (Object, Math, etc. live here)
2742
//      Object, Math, etc. live here)
2743
2744
// Allocate a new environment in current compartment that is compatible with JSM
2745
// shared loading.
2746
extern JS_FRIEND_API(JSObject*)
2747
NewJSMEnvironment(JSContext* cx);
2748
2749
// Execute the given script (copied into compartment if necessary) in the given
2750
// JSMEnvironment. The script must have been compiled for hasNonSyntacticScope.
2751
// The |jsmEnv| must have been previously allocated by NewJSMEnvironment.
2752
//
2753
// NOTE: The associated extensible lexical environment is reused.
2754
extern JS_FRIEND_API(bool)
2755
ExecuteInJSMEnvironment(JSContext* cx, JS::HandleScript script, JS::HandleObject jsmEnv);
2756
2757
// Additionally, target objects may be specified as required by the Gecko
2758
// subscript loader. These are wrapped in non-syntactic WithEnvironments and
2759
// temporarily placed on environment chain.
2760
//
2761
// See also: JS::CloneAndExecuteScript(...)
2762
extern JS_FRIEND_API(bool)
2763
ExecuteInJSMEnvironment(JSContext* cx, JS::HandleScript script, JS::HandleObject jsmEnv,
2764
                        JS::AutoObjectVector& targetObj);
2765
2766
// Used by native methods to determine the JSMEnvironment of caller if possible
2767
// by looking at stack frames. Returns nullptr if top frame isn't a scripted
2768
// caller in a JSM.
2769
//
2770
// NOTE: This may find NonSyntacticVariablesObject generated by other embedding
2771
// such as a Gecko FrameScript. Caller can check the compartment if needed.
2772
extern JS_FRIEND_API(JSObject*)
2773
GetJSMEnvironmentOfScriptedCaller(JSContext* cx);
2774
2775
// Determine if obj is a JSMEnvironment
2776
//
2777
// NOTE: This may return true for an NonSyntacticVariablesObject generated by
2778
// other embedding such as a Gecko FrameScript. Caller can check compartment.
2779
extern JS_FRIEND_API(bool)
2780
IsJSMEnvironment(JSObject* obj);
2781
2782
2783
#if defined(XP_WIN) && defined(_WIN64)
2784
// Parameters use void* types to avoid #including windows.h. The return value of
2785
// this function is returned from the exception handler.
2786
typedef long
2787
(*JitExceptionHandler)(void* exceptionRecord,  // PEXECTION_RECORD
2788
                       void* context);         // PCONTEXT
2789
2790
/**
2791
 * Windows uses "structured exception handling" to handle faults. When a fault
2792
 * occurs, the stack is searched for a handler (similar to C++ exception
2793
 * handling). If the search does not find a handler, the "unhandled exception
2794
 * filter" is called. Breakpad uses the unhandled exception filter to do crash
2795
 * reporting. Unfortunately, on Win64, JIT code on the stack completely throws
2796
 * off this unwinding process and prevents the unhandled exception filter from
2797
 * being called. The reason is that Win64 requires unwind information be
2798
 * registered for all code regions and JIT code has none. While it is possible
2799
 * to register full unwind information for JIT code, this is a lot of work (one
2800
 * has to be able to recover the frame pointer at any PC) so instead we register
2801
 * a handler for all JIT code that simply calls breakpad's unhandled exception
2802
 * filter (which will perform crash reporting and then terminate the process).
2803
 * This would be wrong if there was an outer __try block that expected to handle
2804
 * the fault, but this is not generally allowed.
2805
 *
2806
 * Gecko must call SetJitExceptionFilter before any JIT code is compiled and
2807
 * only once per process.
2808
 */
2809
extern JS_FRIEND_API(void)
2810
SetJitExceptionHandler(JitExceptionHandler handler);
2811
#endif
2812
2813
extern JS_FRIEND_API(bool)
2814
ReportIsNotFunction(JSContext* cx, JS::HandleValue v);
2815
2816
extern JS_FRIEND_API(JSObject*)
2817
ConvertArgsToArray(JSContext* cx, const JS::CallArgs& args);
2818
2819
/**
2820
 * Window and WindowProxy
2821
 *
2822
 * The functions below have to do with Windows and WindowProxies. There's an
2823
 * invariant that actual Window objects (the global objects of web pages) are
2824
 * never directly exposed to script. Instead we often substitute a WindowProxy.
2825
 *
2826
 * The environment chain, on the other hand, contains the Window and never its
2827
 * WindowProxy.
2828
 *
2829
 * As a result, we have calls to these "substitute-this-object-for-that-object"
2830
 * functions sprinkled at apparently arbitrary (but actually *very* carefully
2831
 * and nervously selected) places throughout the engine and indeed the
2832
 * universe.
2833
 */
2834
2835
/**
2836
 * Tell the JS engine which Class is used for WindowProxy objects. Used by the
2837
 * functions below.
2838
 */
2839
extern JS_FRIEND_API(void)
2840
SetWindowProxyClass(JSContext* cx, const Class* clasp);
2841
2842
/**
2843
 * Associates a WindowProxy with a Window (global object). `windowProxy` must
2844
 * have the Class set by SetWindowProxyClass.
2845
 */
2846
extern JS_FRIEND_API(void)
2847
SetWindowProxy(JSContext* cx, JS::HandleObject global, JS::HandleObject windowProxy);
2848
2849
namespace detail {
2850
2851
JS_FRIEND_API(bool)
2852
IsWindowSlow(JSObject* obj);
2853
2854
JS_FRIEND_API(JSObject*)
2855
ToWindowProxyIfWindowSlow(JSObject* obj);
2856
2857
} // namespace detail
2858
2859
/**
2860
 * Returns true iff `obj` is a global object with an associated WindowProxy,
2861
 * see SetWindowProxy.
2862
 */
2863
inline bool
2864
IsWindow(JSObject* obj)
2865
{
2866
    if (GetObjectClass(obj)->flags & JSCLASS_IS_GLOBAL) {
2867
        return detail::IsWindowSlow(obj);
2868
    }
2869
    return false;
2870
}
2871
2872
/**
2873
 * Returns true iff `obj` has the WindowProxy Class (see SetWindowProxyClass).
2874
 */
2875
JS_FRIEND_API(bool)
2876
IsWindowProxy(JSObject* obj);
2877
2878
/**
2879
 * If `obj` is a Window, get its associated WindowProxy (or a CCW or dead
2880
 * wrapper if the page was navigated away from), else return `obj`. This
2881
 * function is infallible and never returns nullptr.
2882
 */
2883
MOZ_ALWAYS_INLINE JSObject*
2884
ToWindowProxyIfWindow(JSObject* obj)
2885
{
2886
    if (GetObjectClass(obj)->flags & JSCLASS_IS_GLOBAL) {
2887
        return detail::ToWindowProxyIfWindowSlow(obj);
2888
    }
2889
    return obj;
2890
}
2891
2892
/**
2893
 * If `obj` is a WindowProxy, get its associated Window (the compartment's
2894
 * global), else return `obj`. This function is infallible and never returns
2895
 * nullptr.
2896
 */
2897
extern JS_FRIEND_API(JSObject*)
2898
ToWindowIfWindowProxy(JSObject* obj);
2899
2900
// Create and add the Intl.MozDateTimeFormat constructor function to the provided
2901
// object.
2902
//
2903
// This custom date/time formatter constructor gives users the ability
2904
// to specify a custom format pattern. This pattern is passed *directly*
2905
// to ICU with NO SYNTAX PARSING OR VALIDATION WHATSOEVER. ICU appears to
2906
// have a a modicum of testing of this, and it won't fall over completely
2907
// if passed bad input. But the current behavior is entirely under-specified
2908
// and emphatically not shippable on the web, and it *must* be fixed before
2909
// this functionality can be exposed in the real world. (There are also some
2910
// questions about whether the format exposed here is the *right* one to
2911
// standardize, that will also need to be resolved to ship this.)
2912
extern bool
2913
AddMozDateTimeFormatConstructor(JSContext* cx, JS::Handle<JSObject*> intl);
2914
2915
// Create and add the Intl.RelativeTimeFormat constructor function to the provided
2916
// object.  This function throws if called more than once per realm/global
2917
// object.
2918
extern bool
2919
AddRelativeTimeFormatConstructor(JSContext* cx, JS::Handle<JSObject*> intl);
2920
2921
class MOZ_STACK_CLASS JS_FRIEND_API(AutoAssertNoContentJS)
2922
{
2923
  public:
2924
    explicit AutoAssertNoContentJS(JSContext* cx);
2925
    ~AutoAssertNoContentJS();
2926
2927
  private:
2928
    JSContext* context_;
2929
    bool prevAllowContentJS_;
2930
};
2931
2932
// Turn on assertions so that we assert that
2933
//     !realm->validAccessPtr || *realm->validAccessPtr
2934
// is true for every |realm| that we run JS code in. The realm's validAccessPtr
2935
// is set via SetRealmValidAccessPtr.
2936
extern JS_FRIEND_API(void)
2937
EnableAccessValidation(JSContext* cx, bool enabled);
2938
2939
// See EnableAccessValidation above. The caller must guarantee that accessp will
2940
// live at least as long as |global| is alive. The JS engine reads accessp from
2941
// threads that are allowed to run code on |global|, so all changes to *accessp
2942
// should be made from whichever thread owns |global| at a given time.
2943
extern JS_FRIEND_API(void)
2944
SetRealmValidAccessPtr(JSContext* cx, JS::HandleObject global, bool* accessp);
2945
2946
// Returns true if the system zone is available (i.e., if no cooperative contexts
2947
// are using it now).
2948
extern JS_FRIEND_API(bool)
2949
SystemZoneAvailable(JSContext* cx);
2950
2951
typedef void
2952
(* LogCtorDtor)(void* self, const char* type, uint32_t sz);
2953
2954
/**
2955
 * Set global function used to monitor a few internal classes to highlight
2956
 * leaks, and to hint at the origin of the leaks.
2957
 */
2958
extern JS_FRIEND_API(void)
2959
SetLogCtorDtorFunctions(LogCtorDtor ctor, LogCtorDtor dtor);
2960
2961
extern JS_FRIEND_API(void)
2962
LogCtor(void* self, const char* type, uint32_t sz);
2963
2964
extern JS_FRIEND_API(void)
2965
LogDtor(void* self, const char* type, uint32_t sz);
2966
2967
#define JS_COUNT_CTOR(Class)                            \
2968
3
    LogCtor((void*) this, #Class, sizeof(Class))
2969
2970
#define JS_COUNT_DTOR(Class)                            \
2971
0
    LogDtor((void*) this, #Class, sizeof(Class))
2972
2973
} /* namespace js */
2974
2975
#endif /* jsfriendapi_h */