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
59479580
Commit
59479580
authored
9 years ago
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Get rid of runtime/capi.h
parent
0809576c
Changes
22
Hide whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
65 additions
and
109 deletions
+65
-109
src/capi/errors.cpp
src/capi/errors.cpp
+0
-1
src/capi/types.h
src/capi/types.h
+0
-1
src/codegen/ast_interpreter.cpp
src/codegen/ast_interpreter.cpp
+0
-1
src/codegen/irgen/hooks.cpp
src/codegen/irgen/hooks.cpp
+0
-1
src/codegen/pypa-parser.cpp
src/codegen/pypa-parser.cpp
+0
-1
src/runtime/builtin_modules/builtins.cpp
src/runtime/builtin_modules/builtins.cpp
+0
-1
src/runtime/builtin_modules/thread.cpp
src/runtime/builtin_modules/thread.cpp
+0
-1
src/runtime/capi.cpp
src/runtime/capi.cpp
+0
-51
src/runtime/capi.h
src/runtime/capi.h
+0
-40
src/runtime/descr.cpp
src/runtime/descr.cpp
+0
-1
src/runtime/import.cpp
src/runtime/import.cpp
+51
-1
src/runtime/import.h
src/runtime/import.h
+1
-0
src/runtime/inline/xrange.cpp
src/runtime/inline/xrange.cpp
+0
-1
src/runtime/int.cpp
src/runtime/int.cpp
+0
-1
src/runtime/long.cpp
src/runtime/long.cpp
+0
-1
src/runtime/objmodel.cpp
src/runtime/objmodel.cpp
+0
-1
src/runtime/set.cpp
src/runtime/set.cpp
+0
-1
src/runtime/str.cpp
src/runtime/str.cpp
+0
-1
src/runtime/tuple.cpp
src/runtime/tuple.cpp
+0
-1
src/runtime/types.cpp
src/runtime/types.cpp
+0
-1
src/runtime/types.h
src/runtime/types.h
+13
-0
src/runtime/util.cpp
src/runtime/util.cpp
+0
-1
No files found.
src/capi/errors.cpp
View file @
59479580
...
...
@@ -21,7 +21,6 @@
#include "core/types.h"
#include "core/util.h"
#include "gc/collector.h"
#include "runtime/capi.h"
#include "runtime/dict.h"
#include "runtime/objmodel.h"
#include "runtime/types.h"
...
...
This diff is collapsed.
Click to expand it.
src/capi/types.h
View file @
59479580
...
...
@@ -15,7 +15,6 @@
#ifndef PYSTON_CAPI_TYPES_H
#define PYSTON_CAPI_TYPES_H
#include "runtime/capi.h"
#include "runtime/objmodel.h"
#include "runtime/types.h"
...
...
This diff is collapsed.
Click to expand it.
src/codegen/ast_interpreter.cpp
View file @
59479580
...
...
@@ -34,7 +34,6 @@
#include "core/stats.h"
#include "core/thread_utils.h"
#include "core/util.h"
#include "runtime/capi.h"
#include "runtime/generator.h"
#include "runtime/import.h"
#include "runtime/inline/boxing.h"
...
...
This diff is collapsed.
Click to expand it.
src/codegen/irgen/hooks.cpp
View file @
59479580
...
...
@@ -38,7 +38,6 @@
#include "core/stats.h"
#include "core/types.h"
#include "core/util.h"
#include "runtime/capi.h"
#include "runtime/objmodel.h"
#include "runtime/types.h"
...
...
This diff is collapsed.
Click to expand it.
src/codegen/pypa-parser.cpp
View file @
59479580
...
...
@@ -33,7 +33,6 @@
#include "core/types.h"
#include "core/util.h"
#include "gc/collector.h"
#include "runtime/capi.h"
#include "runtime/objmodel.h"
#include "runtime/types.h"
...
...
This diff is collapsed.
Click to expand it.
src/runtime/builtin_modules/builtins.cpp
View file @
59479580
...
...
@@ -27,7 +27,6 @@
#include "core/ast.h"
#include "core/types.h"
#include "gc/collector.h"
#include "runtime/capi.h"
#include "runtime/classobj.h"
#include "runtime/file.h"
#include "runtime/ics.h"
...
...
This diff is collapsed.
Click to expand it.
src/runtime/builtin_modules/thread.cpp
View file @
59479580
...
...
@@ -21,7 +21,6 @@
#include "capi/typeobject.h"
#include "core/threading.h"
#include "core/types.h"
#include "runtime/capi.h"
#include "runtime/objmodel.h"
#include "runtime/types.h"
...
...
This diff is collapsed.
Click to expand it.
src/runtime/capi.cpp
View file @
59479580
...
...
@@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include <dlfcn.h>
#include <fcntl.h>
#include <stdarg.h>
#include <string.h>
...
...
@@ -1458,56 +1457,6 @@ extern "C" char* PyModule_GetFilename(PyObject* m) noexcept {
return
PyString_AsString
(
fileobj
);
}
BoxedModule
*
importCExtension
(
const
std
::
string
&
full_name
,
const
std
::
string
&
last_name
,
const
std
::
string
&
path
)
{
void
*
handle
=
dlopen
(
path
.
c_str
(),
RTLD_NOW
);
if
(
!
handle
)
{
// raiseExcHelper(ImportError, "%s", dlerror());
fprintf
(
stderr
,
"%s
\n
"
,
dlerror
());
exit
(
1
);
}
assert
(
handle
);
std
::
string
initname
=
"init"
+
last_name
;
void
(
*
init
)()
=
(
void
(
*
)())
dlsym
(
handle
,
initname
.
c_str
());
char
*
error
;
if
((
error
=
dlerror
())
!=
NULL
)
{
// raiseExcHelper(ImportError, "%s", error);
fprintf
(
stderr
,
"%s
\n
"
,
error
);
exit
(
1
);
}
assert
(
init
);
// Let the GC know about the static variables.
uintptr_t
bss_start
=
(
uintptr_t
)
dlsym
(
handle
,
"__bss_start"
);
uintptr_t
bss_end
=
(
uintptr_t
)
dlsym
(
handle
,
"_end"
);
RELEASE_ASSERT
(
bss_end
-
bss_start
<
100000
,
"Large BSS section detected - there maybe something wrong"
);
// only track void* aligned memory
bss_start
=
(
bss_start
+
(
sizeof
(
void
*
)
-
1
))
&
~
(
sizeof
(
void
*
)
-
1
);
bss_end
-=
bss_end
%
sizeof
(
void
*
);
gc
::
registerPotentialRootRange
((
void
*
)
bss_start
,
(
void
*
)
bss_end
);
char
*
packagecontext
=
strdup
(
full_name
.
c_str
());
char
*
oldcontext
=
_Py_PackageContext
;
_Py_PackageContext
=
packagecontext
;
(
*
init
)();
_Py_PackageContext
=
oldcontext
;
free
(
packagecontext
);
checkAndThrowCAPIException
();
BoxedDict
*
sys_modules
=
getSysModulesDict
();
Box
*
s
=
boxString
(
full_name
);
Box
*
_m
=
sys_modules
->
d
[
s
];
RELEASE_ASSERT
(
_m
,
"dynamic module not initialized properly"
);
assert
(
_m
->
cls
==
module_cls
);
BoxedModule
*
m
=
static_cast
<
BoxedModule
*>
(
_m
);
m
->
setattr
(
"__file__"
,
boxString
(
path
),
NULL
);
return
m
;
}
Box
*
BoxedCApiFunction
::
callInternal
(
BoxedFunctionBase
*
func
,
CallRewriteArgs
*
rewrite_args
,
ArgPassSpec
argspec
,
Box
*
arg1
,
Box
*
arg2
,
Box
*
arg3
,
Box
**
args
,
const
std
::
vector
<
BoxedString
*>*
keyword_names
)
{
...
...
This diff is collapsed.
Click to expand it.
src/runtime/capi.h
deleted
100644 → 0
View file @
0809576c
// 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_RUNTIME_CAPI_H
#define PYSTON_RUNTIME_CAPI_H
#include <string>
namespace
pyston
{
class
Box
;
class
BoxedModule
;
BoxedModule
*
importCExtension
(
const
std
::
string
&
full_name
,
const
std
::
string
&
last_name
,
const
std
::
string
&
path
);
void
checkAndThrowCAPIException
();
void
throwCAPIException
()
__attribute__
((
noreturn
));
struct
ExcInfo
;
void
setCAPIException
(
const
ExcInfo
&
e
);
#define fatalOrError(exception, message) \
do { \
if (CONTINUE_AFTER_FATAL) \
PyErr_SetString((exception), (message)); \
else \
Py_FatalError((message)); \
} while (0)
}
#endif
This diff is collapsed.
Click to expand it.
src/runtime/descr.cpp
View file @
59479580
...
...
@@ -13,7 +13,6 @@
// limitations under the License.
#include "codegen/compvars.h"
#include "runtime/capi.h"
#include "runtime/objmodel.h"
#include "runtime/rewrite_args.h"
#include "runtime/types.h"
...
...
This diff is collapsed.
Click to expand it.
src/runtime/import.cpp
View file @
59479580
...
...
@@ -14,6 +14,7 @@
#include "runtime/import.h"
#include <dlfcn.h>
#include <limits.h>
#include "llvm/Support/FileSystem.h"
...
...
@@ -23,7 +24,6 @@
#include "codegen/parser.h"
#include "codegen/unwinding.h"
#include "core/ast.h"
#include "runtime/capi.h"
#include "runtime/objmodel.h"
namespace
pyston
{
...
...
@@ -777,6 +777,56 @@ Box* impLoadDynamic(Box* _name, Box* _pathname, Box* _file) {
return
importCExtension
(
name
->
s
(),
shortname
,
pathname
->
s
());
}
BoxedModule
*
importCExtension
(
const
std
::
string
&
full_name
,
const
std
::
string
&
last_name
,
const
std
::
string
&
path
)
{
void
*
handle
=
dlopen
(
path
.
c_str
(),
RTLD_NOW
);
if
(
!
handle
)
{
// raiseExcHelper(ImportError, "%s", dlerror());
fprintf
(
stderr
,
"%s
\n
"
,
dlerror
());
exit
(
1
);
}
assert
(
handle
);
std
::
string
initname
=
"init"
+
last_name
;
void
(
*
init
)()
=
(
void
(
*
)())
dlsym
(
handle
,
initname
.
c_str
());
char
*
error
;
if
((
error
=
dlerror
())
!=
NULL
)
{
// raiseExcHelper(ImportError, "%s", error);
fprintf
(
stderr
,
"%s
\n
"
,
error
);
exit
(
1
);
}
assert
(
init
);
// Let the GC know about the static variables.
uintptr_t
bss_start
=
(
uintptr_t
)
dlsym
(
handle
,
"__bss_start"
);
uintptr_t
bss_end
=
(
uintptr_t
)
dlsym
(
handle
,
"_end"
);
RELEASE_ASSERT
(
bss_end
-
bss_start
<
100000
,
"Large BSS section detected - there maybe something wrong"
);
// only track void* aligned memory
bss_start
=
(
bss_start
+
(
sizeof
(
void
*
)
-
1
))
&
~
(
sizeof
(
void
*
)
-
1
);
bss_end
-=
bss_end
%
sizeof
(
void
*
);
gc
::
registerPotentialRootRange
((
void
*
)
bss_start
,
(
void
*
)
bss_end
);
char
*
packagecontext
=
strdup
(
full_name
.
c_str
());
char
*
oldcontext
=
_Py_PackageContext
;
_Py_PackageContext
=
packagecontext
;
(
*
init
)();
_Py_PackageContext
=
oldcontext
;
free
(
packagecontext
);
checkAndThrowCAPIException
();
BoxedDict
*
sys_modules
=
getSysModulesDict
();
Box
*
s
=
boxString
(
full_name
);
Box
*
_m
=
sys_modules
->
d
[
s
];
RELEASE_ASSERT
(
_m
,
"dynamic module not initialized properly"
);
assert
(
_m
->
cls
==
module_cls
);
BoxedModule
*
m
=
static_cast
<
BoxedModule
*>
(
_m
);
m
->
setattr
(
"__file__"
,
boxString
(
path
),
NULL
);
return
m
;
}
Box
*
impGetSuffixes
()
{
BoxedList
*
list
=
new
BoxedList
;
// For now only add *.py
...
...
This diff is collapsed.
Click to expand it.
src/runtime/import.h
View file @
59479580
...
...
@@ -21,6 +21,7 @@ namespace pyston {
extern
"C"
Box
*
import
(
int
level
,
Box
*
from_imports
,
llvm
::
StringRef
module_name
);
extern
Box
*
importModuleLevel
(
llvm
::
StringRef
module_name
,
Box
*
globals
,
Box
*
from_imports
,
int
level
);
BoxedModule
*
importCExtension
(
const
std
::
string
&
full_name
,
const
std
::
string
&
last_name
,
const
std
::
string
&
path
);
}
#endif
This diff is collapsed.
Click to expand it.
src/runtime/inline/xrange.cpp
View file @
59479580
...
...
@@ -13,7 +13,6 @@
// limitations under the License.
#include "core/types.h"
#include "runtime/capi.h"
#include "runtime/objmodel.h"
#include "runtime/types.h"
...
...
This diff is collapsed.
Click to expand it.
src/runtime/int.cpp
View file @
59479580
...
...
@@ -24,7 +24,6 @@
#include "core/stats.h"
#include "core/types.h"
#include "gc/collector.h"
#include "runtime/capi.h"
#include "runtime/float.h"
#include "runtime/inline/boxing.h"
#include "runtime/long.h"
...
...
This diff is collapsed.
Click to expand it.
src/runtime/long.cpp
View file @
59479580
...
...
@@ -27,7 +27,6 @@
#include "core/stats.h"
#include "core/types.h"
#include "gc/collector.h"
#include "runtime/capi.h"
#include "runtime/inline/boxing.h"
#include "runtime/objmodel.h"
#include "runtime/types.h"
...
...
This diff is collapsed.
Click to expand it.
src/runtime/objmodel.cpp
View file @
59479580
...
...
@@ -39,7 +39,6 @@
#include "core/types.h"
#include "gc/collector.h"
#include "gc/heap.h"
#include "runtime/capi.h"
#include "runtime/classobj.h"
#include "runtime/dict.h"
#include "runtime/file.h"
...
...
This diff is collapsed.
Click to expand it.
src/runtime/set.cpp
View file @
59479580
...
...
@@ -17,7 +17,6 @@
#include <llvm/Support/raw_ostream.h>
#include "gc/collector.h"
#include "runtime/capi.h"
#include "runtime/objmodel.h"
namespace
pyston
{
...
...
This diff is collapsed.
Click to expand it.
src/runtime/str.cpp
View file @
59479580
...
...
@@ -29,7 +29,6 @@
#include "core/types.h"
#include "core/util.h"
#include "gc/collector.h"
#include "runtime/capi.h"
#include "runtime/dict.h"
#include "runtime/long.h"
#include "runtime/objmodel.h"
...
...
This diff is collapsed.
Click to expand it.
src/runtime/tuple.cpp
View file @
59479580
...
...
@@ -24,7 +24,6 @@
#include "core/stats.h"
#include "core/types.h"
#include "gc/collector.h"
#include "runtime/capi.h"
#include "runtime/objmodel.h"
#include "runtime/types.h"
#include "runtime/util.h"
...
...
This diff is collapsed.
Click to expand it.
src/runtime/types.cpp
View file @
59479580
...
...
@@ -32,7 +32,6 @@
#include "core/stats.h"
#include "core/types.h"
#include "gc/collector.h"
#include "runtime/capi.h"
#include "runtime/classobj.h"
#include "runtime/complex.h"
#include "runtime/dict.h"
...
...
This diff is collapsed.
Click to expand it.
src/runtime/types.h
View file @
59479580
...
...
@@ -962,6 +962,19 @@ AST* unboxAst(Box* b);
// Our default for tp_alloc:
extern
"C"
PyObject
*
PystonType_GenericAlloc
(
BoxedClass
*
cls
,
Py_ssize_t
nitems
)
noexcept
;
void
checkAndThrowCAPIException
();
void
throwCAPIException
()
__attribute__
((
noreturn
));
struct
ExcInfo
;
void
setCAPIException
(
const
ExcInfo
&
e
);
#define fatalOrError(exception, message) \
do { \
if (CONTINUE_AFTER_FATAL) \
PyErr_SetString((exception), (message)); \
else \
Py_FatalError((message)); \
} while (0)
// A descriptor that you can add to your class to provide instances with a __dict__ accessor.
// Classes created in Python get this automatically, but builtin types (including extension types)
// are supposed to add one themselves. type_cls and function_cls do this, for example.
...
...
This diff is collapsed.
Click to expand it.
src/runtime/util.cpp
View file @
59479580
...
...
@@ -15,7 +15,6 @@
#include "runtime/util.h"
#include "core/options.h"
#include "runtime/capi.h"
#include "runtime/objmodel.h"
#include "runtime/types.h"
...
...
This diff is collapsed.
Click to expand it.
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