1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * vim: set ts=8 sts=2 et sw=2 tw=80:
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef jit_InterpreterEntryTrampoline_h
8 #define jit_InterpreterEntryTrampoline_h
10 #include "gc/Barrier.h"
11 #include "gc/Tracer.h"
12 #include "jit/JitCode.h"
13 #include "js/AllocPolicy.h"
14 #include "js/HashTable.h"
15 #include "js/RootingAPI.h"
19 void ClearInterpreterEntryMap(JSRuntime
* runtime
);
24 * The EntryTrampolineMap is used to cache the trampoline code for
25 * each script as they are created. These trampolines are created
26 * only under --emit-interpreter-entry and are used to identify which
27 * script is being interpeted when profiling with external profilers
30 * The map owns the JitCode objects that are created for each script,
31 * and keeps them alive at least as long as the script associated
32 * with it in case we need to re-enter the trampoline again.
34 * As each script is finalized, the entry is manually removed from
35 * the table in BaseScript::finalize which will also release the
36 * trampoline code associated with it.
38 * During a moving GC, the table is rekeyed in case any scripts
42 class EntryTrampoline
{
43 HeapPtr
<JitCode
*> entryTrampoline_
;
46 void trace(JSTracer
* trc
) {
47 TraceNullableEdge(trc
, &entryTrampoline_
, "interpreter-entry-trampoline");
50 explicit EntryTrampoline(JSContext
* cx
, JitCode
* code
) {
52 entryTrampoline_
= code
;
56 MOZ_ASSERT(entryTrampoline_
, "Empty trampoline code.");
57 return entryTrampoline_
->raw();
60 #ifdef JSGC_HASH_TABLE_CHECKS
61 void checkTrampolineAfterMovingGC();
65 using JSScriptToTrampolineMap
=
66 HashMap
<HeapPtr
<BaseScript
*>, EntryTrampoline
,
67 DefaultHasher
<HeapPtr
<BaseScript
*>>, SystemAllocPolicy
>;
68 class EntryTrampolineMap
: public JSScriptToTrampolineMap
{
70 void traceTrampolineCode(JSTracer
* trc
);
71 void updateScriptsAfterMovingGC(void);
72 #ifdef JSGC_HASH_TABLE_CHECKS
73 void checkScriptsAfterMovingGC();
79 #endif /* jit_InterpreterEntryTrampoline_h */