Commit 7bf59432 authored by Kevin Modzelewski's avatar Kevin Modzelewski

Format src/core/ again

I don't quite remember this but I think the goal was to ignore core/from_llvm, not all of core/
parent b701479b
...@@ -34,123 +34,121 @@ namespace pyston { ...@@ -34,123 +34,121 @@ namespace pyston {
namespace AST_TYPE { namespace AST_TYPE {
// These are in a pretty random order (started off alphabetical but then I had to add more). // These are in a pretty random order (started off alphabetical but then I had to add more).
// These can be changed freely as long as parse_ast.py is also updated // These can be changed freely as long as parse_ast.py is also updated
#define FOREACH_TYPE(X) \ #define FOREACH_TYPE(X) \
X(alias, 1) \ X(alias, 1) \
X(arguments, 2) \ X(arguments, 2) \
X(Assert, 3) \ X(Assert, 3) \
X(Assign, 4) \ X(Assign, 4) \
X(Attribute, 5) \ X(Attribute, 5) \
X(AugAssign, 6) \ X(AugAssign, 6) \
X(BinOp, 7) \ X(BinOp, 7) \
X(BoolOp, 8) \ X(BoolOp, 8) \
X(Call, 9) \ X(Call, 9) \
X(ClassDef, 10) \ X(ClassDef, 10) \
X(Compare, 11) \ X(Compare, 11) \
X(comprehension, 12) \ X(comprehension, 12) \
X(Delete, 13) \ X(Delete, 13) \
X(Dict, 14) \ X(Dict, 14) \
X(Exec, 16) \ X(Exec, 16) \
X(ExceptHandler, 17) \ X(ExceptHandler, 17) \
X(ExtSlice, 18) \ X(ExtSlice, 18) \
X(Expr, 19) \ X(Expr, 19) \
X(For, 20) \ X(For, 20) \
X(FunctionDef, 21) \ X(FunctionDef, 21) \
X(GeneratorExp, 22) \ X(GeneratorExp, 22) \
X(Global, 23) \ X(Global, 23) \
X(If, 24) \ X(If, 24) \
X(IfExp, 25) \ X(IfExp, 25) \
X(Import, 26) \ X(Import, 26) \
X(ImportFrom, 27) \ X(ImportFrom, 27) \
X(Index, 28) \ X(Index, 28) \
X(keyword, 29) \ X(keyword, 29) \
X(Lambda, 30) \ X(Lambda, 30) \
X(List, 31) \ X(List, 31) \
X(ListComp, 32) \ X(ListComp, 32) \
X(Module, 33) \ X(Module, 33) \
X(Num, 34) \ X(Num, 34) \
X(Name, 35) \ X(Name, 35) \
X(Pass, 37) \ X(Pass, 37) \
X(Pow, 38) \ X(Pow, 38) \
X(Print, 39) \ X(Print, 39) \
X(Raise, 40) \ X(Raise, 40) \
X(Repr, 41) \ X(Repr, 41) \
X(Return, 42) \ X(Return, 42) \
X(Slice, 44) \ X(Slice, 44) \
X(Str, 45) \ X(Str, 45) \
X(Subscript, 46) \ X(Subscript, 46) \
X(TryExcept, 47) \ X(TryExcept, 47) \
X(TryFinally, 48) \ X(TryFinally, 48) \
X(Tuple, 49) \ X(Tuple, 49) \
X(UnaryOp, 50) \ X(UnaryOp, 50) \
X(With, 51) \ X(With, 51) \
X(While, 52) \ X(While, 52) \
X(Yield, 53) \ X(Yield, 53) \
X(Store, 54) \ X(Store, 54) \
X(Load, 55) \ X(Load, 55) \
X(Param, 56) \ X(Param, 56) \
X(Not, 57) \ X(Not, 57) \
X(In, 58) \ X(In, 58) \
X(Is, 59) \ X(Is, 59) \
X(IsNot, 60) \ X(IsNot, 60) \
X(Or, 61) \ X(Or, 61) \
X(And, 62) \ X(And, 62) \
X(Eq, 63) \ X(Eq, 63) \
X(NotEq, 64) \ X(NotEq, 64) \
X(NotIn, 65) \ X(NotIn, 65) \
X(GtE, 66) \ X(GtE, 66) \
X(Gt, 67) \ X(Gt, 67) \
X(Mod, 68) \ X(Mod, 68) \
X(Add, 69) \ X(Add, 69) \
X(Continue, 70) \ X(Continue, 70) \
X(Lt, 71) \ X(Lt, 71) \
X(LtE, 72) \ X(LtE, 72) \
X(Break, 73) \ X(Break, 73) \
X(Sub, 74) \ X(Sub, 74) \
X(Del, 75) \ X(Del, 75) \
X(Mult, 76) \ X(Mult, 76) \
X(Div, 77) \ X(Div, 77) \
X(USub, 78) \ X(USub, 78) \
X(BitAnd, 79) \ X(BitAnd, 79) \
X(BitOr, 80) \ X(BitOr, 80) \
X(BitXor, 81) \ X(BitXor, 81) \
X(RShift, 82) \ X(RShift, 82) \
X(LShift, 83) \ X(LShift, 83) \
X(Invert, 84) \ X(Invert, 84) \
X(UAdd, 85) \ X(UAdd, 85) \
X(FloorDiv, 86) \ X(FloorDiv, 86) \
X(DictComp, 15) \ X(DictComp, 15) \
X(Set, 43) \ X(Set, 43) \
X(Ellipsis, 87) \ X(Ellipsis, 87) \
/* like Module, but used for eval. */ \ /* like Module, but used for eval. */ \
X(Expression, 88) \ X(Expression, 88) \
X(SetComp, 89) \ X(SetComp, 89) \
X(Suite, 90) \ X(Suite, 90) \
\ \
/* Pseudo-nodes that are specific to this compiler: */ \ /* Pseudo-nodes that are specific to this compiler: */ \
X(Branch, 200) \ X(Branch, 200) \
X(Jump, 201) \ X(Jump, 201) \
X(ClsAttribute, 202) \ X(ClsAttribute, 202) \
X(AugBinOp, 203) \ X(AugBinOp, 203) \
X(Invoke, 204) \ X(Invoke, 204) \
X(LangPrimitive, 205) \ X(LangPrimitive, 205) \
/* wraps a ClassDef to make it an expr */ \ /* wraps a ClassDef to make it an expr */ \
X(MakeClass, 206) \ X(MakeClass, 206) \
/* wraps a FunctionDef to make it an expr */ \ /* wraps a FunctionDef to make it an expr */ \
X(MakeFunction, 207) \ X(MakeFunction, 207) \
\ \
/* These aren't real AST types, but since we use AST types to represent binexp types */ \ /* These aren't real AST types, but since we use AST types to represent binexp types */ \
/* and divmod+truediv are essentially types of binops, we add them here (at least for now): */ \ /* and divmod+truediv are essentially types of binops, we add them here (at least for now): */ \
X(DivMod, 250) \ X(DivMod, 250) \
X(TrueDiv, 251) \ X(TrueDiv, 251)
#define GENERATE_ENUM(ENUM, N) ENUM = N, #define GENERATE_ENUM(ENUM, N) ENUM = N,
#define GENERATE_STRING(STRING, N) m[N] = #STRING; #define GENERATE_STRING(STRING, N) m[N] = #STRING;
enum AST_TYPE { enum AST_TYPE { FOREACH_TYPE(GENERATE_ENUM) };
FOREACH_TYPE(GENERATE_ENUM)
};
static const char *stringify(int n) { static const char* stringify(int n) {
static std::map<int, const char*> m; static std::map<int, const char*> m;
FOREACH_TYPE(GENERATE_STRING) FOREACH_TYPE(GENERATE_STRING)
return m[n]; return m[n];
...@@ -159,7 +157,6 @@ static const char *stringify(int n) { ...@@ -159,7 +157,6 @@ static const char *stringify(int n) {
#undef FOREACH_TYPE #undef FOREACH_TYPE
#undef GENERATE_ENUM #undef GENERATE_ENUM
#undef GENERATE_STRING #undef GENERATE_STRING
}; };
class ASTVisitor; class ASTVisitor;
...@@ -1360,9 +1357,7 @@ private: ...@@ -1360,9 +1357,7 @@ private:
public: public:
PrintVisitor(int indent = 0, llvm::raw_ostream& stream = llvm::outs()) : stream(stream), indent(indent) {} PrintVisitor(int indent = 0, llvm::raw_ostream& stream = llvm::outs()) : stream(stream), indent(indent) {}
virtual ~PrintVisitor() {} virtual ~PrintVisitor() {}
void flush() { void flush() { stream.flush(); }
stream.flush();
}
virtual bool visit_alias(AST_alias* node); virtual bool visit_alias(AST_alias* node);
virtual bool visit_arguments(AST_arguments* node); virtual bool visit_arguments(AST_arguments* node);
......
...@@ -271,7 +271,8 @@ private: ...@@ -271,7 +271,8 @@ private:
} }
} }
raiseSyntaxError("'continue' not properly in loop", value->lineno, value->col_offset, source->getFn()->s(), "", true); raiseSyntaxError("'continue' not properly in loop", value->lineno, value->col_offset, source->getFn()->s(), "",
true);
} }
void doBreak(AST* value) { void doBreak(AST* value) {
...@@ -2527,7 +2528,8 @@ public: ...@@ -2527,7 +2528,8 @@ public:
llvm::DenseMap<InternedString, int> sym_vreg_map; llvm::DenseMap<InternedString, int> sym_vreg_map;
ScopeInfo* scope_info; ScopeInfo* scope_info;
AssignVRegsVisitor(ScopeInfo* scope_info, bool only_user_visible) : only_user_visible(only_user_visible), scope_info(scope_info) {} AssignVRegsVisitor(ScopeInfo* scope_info, bool only_user_visible)
: only_user_visible(only_user_visible), scope_info(scope_info) {}
bool visit_arguments(AST_arguments* node) override { bool visit_arguments(AST_arguments* node) override {
for (AST_expr* d : node->defaults) for (AST_expr* d : node->defaults)
...@@ -2586,8 +2588,9 @@ void CFG::assignVRegs(const ParamNames& param_names, ScopeInfo* scope_info) { ...@@ -2586,8 +2588,9 @@ void CFG::assignVRegs(const ParamNames& param_names, ScopeInfo* scope_info) {
AssignVRegsVisitor visitor(scope_info, true); AssignVRegsVisitor visitor(scope_info, true);
// we need todo two passes: first we assign the user visible vars a vreg and then the compiler created get there value. // we need todo two passes: first we assign the user visible vars a vreg and then the compiler created get there
for (int i=0; i<2; ++i) { // value.
for (int i = 0; i < 2; ++i) {
for (CFGBlock* b : blocks) { for (CFGBlock* b : blocks) {
for (AST_stmt* stmt : b->body) { for (AST_stmt* stmt : b->body) {
stmt->accept(&visitor); stmt->accept(&visitor);
......
...@@ -67,9 +67,7 @@ public: ...@@ -67,9 +67,7 @@ public:
void push_back(AST_stmt* node) { body.push_back(node); } void push_back(AST_stmt* node) { body.push_back(node); }
void print(llvm::raw_ostream& stream = llvm::outs()); void print(llvm::raw_ostream& stream = llvm::outs());
void _print() { void _print() { print(); }
print();
}
}; };
// Control Flow Graph // Control Flow Graph
......
...@@ -84,8 +84,7 @@ template <typename T1, typename T2, typename T3> struct hash<tuple<T1, T2, T3>> ...@@ -84,8 +84,7 @@ template <typename T1, typename T2, typename T3> struct hash<tuple<T1, T2, T3>>
} }
namespace pyston { namespace pyston {
template <typename T> template <typename T> constexpr bool fitsInto(int64_t x) {
constexpr bool fitsInto(int64_t x) {
return std::numeric_limits<T>::min() <= x && x <= std::numeric_limits<T>::max(); return std::numeric_limits<T>::min() <= x && x <= std::numeric_limits<T>::max();
} }
} }
......
...@@ -50,7 +50,7 @@ bool ENABLE_TRACEBACKS = true; ...@@ -50,7 +50,7 @@ bool ENABLE_TRACEBACKS = true;
bool FORCE_LLVM_CAPI_CALLS = false; bool FORCE_LLVM_CAPI_CALLS = false;
bool FORCE_LLVM_CAPI_THROWS = false; bool FORCE_LLVM_CAPI_THROWS = false;
int OSR_THRESHOLD_INTERPRETER = 5; // XXX int OSR_THRESHOLD_INTERPRETER = 5; // XXX
int REOPT_THRESHOLD_INTERPRETER = 1; // XXX int REOPT_THRESHOLD_INTERPRETER = 1; // XXX
int OSR_THRESHOLD_BASELINE = 2500; int OSR_THRESHOLD_BASELINE = 2500;
int REOPT_THRESHOLD_BASELINE = 1500; int REOPT_THRESHOLD_BASELINE = 1500;
......
...@@ -42,5 +42,4 @@ bool InternedString::isCompilerCreatedName() const { ...@@ -42,5 +42,4 @@ bool InternedString::isCompilerCreatedName() const {
char c = _str->s()[0]; char c = _str->s()[0];
return c == '!' || c == '#'; return c == '!' || c == '#';
} }
} }
...@@ -460,7 +460,6 @@ extern "C" void PyEval_ReInitThreads() noexcept { ...@@ -460,7 +460,6 @@ extern "C" void PyEval_ReInitThreads() noexcept {
else else
Py_DECREF(result); Py_DECREF(result);
Py_DECREF(threading); Py_DECREF(threading);
} }
void acquireGLWrite() { void acquireGLWrite() {
...@@ -599,7 +598,7 @@ extern "C" void PyThread_delete_key_value(int key) noexcept { ...@@ -599,7 +598,7 @@ extern "C" void PyThread_delete_key_value(int key) noexcept {
} }
extern "C" PyObject *_PyThread_CurrentFrames(void) noexcept { extern "C" PyObject* _PyThread_CurrentFrames(void) noexcept {
assert(0 && "check refcounting"); assert(0 && "check refcounting");
try { try {
LOCK_REGION(&threading_lock); LOCK_REGION(&threading_lock);
...@@ -611,9 +610,9 @@ extern "C" PyObject *_PyThread_CurrentFrames(void) noexcept { ...@@ -611,9 +610,9 @@ extern "C" PyObject *_PyThread_CurrentFrames(void) noexcept {
result->d[boxInt(pair.first)] = frame; result->d[boxInt(pair.first)] = frame;
} }
return result; return result;
} catch (ExcInfo) { } catch (ExcInfo) {
RELEASE_ASSERT(0, "not implemented"); RELEASE_ASSERT(0, "not implemented");
} }
} }
......
...@@ -78,10 +78,10 @@ enum Rewritable { ...@@ -78,10 +78,10 @@ enum Rewritable {
enum class RefType { enum class RefType {
UNKNOWN UNKNOWN
#ifndef NDEBUG #ifndef NDEBUG
// Set this to non-zero to make it possible for the debugger to // Set this to non-zero to make it possible for the debugger to
= 1 = 1
#endif #endif
, ,
OWNED, OWNED,
BORROWED, BORROWED,
}; };
...@@ -314,7 +314,8 @@ class JitCodeBlock; ...@@ -314,7 +314,8 @@ class JitCodeBlock;
extern std::vector<Box*> constants; extern std::vector<Box*> constants;
extern std::vector<Box*> late_constants; // constants that should be freed after normal constants extern std::vector<Box*> late_constants; // constants that should be freed after normal constants
// A specific compilation of a FunctionMetadata. Usually these will be created by the LLVM JIT, which will take a FunctionMetadata // A specific compilation of a FunctionMetadata. Usually these will be created by the LLVM JIT, which will take a
// FunctionMetadata
// and some compilation settings, and produce a CompiledFunction // and some compilation settings, and produce a CompiledFunction
// CompiledFunctions can also be created from raw function pointers, using FunctionMetadata::create. // CompiledFunctions can also be created from raw function pointers, using FunctionMetadata::create.
// A single FunctionMetadata can have multiple CompiledFunctions associated with it, if they have different settings. // A single FunctionMetadata can have multiple CompiledFunctions associated with it, if they have different settings.
...@@ -655,10 +656,10 @@ public: ...@@ -655,10 +656,10 @@ public:
int traverse(visitproc visit, void* arg) noexcept; int traverse(visitproc visit, void* arg) noexcept;
void _clearRaw() noexcept; // Raw clear -- clears out and decrefs all the attrs. void _clearRaw() noexcept; // Raw clear -- clears out and decrefs all the attrs.
// Meant for implementing other clear-like functions // Meant for implementing other clear-like functions
void clearForDealloc() noexcept; // meant for normal object deallocation. converts the attrwrapper void clearForDealloc() noexcept; // meant for normal object deallocation. converts the attrwrapper
void moduleClear() noexcept; // Meant for _PyModule_Clear. doesn't clear all attributes. void moduleClear() noexcept; // Meant for _PyModule_Clear. doesn't clear all attributes.
}; };
static_assert(sizeof(HCAttrs) == sizeof(struct _hcattrs), ""); static_assert(sizeof(HCAttrs) == sizeof(struct _hcattrs), "");
...@@ -694,7 +695,7 @@ public: ...@@ -694,7 +695,7 @@ public:
_PyObject_HEAD_EXTRA _PyObject_HEAD_EXTRA
Py_ssize_t ob_refcnt; Py_ssize_t ob_refcnt;
// Note: cls gets initialized in the new() function. // Note: cls gets initialized in the new() function.
BoxedClass* cls; BoxedClass* cls;
...@@ -898,13 +899,13 @@ static_assert(offsetof(BoxVar, ob_size) == offsetof(struct _varobject, ob_size), ...@@ -898,13 +899,13 @@ static_assert(offsetof(BoxVar, ob_size) == offsetof(struct _varobject, ob_size),
} \ } \
void* operator new(size_t size, size_t nitems) __attribute__((visibility("default"))) { \ void* operator new(size_t size, size_t nitems) __attribute__((visibility("default"))) { \
ALLOC_STATS_VAR(default_cls) \ ALLOC_STATS_VAR(default_cls) \
assert(default_cls->tp_alloc == PyType_GenericAlloc); \ assert(default_cls->tp_alloc == PyType_GenericAlloc); \
assert(default_cls->tp_itemsize == itemsize); \ assert(default_cls->tp_itemsize == itemsize); \
assert(default_cls->tp_basicsize == size); \ assert(default_cls->tp_basicsize == size); \
assert(default_cls->is_pyston_class); \ assert(default_cls->is_pyston_class); \
assert(default_cls->attrs_offset == 0); \ assert(default_cls->attrs_offset == 0); \
\ \
void* mem = PyObject_MALLOC(size + nitems * itemsize); \ void* mem = PyObject_MALLOC(size + nitems * itemsize); \
assert(mem); \ assert(mem); \
\ \
BoxVar* rtn = static_cast<BoxVar*>(mem); \ BoxVar* rtn = static_cast<BoxVar*>(mem); \
......
#!/usr/bin/env bash #!/usr/bin/env bash
set -eu set -eu
failed=0 failed=0
for fn in $(find . -path ./core -prune -o -name '*.cpp' -print -o -name '*.h' -print); do for fn in $(find . -path ./core/from_llvm -prune -o -name '*.cpp' -print -o -name '*.h' -print); do
diff -u $fn <($1 -style=file $fn) || failed=1 diff -u $fn <($1 -style=file $fn) || failed=1
done done
......
#!/usr/bin/env bash #!/usr/bin/env bash
set -eu set -eu
for fn in $(find . -path ./core -prune -o -name '*.cpp' -print -o -name '*.h' -print); do for fn in $(find . -path ./core/from_llvm -prune -o -name '*.cpp' -print -o -name '*.h' -print); do
$1 -i --style=file $fn $1 -i --style=file $fn
done done
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment