Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mu
mu-impl-fast
Commits
2c140a07
Commit
2c140a07
authored
Dec 20, 2016
by
qinsoon
Browse files
restoring gc types in vm persisting
parent
b0467947
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/vm/vm.rs
View file @
2c140a07
...
...
@@ -56,7 +56,7 @@ pub struct VM {
// partially serialize
// 13
compiled_funcs
:
RwLock
<
HashMap
<
MuID
,
RwLock
<
CompiledFunction
>>>
,
compiled_funcs
:
RwLock
<
HashMap
<
MuID
,
RwLock
<
CompiledFunction
>>>
,
}
const
VM_SERIALIZE_FIELDS
:
usize
=
14
;
...
...
@@ -474,6 +474,37 @@ impl <'a> VM {
let
vm
:
VM
=
json
::
decode
(
serialized_vm
)
.unwrap
();
vm
.init_vm
();
// restore gc types
{
let
type_info_guard
=
vm
.backend_type_info
.read
()
.unwrap
();
let
mut
type_info_vec
:
Vec
<
Box
<
BackendTypeInfo
>>
=
type_info_guard
.values
()
.map
(|
x
|
x
.clone
())
.collect
();
type_info_vec
.sort_by
(|
a
,
b
|
a
.gc_type.id
.cmp
(
&
b
.gc_type.id
));
let
mut
expect_id
=
0
;
for
ty_info
in
type_info_vec
.iter
()
{
use
runtime
::
mm
;
let
ref
gc_type
=
ty_info
.gc_type
;
if
gc_type
.id
!=
expect_id
{
debug_assert!
(
expect_id
<
gc_type
.id
);
while
expect_id
<
gc_type
.id
{
use
runtime
::
mm
::
common
::
gctype
::
GCType
;
mm
::
add_gc_type
(
GCType
::
new_noreftype
(
0
));
expect_id
+=
1
;
}
}
// now expect_id == gc_type.id
debug_assert!
(
expect_id
==
gc_type
.id
);
mm
::
add_gc_type
(
gc_type
.as_ref
()
.clone
());
expect_id
+=
1
;
}
}
vm
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment