Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
Pyston
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
Pyston
Commits
4c99ad46
Commit
4c99ad46
authored
Aug 10, 2015
by
Rudi Chen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move GC-related declarations to gc folder and add comments.
parent
5de3104a
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
88 additions
and
53 deletions
+88
-53
src/core/types.h
src/core/types.h
+2
-52
src/gc/gc.h
src/gc/gc.h
+85
-0
src/runtime/hiddenclass.h
src/runtime/hiddenclass.h
+1
-1
No files found.
src/core/types.h
View file @
4c99ad46
...
...
@@ -29,6 +29,7 @@
#include "core/common.h"
#include "core/stats.h"
#include "core/stringpool.h"
#include "gc/gc.h"
namespace
llvm
{
class
Function
;
...
...
@@ -38,29 +39,6 @@ class Value;
namespace
pyston
{
namespace
gc
{
class
TraceStack
;
class
GCVisitor
{
private:
bool
isValid
(
void
*
p
);
public:
TraceStack
*
stack
;
GCVisitor
(
TraceStack
*
stack
)
:
stack
(
stack
)
{}
// These all work on *user* pointers, ie pointers to the user_data section of GCAllocations
void
visitIf
(
void
*
p
)
{
if
(
p
)
visit
(
p
);
}
void
visit
(
void
*
p
);
void
visitRange
(
void
*
const
*
start
,
void
*
const
*
end
);
void
visitPotential
(
void
*
p
);
void
visitPotentialRange
(
void
*
const
*
start
,
void
*
const
*
end
);
};
}
// namespace gc
using
gc
::
GCVisitor
;
enum
class
EffortLevel
{
...
...
@@ -459,35 +437,7 @@ class BinopIC;
class
Box
;
namespace
gc
{
enum
class
GCKind
:
uint8_t
{
PYTHON
=
1
,
CONSERVATIVE
=
2
,
PRECISE
=
3
,
UNTRACKED
=
4
,
RUNTIME
=
5
,
CONSERVATIVE_PYTHON
=
6
,
};
extern
"C"
void
*
gc_alloc
(
size_t
nbytes
,
GCKind
kind
);
extern
"C"
void
*
gc_realloc
(
void
*
ptr
,
size_t
bytes
);
extern
"C"
void
gc_free
(
void
*
ptr
);
}
class
GCAllocatedRuntime
{
public:
virtual
~
GCAllocatedRuntime
()
{}
void
*
operator
new
(
size_t
size
)
__attribute__
((
visibility
(
"default"
)))
{
return
gc
::
gc_alloc
(
size
,
gc
::
GCKind
::
RUNTIME
);
}
void
operator
delete
(
void
*
ptr
)
__attribute__
((
visibility
(
"default"
)))
{
gc
::
gc_free
(
ptr
);
}
virtual
void
gc_visit
(
GCVisitor
*
visitor
)
=
0
;
};
class
BoxIteratorImpl
:
public
GCAllocatedRuntime
{
class
BoxIteratorImpl
:
public
gc
::
GCAllocatedRuntime
{
public:
virtual
~
BoxIteratorImpl
()
=
default
;
virtual
void
next
()
=
0
;
...
...
src/gc/gc.h
0 → 100644
View file @
4c99ad46
// Copyright (c) 2014-2015 Dropbox, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef PYSTON_GC_GC_H
#define PYSTON_GC_GC_H
namespace
pyston
{
namespace
gc
{
// GOAL: Eventually, move any declaration that needs to be visible outside the gc/ folder
// to this file and only expose this header.
class
TraceStack
;
class
GCVisitor
{
private:
bool
isValid
(
void
*
p
);
public:
TraceStack
*
stack
;
GCVisitor
(
TraceStack
*
stack
)
:
stack
(
stack
)
{}
// These all work on *user* pointers, ie pointers to the user_data section of GCAllocations
void
visitIf
(
void
*
p
)
{
if
(
p
)
visit
(
p
);
}
void
visit
(
void
*
p
);
void
visitRange
(
void
*
const
*
start
,
void
*
const
*
end
);
void
visitPotential
(
void
*
p
);
void
visitPotentialRange
(
void
*
const
*
start
,
void
*
const
*
end
);
};
enum
class
GCKind
:
uint8_t
{
// Any Python object (e.g. any Box) that can be visited precisely, using
// a GC handler function.
PYTHON
=
1
,
// An arbitrary block of memory that may contain pointers.
CONSERVATIVE
=
2
,
// An arbitrary block of memory with contiguous pointers.
PRECISE
=
3
,
// An arbitrary block of memory that does not contain pointers.
UNTRACKED
=
4
,
// C++ objects that we need to manage with our own heap and GC, either
// because it contains pointers into our heap or our heap points to these
// objects. These objects inherit from GCAllocatedRuntime.
RUNTIME
=
5
,
// A Python object where we don't have a way to visit precisely with a GC
// handler function. These are usually Python objects allocated in C extensions.
CONSERVATIVE_PYTHON
=
6
,
};
extern
"C"
void
*
gc_alloc
(
size_t
nbytes
,
GCKind
kind
);
extern
"C"
void
*
gc_realloc
(
void
*
ptr
,
size_t
bytes
);
extern
"C"
void
gc_free
(
void
*
ptr
);
// Use this if a C++ object needs to be allocated in our heap.
class
GCAllocatedRuntime
{
public:
virtual
~
GCAllocatedRuntime
()
{}
void
*
operator
new
(
size_t
size
)
__attribute__
((
visibility
(
"default"
)))
{
return
gc_alloc
(
size
,
GCKind
::
RUNTIME
);
}
void
operator
delete
(
void
*
ptr
)
__attribute__
((
visibility
(
"default"
)))
{
gc_free
(
ptr
);
}
virtual
void
gc_visit
(
GCVisitor
*
visitor
)
=
0
;
};
}
// namespace gc
}
#endif
src/runtime/hiddenclass.h
View file @
4c99ad46
...
...
@@ -25,7 +25,7 @@
namespace
pyston
{
class
HiddenClass
:
public
GCAllocatedRuntime
{
class
HiddenClass
:
public
gc
::
GCAllocatedRuntime
{
public:
// We have a couple different storage strategies for attributes, which
// are distinguished by having a different hidden class type.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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