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

Side by Side Diff: runtime/vm/code_generator_x64.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/code_generator_ia32.cc ('k') | runtime/vm/scopes.h » ('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) 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/globals.h" // Needed here to get TARGET_ARCH_X64. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64.
6 #if defined(TARGET_ARCH_X64) 6 #if defined(TARGET_ARCH_X64)
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"
(...skipping 966 matching lines...) Expand 10 before | Expand all | Expand 10 after
977 // code checking the type of the actual arguments. 977 // code checking the type of the actual arguments.
978 if (FLAG_enable_type_checks && 978 if (FLAG_enable_type_checks &&
979 (node_sequence == parsed_function_.node_sequence())) { 979 (node_sequence == parsed_function_.node_sequence())) {
980 GenerateArgumentTypeChecks(); 980 GenerateArgumentTypeChecks();
981 } 981 }
982 for (int i = 0; i < node_sequence->length(); i++) { 982 for (int i = 0; i < node_sequence->length(); i++) {
983 AstNode* child_node = node_sequence->NodeAt(i); 983 AstNode* child_node = node_sequence->NodeAt(i);
984 state()->set_root_node(child_node); 984 state()->set_root_node(child_node);
985 child_node->Visit(this); 985 child_node->Visit(this);
986 } 986 }
987 if (node_sequence->label() != NULL) {
988 __ Bind(node_sequence->label()->break_label());
989 }
990 if (num_context_variables > 0) { 987 if (num_context_variables > 0) {
991 // Unchain the previously allocated context. 988 // Unchain the previously allocated context.
992 __ movq(CTX, FieldAddress(CTX, Context::parent_offset())); 989 __ movq(CTX, FieldAddress(CTX, Context::parent_offset()));
993 } 990 }
991 // If this node sequence is labeled, a break out of the sequence will have
992 // taken care of unchaining the context.
993 if (node_sequence->label() != NULL) {
994 __ Bind(node_sequence->label()->break_label());
995 }
994 } 996 }
995 997
996 998
997 void CodeGenerator::VisitArgumentListNode(ArgumentListNode* arguments) { 999 void CodeGenerator::VisitArgumentListNode(ArgumentListNode* arguments) {
998 for (int i = 0; i < arguments->length(); i++) { 1000 for (int i = 0; i < arguments->length(); i++) {
999 AstNode* argument = arguments->NodeAt(i); 1001 AstNode* argument = arguments->NodeAt(i);
1000 argument->Visit(this); 1002 argument->Visit(this);
1001 } 1003 }
1002 } 1004 }
1003 1005
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
1212 1214
1213 1215
1214 void CodeGenerator::VisitUnaryOpNode(UnaryOpNode* node) { 1216 void CodeGenerator::VisitUnaryOpNode(UnaryOpNode* node) {
1215 if (node->kind() == Token::kNOT) { 1217 if (node->kind() == Token::kNOT) {
1216 // "!" cannot be overloaded, therefore inline it. 1218 // "!" cannot be overloaded, therefore inline it.
1217 GenerateLogicalNotOp(node); 1219 GenerateLogicalNotOp(node);
1218 return; 1220 return;
1219 } 1221 }
1220 node->operand()->Visit(this); 1222 node->operand()->Visit(this);
1221 if (node->kind() == Token::kADD) { 1223 if (node->kind() == Token::kADD) {
1224 // TODO(srdjan): Remove this as it is not part of Dart language any longer.
1222 // Unary operator '+' does not exist, it's a NOP, skip it. 1225 // Unary operator '+' does not exist, it's a NOP, skip it.
1223 if (!IsResultNeeded(node)) { 1226 if (!IsResultNeeded(node)) {
1224 __ popq(RAX); 1227 __ popq(RAX);
1225 } 1228 }
1226 return; 1229 return;
1227 } 1230 }
1228 MarkDeoptPoint(node->id(), node->token_index()); 1231 MarkDeoptPoint(node->id(), node->token_index());
1229 String& operator_name = String::ZoneHandle(); 1232 String& operator_name = String::ZoneHandle();
1230 if (node->kind() == Token::kSUB) { 1233 if (node->kind() == Token::kSUB) {
1231 operator_name = String::NewSymbol(Token::Str(Token::kNEGATE)); 1234 operator_name = String::NewSymbol(Token::Str(Token::kNEGATE));
(...skipping 750 matching lines...) Expand 10 before | Expand all | Expand 10 after
1982 1985
1983 // Generate inlined code for all finally blocks as we may transfer 1986 // Generate inlined code for all finally blocks as we may transfer
1984 // control out of the 'try' blocks if any. 1987 // control out of the 'try' blocks if any.
1985 for (intptr_t i = 0; i < node->inlined_finally_list_length(); i++) { 1988 for (intptr_t i = 0; i < node->inlined_finally_list_length(); i++) {
1986 node->InlinedFinallyNodeAt(i)->Visit(this); 1989 node->InlinedFinallyNodeAt(i)->Visit(this);
1987 } 1990 }
1988 1991
1989 // Unchain the context(s) up to the outer context level of the scope which 1992 // Unchain the context(s) up to the outer context level of the scope which
1990 // contains the destination label. 1993 // contains the destination label.
1991 ASSERT(label->owner() != NULL); 1994 ASSERT(label->owner() != NULL);
1992 LocalScope* outer_context_owner = label->owner()->parent();
1993 ASSERT(outer_context_owner != NULL);
1994 int target_context_level = 0; 1995 int target_context_level = 0;
1995 if (outer_context_owner->HasContextLevel()) { 1996 LocalScope* target_scope = label->owner();
1996 target_context_level = outer_context_owner->context_level(); 1997 if (target_scope->num_context_variables() > 0) {
1997 ASSERT(target_context_level >= 0); 1998 // The scope of the target label allocates a context, therefore its outer
1998 int context_level = state()->context_level(); 1999 // scope is at a lower context level.
1999 ASSERT(context_level >= target_context_level); 2000 target_context_level = target_scope->context_level() - 1;
2000 while (context_level-- > target_context_level) { 2001 } else {
2001 __ movq(CTX, FieldAddress(CTX, Context::parent_offset())); 2002 // The scope of the target label does not allocate a context, so its outer
2003 // scope is at the same context level. Find it.
2004 while ((target_scope != NULL) &&
2005 (target_scope->num_context_variables() == 0)) {
2006 target_scope = target_scope->parent();
2002 } 2007 }
2008 if (target_scope != NULL) {
2009 target_context_level = target_scope->context_level();
2010 }
2011 }
2012 ASSERT(target_context_level >= 0);
2013 int context_level = state()->context_level();
2014 ASSERT(context_level >= target_context_level);
2015 while (context_level-- > target_context_level) {
2016 __ movq(CTX, FieldAddress(CTX, Context::parent_offset()));
2003 } 2017 }
2004 2018
2005 if (node->kind() == Token::kBREAK) { 2019 if (node->kind() == Token::kBREAK) {
2006 __ jmp(label->break_label()); 2020 __ jmp(label->break_label());
2007 } else { 2021 } else {
2008 __ jmp(label->continue_label()); 2022 __ jmp(label->continue_label());
2009 } 2023 }
2010 } 2024 }
2011 2025
2012 2026
(...skipping 778 matching lines...) Expand 10 before | Expand all | Expand 10 after
2791 const Error& error = Error::Handle( 2805 const Error& error = Error::Handle(
2792 Parser::FormatError(script, token_index, "Error", format, args)); 2806 Parser::FormatError(script, token_index, "Error", format, args));
2793 va_end(args); 2807 va_end(args);
2794 Isolate::Current()->long_jump_base()->Jump(1, error); 2808 Isolate::Current()->long_jump_base()->Jump(1, error);
2795 UNREACHABLE(); 2809 UNREACHABLE();
2796 } 2810 }
2797 2811
2798 } // namespace dart 2812 } // namespace dart
2799 2813
2800 #endif // defined TARGET_ARCH_X64 2814 #endif // defined TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « runtime/vm/code_generator_ia32.cc ('k') | runtime/vm/scopes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698