Merge pull request #302 from Hackerpilot/allocator_improvements

Allocator improvements
This commit is contained in:
Brian Schott 2016-03-03 02:23:15 -08:00
commit 7028dc1fcf
6 changed files with 21 additions and 13 deletions

@ -1 +1 @@
Subproject commit f6aac6cab1ffebdc2a56321f0c5fed2c896f38c4 Subproject commit 86cf39c41e3173818a3ad9aa60bb253f0da26523

View File

@ -7,8 +7,8 @@
], ],
"license": "GPL-3.0", "license": "GPL-3.0",
"dependencies": { "dependencies": {
"dsymbol": "~>0.1.2", "dsymbol": "~>0.2.0-alpha1",
"libdparse": "~>0.6.0", "libdparse": "~>0.7.0-alpha1",
"msgpack-d": "~>1.0.0-beta.2" "msgpack-d": "~>1.0.0-beta.2"
}, },
"versions": ["built_with_dub"], "versions": ["built_with_dub"],

@ -1 +1 @@
Subproject commit 516a053c9b16d05aee30d2606a88b7f815cd55df Subproject commit 3257b3c905127e8bccf4b9b2ebc50b9b448c0fba

View File

@ -67,6 +67,8 @@ SERVER_SRC := \
${DPARSE_DIR}/src/dparse/lexer.d\ ${DPARSE_DIR}/src/dparse/lexer.d\
${DPARSE_DIR}/src/dparse/parser.d\ ${DPARSE_DIR}/src/dparse/parser.d\
${DPARSE_DIR}/src/dparse/formatter.d\ ${DPARSE_DIR}/src/dparse/formatter.d\
${DPARSE_DIR}/src/dparse/rollback_allocator.d\
${DPARSE_DIR}/src/dparse/stack_buffer.d\
${DPARSE_DIR}/src/std/experimental/lexer.d\ ${DPARSE_DIR}/src/std/experimental/lexer.d\
$(shell find containers/experimental_allocator/src/std/experimental/allocator/ -name "*.d")\ $(shell find containers/experimental_allocator/src/std/experimental/allocator/ -name "*.d")\
containers/src/containers/dynamicarray.d\ containers/src/containers/dynamicarray.d\

View File

@ -21,7 +21,7 @@ module common.dcd_version;
/** /**
* Human-readable version number * Human-readable version number
*/ */
enum DCD_VERSION = "v0.8.0"; enum DCD_VERSION = "v0.9.0-alpha1";
version (Windows) {} version (Windows) {}
else version (built_with_dub) {} else version (built_with_dub) {}

View File

