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

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

Issue 15904010: Fix issue 3874: non-deterministic AST generation caused by exceptions being thrown during parsing (… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 6 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/flow_graph_inliner.cc ('k') | no next file » | 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/parser.h" 5 #include "vm/parser.h"
6 6
7 #include "lib/invocation_mirror.h" 7 #include "lib/invocation_mirror.h"
8 #include "vm/bigint_operations.h" 8 #include "vm/bigint_operations.h"
9 #include "vm/class_finalizer.h" 9 #include "vm/class_finalizer.h"
10 #include "vm/compiler.h" 10 #include "vm/compiler.h"
(...skipping 8100 matching lines...) Expand 10 before | Expand all | Expand 10 after
8111 kNumArguments, 8111 kNumArguments,
8112 Object::empty_array(), 8112 Object::empty_array(),
8113 Resolver::kIsQualified)); 8113 Resolver::kIsQualified));
8114 ASSERT(!func.IsNull()); 8114 ASSERT(!func.IsNull());
8115 ASSERT(func.kind() == RawFunction::kConstImplicitGetter); 8115 ASSERT(func.kind() == RawFunction::kConstImplicitGetter);
8116 Object& const_value = Object::Handle( 8116 Object& const_value = Object::Handle(
8117 DartEntry::InvokeFunction(func, Object::empty_array())); 8117 DartEntry::InvokeFunction(func, Object::empty_array()));
8118 if (const_value.IsError()) { 8118 if (const_value.IsError()) {
8119 const Error& error = Error::Cast(const_value); 8119 const Error& error = Error::Cast(const_value);
8120 if (error.IsUnhandledException()) { 8120 if (error.IsUnhandledException()) {
8121 // An exception may not occur in every parse attempt, i.e., the
8122 // generated AST is not deterministic. Therefore mark the function as
8123 // not optimizable.
8124 current_function().set_is_optimizable(false);
8121 field.set_value(Instance::Handle()); 8125 field.set_value(Instance::Handle());
8122 // It is a compile-time error if evaluation of a compile-time constant 8126 // It is a compile-time error if evaluation of a compile-time constant
8123 // would raise an exception. 8127 // would raise an exception.
8124 AppendErrorMsg(error, TokenPos(), 8128 AppendErrorMsg(error, TokenPos(),
8125 "error initializing const field '%s'", 8129 "error initializing const field '%s'",
8126 String::Handle(field.name()).ToCString()); 8130 String::Handle(field.name()).ToCString());
8127 } else { 8131 } else {
8128 Isolate::Current()->long_jump_base()->Jump(1, error); 8132 Isolate::Current()->long_jump_base()->Jump(1, error);
8129 } 8133 }
8130 } 8134 }
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
8174 arg_values.SetAt((i + kNumExtraArgs), arg->AsLiteralNode()->literal()); 8178 arg_values.SetAt((i + kNumExtraArgs), arg->AsLiteralNode()->literal());
8175 } 8179 }
8176 const Array& arg_descriptor = 8180 const Array& arg_descriptor =
8177 Array::Handle(ArgumentsDescriptor::New(num_arguments, 8181 Array::Handle(ArgumentsDescriptor::New(num_arguments,
8178 arguments->names())); 8182 arguments->names()));
8179 const Object& result = 8183 const Object& result =
8180 Object::Handle(DartEntry::InvokeFunction(constructor, 8184 Object::Handle(DartEntry::InvokeFunction(constructor,
8181 arg_values, 8185 arg_values,
8182 arg_descriptor)); 8186 arg_descriptor));
8183 if (result.IsError()) { 8187 if (result.IsError()) {
8188 // An exception may not occur in every parse attempt, i.e., the
8189 // generated AST is not deterministic. Therefore mark the function as
8190 // not optimizable.
8191 current_function().set_is_optimizable(false);
8184 if (result.IsUnhandledException()) { 8192 if (result.IsUnhandledException()) {
8185 return result.raw(); 8193 return result.raw();
8186 } else { 8194 } else {
8187 Isolate::Current()->long_jump_base()->Jump(1, Error::Cast(result)); 8195 Isolate::Current()->long_jump_base()->Jump(1, Error::Cast(result));
8188 UNREACHABLE(); 8196 UNREACHABLE();
8189 return Object::null(); 8197 return Object::null();
8190 } 8198 }
8191 } else { 8199 } else {
8192 if (!instance.IsNull()) { 8200 if (!instance.IsNull()) {
8193 instance ^= instance.Canonicalize(); 8201 instance ^= instance.Canonicalize();
(...skipping 1794 matching lines...) Expand 10 before | Expand all | Expand 10 after
9988 void Parser::SkipQualIdent() { 9996 void Parser::SkipQualIdent() {
9989 ASSERT(IsIdentifier()); 9997 ASSERT(IsIdentifier());
9990 ConsumeToken(); 9998 ConsumeToken();
9991 if (CurrentToken() == Token::kPERIOD) { 9999 if (CurrentToken() == Token::kPERIOD) {
9992 ConsumeToken(); // Consume the kPERIOD token. 10000 ConsumeToken(); // Consume the kPERIOD token.
9993 ExpectIdentifier("identifier expected after '.'"); 10001 ExpectIdentifier("identifier expected after '.'");
9994 } 10002 }
9995 } 10003 }
9996 10004
9997 } // namespace dart 10005 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_inliner.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698