Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(333)

Side by Side Diff: runtime/vm/parser.cc

Issue 1436243005: Collect closure functions in isolate (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/parser.h" 5 #include "vm/parser.h"
6 6
7 #include "lib/invocation_mirror.h" 7 #include "lib/invocation_mirror.h"
8 #include "platform/utils.h" 8 #include "platform/utils.h"
9 #include "vm/ast_transformer.h" 9 #include "vm/ast_transformer.h"
10 #include "vm/bootstrap.h" 10 #include "vm/bootstrap.h"
(...skipping 6553 matching lines...) Expand 10 before | Expand all | Expand 10 after
6564 Function& body = Function::Handle(Z); 6564 Function& body = Function::Handle(Z);
6565 String& body_closure_name = String::Handle(Z); 6565 String& body_closure_name = String::Handle(Z);
6566 bool is_new_closure = false; 6566 bool is_new_closure = false;
6567 6567
6568 AddContinuationVariables(); 6568 AddContinuationVariables();
6569 6569
6570 // Check whether a function for the body of this generator 6570 // Check whether a function for the body of this generator
6571 // function has already been created by a previous 6571 // function has already been created by a previous
6572 // compilation. 6572 // compilation.
6573 const Function& found_func = Function::Handle( 6573 const Function& found_func = Function::Handle(
6574 Z, current_class().LookupClosureFunction(func_pos)); 6574 Z, I->LookupClosureFunction(script_, func_pos));
6575 if (!found_func.IsNull() && 6575 if (!found_func.IsNull() &&
6576 (found_func.token_pos() == func_pos) && 6576 (found_func.token_pos() == func_pos) &&
6577 (found_func.script() == innermost_function().script()) && 6577 (found_func.script() == innermost_function().script()) &&
6578 (found_func.parent_function() == innermost_function().raw())) { 6578 (found_func.parent_function() == innermost_function().raw())) {
6579 ASSERT(found_func.IsSyncGenClosure()); 6579 ASSERT(found_func.IsSyncGenClosure());
6580 body = found_func.raw(); 6580 body = found_func.raw();
6581 body_closure_name = body.name(); 6581 body_closure_name = body.name();
6582 } else { 6582 } else {
6583 // Create the closure containing the body of this generator function. 6583 // Create the closure containing the body of this generator function.
6584 String& generator_name = String::Handle(Z, innermost_function().name()); 6584 String& generator_name = String::Handle(Z, innermost_function().name());
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
6705 TRACE_PARSER("OpenAsyncFunction"); 6705 TRACE_PARSER("OpenAsyncFunction");
6706 AddContinuationVariables(); 6706 AddContinuationVariables();
6707 AddAsyncClosureVariables(); 6707 AddAsyncClosureVariables();
6708 Function& closure = Function::Handle(Z); 6708 Function& closure = Function::Handle(Z);
6709 bool is_new_closure = false; 6709 bool is_new_closure = false;
6710 6710
6711 // Check whether a function for the asynchronous function body of 6711 // Check whether a function for the asynchronous function body of
6712 // this async function has already been created by a previous 6712 // this async function has already been created by a previous
6713 // compilation of this function. 6713 // compilation of this function.
6714 const Function& found_func = Function::Handle( 6714 const Function& found_func = Function::Handle(
6715 Z, current_class().LookupClosureFunction(async_func_pos)); 6715 Z, I->LookupClosureFunction(script_, async_func_pos));
6716 if (!found_func.IsNull() && 6716 if (!found_func.IsNull() &&
6717 (found_func.token_pos() == async_func_pos) && 6717 (found_func.token_pos() == async_func_pos) &&
6718 (found_func.script() == innermost_function().script()) && 6718 (found_func.script() == innermost_function().script()) &&
6719 (found_func.parent_function() == innermost_function().raw())) { 6719 (found_func.parent_function() == innermost_function().raw())) {
6720 ASSERT(found_func.IsAsyncClosure()); 6720 ASSERT(found_func.IsAsyncClosure());
6721 closure = found_func.raw(); 6721 closure = found_func.raw();
6722 } else { 6722 } else {
6723 // Create the closure containing the body of this async function. 6723 // Create the closure containing the body of this async function.
6724 const String& async_func_name = 6724 const String& async_func_name =
6725 String::Handle(Z, innermost_function().name()); 6725 String::Handle(Z, innermost_function().name());
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
6841 AddContinuationVariables(); 6841 AddContinuationVariables();
6842 AddAsyncGeneratorVariables(); 6842 AddAsyncGeneratorVariables();
6843 6843
6844 Function& closure = Function::Handle(Z); 6844 Function& closure = Function::Handle(Z);
6845 bool is_new_closure = false; 6845 bool is_new_closure = false;
6846 6846
6847 // Check whether a function for the asynchronous function body of 6847 // Check whether a function for the asynchronous function body of
6848 // this async generator has already been created by a previous 6848 // this async generator has already been created by a previous
6849 // compilation of this function. 6849 // compilation of this function.
6850 const Function& found_func = Function::Handle( 6850 const Function& found_func = Function::Handle(
6851 Z, current_class().LookupClosureFunction(async_func_pos)); 6851 Z, I->LookupClosureFunction(script_, async_func_pos));
6852 if (!found_func.IsNull() && 6852 if (!found_func.IsNull() &&
6853 (found_func.token_pos() == async_func_pos) && 6853 (found_func.token_pos() == async_func_pos) &&
6854 (found_func.script() == innermost_function().script()) && 6854 (found_func.script() == innermost_function().script()) &&
6855 (found_func.parent_function() == innermost_function().raw())) { 6855 (found_func.parent_function() == innermost_function().raw())) {
6856 ASSERT(found_func.IsAsyncGenClosure()); 6856 ASSERT(found_func.IsAsyncGenClosure());
6857 closure = found_func.raw(); 6857 closure = found_func.raw();
6858 } else { 6858 } else {
6859 // Create the closure containing the body of this async generator function. 6859 // Create the closure containing the body of this async generator function.
6860 const String& async_generator_name = 6860 const String& async_generator_name =
6861 String::Handle(Z, innermost_function().name()); 6861 String::Handle(Z, innermost_function().name());
(...skipping 750 matching lines...) Expand 10 before | Expand all | Expand 10 after
7612 // Check whether we have parsed this closure function before, in a previous 7612 // Check whether we have parsed this closure function before, in a previous
7613 // compilation. If so, reuse the function object, else create a new one 7613 // compilation. If so, reuse the function object, else create a new one
7614 // and register it in the current class. 7614 // and register it in the current class.
7615 // Note that we cannot share the same closure function between the closurized 7615 // Note that we cannot share the same closure function between the closurized
7616 // and non-closurized versions of the same parent function. 7616 // and non-closurized versions of the same parent function.
7617 Function& function = Function::ZoneHandle(Z); 7617 Function& function = Function::ZoneHandle(Z);
7618 bool is_new_closure = false; 7618 bool is_new_closure = false;
7619 // TODO(hausner): There could be two different closures at the given 7619 // TODO(hausner): There could be two different closures at the given
7620 // function_pos, one enclosed in a closurized function and one enclosed in the 7620 // function_pos, one enclosed in a closurized function and one enclosed in the
7621 // non-closurized version of this same function. 7621 // non-closurized version of this same function.
7622 function = current_class().LookupClosureFunction(function_pos); 7622 function = I->LookupClosureFunction(script_, function_pos);
7623 if (function.IsNull() || (function.token_pos() != function_pos) || 7623 if (function.IsNull() || (function.token_pos() != function_pos) ||
7624 (function.parent_function() != innermost_function().raw())) { 7624 (function.parent_function() != innermost_function().raw())) {
7625 // The function will be registered in the lookup table by the 7625 // The function will be registered in the lookup table by the
7626 // EffectGraphVisitor::VisitClosureNode when the newly allocated closure 7626 // EffectGraphVisitor::VisitClosureNode when the newly allocated closure
7627 // function has been properly setup. 7627 // function has been properly setup.
7628 is_new_closure = true; 7628 is_new_closure = true;
7629 function = Function::NewClosureFunction(*function_name, 7629 function = Function::NewClosureFunction(*function_name,
7630 innermost_function(), 7630 innermost_function(),
7631 function_pos); 7631 function_pos);
7632 function.set_result_type(result_type); 7632 function.set_result_type(result_type);
(...skipping 5481 matching lines...) Expand 10 before | Expand all | Expand 10 after
13114 symbol_instance ^= result.raw(); 13114 symbol_instance ^= result.raw();
13115 CacheConstantValue(symbol_pos, symbol_instance); 13115 CacheConstantValue(symbol_pos, symbol_instance);
13116 return new(Z) LiteralNode(symbol_pos, symbol_instance); 13116 return new(Z) LiteralNode(symbol_pos, symbol_instance);
13117 } 13117 }
13118 13118
13119 13119
13120 RawFunction* Parser::BuildConstructorClosureFunction(const Function& ctr, 13120 RawFunction* Parser::BuildConstructorClosureFunction(const Function& ctr,
13121 intptr_t token_pos) { 13121 intptr_t token_pos) {
13122 ASSERT(ctr.kind() == RawFunction::kConstructor); 13122 ASSERT(ctr.kind() == RawFunction::kConstructor);
13123 Function& closure = Function::Handle(Z); 13123 Function& closure = Function::Handle(Z);
13124 closure = current_class().LookupClosureFunction(token_pos); 13124 closure = I->LookupClosureFunction(script_, token_pos);
13125 if (!closure.IsNull()) { 13125 if (!closure.IsNull()) {
13126 ASSERT(closure.IsConstructorClosureFunction()); 13126 ASSERT(closure.IsConstructorClosureFunction());
13127 return closure.raw(); 13127 return closure.raw();
13128 } 13128 }
13129 13129
13130 String& closure_name = String::Handle(Z, ctr.name()); 13130 String& closure_name = String::Handle(Z, ctr.name());
13131 closure_name = Symbols::FromConcat(Symbols::ConstructorClosurePrefix(), 13131 closure_name = Symbols::FromConcat(Symbols::ConstructorClosurePrefix(),
13132 closure_name); 13132 closure_name);
13133 13133
13134 ParamList params; 13134 ParamList params;
(...skipping 1197 matching lines...) Expand 10 before | Expand all | Expand 10 after
14332 void Parser::SkipQualIdent() { 14332 void Parser::SkipQualIdent() {
14333 ASSERT(IsIdentifier()); 14333 ASSERT(IsIdentifier());
14334 ConsumeToken(); 14334 ConsumeToken();
14335 if (CurrentToken() == Token::kPERIOD) { 14335 if (CurrentToken() == Token::kPERIOD) {
14336 ConsumeToken(); // Consume the kPERIOD token. 14336 ConsumeToken(); // Consume the kPERIOD token.
14337 ExpectIdentifier("identifier expected after '.'"); 14337 ExpectIdentifier("identifier expected after '.'");
14338 } 14338 }
14339 } 14339 }
14340 14340
14341 } // namespace dart 14341 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698