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

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

Issue 2777413002: Revert "VM: [Kernel] Avoid emitting :expr_temp and capturing :iterator" (Closed)
Patch Set: Created 3 years, 9 months 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
« no previous file with comments | « no previous file | tests/language/language_kernel.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 13 matching lines...) Expand all
24 DECLARE_FLAG(bool, support_externalizable_strings); 24 DECLARE_FLAG(bool, support_externalizable_strings);
25 25
26 namespace kernel { 26 namespace kernel {
27 27
28 #define Z (zone_) 28 #define Z (zone_)
29 #define H (translation_helper_) 29 #define H (translation_helper_)
30 #define T (type_translator_) 30 #define T (type_translator_)
31 #define I Isolate::Current() 31 #define I Isolate::Current()
32 32
33 33
34 class NeedsExprTempVisitor : public RecursiveVisitor {
35 public:
36 NeedsExprTempVisitor() : needs_expr_temp_(false) {}
37
38 virtual void VisitConditionalExpression(ConditionalExpression* node) {
39 needs_expr_temp_ = true;
40 }
41
42 virtual void VisitLogicalExpression(LogicalExpression* node) {
43 needs_expr_temp_ = true;
44 }
45
46 bool needs_expr_temp() const { return needs_expr_temp_; }
47
48 private:
49 bool needs_expr_temp_;
50 };
51
52
53 static bool NeedsExprTemp(TreeNode* node) {
54 NeedsExprTempVisitor visitor;
55 node->AcceptVisitor(&visitor);
56 return visitor.needs_expr_temp();
57 }
58
59
60 static void DiscoverEnclosingElements(Zone* zone, 34 static void DiscoverEnclosingElements(Zone* zone,
61 const Function& function, 35 const Function& function,
62 Function* outermost_function, 36 Function* outermost_function,
63 TreeNode** outermost_node, 37 TreeNode** outermost_node,
64 Class** klass) { 38 Class** klass) {
65 // Find out if there is an enclosing kernel class (which will be used to 39 // Find out if there is an enclosing kernel class (which will be used to
66 // resolve type parameters). 40 // resolve type parameters).
67 *outermost_function = function.raw(); 41 *outermost_function = function.raw();
68 while (outermost_function->parent_function() != Object::null()) { 42 while (outermost_function->parent_function() != Object::null()) {
69 *outermost_function = outermost_function->parent_function(); 43 *outermost_function = outermost_function->parent_function();
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 92
119 93
120 void ScopeBuilder::AddParameter(VariableDeclaration* declaration, 94 void ScopeBuilder::AddParameter(VariableDeclaration* declaration,
121 intptr_t pos) { 95 intptr_t pos) {
122 LocalVariable* variable = MakeVariable( 96 LocalVariable* variable = MakeVariable(
123 declaration->position(), declaration->position(), 97 declaration->position(), declaration->position(),
124 H.DartSymbol(declaration->name()), T.TranslateVariableType(declaration)); 98 H.DartSymbol(declaration->name()), T.TranslateVariableType(declaration));
125 if (declaration->IsFinal()) { 99 if (declaration->IsFinal()) {
126 variable->set_is_final(); 100 variable->set_is_final();
127 } 101 }
128 if (variable->name().raw() == Symbols::IteratorParameter().raw()) {
129 variable->set_is_forced_stack();
130 }
131 scope_->InsertParameterAt(pos, variable); 102 scope_->InsertParameterAt(pos, variable);
132 result_->locals.Insert(declaration, variable); 103 result_->locals.Insert(declaration, variable);
133 104
134 // The default value may contain 'let' bindings for which the constant 105 // The default value may contain 'let' bindings for which the constant
135 // evaluator needs scope bindings. 106 // evaluator needs scope bindings.
136 Expression* defaultValue = declaration->initializer(); 107 Expression* defaultValue = declaration->initializer();
137 if (defaultValue != NULL) { 108 if (defaultValue != NULL) {
138 defaultValue->AcceptExpressionVisitor(this); 109 defaultValue->AcceptExpressionVisitor(this);
139 } 110 }
140 } 111 }
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 enclosing_scope = LocalScope::RestoreOuterScope( 293 enclosing_scope = LocalScope::RestoreOuterScope(
323 ContextScope::Handle(Z, function.context_scope())); 294 ContextScope::Handle(Z, function.context_scope()));
324 } 295 }
325 current_function_scope_ = scope_ = new (Z) LocalScope(enclosing_scope, 0, 0); 296 current_function_scope_ = scope_ = new (Z) LocalScope(enclosing_scope, 0, 0);
326 scope_->set_begin_token_pos(function.token_pos()); 297 scope_->set_begin_token_pos(function.token_pos());
327 scope_->set_end_token_pos(function.end_token_pos()); 298 scope_->set_end_token_pos(function.end_token_pos());
328 299
329 LocalVariable* context_var = parsed_function->current_context_var(); 300 LocalVariable* context_var = parsed_function->current_context_var();
330 context_var->set_is_forced_stack(); 301 context_var->set_is_forced_stack();
331 scope_->AddVariable(context_var); 302 scope_->AddVariable(context_var);
332 bool has_expr_temp = false; 303 scope_->AddVariable(parsed_function->EnsureExpressionTemp());
333 if (node_ != NULL && NeedsExprTemp(node_)) {
334 scope_->AddVariable(parsed_function->EnsureExpressionTemp());
335 has_expr_temp = true;
336 }
337 304
338 parsed_function->SetNodeSequence( 305 parsed_function->SetNodeSequence(
339 new SequenceNode(TokenPosition::kNoSource, scope_)); 306 new SequenceNode(TokenPosition::kNoSource, scope_));
340 307
341 switch (function.kind()) { 308 switch (function.kind()) {
342 case RawFunction::kClosureFunction: 309 case RawFunction::kClosureFunction:
343 case RawFunction::kRegularFunction: 310 case RawFunction::kRegularFunction:
344 case RawFunction::kGetterFunction: 311 case RawFunction::kGetterFunction:
345 case RawFunction::kSetterFunction: 312 case RawFunction::kSetterFunction:
346 case RawFunction::kConstructor: { 313 case RawFunction::kConstructor: {
(...skipping 27 matching lines...) Expand all
374 341
375 // We visit instance field initializers because they might contain 342 // We visit instance field initializers because they might contain
376 // [Let] expressions and we need to have a mapping. 343 // [Let] expressions and we need to have a mapping.
377 if (node_->IsConstructor()) { 344 if (node_->IsConstructor()) {
378 Class* klass = Class::Cast(Constructor::Cast(node_)->parent()); 345 Class* klass = Class::Cast(Constructor::Cast(node_)->parent());
379 346
380 for (intptr_t i = 0; i < klass->fields().length(); i++) { 347 for (intptr_t i = 0; i < klass->fields().length(); i++) {
381 Field* field = klass->fields()[i]; 348 Field* field = klass->fields()[i];
382 if (!field->IsStatic() && (field->initializer() != NULL)) { 349 if (!field->IsStatic() && (field->initializer() != NULL)) {
383 EnterScope(field, field->position()); 350 EnterScope(field, field->position());
384 if (!has_expr_temp && NeedsExprTemp(field->initializer())) {
385 scope_->AddVariable(parsed_function->EnsureExpressionTemp());
386 has_expr_temp = true;
387 }
388 field->initializer()->AcceptExpressionVisitor(this); 351 field->initializer()->AcceptExpressionVisitor(this);
389 ExitScope(field->end_position()); 352 ExitScope(field->end_position());
390 } 353 }
391 } 354 }
392 } 355 }
393 } else if (function.IsFactory()) { 356 } else if (function.IsFactory()) {
394 LocalVariable* variable = MakeVariable( 357 LocalVariable* variable = MakeVariable(
395 TokenPosition::kNoSource, TokenPosition::kNoSource, 358 TokenPosition::kNoSource, TokenPosition::kNoSource,
396 Symbols::TypeArgumentsParameter(), AbstractType::dynamic_type()); 359 Symbols::TypeArgumentsParameter(), AbstractType::dynamic_type());
397 scope_->InsertParameterAt(pos++, variable); 360 scope_->InsertParameterAt(pos++, variable);
(...skipping 6098 matching lines...) Expand 10 before | Expand all | Expand 10 after
6496 thread->clear_sticky_error(); 6459 thread->clear_sticky_error();
6497 return error.raw(); 6460 return error.raw();
6498 } 6461 }
6499 } 6462 }
6500 6463
6501 6464
6502 } // namespace kernel 6465 } // namespace kernel
6503 } // namespace dart 6466 } // namespace dart
6504 6467
6505 #endif // !defined(DART_PRECOMPILED_RUNTIME) 6468 #endif // !defined(DART_PRECOMPILED_RUNTIME)
OLDNEW
« no previous file with comments | « no previous file | tests/language/language_kernel.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698