-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathpz.cpp
More file actions
76 lines (62 loc) · 1.47 KB
/
pz.cpp
File metadata and controls
76 lines (62 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*
* Plasma in-memory representation
* vim: ts=4 sw=4 et
*
* Copyright (C) Plasma Team
* Distributed under the terms of the MIT license, see ../LICENSE.code
*/
#include "pz_common.h"
#include <stdio.h>
#include <string.h>
#include "pz_code.h"
#include "pz_data.h"
#include "pz_interp.h"
#include "pz.h"
namespace pz {
/*
* PZ Programs
*************/
PZ::PZ(const Options & options, Heap & heap)
: AbstractGCTracer(heap)
, m_options(options)
, m_program(nullptr)
{}
// Defined here rather than the header even though it's a default destructor
// so that it can access the heap destructor.
PZ::~PZ() {}
Library * PZ::new_library(const String name, GCCapability & gc_cap)
{
assert(!m_libraries[name]);
m_libraries[name] = new (gc_cap) Library();
return m_libraries[name];
}
void PZ::add_library(const String name, Library * library)
{
assert(!m_libraries[name]);
m_libraries[name] = library;
}
Library * PZ::lookup_library(const String name)
{
auto iter = m_libraries.find(name);
if (iter != m_libraries.end()) {
return iter->second;
} else {
return nullptr;
}
}
void PZ::add_program_lib(Library * program)
{
assert(nullptr == m_program);
m_program = program;
}
void PZ::do_trace(HeapMarkState * marker) const
{
for (auto m : m_libraries) {
marker->mark_root(m.first.ptr());
marker->mark_root(m.second);
}
if (m_program) {
marker->mark_root(m_program);
}
}
} // namespace pz