Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
DIVINE
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
paradise
mirror
DIVINE
Commits
11baef6d
There was an error fetching the commit references. Please try again later.
Commit
11baef6d
authored
5 years ago
by
Petr Rockai
Browse files
Options
Downloads
Patches
Plain Diff
VM: Move loop tracking code into a separate header file.
parent
585d731b
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
divine/vm/context.hpp
+3
-31
3 additions, 31 deletions
divine/vm/context.hpp
divine/vm/loops.hpp
+53
-0
53 additions, 0 deletions
divine/vm/loops.hpp
with
56 additions
and
31 deletions
divine/vm/context.hpp
+
3
−
31
View file @
11baef6d
...
@@ -18,10 +18,11 @@
...
@@ -18,10 +18,11 @@
#pragma once
#pragma once
#include
<divine/vm/loops.hpp>
#include
<divine/vm/frame.hpp>
#include
<divine/vm/value.hpp>
#include
<divine/vm/value.hpp>
#include
<divine/vm/memory.hpp>
#include
<divine/vm/memory.hpp>
#include
<divine/vm/types.hpp>
#include
<divine/vm/types.hpp>
#include
<divine/vm/frame.hpp>
#include
<divine/vm/divm.h>
#include
<divine/vm/divm.h>
#include
<brick-data>
#include
<brick-data>
...
@@ -33,41 +34,12 @@ namespace llvm { class Value; }
...
@@ -33,41 +34,12 @@ namespace llvm { class Value; }
namespace
divine
::
vm
namespace
divine
::
vm
{
{
struct
TraceSchedChoice
{
value
::
Pointer
list
;
};
struct
TraceSchedChoice
{
value
::
Pointer
list
;
};
using
Location
=
_VM_Operand
::
Location
;
using
Location
=
_VM_Operand
::
Location
;
using
PtrRegister
=
GenericPointer
;
using
PtrRegister
=
GenericPointer
;
using
IntRegister
=
uint64_t
;
using
IntRegister
=
uint64_t
;
struct
LoopTrack
{
std
::
vector
<
std
::
unordered_set
<
GenericPointer
>
>
loops
;
void
entered
(
CodePointer
)
{
loops
.
emplace_back
();
}
void
left
(
CodePointer
)
{
loops
.
pop_back
();
if
(
loops
.
empty
()
)
/* more returns than calls could happen along an edge */
loops
.
emplace_back
();
}
bool
test_loop
(
CodePointer
pc
,
int
/* TODO */
)
{
/* TODO track the counter value too */
if
(
loops
.
back
().
count
(
pc
)
)
return
true
;
else
loops
.
back
().
insert
(
pc
);
return
false
;
}
};
/* state of a computation */
/* state of a computation */
struct
State
struct
State
{
{
...
@@ -212,7 +184,7 @@ namespace divine::vm
...
@@ -212,7 +184,7 @@ namespace divine::vm
struct
Tracing
:
NoTracing
struct
Tracing
:
NoTracing
{
{
State
_debug_state
;
State
_debug_state
;
LoopTrack
_loops
;
track_loops
_loops
;
PtrRegister
_debug_pc
;
PtrRegister
_debug_pc
;
int
_debug_depth
=
0
;
int
_debug_depth
=
0
;
...
...
This diff is collapsed.
Click to expand it.
divine/vm/loops.hpp
0 → 100644
+
53
−
0
View file @
11baef6d
// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 4 -*-
/*
* (c) 2019 Petr Ročkai <code@fixp.eu>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#pragma once
#include
<divine/vm/pointer.hpp>
#include
<unordered_set>
namespace
divine
::
vm
{
struct
track_loops
{
std
::
vector
<
std
::
unordered_set
<
GenericPointer
>
>
loops
;
void
entered
(
CodePointer
)
{
loops
.
emplace_back
();
}
void
left
(
CodePointer
)
{
loops
.
pop_back
();
if
(
loops
.
empty
()
)
/* more returns than calls could happen along an edge */
loops
.
emplace_back
();
}
bool
test_loop
(
CodePointer
pc
,
int
/* TODO */
)
{
/* TODO track the counter value too */
if
(
loops
.
back
().
count
(
pc
)
)
return
true
;
else
loops
.
back
().
insert
(
pc
);
return
false
;
}
};
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment