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

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

Issue 9392020: Fix context unchaining (issue 5991015). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 8 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/ast_printer.cc ('k') | runtime/vm/code_generator_x64.cc » ('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) 2011, 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/globals.h" // Needed here to get TARGET_ARCH_IA32. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32.
6 #if defined(TARGET_ARCH_IA32) 6 #if defined(TARGET_ARCH_IA32)
7 7
8 #include "vm/code_generator.h" 8 #include "vm/code_generator.h"
9 9
10 #include "lib/error.h" 10 #include "lib/error.h"
11 #include "vm/ast_printer.h" 11 #include "vm/ast_printer.h"
(...skipping 968 matching lines...) Expand 10 before | Expand all | Expand 10 after
980 // code checking the type of the actual arguments. 980 // code checking the type of the actual arguments.
981 if (FLAG_enable_type_checks && 981 if (FLAG_enable_type_checks &&
982 (node_sequence == parsed_function_.node_sequence())) { 982 (node_sequence == parsed_function_.node_sequence())) {
983 GenerateArgumentTypeChecks(); 983 GenerateArgumentTypeChecks();
984 } 984 }
985 for (int i = 0; i < node_sequence->length(); i++) { 985 for (int i = 0; i < node_sequence->length(); i++) {
986 AstNode* child_node = node_sequence->NodeAt(i); 986 AstNode* child_node = node_sequence->NodeAt(i);
987 state()->set_root_node(child_node); 987 state()->set_root_node(child_node);
988 child_node->Visit(this); 988 child_node->Visit(this);
989 } 989 }
990 if (node_sequence->label() != NULL) {
991 __ Bind(node_sequence->label()->break_label());
992 }
993 if (num_context_variables > 0) { 990 if (num_context_variables > 0) {
994 // Unchain the previously allocated context. 991 // Unchain the previously allocated context.
995 __ movl(CTX, FieldAddress(CTX, Context::parent_offset())); 992 __ movl(CTX, FieldAddress(CTX, Context::parent_offset()));
996 } 993 }
994 // If this node sequence is labeled, a break out of the sequence will have
995 // taken care of unchaining the context.
996 if (node_sequence->label() != NULL) {
997 __ Bind(node_sequence->label()->break_label());
998 }
997 } 999 }
998 1000
999 1001
1000 void CodeGenerator::VisitArgumentListNode(ArgumentListNode* arguments) { 1002 void CodeGenerator::VisitArgumentListNode(ArgumentListNode* arguments) {
1001 for (int i = 0; i < arguments->length(); i++) { 1003 for (int i = 0; i < arguments->length(); i++) {
1002 AstNode* argument = arguments->NodeAt(i); 1004 AstNode* argument = arguments->NodeAt(i);
1003 argument->Visit(this); 1005 argument->Visit(this);
1004 } 1006 }
1005 } 1007 }
1006 1008
(...skipping 979 matching lines...) Expand 10 before | Expand all | Expand 10 after
1986 1988
1987 // Generate inlined code for all finally blocks as we may transfer 1989 // Generate inlined code for all finally blocks as we may transfer
1988 // control out of the 'try' blocks if any. 1990 // control out of the 'try' blocks if any.
1989 for (intptr_t i = 0; i < node->inlined_finally_list_length(); i++) { 1991 for (intptr_t i = 0; i < node->inlined_finally_list_length(); i++) {
1990 node->InlinedFinallyNodeAt(i)->Visit(this); 1992 node->InlinedFinallyNodeAt(i)->Visit(this);
1991 } 1993 }
1992 1994
1993 // Unchain the context(s) up to the outer context level of the scope which 1995 // Unchain the context(s) up to the outer context level of the scope which
1994 // contains the destination label. 1996 // contains the destination label.
1995 ASSERT(label->owner() != NULL); 1997 ASSERT(label->owner() != NULL);
1996 LocalScope* outer_context_owner = label->owner()->parent();
1997 ASSERT(outer_context_owner != NULL);
1998 int target_context_level = 0; 1998 int target_context_level = 0;
1999 if (outer_context_owner->HasContextLevel()) { 1999 LocalScope* target_scope = label->owner();
2000 target_context_level = outer_context_owner->context_level(); 2000 if (target_scope->num_context_variables() > 0) {
2001 ASSERT(target_context_level >= 0); 2001 // The scope of the target label allocates a context, therefore its outer
2002 int context_level = state()->context_level(); 2002 // scope is at a lower context level.
2003 ASSERT(context_level >= target_context_level); 2003 target_context_level = target_scope->context_level() - 1;
2004 while (context_level-- > target_context_level) { 2004 } else {
2005 __ movl(CTX, FieldAddress(CTX, Context::parent_offset())); 2005 // The scope of the target label does not allocate a context, so its outer
2006 // scope is at the same context level. Find it.
2007 while ((target_scope != NULL) &&
2008 (target_scope->num_context_variables() == 0)) {
2009 target_scope = target_scope->parent();
2006 } 2010 }
2011 if (target_scope != NULL) {
2012 target_context_level = target_scope->context_level();
2013 }
2014 }
2015 ASSERT(target_context_level >= 0);
2016 int context_level = state()->context_level();
2017 ASSERT(context_level >= target_context_level);
2018 while (context_level-- > target_context_level) {
2019 __ movl(CTX, FieldAddress(CTX, Context::parent_offset()));
2007 } 2020 }
2008 2021
2009 if (node->kind() == Token::kBREAK) { 2022 if (node->kind() == Token::kBREAK) {
2010 __ jmp(label->break_label()); 2023 __ jmp(label->break_label());
2011 } else { 2024 } else {
2012 __ jmp(label->continue_label()); 2025 __ jmp(label->continue_label());
2013 } 2026 }
2014 } 2027 }
2015 2028
2016 2029
(...skipping 778 matching lines...) Expand 10 before | Expand all | Expand 10 after
2795 const Error& error = Error::Handle( 2808 const Error& error = Error::Handle(
2796 Parser::FormatError(script, token_index, "Error", format, args)); 2809 Parser::FormatError(script, token_index, "Error", format, args));
2797 va_end(args); 2810 va_end(args);
2798 Isolate::Current()->long_jump_base()->Jump(1, error); 2811 Isolate::Current()->long_jump_base()->Jump(1, error);
2799 UNREACHABLE(); 2812 UNREACHABLE();
2800 } 2813 }
2801 2814
2802 } // namespace dart 2815 } // namespace dart
2803 2816
2804 #endif // defined TARGET_ARCH_IA32 2817 #endif // defined TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « runtime/vm/ast_printer.cc ('k') | runtime/vm/code_generator_x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698