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
f69d1a99
Commit
f69d1a99
authored
Mar 27, 2015
by
Chris Toshok
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #417 from toshok/stack-rooting
add StackRoot<> and #defines for DECREF
parents
8effb5a4
6a8be0a1
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
63 additions
and
2 deletions
+63
-2
from_cpython/Include/object.h
from_cpython/Include/object.h
+2
-2
src/gc/roots.h
src/gc/roots.h
+61
-0
No files found.
from_cpython/Include/object.h
View file @
f69d1a99
...
...
@@ -826,7 +826,7 @@ PyAPI_FUNC(void) _Py_AddToAllObjects(PyObject *, int force) PYSTON_NOEXCEPT;
#define Py_INCREF(op) ((void)(op))
#define Py_DECREF(op)
((void)
(op))
#define Py_DECREF(op)
asm volatile("" : : "X"
(op))
/* Safely decref `op` and set `op` to NULL, especially useful in tp_clear
* and tp_dealloc implementatons.
...
...
@@ -874,7 +874,7 @@ PyAPI_FUNC(void) _Py_AddToAllObjects(PyObject *, int force) PYSTON_NOEXCEPT;
/* Macros to use in case the object pointer may be NULL: */
// Pyston change: made these noops as well
#define Py_XINCREF(op) ((void)(op))
#define Py_XDECREF(op)
((void)
(op))
#define Py_XDECREF(op)
asm volatile("" : : "X"
(op))
/*
These are provided as conveniences to Python runtime embedders, so that
...
...
src/gc/roots.h
0 → 100644
View file @
f69d1a99
// 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_ROOTS_H
#define PYSTON_GC_ROOTS_H
#include "core/common.h"
#include "core/threading.h"
namespace
pyston
{
#define GC_KEEP_ALIVE(t) asm volatile("" : : "X"(t))
template
<
class
T
>
class
StackRoot
{
public:
explicit
StackRoot
(
T
*
t
)
:
t
(
t
)
{}
StackRoot
(
const
StackRoot
&
other
)
:
t
(
other
.
t
)
{}
template
<
class
...
Args
>
StackRoot
(
Args
&&
...
args
)
:
t
(
new
T
(
std
::
forward
(
args
...)))
{}
~
StackRoot
()
{
GC_KEEP_ALIVE
(
t
);
}
T
&
operator
*
()
const
{
return
*
t
;
}
T
*
operator
->
()
const
{
return
t
;
}
operator
T
*
()
const
{
return
t
;
}
private:
T
*
t
;
};
class
Box
;
class
BoxedString
;
typedef
StackRoot
<
Box
>
RootedBox
;
typedef
StackRoot
<
BoxedString
>
RootedBoxedString
;
//
// the above types can be used whenever we want to explicitly root a Box subclass within some lexical scope.
//
// {
// RootedBoxedString sub("hello world");
// for (auto c : sub->s) {
// doSomethingThatCouldTriggerACollection();
// }
// callWithString(sub); // pass RootedBoxedString to a function taking BoxedString*
// // sub will be rooted conservatively until here
// }
//
}
#endif
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