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
1a21d2dd
Commit
1a21d2dd
authored
Mar 18, 2015
by
Chris Toshok
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add StackRoot<> and #defines for DECREF
parent
8effb5a4
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
61 additions
and
2 deletions
+61
-2
from_cpython/Include/object.h
from_cpython/Include/object.h
+2
-2
src/gc/roots.h
src/gc/roots.h
+59
-0
No files found.
from_cpython/Include/object.h
View file @
1a21d2dd
...
...
@@ -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 @
1a21d2dd
// 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:
StackRoot
(
T
*
t
)
:
t
(
t
)
{}
StackRoot
(
const
StackRoot
&
other
)
:
t
(
other
.
t
)
{}
~
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 need to explicitly root a Box subclass within some lexical scope.
//
// {
// RootedBoxedString sub(new BoxedString("hello world"));
// for (auto c : sub->s) {
// doSomethingThatCouldTriggerACollection();
// }
// // 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