@ -35,6 +35,7 @@ import std.uni;
import dparse.ast; import dparse.ast;
import dparse.lexer; import dparse.lexer;
import dparse.parser; import dparse.parser;
import dparse.rollback_allocator;
import dsymbol.conversion; import dsymbol.conversion;
import dsymbol.modulecache; import dsymbol.modulecache;
@ -59,10 +60,11 @@ public AutocompleteResponse getDoc(const AutocompleteRequest request,
{ {
// trace("Getting doc comments"); // trace("Getting doc comments");
AutocompleteResponse response; AutocompleteResponse response;
RollbackAllocator rba;
auto allocator = scoped!(ASTAllocator)(); auto allocator = scoped!(ASTAllocator)();
auto cache = StringCache(StringCache.defaultBucketCount); auto cache = StringCache(StringCache.defaultBucketCount);
SymbolStuff stuff = getSymbolsForCompletion(request, CompletionType.ddoc, SymbolStuff stuff = getSymbolsForCompletion(request, CompletionType.ddoc,
allocator, cache, moduleCache); allocator, &rba, cache, moduleCache);
if (stuff.symbols.length == 0) if (stuff.symbols.length == 0)
warning("Could not find symbol"); warning("Could not find symbol");
else else
@ -121,10 +123,11 @@ public AutocompleteResponse findDeclaration(const AutocompleteRequest request,
ref ModuleCache moduleCache) ref ModuleCache moduleCache)
{ {
AutocompleteResponse response; AutocompleteResponse response;
RollbackAllocator rba;
auto allocator = scoped!(ASTAllocator)(); auto allocator = scoped!(ASTAllocator)();
auto cache = StringCache(StringCache.defaultBucketCount); auto cache = StringCache(StringCache.defaultBucketCount);
SymbolStuff stuff = getSymbolsForCompletion(request, SymbolStuff stuff = getSymbolsForCompletion(request,
CompletionType.location, allocator, cache, moduleCache); CompletionType.location, allocator, &rba, cache, moduleCache);
scope(exit) stuff.destroy(); scope(exit) stuff.destroy();
if (stuff.symbols.length > 0) if (stuff.symbols.length > 0)
{ {
@ -191,8 +194,9 @@ public AutocompleteResponse symbolSearch(const AutocompleteRequest request,
const(Token)[] tokenArray = getTokensForParser(cast(ubyte[]) request.sourceCode, const(Token)[] tokenArray = getTokensForParser(cast(ubyte[]) request.sourceCode,
config, &cache); config, &cache);
auto allocator = scoped!(ASTAllocator)(); auto allocator = scoped!(ASTAllocator)();
RollbackAllocator rba;
ScopeSymbolPair pair = generateAutocompleteTrees(tokenArray, allocator, ScopeSymbolPair pair = generateAutocompleteTrees(tokenArray, allocator,
request.cursorPosition, moduleCache); &rba, request.cursorPosition, moduleCache);
scope(exit) pair.destroy(); scope(exit) pair.destroy();
static struct SearchResults static struct SearchResults
@ -328,8 +332,9 @@ AutocompleteResponse dotCompletion(T)(T beforeTokens, const(Token)[] tokenArray,
case tok!"this": case tok!"this":
case tok!"super": case tok!"super":
auto allocator = scoped!(ASTAllocator)(); auto allocator = scoped!(ASTAllocator)();
RollbackAllocator rba;
ScopeSymbolPair pair = generateAutocompleteTrees(tokenArray, allocator, ScopeSymbolPair pair = generateAutocompleteTrees(tokenArray, allocator,
cursorPosition, moduleCache); &rba, cursorPosition, moduleCache);
scope(exit) pair.destroy(); scope(exit) pair.destroy();
response.setCompletions(pair.scope_, getExpression(beforeTokens), response.setCompletions(pair.scope_, getExpression(beforeTokens),
cursorPosition, CompletionType.identifiers, false, partial); cursorPosition, CompletionType.identifiers, false, partial);
@ -372,14 +377,14 @@ auto getTokensBeforeCursor(const(ubyte[]) sourceCode, size_t cursorPosition,
* the request's source code, cursor position, and completion type. * the request's source code, cursor position, and completion type.
*/ */
SymbolStuff getSymbolsForCompletion(const AutocompleteRequest request, SymbolStuff getSymbolsForCompletion(const AutocompleteRequest request,
const CompletionType type, IAllocator allocator, ref StringCache cache, const CompletionType type, IAllocator allocator, RollbackAllocator* rba,
ref ModuleCache moduleCache) ref StringCache cache, ref ModuleCache moduleCache)
{ {
const(Token)[] tokenArray; const(Token)[] tokenArray;
auto beforeTokens = getTokensBeforeCursor(request.sourceCode, auto beforeTokens = getTokensBeforeCursor(request.sourceCode,
request.cursorPosition, cache, tokenArray); request.cursorPosition, cache, tokenArray);
ScopeSymbolPair pair = generateAutocompleteTrees(tokenArray, allocator, ScopeSymbolPair pair = generateAutocompleteTrees(tokenArray, allocator,
request.cursorPosition, moduleCache); rba, request.cursorPosition, moduleCache);
auto expression = getExpression(beforeTokens); auto expression = getExpression(beforeTokens);
return SymbolStuff(getSymbolsByTokenChain(pair.scope_, expression, return SymbolStuff(getSymbolsByTokenChain(pair.scope_, expression,
request.cursorPosition, type), pair.symbol, pair.scope_); request.cursorPosition, type), pair.symbol, pair.scope_);
@ -456,8 +461,9 @@ AutocompleteResponse parenCompletion(T)(T beforeTokens,
case tok!")": case tok!")":
case tok!"]": case tok!"]":
auto allocator = scoped!(ASTAllocator)(); auto allocator = scoped!(ASTAllocator)();
RollbackAllocator rba;
ScopeSymbolPair pair = generateAutocompleteTrees(tokenArray, allocator, ScopeSymbolPair pair = generateAutocompleteTrees(tokenArray, allocator,
cursorPosition, moduleCache); &rba, cursorPosition, moduleCache);
scope(exit) pair.destroy(); scope(exit) pair.destroy();
auto expression = getExpression(beforeTokens[0 .. $ - 1]); auto expression = getExpression(beforeTokens[0 .. $ - 1]);
response.setCompletions(pair.scope_, expression, response.setCompletions(pair.scope_, expression,