| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 <map> | 5 #include <map> |
| 6 #include <set> | 6 #include <set> |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "vm/kernel_to_il.h" | 9 #include "vm/kernel_to_il.h" |
| 10 | 10 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 } | 56 } |
| 57 } | 57 } |
| 58 | 58 |
| 59 | 59 |
| 60 void ScopeBuilder::EnterScope(TreeNode* node) { | 60 void ScopeBuilder::EnterScope(TreeNode* node) { |
| 61 scope_ = new (Z) LocalScope(scope_, depth_.function_, depth_.loop_); | 61 scope_ = new (Z) LocalScope(scope_, depth_.function_, depth_.loop_); |
| 62 result_->scopes.Insert(node, scope_); | 62 result_->scopes.Insert(node, scope_); |
| 63 } | 63 } |
| 64 | 64 |
| 65 | 65 |
| 66 void ScopeBuilder::ExitScope() { scope_ = scope_->parent(); } | 66 void ScopeBuilder::ExitScope() { |
| 67 scope_ = scope_->parent(); |
| 68 } |
| 67 | 69 |
| 68 | 70 |
| 69 LocalVariable* ScopeBuilder::MakeVariable(const dart::String& name, | 71 LocalVariable* ScopeBuilder::MakeVariable(const dart::String& name, |
| 70 const AbstractType& type) { | 72 const AbstractType& type) { |
| 71 return new (Z) LocalVariable(TokenPosition::kNoSource, | 73 return new (Z) LocalVariable(TokenPosition::kNoSource, |
| 72 TokenPosition::kNoSource, | 74 TokenPosition::kNoSource, name, type); |
| 73 name, | |
| 74 type); | |
| 75 } | 75 } |
| 76 | 76 |
| 77 | 77 |
| 78 void ScopeBuilder::AddParameters(FunctionNode* function, intptr_t pos) { | 78 void ScopeBuilder::AddParameters(FunctionNode* function, intptr_t pos) { |
| 79 List<VariableDeclaration>& positional = function->positional_parameters(); | 79 List<VariableDeclaration>& positional = function->positional_parameters(); |
| 80 for (intptr_t i = 0; i < positional.length(); ++i) { | 80 for (intptr_t i = 0; i < positional.length(); ++i) { |
| 81 AddParameter(positional[i], pos++); | 81 AddParameter(positional[i], pos++); |
| 82 } | 82 } |
| 83 List<VariableDeclaration>& named = function->named_parameters(); | 83 List<VariableDeclaration>& named = function->named_parameters(); |
| 84 for (intptr_t i = 0; i < named.length(); ++i) { | 84 for (intptr_t i = 0; i < named.length(); ++i) { |
| 85 AddParameter(named[i], pos++); | 85 AddParameter(named[i], pos++); |
| 86 } | 86 } |
| 87 } | 87 } |
| 88 | 88 |
| 89 | 89 |
| 90 void ScopeBuilder::AddParameter(VariableDeclaration* declaration, | 90 void ScopeBuilder::AddParameter(VariableDeclaration* declaration, |
| 91 intptr_t pos) { | 91 intptr_t pos) { |
| 92 LocalVariable* variable = | 92 LocalVariable* variable = MakeVariable(H.DartSymbol(declaration->name()), |
| 93 MakeVariable(H.DartSymbol(declaration->name()), | 93 T.TranslateVariableType(declaration)); |
| 94 T.TranslateVariableType(declaration)); | |
| 95 if (declaration->IsFinal()) { | 94 if (declaration->IsFinal()) { |
| 96 variable->set_is_final(); | 95 variable->set_is_final(); |
| 97 } | 96 } |
| 98 scope_->InsertParameterAt(pos, variable); | 97 scope_->InsertParameterAt(pos, variable); |
| 99 result_->locals.Insert(declaration, variable); | 98 result_->locals.Insert(declaration, variable); |
| 100 | 99 |
| 101 // The default value may contain 'let' bindings for which the constant | 100 // The default value may contain 'let' bindings for which the constant |
| 102 // evaluator needs scope bindings. | 101 // evaluator needs scope bindings. |
| 103 Expression* defaultValue = declaration->initializer(); | 102 Expression* defaultValue = declaration->initializer(); |
| 104 if (defaultValue != NULL) { | 103 if (defaultValue != NULL) { |
| 105 defaultValue->AcceptExpressionVisitor(this); | 104 defaultValue->AcceptExpressionVisitor(this); |
| 106 } | 105 } |
| 107 } | 106 } |
| 108 | 107 |
| 109 | 108 |
| 110 void ScopeBuilder::AddExceptionVariable( | 109 void ScopeBuilder::AddExceptionVariable( |
| 111 GrowableArray<LocalVariable*>* variables, const char* prefix, | 110 GrowableArray<LocalVariable*>* variables, |
| 111 const char* prefix, |
| 112 intptr_t nesting_depth) { | 112 intptr_t nesting_depth) { |
| 113 LocalVariable* v = NULL; | 113 LocalVariable* v = NULL; |
| 114 | 114 |
| 115 // If we are inside a function with yield points then Kernel transformer | 115 // If we are inside a function with yield points then Kernel transformer |
| 116 // could have lifted some of the auxiliary exception variables into the | 116 // could have lifted some of the auxiliary exception variables into the |
| 117 // context to preserve them across yield points because they might | 117 // context to preserve them across yield points because they might |
| 118 // be needed for rethrow. | 118 // be needed for rethrow. |
| 119 // Check if it did and capture such variables instead of introducing | 119 // Check if it did and capture such variables instead of introducing |
| 120 // new local ones. | 120 // new local ones. |
| 121 // Note: function that wrap kSyncYielding function does not contain | 121 // Note: function that wrap kSyncYielding function does not contain |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 ParsedFunction* parsed_function = parsed_function_; | 261 ParsedFunction* parsed_function = parsed_function_; |
| 262 const dart::Function& function = parsed_function->function(); | 262 const dart::Function& function = parsed_function->function(); |
| 263 | 263 |
| 264 // Setup a [ActiveClassScope] and a [ActiveMemberScope] which will be used | 264 // Setup a [ActiveClassScope] and a [ActiveMemberScope] which will be used |
| 265 // e.g. for type translation. | 265 // e.g. for type translation. |
| 266 const dart::Class& klass = | 266 const dart::Class& klass = |
| 267 dart::Class::Handle(zone_, parsed_function_->function().Owner()); | 267 dart::Class::Handle(zone_, parsed_function_->function().Owner()); |
| 268 Function& outermost_function = Function::Handle(Z); | 268 Function& outermost_function = Function::Handle(Z); |
| 269 TreeNode* outermost_node = NULL; | 269 TreeNode* outermost_node = NULL; |
| 270 Class* kernel_klass = NULL; | 270 Class* kernel_klass = NULL; |
| 271 DiscoverEnclosingElements( | 271 DiscoverEnclosingElements(Z, function, &outermost_function, &outermost_node, |
| 272 Z, function, &outermost_function, &outermost_node, &kernel_klass); | 272 &kernel_klass); |
| 273 // Use [klass]/[kernel_klass] as active class. Type parameters will get | 273 // Use [klass]/[kernel_klass] as active class. Type parameters will get |
| 274 // resolved via [kernel_klass] unless we are nested inside a static factory | 274 // resolved via [kernel_klass] unless we are nested inside a static factory |
| 275 // in which case we will use [member]. | 275 // in which case we will use [member]. |
| 276 ActiveClassScope active_class_scope(&active_class_, kernel_klass, &klass); | 276 ActiveClassScope active_class_scope(&active_class_, kernel_klass, &klass); |
| 277 Member* member = ((outermost_node != NULL) && outermost_node->IsMember()) | 277 Member* member = ((outermost_node != NULL) && outermost_node->IsMember()) |
| 278 ? Member::Cast(outermost_node) | 278 ? Member::Cast(outermost_node) |
| 279 : NULL; | 279 : NULL; |
| 280 ActiveMemberScope active_member(&active_class_, member); | 280 ActiveMemberScope active_member(&active_class_, member); |
| 281 | 281 |
| 282 | 282 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 306 node = Procedure::Cast(node_)->function(); | 306 node = Procedure::Cast(node_)->function(); |
| 307 } else if (node_->IsConstructor()) { | 307 } else if (node_->IsConstructor()) { |
| 308 node = Constructor::Cast(node_)->function(); | 308 node = Constructor::Cast(node_)->function(); |
| 309 } else { | 309 } else { |
| 310 node = FunctionNode::Cast(node_); | 310 node = FunctionNode::Cast(node_); |
| 311 } | 311 } |
| 312 current_function_node_ = node; | 312 current_function_node_ = node; |
| 313 | 313 |
| 314 intptr_t pos = 0; | 314 intptr_t pos = 0; |
| 315 if (function.IsClosureFunction()) { | 315 if (function.IsClosureFunction()) { |
| 316 LocalVariable* variable = | 316 LocalVariable* variable = MakeVariable(Symbols::ClosureParameter(), |
| 317 MakeVariable(Symbols::ClosureParameter(), | 317 AbstractType::dynamic_type()); |
| 318 AbstractType::dynamic_type()); | |
| 319 variable->set_is_forced_stack(); | 318 variable->set_is_forced_stack(); |
| 320 scope_->InsertParameterAt(pos++, variable); | 319 scope_->InsertParameterAt(pos++, variable); |
| 321 } else if (!function.is_static()) { | 320 } else if (!function.is_static()) { |
| 322 // We use [is_static] instead of [IsStaticFunction] because the latter | 321 // We use [is_static] instead of [IsStaticFunction] because the latter |
| 323 // returns `false` for constructors. | 322 // returns `false` for constructors. |
| 324 dart::Class& klass = dart::Class::Handle(Z, function.Owner()); | 323 dart::Class& klass = dart::Class::Handle(Z, function.Owner()); |
| 325 Type& klass_type = H.GetCanonicalType(klass); | 324 Type& klass_type = H.GetCanonicalType(klass); |
| 326 LocalVariable* variable = MakeVariable(Symbols::This(), klass_type); | 325 LocalVariable* variable = MakeVariable(Symbols::This(), klass_type); |
| 327 scope_->InsertParameterAt(pos++, variable); | 326 scope_->InsertParameterAt(pos++, variable); |
| 328 result_->this_variable = variable; | 327 result_->this_variable = variable; |
| 329 | 328 |
| 330 // We visit instance field initializers because they might contain | 329 // We visit instance field initializers because they might contain |
| 331 // [Let] expressions and we need to have a mapping. | 330 // [Let] expressions and we need to have a mapping. |
| 332 if (node_->IsConstructor()) { | 331 if (node_->IsConstructor()) { |
| 333 Class* klass = Class::Cast(Constructor::Cast(node_)->parent()); | 332 Class* klass = Class::Cast(Constructor::Cast(node_)->parent()); |
| 334 | 333 |
| 335 for (intptr_t i = 0; i < klass->fields().length(); i++) { | 334 for (intptr_t i = 0; i < klass->fields().length(); i++) { |
| 336 Field* field = klass->fields()[i]; | 335 Field* field = klass->fields()[i]; |
| 337 if (!field->IsStatic() && (field->initializer() != NULL)) { | 336 if (!field->IsStatic() && (field->initializer() != NULL)) { |
| 338 EnterScope(field); | 337 EnterScope(field); |
| 339 field->initializer()->AcceptExpressionVisitor(this); | 338 field->initializer()->AcceptExpressionVisitor(this); |
| 340 ExitScope(); | 339 ExitScope(); |
| 341 } | 340 } |
| 342 } | 341 } |
| 343 } | 342 } |
| 344 } else if (function.IsFactory()) { | 343 } else if (function.IsFactory()) { |
| 345 LocalVariable* variable = MakeVariable( | 344 LocalVariable* variable = MakeVariable( |
| 346 Symbols::TypeArgumentsParameter(), | 345 Symbols::TypeArgumentsParameter(), AbstractType::dynamic_type()); |
| 347 AbstractType::dynamic_type()); | |
| 348 scope_->InsertParameterAt(pos++, variable); | 346 scope_->InsertParameterAt(pos++, variable); |
| 349 result_->type_arguments_variable = variable; | 347 result_->type_arguments_variable = variable; |
| 350 } | 348 } |
| 351 AddParameters(node, pos); | 349 AddParameters(node, pos); |
| 352 | 350 |
| 353 // We generate a syntethic body for implicit closure functions - which | 351 // We generate a syntethic body for implicit closure functions - which |
| 354 // will forward the call to the real function. | 352 // will forward the call to the real function. |
| 355 // -> see BuildGraphOfImplicitClosureFunction | 353 // -> see BuildGraphOfImplicitClosureFunction |
| 356 if (!function.IsImplicitClosureFunction()) { | 354 if (!function.IsImplicitClosureFunction()) { |
| 357 node_->AcceptVisitor(this); | 355 node_->AcceptVisitor(this); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 370 bool is_method = !function.IsStaticFunction(); | 368 bool is_method = !function.IsStaticFunction(); |
| 371 intptr_t pos = 0; | 369 intptr_t pos = 0; |
| 372 if (is_method) { | 370 if (is_method) { |
| 373 dart::Class& klass = dart::Class::Handle(Z, function.Owner()); | 371 dart::Class& klass = dart::Class::Handle(Z, function.Owner()); |
| 374 Type& klass_type = H.GetCanonicalType(klass); | 372 Type& klass_type = H.GetCanonicalType(klass); |
| 375 LocalVariable* variable = MakeVariable(Symbols::This(), klass_type); | 373 LocalVariable* variable = MakeVariable(Symbols::This(), klass_type); |
| 376 scope_->InsertParameterAt(pos++, variable); | 374 scope_->InsertParameterAt(pos++, variable); |
| 377 result_->this_variable = variable; | 375 result_->this_variable = variable; |
| 378 } | 376 } |
| 379 if (is_setter) { | 377 if (is_setter) { |
| 380 result_->setter_value = MakeVariable( | 378 result_->setter_value = |
| 381 Symbols::Value(), AbstractType::dynamic_type()); | 379 MakeVariable(Symbols::Value(), AbstractType::dynamic_type()); |
| 382 scope_->InsertParameterAt(pos++, result_->setter_value); | 380 scope_->InsertParameterAt(pos++, result_->setter_value); |
| 383 } | 381 } |
| 384 break; | 382 break; |
| 385 } | 383 } |
| 386 case RawFunction::kMethodExtractor: { | 384 case RawFunction::kMethodExtractor: { |
| 387 // Add a receiver parameter. Though it is captured, we emit code to | 385 // Add a receiver parameter. Though it is captured, we emit code to |
| 388 // explicitly copy it to a fixed offset in a freshly-allocated context | 386 // explicitly copy it to a fixed offset in a freshly-allocated context |
| 389 // instead of using the generic code for regular functions. | 387 // instead of using the generic code for regular functions. |
| 390 // Therefore, it isn't necessary to mark it as captured here. | 388 // Therefore, it isn't necessary to mark it as captured here. |
| 391 dart::Class& klass = dart::Class::Handle(Z, function.Owner()); | 389 dart::Class& klass = dart::Class::Handle(Z, function.Owner()); |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 568 VisitVariableDeclaration(node->variable()); | 566 VisitVariableDeclaration(node->variable()); |
| 569 node->body()->AcceptStatementVisitor(this); | 567 node->body()->AcceptStatementVisitor(this); |
| 570 ExitScope(); | 568 ExitScope(); |
| 571 --depth_.loop_; | 569 --depth_.loop_; |
| 572 --depth_.for_in_; | 570 --depth_.for_in_; |
| 573 } | 571 } |
| 574 | 572 |
| 575 | 573 |
| 576 void ScopeBuilder::AddSwitchVariable() { | 574 void ScopeBuilder::AddSwitchVariable() { |
| 577 if ((depth_.function_ == 0) && (result_->switch_variable == NULL)) { | 575 if ((depth_.function_ == 0) && (result_->switch_variable == NULL)) { |
| 578 LocalVariable* variable = MakeVariable( | 576 LocalVariable* variable = |
| 579 Symbols::SwitchExpr(), | 577 MakeVariable(Symbols::SwitchExpr(), AbstractType::dynamic_type()); |
| 580 AbstractType::dynamic_type()); | |
| 581 variable->set_is_forced_stack(); | 578 variable->set_is_forced_stack(); |
| 582 current_function_scope_->AddVariable(variable); | 579 current_function_scope_->AddVariable(variable); |
| 583 result_->switch_variable = variable; | 580 result_->switch_variable = variable; |
| 584 } | 581 } |
| 585 } | 582 } |
| 586 | 583 |
| 587 | 584 |
| 588 void ScopeBuilder::VisitSwitchStatement(SwitchStatement* node) { | 585 void ScopeBuilder::VisitSwitchStatement(SwitchStatement* node) { |
| 589 AddSwitchVariable(); | 586 AddSwitchVariable(); |
| 590 node->VisitChildren(this); | 587 node->VisitChildren(this); |
| 591 } | 588 } |
| 592 | 589 |
| 593 | 590 |
| 594 void ScopeBuilder::VisitReturnStatement(ReturnStatement* node) { | 591 void ScopeBuilder::VisitReturnStatement(ReturnStatement* node) { |
| 595 if ((depth_.function_ == 0) && (depth_.finally_ > 0) && | 592 if ((depth_.function_ == 0) && (depth_.finally_ > 0) && |
| 596 (result_->finally_return_variable == NULL)) { | 593 (result_->finally_return_variable == NULL)) { |
| 597 const dart::String& name = H.DartSymbol(":try_finally_return_value"); | 594 const dart::String& name = H.DartSymbol(":try_finally_return_value"); |
| 598 LocalVariable* variable = MakeVariable( | 595 LocalVariable* variable = MakeVariable(name, AbstractType::dynamic_type()); |
| 599 name, | |
| 600 AbstractType::dynamic_type()); | |
| 601 current_function_scope_->AddVariable(variable); | 596 current_function_scope_->AddVariable(variable); |
| 602 result_->finally_return_variable = variable; | 597 result_->finally_return_variable = variable; |
| 603 } | 598 } |
| 604 node->VisitChildren(this); | 599 node->VisitChildren(this); |
| 605 } | 600 } |
| 606 | 601 |
| 607 | 602 |
| 608 void ScopeBuilder::VisitTryCatch(TryCatch* node) { | 603 void ScopeBuilder::VisitTryCatch(TryCatch* node) { |
| 609 ++depth_.try_; | 604 ++depth_.try_; |
| 610 AddTryVariables(); | 605 AddTryVariables(); |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 880 | 875 |
| 881 private: | 876 private: |
| 882 FlowGraphBuilder* builder_; | 877 FlowGraphBuilder* builder_; |
| 883 TryCatchBlock* outer_; | 878 TryCatchBlock* outer_; |
| 884 intptr_t try_index_; | 879 intptr_t try_index_; |
| 885 }; | 880 }; |
| 886 | 881 |
| 887 | 882 |
| 888 class CatchBlock { | 883 class CatchBlock { |
| 889 public: | 884 public: |
| 890 CatchBlock(FlowGraphBuilder* builder, LocalVariable* exception_var, | 885 CatchBlock(FlowGraphBuilder* builder, |
| 891 LocalVariable* stack_trace_var, intptr_t catch_try_index) | 886 LocalVariable* exception_var, |
| 887 LocalVariable* stack_trace_var, |
| 888 intptr_t catch_try_index) |
| 892 : builder_(builder), | 889 : builder_(builder), |
| 893 outer_(builder->catch_block_), | 890 outer_(builder->catch_block_), |
| 894 exception_var_(exception_var), | 891 exception_var_(exception_var), |
| 895 stack_trace_var_(stack_trace_var), | 892 stack_trace_var_(stack_trace_var), |
| 896 catch_try_index_(catch_try_index) { | 893 catch_try_index_(catch_try_index) { |
| 897 builder_->catch_block_ = this; | 894 builder_->catch_block_ = this; |
| 898 } | 895 } |
| 899 ~CatchBlock() { builder_->catch_block_ = outer_; } | 896 ~CatchBlock() { builder_->catch_block_ = outer_; } |
| 900 | 897 |
| 901 LocalVariable* exception_var() { return exception_var_; } | 898 LocalVariable* exception_var() { return exception_var_; } |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1025 // The VM uses `get:fieldname` and `set:fieldname`. | 1022 // The VM uses `get:fieldname` and `set:fieldname`. |
| 1026 // | 1023 // |
| 1027 // => In order to be consistent, we remove the `=` always and adopt the VM | 1024 // => In order to be consistent, we remove the `=` always and adopt the VM |
| 1028 // conventions. | 1025 // conventions. |
| 1029 String* content = kernel_name->string(); | 1026 String* content = kernel_name->string(); |
| 1030 ASSERT(content->size() > 0); | 1027 ASSERT(content->size() > 0); |
| 1031 intptr_t skip = 0; | 1028 intptr_t skip = 0; |
| 1032 if (content->buffer()[content->size() - 1] == '=') { | 1029 if (content->buffer()[content->size() - 1] == '=') { |
| 1033 skip = 1; | 1030 skip = 1; |
| 1034 } | 1031 } |
| 1035 dart::String& name = dart::String::ZoneHandle(Z, dart::String::FromUTF8( | 1032 dart::String& name = dart::String::ZoneHandle( |
| 1036 content->buffer(), content->size() - skip, allocation_space_)); | 1033 Z, dart::String::FromUTF8(content->buffer(), content->size() - skip, |
| 1034 allocation_space_)); |
| 1037 ManglePrivateName(kernel_name->library(), &name, false); | 1035 ManglePrivateName(kernel_name->library(), &name, false); |
| 1038 name = dart::Field::SetterSymbol(name); | 1036 name = dart::Field::SetterSymbol(name); |
| 1039 return name; | 1037 return name; |
| 1040 } | 1038 } |
| 1041 | 1039 |
| 1042 | 1040 |
| 1043 const dart::String& TranslationHelper::DartGetterName(Name* kernel_name) { | 1041 const dart::String& TranslationHelper::DartGetterName(Name* kernel_name) { |
| 1044 dart::String& name = DartString(kernel_name->string()); | 1042 dart::String& name = DartString(kernel_name->string()); |
| 1045 ManglePrivateName(kernel_name->library(), &name, false); | 1043 ManglePrivateName(kernel_name->library(), &name, false); |
| 1046 name = dart::Field::GetterSymbol(name); | 1044 name = dart::Field::GetterSymbol(name); |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1165 dart::RawFunction* TranslationHelper::LookupConstructorByKernelConstructor( | 1163 dart::RawFunction* TranslationHelper::LookupConstructorByKernelConstructor( |
| 1166 Constructor* constructor) { | 1164 Constructor* constructor) { |
| 1167 Class* kernel_klass = Class::Cast(constructor->parent()); | 1165 Class* kernel_klass = Class::Cast(constructor->parent()); |
| 1168 dart::Class& klass = | 1166 dart::Class& klass = |
| 1169 dart::Class::Handle(Z, LookupClassByKernelClass(kernel_klass)); | 1167 dart::Class::Handle(Z, LookupClassByKernelClass(kernel_klass)); |
| 1170 return LookupConstructorByKernelConstructor(klass, constructor); | 1168 return LookupConstructorByKernelConstructor(klass, constructor); |
| 1171 } | 1169 } |
| 1172 | 1170 |
| 1173 | 1171 |
| 1174 dart::RawFunction* TranslationHelper::LookupConstructorByKernelConstructor( | 1172 dart::RawFunction* TranslationHelper::LookupConstructorByKernelConstructor( |
| 1175 const dart::Class& owner, Constructor* constructor) { | 1173 const dart::Class& owner, |
| 1174 Constructor* constructor) { |
| 1176 dart::RawFunction* function = | 1175 dart::RawFunction* function = |
| 1177 owner.LookupConstructorAllowPrivate(DartConstructorName(constructor)); | 1176 owner.LookupConstructorAllowPrivate(DartConstructorName(constructor)); |
| 1178 ASSERT(function != Object::null()); | 1177 ASSERT(function != Object::null()); |
| 1179 return function; | 1178 return function; |
| 1180 } | 1179 } |
| 1181 | 1180 |
| 1182 | 1181 |
| 1183 dart::Type& TranslationHelper::GetCanonicalType(const dart::Class& klass) { | 1182 dart::Type& TranslationHelper::GetCanonicalType(const dart::Class& klass) { |
| 1184 ASSERT(!klass.IsNull()); | 1183 ASSERT(!klass.IsNull()); |
| 1185 // Note that if cls is _Closure, the returned type will be _Closure, | 1184 // Note that if cls is _Closure, the returned type will be _Closure, |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1205 | 1204 |
| 1206 va_list args; | 1205 va_list args; |
| 1207 va_start(args, format); | 1206 va_start(args, format); |
| 1208 Report::MessageV(Report::kError, null_script, TokenPosition::kNoSource, | 1207 Report::MessageV(Report::kError, null_script, TokenPosition::kNoSource, |
| 1209 Report::AtLocation, format, args); | 1208 Report::AtLocation, format, args); |
| 1210 va_end(args); | 1209 va_end(args); |
| 1211 UNREACHABLE(); | 1210 UNREACHABLE(); |
| 1212 } | 1211 } |
| 1213 | 1212 |
| 1214 | 1213 |
| 1215 void TranslationHelper::ReportError(const Error& prev_error, const char* format, | 1214 void TranslationHelper::ReportError(const Error& prev_error, |
| 1215 const char* format, |
| 1216 ...) { | 1216 ...) { |
| 1217 const Script& null_script = Script::Handle(Z); | 1217 const Script& null_script = Script::Handle(Z); |
| 1218 | 1218 |
| 1219 va_list args; | 1219 va_list args; |
| 1220 va_start(args, format); | 1220 va_start(args, format); |
| 1221 Report::LongJumpV(prev_error, null_script, TokenPosition::kNoSource, format, | 1221 Report::LongJumpV(prev_error, null_script, TokenPosition::kNoSource, format, |
| 1222 args); | 1222 args); |
| 1223 va_end(args); | 1223 va_end(args); |
| 1224 UNREACHABLE(); | 1224 UNREACHABLE(); |
| 1225 } | 1225 } |
| 1226 | 1226 |
| 1227 | 1227 |
| 1228 dart::String& TranslationHelper::ManglePrivateName(Library* kernel_library, | 1228 dart::String& TranslationHelper::ManglePrivateName(Library* kernel_library, |
| 1229 dart::String* name_to_modify, | 1229 dart::String* name_to_modify, |
| 1230 bool symbolize) { | 1230 bool symbolize) { |
| 1231 if (name_to_modify->Length() >= 1 && name_to_modify->CharAt(0) == '_') { | 1231 if (name_to_modify->Length() >= 1 && name_to_modify->CharAt(0) == '_') { |
| 1232 const dart::Library& library = | 1232 const dart::Library& library = |
| 1233 dart::Library::Handle(Z, LookupLibraryByKernelLibrary(kernel_library)); | 1233 dart::Library::Handle(Z, LookupLibraryByKernelLibrary(kernel_library)); |
| 1234 *name_to_modify = library.PrivateName(*name_to_modify); | 1234 *name_to_modify = library.PrivateName(*name_to_modify); |
| 1235 } else if (symbolize) { | 1235 } else if (symbolize) { |
| 1236 *name_to_modify = Symbols::New(thread_, *name_to_modify); | 1236 *name_to_modify = Symbols::New(thread_, *name_to_modify); |
| 1237 } | 1237 } |
| 1238 return *name_to_modify; | 1238 return *name_to_modify; |
| 1239 } | 1239 } |
| 1240 | 1240 |
| 1241 | 1241 |
| 1242 const Array& TranslationHelper::ArgumentNames(List<NamedExpression>* named) { | 1242 const Array& TranslationHelper::ArgumentNames(List<NamedExpression>* named) { |
| 1243 if (named->length() == 0) return Array::ZoneHandle(Z); | 1243 if (named->length() == 0) return Array::ZoneHandle(Z); |
| 1244 | 1244 |
| 1245 const Array& names = Array::ZoneHandle(Z, | 1245 const Array& names = |
| 1246 Array::New(named->length(), allocation_space_)); | 1246 Array::ZoneHandle(Z, Array::New(named->length(), allocation_space_)); |
| 1247 for (intptr_t i = 0; i < named->length(); ++i) { | 1247 for (intptr_t i = 0; i < named->length(); ++i) { |
| 1248 names.SetAt(i, DartSymbol((*named)[i]->name())); | 1248 names.SetAt(i, DartSymbol((*named)[i]->name())); |
| 1249 } | 1249 } |
| 1250 return names; | 1250 return names; |
| 1251 } | 1251 } |
| 1252 | 1252 |
| 1253 | 1253 |
| 1254 ConstantEvaluator::ConstantEvaluator(FlowGraphBuilder* builder, | 1254 ConstantEvaluator::ConstantEvaluator(FlowGraphBuilder* builder, |
| 1255 Zone* zone, | 1255 Zone* zone, |
| 1256 TranslationHelper* h, | 1256 TranslationHelper* h, |
| 1257 DartTypeTranslator* type_translator) | 1257 DartTypeTranslator* type_translator) |
| 1258 : builder_(builder), | 1258 : builder_(builder), |
| 1259 isolate_(Isolate::Current()), | 1259 isolate_(Isolate::Current()), |
| 1260 zone_(zone), | 1260 zone_(zone), |
| 1261 translation_helper_(*h), | 1261 translation_helper_(*h), |
| 1262 type_translator_(*type_translator), | 1262 type_translator_(*type_translator), |
| 1263 script_(dart::Script::Handle( | 1263 script_(dart::Script::Handle( |
| 1264 zone, builder_->parsed_function_->function().script())), | 1264 zone, |
| 1265 builder_->parsed_function_->function().script())), |
| 1265 result_(dart::Instance::Handle(zone)) {} | 1266 result_(dart::Instance::Handle(zone)) {} |
| 1266 | 1267 |
| 1267 | 1268 |
| 1268 Instance& ConstantEvaluator::EvaluateExpression(Expression* expression) { | 1269 Instance& ConstantEvaluator::EvaluateExpression(Expression* expression) { |
| 1269 if (!GetCachedConstant(expression, &result_)) { | 1270 if (!GetCachedConstant(expression, &result_)) { |
| 1270 expression->AcceptExpressionVisitor(this); | 1271 expression->AcceptExpressionVisitor(this); |
| 1271 CacheConstantValue(expression, result_); | 1272 CacheConstantValue(expression, result_); |
| 1272 } | 1273 } |
| 1273 // We return a new `ZoneHandle` here on purpose: The intermediate language | 1274 // We return a new `ZoneHandle` here on purpose: The intermediate language |
| 1274 // instructions do not make a copy of the handle, so we do it. | 1275 // instructions do not make a copy of the handle, so we do it. |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1361 void ConstantEvaluator::VisitTypeLiteral(TypeLiteral* node) { | 1362 void ConstantEvaluator::VisitTypeLiteral(TypeLiteral* node) { |
| 1362 const AbstractType& type = T.TranslateType(node->type()); | 1363 const AbstractType& type = T.TranslateType(node->type()); |
| 1363 if (type.IsMalformed()) { | 1364 if (type.IsMalformed()) { |
| 1364 H.ReportError("Malformed type literal in constant expression."); | 1365 H.ReportError("Malformed type literal in constant expression."); |
| 1365 } | 1366 } |
| 1366 result_ = type.raw(); | 1367 result_ = type.raw(); |
| 1367 } | 1368 } |
| 1368 | 1369 |
| 1369 | 1370 |
| 1370 RawObject* ConstantEvaluator::EvaluateConstConstructorCall( | 1371 RawObject* ConstantEvaluator::EvaluateConstConstructorCall( |
| 1371 const dart::Class& type_class, const TypeArguments& type_arguments, | 1372 const dart::Class& type_class, |
| 1372 const Function& constructor, const Object& argument) { | 1373 const TypeArguments& type_arguments, |
| 1374 const Function& constructor, |
| 1375 const Object& argument) { |
| 1373 // Factories have one extra argument: the type arguments. | 1376 // Factories have one extra argument: the type arguments. |
| 1374 // Constructors have 1 extra arguments: receiver. | 1377 // Constructors have 1 extra arguments: receiver. |
| 1375 const int kNumArgs = 1; | 1378 const int kNumArgs = 1; |
| 1376 const int kNumExtraArgs = 1; | 1379 const int kNumExtraArgs = 1; |
| 1377 const int num_arguments = kNumArgs + kNumExtraArgs; | 1380 const int num_arguments = kNumArgs + kNumExtraArgs; |
| 1378 const Array& arg_values = | 1381 const Array& arg_values = |
| 1379 Array::Handle(Z, Array::New(num_arguments, Heap::kOld)); | 1382 Array::Handle(Z, Array::New(num_arguments, Heap::kOld)); |
| 1380 Instance& instance = Instance::Handle(Z); | 1383 Instance& instance = Instance::Handle(Z); |
| 1381 if (!constructor.IsFactory()) { | 1384 if (!constructor.IsFactory()) { |
| 1382 instance = Instance::New(type_class, Heap::kOld); | 1385 instance = Instance::New(type_class, Heap::kOld); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1437 | 1440 |
| 1438 const Function& function = builder_->parsed_function_->function(); | 1441 const Function& function = builder_->parsed_function_->function(); |
| 1439 if (function.kind() == RawFunction::kImplicitStaticFinalGetter) { | 1442 if (function.kind() == RawFunction::kImplicitStaticFinalGetter) { |
| 1440 // Don't cache constants in initializer expressions. They get | 1443 // Don't cache constants in initializer expressions. They get |
| 1441 // evaluated only once. | 1444 // evaluated only once. |
| 1442 return; | 1445 return; |
| 1443 } | 1446 } |
| 1444 const intptr_t kInitialConstMapSize = 16; | 1447 const intptr_t kInitialConstMapSize = 16; |
| 1445 ASSERT(!script_.InVMHeap()); | 1448 ASSERT(!script_.InVMHeap()); |
| 1446 if (script_.compile_time_constants() == Array::null()) { | 1449 if (script_.compile_time_constants() == Array::null()) { |
| 1447 const Array& array = | 1450 const Array& array = Array::Handle( |
| 1448 Array::Handle(HashTables::New<KernelConstantsMap>(kInitialConstMapSize, | 1451 HashTables::New<KernelConstantsMap>(kInitialConstMapSize, Heap::kNew)); |
| 1449 Heap::kNew)); | |
| 1450 script_.set_compile_time_constants(array); | 1452 script_.set_compile_time_constants(array); |
| 1451 } | 1453 } |
| 1452 KernelConstantsMap constants(script_.compile_time_constants()); | 1454 KernelConstantsMap constants(script_.compile_time_constants()); |
| 1453 constants.InsertNewOrGetValue(node, value); | 1455 constants.InsertNewOrGetValue(node, value); |
| 1454 script_.set_compile_time_constants(constants.Release()); | 1456 script_.set_compile_time_constants(constants.Release()); |
| 1455 } | 1457 } |
| 1456 | 1458 |
| 1457 | 1459 |
| 1458 void ConstantEvaluator::VisitSymbolLiteral(SymbolLiteral* node) { | 1460 void ConstantEvaluator::VisitSymbolLiteral(SymbolLiteral* node) { |
| 1459 const dart::String& symbol_value = H.DartSymbol(node->value()); | 1461 const dart::String& symbol_value = H.DartSymbol(node->value()); |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1725 | 1727 |
| 1726 void ConstantEvaluator::VisitNot(Not* node) { | 1728 void ConstantEvaluator::VisitNot(Not* node) { |
| 1727 EvaluateExpression(node->expression()); | 1729 EvaluateExpression(node->expression()); |
| 1728 ASSERT(result_.IsBool()); | 1730 ASSERT(result_.IsBool()); |
| 1729 result_ = | 1731 result_ = |
| 1730 Bool::Cast(result_).value() ? Bool::False().raw() : Bool::True().raw(); | 1732 Bool::Cast(result_).value() ? Bool::False().raw() : Bool::True().raw(); |
| 1731 } | 1733 } |
| 1732 | 1734 |
| 1733 | 1735 |
| 1734 const TypeArguments* ConstantEvaluator::TranslateTypeArguments( | 1736 const TypeArguments* ConstantEvaluator::TranslateTypeArguments( |
| 1735 const Function& target, dart::Class* target_klass, | 1737 const Function& target, |
| 1738 dart::Class* target_klass, |
| 1736 Arguments* kernel_arguments) { | 1739 Arguments* kernel_arguments) { |
| 1737 List<DartType>& kernel_type_arguments = kernel_arguments->types(); | 1740 List<DartType>& kernel_type_arguments = kernel_arguments->types(); |
| 1738 | 1741 |
| 1739 const TypeArguments* type_arguments = NULL; | 1742 const TypeArguments* type_arguments = NULL; |
| 1740 if (kernel_type_arguments.length() > 0) { | 1743 if (kernel_type_arguments.length() > 0) { |
| 1741 type_arguments = &T.TranslateInstantiatedTypeArguments( | 1744 type_arguments = &T.TranslateInstantiatedTypeArguments( |
| 1742 *target_klass, kernel_type_arguments.raw_array(), | 1745 *target_klass, kernel_type_arguments.raw_array(), |
| 1743 kernel_type_arguments.length()); | 1746 kernel_type_arguments.length()); |
| 1744 | 1747 |
| 1745 if (!(type_arguments->IsNull() || type_arguments->IsInstantiated())) { | 1748 if (!(type_arguments->IsNull() || type_arguments->IsInstantiated())) { |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1797 const Object& result = Object::Handle( | 1800 const Object& result = Object::Handle( |
| 1798 Z, DartEntry::InvokeFunction(function, arguments, args_descriptor)); | 1801 Z, DartEntry::InvokeFunction(function, arguments, args_descriptor)); |
| 1799 if (result.IsError()) { | 1802 if (result.IsError()) { |
| 1800 H.ReportError(Error::Cast(result), "error evaluating constant constructor"); | 1803 H.ReportError(Error::Cast(result), "error evaluating constant constructor"); |
| 1801 } | 1804 } |
| 1802 return result; | 1805 return result; |
| 1803 } | 1806 } |
| 1804 | 1807 |
| 1805 | 1808 |
| 1806 FlowGraphBuilder::FlowGraphBuilder( | 1809 FlowGraphBuilder::FlowGraphBuilder( |
| 1807 TreeNode* node, ParsedFunction* parsed_function, | 1810 TreeNode* node, |
| 1811 ParsedFunction* parsed_function, |
| 1808 const ZoneGrowableArray<const ICData*>& ic_data_array, | 1812 const ZoneGrowableArray<const ICData*>& ic_data_array, |
| 1809 InlineExitCollector* exit_collector, intptr_t osr_id, | 1813 InlineExitCollector* exit_collector, |
| 1814 intptr_t osr_id, |
| 1810 intptr_t first_block_id) | 1815 intptr_t first_block_id) |
| 1811 : zone_(Thread::Current()->zone()), | 1816 : zone_(Thread::Current()->zone()), |
| 1812 translation_helper_(Thread::Current(), zone_, | 1817 translation_helper_(Thread::Current(), |
| 1818 zone_, |
| 1813 Thread::Current()->isolate()), | 1819 Thread::Current()->isolate()), |
| 1814 node_(node), | 1820 node_(node), |
| 1815 parsed_function_(parsed_function), | 1821 parsed_function_(parsed_function), |
| 1816 osr_id_(osr_id), | 1822 osr_id_(osr_id), |
| 1817 ic_data_array_(ic_data_array), | 1823 ic_data_array_(ic_data_array), |
| 1818 exit_collector_(exit_collector), | 1824 exit_collector_(exit_collector), |
| 1819 next_block_id_(first_block_id), | 1825 next_block_id_(first_block_id), |
| 1820 next_function_id_(0), | 1826 next_function_id_(0), |
| 1821 context_depth_(0), | 1827 context_depth_(0), |
| 1822 loop_depth_(0), | 1828 loop_depth_(0), |
| 1823 try_depth_(0), | 1829 try_depth_(0), |
| 1824 catch_depth_(0), | 1830 catch_depth_(0), |
| 1825 for_in_depth_(0), | 1831 for_in_depth_(0), |
| 1826 stack_(NULL), | 1832 stack_(NULL), |
| 1827 pending_argument_count_(0), | 1833 pending_argument_count_(0), |
| 1828 graph_entry_(NULL), | 1834 graph_entry_(NULL), |
| 1829 scopes_(NULL), | 1835 scopes_(NULL), |
| 1830 breakable_block_(NULL), | 1836 breakable_block_(NULL), |
| 1831 switch_block_(NULL), | 1837 switch_block_(NULL), |
| 1832 try_finally_block_(NULL), | 1838 try_finally_block_(NULL), |
| 1833 try_catch_block_(NULL), | 1839 try_catch_block_(NULL), |
| 1834 next_used_try_index_(0), | 1840 next_used_try_index_(0), |
| 1835 catch_block_(NULL), | 1841 catch_block_(NULL), |
| 1836 type_translator_(&translation_helper_, &active_class_), | 1842 type_translator_(&translation_helper_, &active_class_), |
| 1837 constant_evaluator_(this, zone_, &translation_helper_, | 1843 constant_evaluator_(this, |
| 1844 zone_, |
| 1845 &translation_helper_, |
| 1838 &type_translator_) {} | 1846 &type_translator_) {} |
| 1839 | 1847 |
| 1840 | 1848 |
| 1841 FlowGraphBuilder::~FlowGraphBuilder() {} | 1849 FlowGraphBuilder::~FlowGraphBuilder() {} |
| 1842 | 1850 |
| 1843 | 1851 |
| 1844 Fragment FlowGraphBuilder::TranslateFinallyFinalizers( | 1852 Fragment FlowGraphBuilder::TranslateFinallyFinalizers( |
| 1845 TryFinallyBlock* outer_finally, intptr_t target_context_depth) { | 1853 TryFinallyBlock* outer_finally, |
| 1854 intptr_t target_context_depth) { |
| 1846 TryFinallyBlock* const saved_block = try_finally_block_; | 1855 TryFinallyBlock* const saved_block = try_finally_block_; |
| 1847 const intptr_t saved_depth = context_depth_; | 1856 const intptr_t saved_depth = context_depth_; |
| 1848 const intptr_t saved_try_depth = try_depth_; | 1857 const intptr_t saved_try_depth = try_depth_; |
| 1849 | 1858 |
| 1850 Fragment instructions; | 1859 Fragment instructions; |
| 1851 | 1860 |
| 1852 // While translating the body of a finalizer we need to set the try-finally | 1861 // While translating the body of a finalizer we need to set the try-finally |
| 1853 // block which is active when translating the body. | 1862 // block which is active when translating the body. |
| 1854 while (try_finally_block_ != outer_finally) { | 1863 while (try_finally_block_ != outer_finally) { |
| 1855 // Set correct try depth (in case there are nested try statements). | 1864 // Set correct try depth (in case there are nested try statements). |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2099 TokenPosition::kNoSource, negate ? Token::kNE_STRICT : Token::kEQ_STRICT, | 2108 TokenPosition::kNoSource, negate ? Token::kNE_STRICT : Token::kEQ_STRICT, |
| 2100 left_value, right_value, false); | 2109 left_value, right_value, false); |
| 2101 BranchInstr* branch = new (Z) BranchInstr(compare); | 2110 BranchInstr* branch = new (Z) BranchInstr(compare); |
| 2102 *then_entry = *branch->true_successor_address() = BuildTargetEntry(); | 2111 *then_entry = *branch->true_successor_address() = BuildTargetEntry(); |
| 2103 *otherwise_entry = *branch->false_successor_address() = BuildTargetEntry(); | 2112 *otherwise_entry = *branch->false_successor_address() = BuildTargetEntry(); |
| 2104 return Fragment(branch).closed(); | 2113 return Fragment(branch).closed(); |
| 2105 } | 2114 } |
| 2106 | 2115 |
| 2107 | 2116 |
| 2108 Fragment FlowGraphBuilder::BranchIfStrictEqual( | 2117 Fragment FlowGraphBuilder::BranchIfStrictEqual( |
| 2109 TargetEntryInstr** then_entry, TargetEntryInstr** otherwise_entry) { | 2118 TargetEntryInstr** then_entry, |
| 2119 TargetEntryInstr** otherwise_entry) { |
| 2110 Value* rhs = Pop(); | 2120 Value* rhs = Pop(); |
| 2111 Value* lhs = Pop(); | 2121 Value* lhs = Pop(); |
| 2112 StrictCompareInstr* compare = new (Z) StrictCompareInstr( | 2122 StrictCompareInstr* compare = new (Z) StrictCompareInstr( |
| 2113 TokenPosition::kNoSource, Token::kEQ_STRICT, lhs, rhs, false); | 2123 TokenPosition::kNoSource, Token::kEQ_STRICT, lhs, rhs, false); |
| 2114 BranchInstr* branch = new (Z) BranchInstr(compare); | 2124 BranchInstr* branch = new (Z) BranchInstr(compare); |
| 2115 *then_entry = *branch->true_successor_address() = BuildTargetEntry(); | 2125 *then_entry = *branch->true_successor_address() = BuildTargetEntry(); |
| 2116 *otherwise_entry = *branch->false_successor_address() = BuildTargetEntry(); | 2126 *otherwise_entry = *branch->false_successor_address() = BuildTargetEntry(); |
| 2117 return Fragment(branch).closed(); | 2127 return Fragment(branch).closed(); |
| 2118 } | 2128 } |
| 2119 | 2129 |
| 2120 | 2130 |
| 2121 Fragment FlowGraphBuilder::CatchBlockEntry(const Array& handler_types, | 2131 Fragment FlowGraphBuilder::CatchBlockEntry(const Array& handler_types, |
| 2122 intptr_t handler_index) { | 2132 intptr_t handler_index) { |
| 2123 ASSERT(CurrentException()->is_captured() == | 2133 ASSERT(CurrentException()->is_captured() == |
| 2124 CurrentStackTrace()->is_captured()); | 2134 CurrentStackTrace()->is_captured()); |
| 2125 const bool should_restore_closure_context = | 2135 const bool should_restore_closure_context = |
| 2126 CurrentException()->is_captured() || | 2136 CurrentException()->is_captured() || CurrentCatchContext()->is_captured(); |
| 2127 CurrentCatchContext()->is_captured(); | |
| 2128 CatchBlockEntryInstr* entry = new (Z) CatchBlockEntryInstr( | 2137 CatchBlockEntryInstr* entry = new (Z) CatchBlockEntryInstr( |
| 2129 AllocateBlockId(), CurrentTryIndex(), graph_entry_, handler_types, | 2138 AllocateBlockId(), CurrentTryIndex(), graph_entry_, handler_types, |
| 2130 handler_index, *CurrentException(), *CurrentStackTrace(), | 2139 handler_index, *CurrentException(), *CurrentStackTrace(), |
| 2131 /* needs_stacktrace = */ true, Thread::Current()->GetNextDeoptId(), | 2140 /* needs_stacktrace = */ true, Thread::Current()->GetNextDeoptId(), |
| 2132 should_restore_closure_context); | 2141 should_restore_closure_context); |
| 2133 graph_entry_->AddCatchEntry(entry); | 2142 graph_entry_->AddCatchEntry(entry); |
| 2134 Fragment instructions(entry); | 2143 Fragment instructions(entry); |
| 2135 | 2144 |
| 2136 // :saved_try_context_var can be captured in the context of | 2145 // :saved_try_context_var can be captured in the context of |
| 2137 // of the closure, in this case CatchBlockEntryInstr restores | 2146 // of the closure, in this case CatchBlockEntryInstr restores |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2315 Fragment FlowGraphBuilder::LoadField(intptr_t offset, intptr_t class_id) { | 2324 Fragment FlowGraphBuilder::LoadField(intptr_t offset, intptr_t class_id) { |
| 2316 LoadFieldInstr* load = new (Z) LoadFieldInstr( | 2325 LoadFieldInstr* load = new (Z) LoadFieldInstr( |
| 2317 Pop(), offset, AbstractType::ZoneHandle(Z), TokenPosition::kNoSource); | 2326 Pop(), offset, AbstractType::ZoneHandle(Z), TokenPosition::kNoSource); |
| 2318 load->set_result_cid(class_id); | 2327 load->set_result_cid(class_id); |
| 2319 Push(load); | 2328 Push(load); |
| 2320 return Fragment(load); | 2329 return Fragment(load); |
| 2321 } | 2330 } |
| 2322 | 2331 |
| 2323 | 2332 |
| 2324 Fragment FlowGraphBuilder::LoadNativeField(MethodRecognizer::Kind kind, | 2333 Fragment FlowGraphBuilder::LoadNativeField(MethodRecognizer::Kind kind, |
| 2325 intptr_t offset, const Type& type, | 2334 intptr_t offset, |
| 2335 const Type& type, |
| 2326 intptr_t class_id, | 2336 intptr_t class_id, |
| 2327 bool is_immutable) { | 2337 bool is_immutable) { |
| 2328 LoadFieldInstr* load = | 2338 LoadFieldInstr* load = |
| 2329 new (Z) LoadFieldInstr(Pop(), offset, type, TokenPosition::kNoSource); | 2339 new (Z) LoadFieldInstr(Pop(), offset, type, TokenPosition::kNoSource); |
| 2330 load->set_recognized_kind(kind); | 2340 load->set_recognized_kind(kind); |
| 2331 load->set_result_cid(class_id); | 2341 load->set_result_cid(class_id); |
| 2332 load->set_is_immutable(is_immutable); | 2342 load->set_is_immutable(is_immutable); |
| 2333 Push(load); | 2343 Push(load); |
| 2334 return Fragment(load); | 2344 return Fragment(load); |
| 2335 } | 2345 } |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2445 } | 2455 } |
| 2446 Push(call); | 2456 Push(call); |
| 2447 return Fragment(call); | 2457 return Fragment(call); |
| 2448 } | 2458 } |
| 2449 | 2459 |
| 2450 | 2460 |
| 2451 Fragment FlowGraphBuilder::StoreIndexed(intptr_t class_id) { | 2461 Fragment FlowGraphBuilder::StoreIndexed(intptr_t class_id) { |
| 2452 Value* value = Pop(); | 2462 Value* value = Pop(); |
| 2453 Value* index = Pop(); | 2463 Value* index = Pop(); |
| 2454 const StoreBarrierType emit_store_barrier = | 2464 const StoreBarrierType emit_store_barrier = |
| 2455 value->BindsToConstant() | 2465 value->BindsToConstant() ? kNoStoreBarrier : kEmitStoreBarrier; |
| 2456 ? kNoStoreBarrier | |
| 2457 : kEmitStoreBarrier; | |
| 2458 StoreIndexedInstr* store = new (Z) StoreIndexedInstr( | 2466 StoreIndexedInstr* store = new (Z) StoreIndexedInstr( |
| 2459 Pop(), // Array. | 2467 Pop(), // Array. |
| 2460 index, value, emit_store_barrier, Instance::ElementSizeFor(class_id), | 2468 index, value, emit_store_barrier, Instance::ElementSizeFor(class_id), |
| 2461 class_id, kAlignedAccess, Thread::kNoDeoptId, TokenPosition::kNoSource); | 2469 class_id, kAlignedAccess, Thread::kNoDeoptId, TokenPosition::kNoSource); |
| 2462 Push(store); | 2470 Push(store); |
| 2463 return Fragment(store); | 2471 return Fragment(store); |
| 2464 } | 2472 } |
| 2465 | 2473 |
| 2466 | 2474 |
| 2467 Fragment FlowGraphBuilder::StoreInstanceField( | 2475 Fragment FlowGraphBuilder::StoreInstanceField( |
| 2468 const dart::Field& field, StoreBarrierType emit_store_barrier) { | 2476 const dart::Field& field, |
| 2477 StoreBarrierType emit_store_barrier) { |
| 2469 Value* value = Pop(); | 2478 Value* value = Pop(); |
| 2470 if (value->BindsToConstant()) { | 2479 if (value->BindsToConstant()) { |
| 2471 emit_store_barrier = kNoStoreBarrier; | 2480 emit_store_barrier = kNoStoreBarrier; |
| 2472 } | 2481 } |
| 2473 StoreInstanceFieldInstr* store = new (Z) StoreInstanceFieldInstr( | 2482 StoreInstanceFieldInstr* store = new (Z) StoreInstanceFieldInstr( |
| 2474 field, Pop(), value, emit_store_barrier, TokenPosition::kNoSource); | 2483 field, Pop(), value, emit_store_barrier, TokenPosition::kNoSource); |
| 2475 return Fragment(store); | 2484 return Fragment(store); |
| 2476 } | 2485 } |
| 2477 | 2486 |
| 2478 | 2487 |
| 2479 Fragment FlowGraphBuilder::StoreInstanceFieldGuarded(const dart::Field& field) { | 2488 Fragment FlowGraphBuilder::StoreInstanceFieldGuarded(const dart::Field& field) { |
| 2480 Fragment instructions; | 2489 Fragment instructions; |
| 2481 if (FLAG_use_field_guards) { | 2490 if (FLAG_use_field_guards) { |
| 2482 LocalVariable* store_expression = MakeTemporary(); | 2491 LocalVariable* store_expression = MakeTemporary(); |
| 2483 instructions += LoadLocal(store_expression); | 2492 instructions += LoadLocal(store_expression); |
| 2484 instructions += GuardFieldClass(field, Thread::Current()->GetNextDeoptId()); | 2493 instructions += GuardFieldClass(field, Thread::Current()->GetNextDeoptId()); |
| 2485 instructions += LoadLocal(store_expression); | 2494 instructions += LoadLocal(store_expression); |
| 2486 instructions += | 2495 instructions += |
| 2487 GuardFieldLength(field, Thread::Current()->GetNextDeoptId()); | 2496 GuardFieldLength(field, Thread::Current()->GetNextDeoptId()); |
| 2488 } | 2497 } |
| 2489 instructions += StoreInstanceField(field); | 2498 instructions += StoreInstanceField(field); |
| 2490 return instructions; | 2499 return instructions; |
| 2491 } | 2500 } |
| 2492 | 2501 |
| 2493 | 2502 |
| 2494 Fragment FlowGraphBuilder::StoreInstanceField( | 2503 Fragment FlowGraphBuilder::StoreInstanceField( |
| 2495 intptr_t offset, StoreBarrierType emit_store_barrier) { | 2504 intptr_t offset, |
| 2505 StoreBarrierType emit_store_barrier) { |
| 2496 Value* value = Pop(); | 2506 Value* value = Pop(); |
| 2497 if (value->BindsToConstant()) { | 2507 if (value->BindsToConstant()) { |
| 2498 emit_store_barrier = kNoStoreBarrier; | 2508 emit_store_barrier = kNoStoreBarrier; |
| 2499 } | 2509 } |
| 2500 StoreInstanceFieldInstr* store = new (Z) StoreInstanceFieldInstr( | 2510 StoreInstanceFieldInstr* store = new (Z) StoreInstanceFieldInstr( |
| 2501 offset, Pop(), value, emit_store_barrier, TokenPosition::kNoSource); | 2511 offset, Pop(), value, emit_store_barrier, TokenPosition::kNoSource); |
| 2502 return Fragment(store); | 2512 return Fragment(store); |
| 2503 } | 2513 } |
| 2504 | 2514 |
| 2505 | 2515 |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2613 | 2623 |
| 2614 instructions += StaticCall(throw_function, 6); | 2624 instructions += StaticCall(throw_function, 6); |
| 2615 // Leave "result" on the stack since callers expect it to be there (even | 2625 // Leave "result" on the stack since callers expect it to be there (even |
| 2616 // though the function will result in an exception). | 2626 // though the function will result in an exception). |
| 2617 | 2627 |
| 2618 return instructions; | 2628 return instructions; |
| 2619 } | 2629 } |
| 2620 | 2630 |
| 2621 | 2631 |
| 2622 dart::RawFunction* FlowGraphBuilder::LookupMethodByMember( | 2632 dart::RawFunction* FlowGraphBuilder::LookupMethodByMember( |
| 2623 Member* target, const dart::String& method_name) { | 2633 Member* target, |
| 2634 const dart::String& method_name) { |
| 2624 Class* kernel_klass = Class::Cast(target->parent()); | 2635 Class* kernel_klass = Class::Cast(target->parent()); |
| 2625 dart::Class& klass = | 2636 dart::Class& klass = |
| 2626 dart::Class::Handle(Z, H.LookupClassByKernelClass(kernel_klass)); | 2637 dart::Class::Handle(Z, H.LookupClassByKernelClass(kernel_klass)); |
| 2627 | 2638 |
| 2628 dart::RawFunction* function = klass.LookupFunctionAllowPrivate(method_name); | 2639 dart::RawFunction* function = klass.LookupFunctionAllowPrivate(method_name); |
| 2629 ASSERT(function != Object::null()); | 2640 ASSERT(function != Object::null()); |
| 2630 return function; | 2641 return function; |
| 2631 } | 2642 } |
| 2632 | 2643 |
| 2633 | 2644 |
| 2634 LocalVariable* FlowGraphBuilder::MakeTemporary() { | 2645 LocalVariable* FlowGraphBuilder::MakeTemporary() { |
| 2635 char name[64]; | 2646 char name[64]; |
| 2636 intptr_t index = stack_->definition()->temp_index(); | 2647 intptr_t index = stack_->definition()->temp_index(); |
| 2637 OS::SNPrint(name, 64, ":temp%" Pd, index); | 2648 OS::SNPrint(name, 64, ":temp%" Pd, index); |
| 2638 LocalVariable* variable = new (Z) LocalVariable( | 2649 LocalVariable* variable = |
| 2639 TokenPosition::kNoSource, | 2650 new (Z) LocalVariable(TokenPosition::kNoSource, TokenPosition::kNoSource, |
| 2640 TokenPosition::kNoSource, | 2651 H.DartSymbol(name), Object::dynamic_type()); |
| 2641 H.DartSymbol(name), | |
| 2642 Object::dynamic_type()); | |
| 2643 // Set the index relative to the base of the expression stack including | 2652 // Set the index relative to the base of the expression stack including |
| 2644 // outgoing arguments. | 2653 // outgoing arguments. |
| 2645 variable->set_index(parsed_function_->first_stack_local_index() - | 2654 variable->set_index(parsed_function_->first_stack_local_index() - |
| 2646 parsed_function_->num_stack_locals() - | 2655 parsed_function_->num_stack_locals() - |
| 2647 pending_argument_count_ - index); | 2656 pending_argument_count_ - index); |
| 2648 | 2657 |
| 2649 // The value has uses as if it were a local variable. Mark the definition | 2658 // The value has uses as if it were a local variable. Mark the definition |
| 2650 // as used so that its temp index will not be cleared (causing it to never | 2659 // as used so that its temp index will not be cleared (causing it to never |
| 2651 // be materialized in the expression stack). | 2660 // be materialized in the expression stack). |
| 2652 stack_->definition()->set_ssa_temp_index(0); | 2661 stack_->definition()->set_ssa_temp_index(0); |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2778 const dart::Function& function = parsed_function_->function(); | 2787 const dart::Function& function = parsed_function_->function(); |
| 2779 | 2788 |
| 2780 if (function.IsConstructorClosureFunction()) return NULL; | 2789 if (function.IsConstructorClosureFunction()) return NULL; |
| 2781 | 2790 |
| 2782 dart::Class& klass = | 2791 dart::Class& klass = |
| 2783 dart::Class::Handle(zone_, parsed_function_->function().Owner()); | 2792 dart::Class::Handle(zone_, parsed_function_->function().Owner()); |
| 2784 | 2793 |
| 2785 Function& outermost_function = Function::Handle(Z); | 2794 Function& outermost_function = Function::Handle(Z); |
| 2786 TreeNode* outermost_node = NULL; | 2795 TreeNode* outermost_node = NULL; |
| 2787 Class* kernel_klass = NULL; | 2796 Class* kernel_klass = NULL; |
| 2788 DiscoverEnclosingElements( | 2797 DiscoverEnclosingElements(Z, function, &outermost_function, &outermost_node, |
| 2789 Z, function, &outermost_function, &outermost_node, &kernel_klass); | 2798 &kernel_klass); |
| 2790 | 2799 |
| 2791 // Mark that we are using [klass]/[kernell_klass] as active class. Resolving | 2800 // Mark that we are using [klass]/[kernell_klass] as active class. Resolving |
| 2792 // of type parameters will get resolved via [kernell_klass] unless we are | 2801 // of type parameters will get resolved via [kernell_klass] unless we are |
| 2793 // nested inside a static factory in which case we will use [member]. | 2802 // nested inside a static factory in which case we will use [member]. |
| 2794 ActiveClassScope active_class_scope(&active_class_, kernel_klass, &klass); | 2803 ActiveClassScope active_class_scope(&active_class_, kernel_klass, &klass); |
| 2795 Member* member = ((outermost_node != NULL) && outermost_node->IsMember()) | 2804 Member* member = ((outermost_node != NULL) && outermost_node->IsMember()) |
| 2796 ? Member::Cast(outermost_node) | 2805 ? Member::Cast(outermost_node) |
| 2797 : NULL; | 2806 : NULL; |
| 2798 ActiveMemberScope active_member(&active_class_, member); | 2807 ActiveMemberScope active_member(&active_class_, member); |
| 2799 | 2808 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2853 } | 2862 } |
| 2854 UNREACHABLE(); | 2863 UNREACHABLE(); |
| 2855 return NULL; | 2864 return NULL; |
| 2856 } | 2865 } |
| 2857 | 2866 |
| 2858 | 2867 |
| 2859 FlowGraph* FlowGraphBuilder::BuildGraphOfFunction(FunctionNode* function, | 2868 FlowGraph* FlowGraphBuilder::BuildGraphOfFunction(FunctionNode* function, |
| 2860 Constructor* constructor) { | 2869 Constructor* constructor) { |
| 2861 const Function& dart_function = parsed_function_->function(); | 2870 const Function& dart_function = parsed_function_->function(); |
| 2862 TargetEntryInstr* normal_entry = BuildTargetEntry(); | 2871 TargetEntryInstr* normal_entry = BuildTargetEntry(); |
| 2863 graph_entry_ = new (Z) | 2872 graph_entry_ = |
| 2864 GraphEntryInstr(*parsed_function_, normal_entry, osr_id_); | 2873 new (Z) GraphEntryInstr(*parsed_function_, normal_entry, osr_id_); |
| 2865 | 2874 |
| 2866 SetupDefaultParameterValues(function); | 2875 SetupDefaultParameterValues(function); |
| 2867 | 2876 |
| 2868 Fragment body; | 2877 Fragment body; |
| 2869 if (!dart_function.is_native()) body += CheckStackOverflowInPrologue(); | 2878 if (!dart_function.is_native()) body += CheckStackOverflowInPrologue(); |
| 2870 intptr_t context_size = | 2879 intptr_t context_size = |
| 2871 parsed_function_->node_sequence()->scope()->num_context_variables(); | 2880 parsed_function_->node_sequence()->scope()->num_context_variables(); |
| 2872 if (context_size > 0) { | 2881 if (context_size > 0) { |
| 2873 body += PushContext(context_size); | 2882 body += PushContext(context_size); |
| 2874 LocalVariable* context = MakeTemporary(); | 2883 LocalVariable* context = MakeTemporary(); |
| 2875 | 2884 |
| 2876 // Copy captured parameters from the stack into the context. | 2885 // Copy captured parameters from the stack into the context. |
| 2877 LocalScope* scope = parsed_function_->node_sequence()->scope(); | 2886 LocalScope* scope = parsed_function_->node_sequence()->scope(); |
| 2878 intptr_t parameter_count = dart_function.NumParameters(); | 2887 intptr_t parameter_count = dart_function.NumParameters(); |
| 2879 intptr_t parameter_index = parsed_function_->first_parameter_index(); | 2888 intptr_t parameter_index = parsed_function_->first_parameter_index(); |
| 2880 for (intptr_t i = 0; i < parameter_count; ++i, --parameter_index) { | 2889 for (intptr_t i = 0; i < parameter_count; ++i, --parameter_index) { |
| 2881 LocalVariable* variable = scope->VariableAt(i); | 2890 LocalVariable* variable = scope->VariableAt(i); |
| 2882 if (variable->is_captured()) { | 2891 if (variable->is_captured()) { |
| 2883 // There is no LocalVariable describing the on-stack parameter so | 2892 // There is no LocalVariable describing the on-stack parameter so |
| 2884 // create one directly and use the same type. | 2893 // create one directly and use the same type. |
| 2885 LocalVariable* parameter = | 2894 LocalVariable* parameter = new (Z) |
| 2886 new (Z) LocalVariable(TokenPosition::kNoSource, | 2895 LocalVariable(TokenPosition::kNoSource, TokenPosition::kNoSource, |
| 2887 TokenPosition::kNoSource, | 2896 Symbols::TempParam(), variable->type()); |
| 2888 Symbols::TempParam(), | |
| 2889 variable->type()); | |
| 2890 parameter->set_index(parameter_index); | 2897 parameter->set_index(parameter_index); |
| 2891 // Mark the stack variable so it will be ignored by the code for | 2898 // Mark the stack variable so it will be ignored by the code for |
| 2892 // try/catch. | 2899 // try/catch. |
| 2893 parameter->set_is_captured_parameter(true); | 2900 parameter->set_is_captured_parameter(true); |
| 2894 | 2901 |
| 2895 // Copy the parameter from the stack to the context. Overwrite it | 2902 // Copy the parameter from the stack to the context. Overwrite it |
| 2896 // with a null constant on the stack so the original value is | 2903 // with a null constant on the stack so the original value is |
| 2897 // eligible for garbage collection. | 2904 // eligible for garbage collection. |
| 2898 body += LoadLocal(context); | 2905 body += LoadLocal(context); |
| 2899 body += LoadLocal(parameter); | 2906 body += LoadLocal(parameter); |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3025 body = dispatch; | 3032 body = dispatch; |
| 3026 | 3033 |
| 3027 context_depth_ = current_context_depth; | 3034 context_depth_ = current_context_depth; |
| 3028 } | 3035 } |
| 3029 normal_entry->LinkTo(body.entry); | 3036 normal_entry->LinkTo(body.entry); |
| 3030 | 3037 |
| 3031 // When compiling for OSR, use a depth first search to prune instructions | 3038 // When compiling for OSR, use a depth first search to prune instructions |
| 3032 // unreachable from the OSR entry. Catch entries are always considered | 3039 // unreachable from the OSR entry. Catch entries are always considered |
| 3033 // reachable, even if they become unreachable after OSR. | 3040 // reachable, even if they become unreachable after OSR. |
| 3034 if (osr_id_ != Compiler::kNoOSRDeoptId) { | 3041 if (osr_id_ != Compiler::kNoOSRDeoptId) { |
| 3035 BitVector* block_marks = new(Z) BitVector(Z, next_block_id_); | 3042 BitVector* block_marks = new (Z) BitVector(Z, next_block_id_); |
| 3036 bool found = graph_entry_->PruneUnreachable(graph_entry_, NULL, osr_id_, | 3043 bool found = graph_entry_->PruneUnreachable(graph_entry_, NULL, osr_id_, |
| 3037 block_marks); | 3044 block_marks); |
| 3038 ASSERT(found); | 3045 ASSERT(found); |
| 3039 } | 3046 } |
| 3040 return new (Z) FlowGraph(*parsed_function_, graph_entry_, next_block_id_ - 1); | 3047 return new (Z) FlowGraph(*parsed_function_, graph_entry_, next_block_id_ - 1); |
| 3041 } | 3048 } |
| 3042 | 3049 |
| 3043 | 3050 |
| 3044 Fragment FlowGraphBuilder::NativeFunctionBody(FunctionNode* kernel_function, | 3051 Fragment FlowGraphBuilder::NativeFunctionBody(FunctionNode* kernel_function, |
| 3045 const Function& function) { | 3052 const Function& function) { |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3191 dart::String& name = dart::String::ZoneHandle(Z, function.native_name()); | 3198 dart::String& name = dart::String::ZoneHandle(Z, function.native_name()); |
| 3192 body += NativeCall(&name, &function); | 3199 body += NativeCall(&name, &function); |
| 3193 break; | 3200 break; |
| 3194 } | 3201 } |
| 3195 } | 3202 } |
| 3196 return body + Return(); | 3203 return body + Return(); |
| 3197 } | 3204 } |
| 3198 | 3205 |
| 3199 | 3206 |
| 3200 FlowGraph* FlowGraphBuilder::BuildGraphOfFieldAccessor( | 3207 FlowGraph* FlowGraphBuilder::BuildGraphOfFieldAccessor( |
| 3201 Field* kernel_field, LocalVariable* setter_value) { | 3208 Field* kernel_field, |
| 3209 LocalVariable* setter_value) { |
| 3202 const dart::Function& function = parsed_function_->function(); | 3210 const dart::Function& function = parsed_function_->function(); |
| 3203 | 3211 |
| 3204 bool is_setter = function.IsImplicitSetterFunction(); | 3212 bool is_setter = function.IsImplicitSetterFunction(); |
| 3205 bool is_method = !function.IsStaticFunction(); | 3213 bool is_method = !function.IsStaticFunction(); |
| 3206 dart::Field& field = | 3214 dart::Field& field = |
| 3207 dart::Field::ZoneHandle(Z, H.LookupFieldByKernelField(kernel_field)); | 3215 dart::Field::ZoneHandle(Z, H.LookupFieldByKernelField(kernel_field)); |
| 3208 | 3216 |
| 3209 TargetEntryInstr* normal_entry = BuildTargetEntry(); | 3217 TargetEntryInstr* normal_entry = BuildTargetEntry(); |
| 3210 graph_entry_ = new (Z) | 3218 graph_entry_ = new (Z) |
| 3211 GraphEntryInstr(*parsed_function_, normal_entry, Compiler::kNoOSRDeoptId); | 3219 GraphEntryInstr(*parsed_function_, normal_entry, Compiler::kNoOSRDeoptId); |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3327 Fragment body(normal_entry); | 3335 Fragment body(normal_entry); |
| 3328 body += CheckStackOverflowInPrologue(); | 3336 body += CheckStackOverflowInPrologue(); |
| 3329 body += BuildImplicitClosureCreation(function); | 3337 body += BuildImplicitClosureCreation(function); |
| 3330 body += Return(); | 3338 body += Return(); |
| 3331 | 3339 |
| 3332 return new (Z) FlowGraph(*parsed_function_, graph_entry_, next_block_id_ - 1); | 3340 return new (Z) FlowGraph(*parsed_function_, graph_entry_, next_block_id_ - 1); |
| 3333 } | 3341 } |
| 3334 | 3342 |
| 3335 | 3343 |
| 3336 FlowGraph* FlowGraphBuilder::BuildGraphOfImplicitClosureFunction( | 3344 FlowGraph* FlowGraphBuilder::BuildGraphOfImplicitClosureFunction( |
| 3337 FunctionNode* kernel_function, const Function& function) { | 3345 FunctionNode* kernel_function, |
| 3346 const Function& function) { |
| 3338 const Function& target = Function::ZoneHandle(Z, function.parent_function()); | 3347 const Function& target = Function::ZoneHandle(Z, function.parent_function()); |
| 3339 | 3348 |
| 3340 TargetEntryInstr* normal_entry = BuildTargetEntry(); | 3349 TargetEntryInstr* normal_entry = BuildTargetEntry(); |
| 3341 graph_entry_ = new (Z) | 3350 graph_entry_ = new (Z) |
| 3342 GraphEntryInstr(*parsed_function_, normal_entry, Compiler::kNoOSRDeoptId); | 3351 GraphEntryInstr(*parsed_function_, normal_entry, Compiler::kNoOSRDeoptId); |
| 3343 SetupDefaultParameterValues(kernel_function); | 3352 SetupDefaultParameterValues(kernel_function); |
| 3344 | 3353 |
| 3345 Fragment body(normal_entry); | 3354 Fragment body(normal_entry); |
| 3346 body += CheckStackOverflowInPrologue(); | 3355 body += CheckStackOverflowInPrologue(); |
| 3347 | 3356 |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3615 return new (Z) TargetEntryInstr(AllocateBlockId(), CurrentTryIndex()); | 3624 return new (Z) TargetEntryInstr(AllocateBlockId(), CurrentTryIndex()); |
| 3616 } | 3625 } |
| 3617 | 3626 |
| 3618 | 3627 |
| 3619 JoinEntryInstr* FlowGraphBuilder::BuildJoinEntry() { | 3628 JoinEntryInstr* FlowGraphBuilder::BuildJoinEntry() { |
| 3620 return new (Z) JoinEntryInstr(AllocateBlockId(), CurrentTryIndex()); | 3629 return new (Z) JoinEntryInstr(AllocateBlockId(), CurrentTryIndex()); |
| 3621 } | 3630 } |
| 3622 | 3631 |
| 3623 | 3632 |
| 3624 Fragment FlowGraphBuilder::TranslateInitializers( | 3633 Fragment FlowGraphBuilder::TranslateInitializers( |
| 3625 Class* kernel_klass, List<Initializer>* initializers) { | 3634 Class* kernel_klass, |
| 3635 List<Initializer>* initializers) { |
| 3626 Fragment instructions; | 3636 Fragment instructions; |
| 3627 | 3637 |
| 3628 // These come from: | 3638 // These come from: |
| 3629 // class A { | 3639 // class A { |
| 3630 // var x = (expr); | 3640 // var x = (expr); |
| 3631 // } | 3641 // } |
| 3632 for (intptr_t i = 0; i < kernel_klass->fields().length(); i++) { | 3642 for (intptr_t i = 0; i < kernel_klass->fields().length(); i++) { |
| 3633 Field* kernel_field = kernel_klass->fields()[i]; | 3643 Field* kernel_field = kernel_klass->fields()[i]; |
| 3634 Expression* init = kernel_field->initializer(); | 3644 Expression* init = kernel_field->initializer(); |
| 3635 if (!kernel_field->IsStatic() && init != NULL) { | 3645 if (!kernel_field->IsStatic() && init != NULL) { |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4006 result_ = Object::dynamic_type().raw(); | 4016 result_ = Object::dynamic_type().raw(); |
| 4007 } | 4017 } |
| 4008 | 4018 |
| 4009 | 4019 |
| 4010 void DartTypeTranslator::VisitVoidType(VoidType* node) { | 4020 void DartTypeTranslator::VisitVoidType(VoidType* node) { |
| 4011 result_ = Object::void_type().raw(); | 4021 result_ = Object::void_type().raw(); |
| 4012 } | 4022 } |
| 4013 | 4023 |
| 4014 | 4024 |
| 4015 const TypeArguments& DartTypeTranslator::TranslateTypeArguments( | 4025 const TypeArguments& DartTypeTranslator::TranslateTypeArguments( |
| 4016 DartType** dart_types, intptr_t length) { | 4026 DartType** dart_types, |
| 4027 intptr_t length) { |
| 4017 bool only_dynamic = true; | 4028 bool only_dynamic = true; |
| 4018 for (intptr_t i = 0; i < length; i++) { | 4029 for (intptr_t i = 0; i < length; i++) { |
| 4019 if (!dart_types[i]->IsDynamicType()) { | 4030 if (!dart_types[i]->IsDynamicType()) { |
| 4020 only_dynamic = false; | 4031 only_dynamic = false; |
| 4021 break; | 4032 break; |
| 4022 } | 4033 } |
| 4023 } | 4034 } |
| 4024 TypeArguments& type_arguments = TypeArguments::ZoneHandle(Z); | 4035 TypeArguments& type_arguments = TypeArguments::ZoneHandle(Z); |
| 4025 if (!only_dynamic) { | 4036 if (!only_dynamic) { |
| 4026 type_arguments = TypeArguments::New(length); | 4037 type_arguments = TypeArguments::New(length); |
| 4027 for (intptr_t i = 0; i < length; i++) { | 4038 for (intptr_t i = 0; i < length; i++) { |
| 4028 dart_types[i]->AcceptDartTypeVisitor(this); | 4039 dart_types[i]->AcceptDartTypeVisitor(this); |
| 4029 if (result_.IsMalformed()) { | 4040 if (result_.IsMalformed()) { |
| 4030 type_arguments = TypeArguments::null(); | 4041 type_arguments = TypeArguments::null(); |
| 4031 return type_arguments; | 4042 return type_arguments; |
| 4032 } | 4043 } |
| 4033 type_arguments.SetTypeAt(i, result_); | 4044 type_arguments.SetTypeAt(i, result_); |
| 4034 } | 4045 } |
| 4035 if (finalize_) { | 4046 if (finalize_) { |
| 4036 type_arguments = type_arguments.Canonicalize(); | 4047 type_arguments = type_arguments.Canonicalize(); |
| 4037 } | 4048 } |
| 4038 } | 4049 } |
| 4039 return type_arguments; | 4050 return type_arguments; |
| 4040 } | 4051 } |
| 4041 | 4052 |
| 4042 | 4053 |
| 4043 const TypeArguments& DartTypeTranslator::TranslateInstantiatedTypeArguments( | 4054 const TypeArguments& DartTypeTranslator::TranslateInstantiatedTypeArguments( |
| 4044 const dart::Class& receiver_class, DartType** receiver_type_arguments, | 4055 const dart::Class& receiver_class, |
| 4056 DartType** receiver_type_arguments, |
| 4045 intptr_t length) { | 4057 intptr_t length) { |
| 4046 const TypeArguments& type_arguments = | 4058 const TypeArguments& type_arguments = |
| 4047 TranslateTypeArguments(receiver_type_arguments, length); | 4059 TranslateTypeArguments(receiver_type_arguments, length); |
| 4048 if (type_arguments.IsNull()) return type_arguments; | 4060 if (type_arguments.IsNull()) return type_arguments; |
| 4049 | 4061 |
| 4050 // We make a temporary [Type] object and use `ClassFinalizer::FinalizeType` to | 4062 // We make a temporary [Type] object and use `ClassFinalizer::FinalizeType` to |
| 4051 // finalize the argument types. | 4063 // finalize the argument types. |
| 4052 // (This can for example make the [type_arguments] vector larger) | 4064 // (This can for example make the [type_arguments] vector larger) |
| 4053 Type& type = Type::Handle( | 4065 Type& type = Type::Handle( |
| 4054 Z, Type::New(receiver_class, type_arguments, TokenPosition::kNoSource)); | 4066 Z, Type::New(receiver_class, type_arguments, TokenPosition::kNoSource)); |
| (...skipping 1651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5706 instructions += LoadLocal(closure); | 5718 instructions += LoadLocal(closure); |
| 5707 instructions += LoadLocal(parsed_function_->current_context_var()); | 5719 instructions += LoadLocal(parsed_function_->current_context_var()); |
| 5708 instructions += StoreInstanceField(Closure::context_offset()); | 5720 instructions += StoreInstanceField(Closure::context_offset()); |
| 5709 | 5721 |
| 5710 return instructions; | 5722 return instructions; |
| 5711 } | 5723 } |
| 5712 | 5724 |
| 5713 | 5725 |
| 5714 } // namespace kernel | 5726 } // namespace kernel |
| 5715 } // namespace dart | 5727 } // namespace dart |
| OLD | NEW |