Commit 1c1dcdb9 authored by Marius Wachtler's avatar Marius Wachtler

Allocate all ASTInterpreter instances on the stack and remove the interpreter map.

Not having the ASTInterpreter GC allocated improves performance.
I had to add a small asm function in order to produce a special stack frame where we can easily retrieve the ASTInterpreter*,
to replace s_interpreterMaps job. This also make sure that this function really does not get inlined.
The s_interpreterMap was hard to understand and produced several times problems (duplicate entries,...)

This patch contains a hack which limits the number of variables inside a function to 512.
Because we have to make sure the are all on the stack and can't dynamically add more space.
An upcoming patch will remove this limitation and replace it with a stack alloca of the size of the actual number of variables the function uses.
parent 5071e380
......@@ -34,6 +34,7 @@ add_library(PYSTON_OBJECTS OBJECT ${OPTIONAL_SRCS}
capi/object.cpp
capi/typeobject.cpp
codegen/ast_interpreter.cpp
codegen/ast_interpreter_exec.S
codegen/baseline_jit.cpp
codegen/codegen.cpp
codegen/compvars.cpp
......
This diff is collapsed.
......@@ -70,7 +70,6 @@ struct Value {
Value(Box* o, RewriterVar* var) : o(o), var(var) {}
};
void setupInterpreter();
Box* astInterpretFunction(CLFunction* f, int nargs, Box* closure, Box* generator, Box* globals, Box* arg1, Box* arg2,
Box* arg3, Box** args);
Box* astInterpretFunctionEval(CLFunction* cf, Box* globals, Box* boxedLocals);
......
// 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.
// This functions sets up a fixed stack frame which we use to detect ASTInterpreter frames
// and which makes it easy retrieve the passed ASTInterpreter pointer (stored at frame_ptr-8).
// It's written in ASM to make sure the stack layout keeps beeing the same and that nothing gets inlined.
// Our unwinder treats this function specialy.
// Box* executeInnerAndSetupFrame(ASTInterpreter& interpreter, CFGBlock* start_block, AST_stmt* start_at)
.text
.globl executeInnerAndSetupFrame
.type executeInnerAndSetupFrame,@function
.align 16
executeInnerAndSetupFrame:
.cfi_startproc
push %rbp
.cfi_def_cfa_offset 16
.cfi_offset rbp,-16
mov %rsp, %rbp
.cfi_def_cfa_register rbp
sub $16, %rsp
mov %rdi, -8(%rbp)
call executeInnerFromASM
leave
.cfi_def_cfa rsp,8
ret
.cfi_endproc
.size executeInnerAndSetupFrame,.-executeInnerAndSetupFrame
.section .note.GNU-stack,"",%progbits // we don't need executable stack
......@@ -21,9 +21,10 @@
namespace pyston {
template <class TKey, class TVal, class TMap = llvm::DenseMap<TKey, int>> class ContiguousMap {
template <class TKey, class TVal, class TMap = llvm::DenseMap<TKey, int>, class TVec = std::vector<TVal>>
class ContiguousMap {
typedef TMap map_type;
typedef std::vector<TVal> vec_type;
typedef TVec vec_type;
map_type map;
vec_type vec;
......
......@@ -3339,7 +3339,6 @@ void setupRuntime() {
closure_cls->freeze();
setupUnwinding();
setupInterpreter();
setupCAPI();
// Can't set up object methods until we set up CAPI support:
......
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