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

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

Issue 678763004: Make CTX allocatable by the register allocator. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 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 | Annotate | Revision Log
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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 Symbols::ExprTemp(), 120 Symbols::ExprTemp(),
121 Type::ZoneHandle(Type::DynamicType())); 121 Type::ZoneHandle(Type::DynamicType()));
122 ASSERT(temp != NULL); 122 ASSERT(temp != NULL);
123 set_expression_temp_var(temp); 123 set_expression_temp_var(temp);
124 } 124 }
125 ASSERT(has_expression_temp_var()); 125 ASSERT(has_expression_temp_var());
126 return expression_temp_var(); 126 return expression_temp_var();
127 } 127 }
128 128
129 129
130 LocalVariable* ParsedFunction::EnsureSavedCurrentContext() {
131 if (!has_saved_current_context_var()) {
132 LocalVariable* temp = new(I) LocalVariable(
133 function().token_pos(),
134 Symbols::SavedCurrentContextVar(),
135 Type::ZoneHandle(I, Type::DynamicType()));
136 ASSERT(temp != NULL);
137 set_saved_current_context_var(temp);
138 }
139 return saved_current_context_var();
140 }
141
142
130 void ParsedFunction::EnsureFinallyReturnTemp() { 143 void ParsedFunction::EnsureFinallyReturnTemp() {
131 if (!has_finally_return_temp_var()) { 144 if (!has_finally_return_temp_var()) {
132 LocalVariable* temp = new(I) LocalVariable( 145 LocalVariable* temp = new(I) LocalVariable(
133 function_.token_pos(), 146 function_.token_pos(),
134 String::ZoneHandle(I, Symbols::New(":finally_ret_val")), 147 String::ZoneHandle(I, Symbols::New(":finally_ret_val")),
135 Type::ZoneHandle(I, Type::DynamicType())); 148 Type::ZoneHandle(I, Type::DynamicType()));
136 ASSERT(temp != NULL); 149 ASSERT(temp != NULL);
137 temp->set_is_final(); 150 temp->set_is_final();
138 set_finally_return_temp_var(temp); 151 set_finally_return_temp_var(temp);
139 } 152 }
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 parsed_function->function().origin()).library())), 351 parsed_function->function().origin()).library())),
339 try_blocks_list_(NULL), 352 try_blocks_list_(NULL),
340 last_used_try_index_(0), 353 last_used_try_index_(0),
341 unregister_pending_function_(false), 354 unregister_pending_function_(false),
342 async_temp_scope_(NULL) { 355 async_temp_scope_(NULL) {
343 ASSERT(tokens_iterator_.IsValid()); 356 ASSERT(tokens_iterator_.IsValid());
344 ASSERT(!current_function().IsNull()); 357 ASSERT(!current_function().IsNull());
345 if (FLAG_enable_type_checks) { 358 if (FLAG_enable_type_checks) {
346 EnsureExpressionTemp(); 359 EnsureExpressionTemp();
347 } 360 }
361 EnsureSavedCurrentContext();
348 } 362 }
349 363
350 364
351 Parser::~Parser() { 365 Parser::~Parser() {
352 if (unregister_pending_function_) { 366 if (unregister_pending_function_) {
353 const GrowableObjectArray& pending_functions = 367 const GrowableObjectArray& pending_functions =
354 GrowableObjectArray::Handle(I->object_store()->pending_functions()); 368 GrowableObjectArray::Handle(I->object_store()->pending_functions());
355 ASSERT(pending_functions.Length() > 0); 369 ASSERT(pending_functions.Length() > 0);
356 ASSERT(pending_functions.At(pending_functions.Length()-1) == 370 ASSERT(pending_functions.At(pending_functions.Length()-1) ==
357 current_function().raw()); 371 current_function().raw());
(...skipping 1022 matching lines...) Expand 10 before | Expand all | Expand 10 after
1380 args->Add(new(I) LoadLocalNode(token_pos, scope->VariableAt(i))); 1394 args->Add(new(I) LoadLocalNode(token_pos, scope->VariableAt(i)));
1381 intptr_t index = i - desc.PositionalCount(); 1395 intptr_t index = i - desc.PositionalCount();
1382 names.SetAt(index, String::Handle(I, desc.NameAt(index))); 1396 names.SetAt(index, String::Handle(I, desc.NameAt(index)));
1383 } 1397 }
1384 args->set_names(names); 1398 args->set_names(names);
1385 1399
1386 const Class& owner = Class::Handle(I, func.Owner()); 1400 const Class& owner = Class::Handle(I, func.Owner());
1387 ASSERT(!owner.IsNull()); 1401 ASSERT(!owner.IsNull());
1388 AstNode* result = NULL; 1402 AstNode* result = NULL;
1389 if (owner.IsSignatureClass() && name.Equals(Symbols::Call())) { 1403 if (owner.IsSignatureClass() && name.Equals(Symbols::Call())) {
1390 EnsureSavedCurrentContext();
1391 result = new ClosureCallNode(token_pos, getter_call, args); 1404 result = new ClosureCallNode(token_pos, getter_call, args);
1392 } else { 1405 } else {
1393 result = BuildClosureCall(token_pos, getter_call, args); 1406 result = BuildClosureCall(token_pos, getter_call, args);
1394 } 1407 }
1395 1408
1396 ReturnNode* return_node = new ReturnNode(token_pos, result); 1409 ReturnNode* return_node = new ReturnNode(token_pos, result);
1397 current_block_->statements->Add(return_node); 1410 current_block_->statements->Add(return_node);
1398 return CloseBlock(); 1411 return CloseBlock();
1399 } 1412 }
1400 1413
(...skipping 7141 matching lines...) Expand 10 before | Expand all | Expand 10 after
8542 } 8555 }
8543 8556
8544 8557
8545 void Parser::EnsureExpressionTemp() { 8558 void Parser::EnsureExpressionTemp() {
8546 // Temporary used later by the flow_graph_builder. 8559 // Temporary used later by the flow_graph_builder.
8547 parsed_function()->EnsureExpressionTemp(); 8560 parsed_function()->EnsureExpressionTemp();
8548 } 8561 }
8549 8562
8550 8563
8551 void Parser::EnsureSavedCurrentContext() { 8564 void Parser::EnsureSavedCurrentContext() {
8552 // Used later by the flow_graph_builder to save current context. 8565 parsed_function()->EnsureSavedCurrentContext();
8553 if (!parsed_function()->has_saved_current_context_var()) {
8554 LocalVariable* temp = new(I) LocalVariable(
8555 current_function().token_pos(),
8556 Symbols::SavedCurrentContextVar(),
8557 Type::ZoneHandle(I, Type::DynamicType()));
8558 ASSERT(temp != NULL);
8559 parsed_function()->set_saved_current_context_var(temp);
8560 }
8561 } 8566 }
8562 8567
8563 8568
8564 LocalVariable* Parser::CreateTempConstVariable(intptr_t token_pos, 8569 LocalVariable* Parser::CreateTempConstVariable(intptr_t token_pos,
8565 const char* s) { 8570 const char* s) {
8566 char name[64]; 8571 char name[64];
8567 OS::SNPrint(name, 64, ":%s%" Pd, s, token_pos); 8572 OS::SNPrint(name, 64, ":%s%" Pd, s, token_pos);
8568 LocalVariable* temp = new(I) LocalVariable( 8573 LocalVariable* temp = new(I) LocalVariable(
8569 token_pos, 8574 token_pos,
8570 String::ZoneHandle(I, Symbols::New(name)), 8575 String::ZoneHandle(I, Symbols::New(name)),
(...skipping 3228 matching lines...) Expand 10 before | Expand all | Expand 10 after
11799 void Parser::SkipQualIdent() { 11804 void Parser::SkipQualIdent() {
11800 ASSERT(IsIdentifier()); 11805 ASSERT(IsIdentifier());
11801 ConsumeToken(); 11806 ConsumeToken();
11802 if (CurrentToken() == Token::kPERIOD) { 11807 if (CurrentToken() == Token::kPERIOD) {
11803 ConsumeToken(); // Consume the kPERIOD token. 11808 ConsumeToken(); // Consume the kPERIOD token.
11804 ExpectIdentifier("identifier expected after '.'"); 11809 ExpectIdentifier("identifier expected after '.'");
11805 } 11810 }
11806 } 11811 }
11807 11812
11808 } // namespace dart 11813 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698