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

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

Issue 10407018: Start porting fast typechecks to x64. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 7 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
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 "vm/bigint_operations.h" 7 #include "vm/bigint_operations.h"
8 #include "vm/class_finalizer.h" 8 #include "vm/class_finalizer.h"
9 #include "vm/compiler.h" 9 #include "vm/compiler.h"
10 #include "vm/compiler_stats.h" 10 #include "vm/compiler_stats.h"
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 229
230 DISALLOW_COPY_AND_ASSIGN(TryBlocks); 230 DISALLOW_COPY_AND_ASSIGN(TryBlocks);
231 }; 231 };
232 232
233 233
234 void Parser::TryBlocks::AddNodeForFinallyInlining(AstNode* node) { 234 void Parser::TryBlocks::AddNodeForFinallyInlining(AstNode* node) {
235 inlined_finally_nodes_.Add(node); 235 inlined_finally_nodes_.Add(node);
236 } 236 }
237 237
238 238
239 // For parsing a compilation unit.
239 Parser::Parser(const Script& script, 240 Parser::Parser(const Script& script,
240 const Library& library) 241 const Library& library)
241 : script_(script), 242 : script_(script),
242 tokens_(TokenStream::Handle(script.tokens())), 243 tokens_(TokenStream::Handle(script.tokens())),
243 token_index_(0), 244 token_index_(0),
244 current_block_(NULL), 245 current_block_(NULL),
245 is_top_level_(false), 246 is_top_level_(false),
246 current_member_(NULL), 247 current_member_(NULL),
247 allow_function_literals_(true), 248 allow_function_literals_(true),
248 current_function_(Function::Handle()), 249 current_function_(Function::Handle()),
249 current_class_(Class::Handle()), 250 current_class_(Class::Handle()),
250 library_(library), 251 library_(library),
251 try_blocks_list_(NULL), 252 try_blocks_list_(NULL),
252 expression_temp_(NULL) { 253 expression_temp_(NULL) {
253 ASSERT(!tokens_.IsNull()); 254 ASSERT(!tokens_.IsNull());
254 ASSERT(!library.IsNull()); 255 ASSERT(!library.IsNull());
255 SetPosition(0); 256 SetPosition(0);
256 } 257 }
257 258
258 259
260 // For parsing a function.
259 Parser::Parser(const Script& script, 261 Parser::Parser(const Script& script,
260 const Function& function, 262 const Function& function,
261 intptr_t token_index) 263 intptr_t token_index)
262 : script_(script), 264 : script_(script),
263 tokens_(TokenStream::Handle(script.tokens())), 265 tokens_(TokenStream::Handle(script.tokens())),
264 token_index_(0), 266 token_index_(0),
265 current_block_(NULL), 267 current_block_(NULL),
266 is_top_level_(false), 268 is_top_level_(false),
267 current_member_(NULL), 269 current_member_(NULL),
268 allow_function_literals_(true), 270 allow_function_literals_(true),
269 current_function_(function), 271 current_function_(function),
270 current_class_(Class::Handle(current_function_.owner())), 272 current_class_(Class::Handle(current_function_.owner())),
271 library_(Library::Handle(current_class_.library())), 273 library_(Library::Handle(current_class_.library())),
272 try_blocks_list_(NULL), 274 try_blocks_list_(NULL),
273 expression_temp_(NULL) { 275 expression_temp_(NULL) {
274 ASSERT(!tokens_.IsNull()); 276 ASSERT(!tokens_.IsNull());
275 ASSERT(!function.IsNull()); 277 ASSERT(!function.IsNull());
276 SetPosition(token_index); 278 SetPosition(token_index);
279 if (FLAG_enable_type_checks) {
280 EnsureExpressionTemp();
281 }
277 } 282 }
278 283
279 284
280 bool Parser::SetAllowFunctionLiterals(bool value) { 285 bool Parser::SetAllowFunctionLiterals(bool value) {
281 bool current_value = allow_function_literals_; 286 bool current_value = allow_function_literals_;
282 allow_function_literals_ = value; 287 allow_function_literals_ = value;
283 return current_value; 288 return current_value;
284 } 289 }
285 290
286 291
(...skipping 4967 matching lines...) Expand 10 before | Expand all | Expand 10 after
5254 ExpectToken(Token::kRBRACE); 5259 ExpectToken(Token::kRBRACE);
5255 5260
5256 if (!exception_param.type->IsDynamicType()) { // Has a type specification. 5261 if (!exception_param.type->IsDynamicType()) { // Has a type specification.
5257 // Now form an 'if type check' as an exception type exists in 5262 // Now form an 'if type check' as an exception type exists in
5258 // the catch specifier. 5263 // the catch specifier.
5259 if (!exception_param.type->IsInstantiated() && 5264 if (!exception_param.type->IsInstantiated() &&
5260 (current_block_->scope->function_level() > 0)) { 5265 (current_block_->scope->function_level() > 0)) {
5261 // Make sure that the instantiator is captured. 5266 // Make sure that the instantiator is captured.
5262 CaptureReceiver(); 5267 CaptureReceiver();
5263 } 5268 }
5264 AstNode* exception_type = new TypeNode(catch_pos, *exception_param.type); 5269 TypeNode* exception_type = new TypeNode(catch_pos, *exception_param.type);
5265 AstNode* exception_var = new LoadLocalNode(catch_pos, *catch_excp_var); 5270 AstNode* exception_var = new LoadLocalNode(catch_pos, *catch_excp_var);
5271 if (!exception_type->type().IsInstantiated()) {
5272 EnsureExpressionTemp();
5273 }
5266 AstNode* type_cond_expr = new ComparisonNode( 5274 AstNode* type_cond_expr = new ComparisonNode(
5267 catch_pos, Token::kIS, exception_var, exception_type); 5275 catch_pos, Token::kIS, exception_var, exception_type);
5268 current_block_->statements->Add( 5276 current_block_->statements->Add(
5269 new IfNode(catch_pos, type_cond_expr, catch_handler, NULL)); 5277 new IfNode(catch_pos, type_cond_expr, catch_handler, NULL));
5270 } else { 5278 } else {
5271 // No exception type exists in the catch specifier so execute the 5279 // No exception type exists in the catch specifier so execute the
5272 // catch handler code unconditionally. 5280 // catch handler code unconditionally.
5273 current_block_->statements->Add(catch_handler); 5281 current_block_->statements->Add(catch_handler);
5274 generic_catch_seen = true; 5282 generic_catch_seen = true;
5275 } 5283 }
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after
5835 } 5843 }
5836 right_operand = new TypeNode(type_pos, type); 5844 right_operand = new TypeNode(type_pos, type);
5837 if (type.IsMalformed()) { 5845 if (type.IsMalformed()) {
5838 // Note that a type error is thrown even if the tested value is null. 5846 // Note that a type error is thrown even if the tested value is null.
5839 return ThrowTypeError(type_pos, type); 5847 return ThrowTypeError(type_pos, type);
5840 } 5848 }
5841 } 5849 }
5842 if (Token::IsRelationalOperator(op_kind) 5850 if (Token::IsRelationalOperator(op_kind)
5843 || Token::IsInstanceofOperator(op_kind) 5851 || Token::IsInstanceofOperator(op_kind)
5844 || Token::IsEqualityOperator(op_kind)) { 5852 || Token::IsEqualityOperator(op_kind)) {
5853 if (Token::IsInstanceofOperator(op_kind)) {
5854 if (!right_operand->AsTypeNode()->type().IsInstantiated()) {
5855 EnsureExpressionTemp();
5856 }
5857 }
5845 left_operand = new ComparisonNode( 5858 left_operand = new ComparisonNode(
5846 op_pos, op_kind, left_operand, right_operand); 5859 op_pos, op_kind, left_operand, right_operand);
5847 break; // Equality and relational operators cannot be chained. 5860 break; // Equality and relational operators cannot be chained.
5848 } else { 5861 } else {
5849 StringConcatNode* str_concat = NULL; 5862 StringConcatNode* str_concat = NULL;
5850 if (op_kind == Token::kADD) { 5863 if (op_kind == Token::kADD) {
5851 if (left_operand->IsLiteralNode()) { 5864 if (left_operand->IsLiteralNode()) {
5852 LiteralNode* lit = left_operand->AsLiteralNode(); 5865 LiteralNode* lit = left_operand->AsLiteralNode();
5853 if (lit->literal().IsString()) { 5866 if (lit->literal().IsString()) {
5854 if (FLAG_allow_string_plus) { 5867 if (FLAG_allow_string_plus) {
(...skipping 2608 matching lines...) Expand 10 before | Expand all | Expand 10 after
8463 void Parser::SkipQualIdent() { 8476 void Parser::SkipQualIdent() {
8464 ASSERT(IsIdentifier()); 8477 ASSERT(IsIdentifier());
8465 ConsumeToken(); 8478 ConsumeToken();
8466 if (CurrentToken() == Token::kPERIOD) { 8479 if (CurrentToken() == Token::kPERIOD) {
8467 ConsumeToken(); // Consume the kPERIOD token. 8480 ConsumeToken(); // Consume the kPERIOD token.
8468 ExpectIdentifier("identifier expected after '.'"); 8481 ExpectIdentifier("identifier expected after '.'");
8469 } 8482 }
8470 } 8483 }
8471 8484
8472 } // namespace dart 8485 } // namespace dart
OLDNEW
« runtime/vm/flow_graph_builder.cc ('K') | « runtime/vm/intermediate_language.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698