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

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

Issue 9693020: Optional arguments in new compiler. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/vm/code_generator_x64.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_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"
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 num_copied_params + parsed_function_.stack_local_count(); 362 num_copied_params + parsed_function_.stack_local_count();
363 set_locals_space_size(stack_slot_count * kWordSize); 363 set_locals_space_size(stack_slot_count * kWordSize);
364 __ EnterFrame(locals_space_size()); 364 __ EnterFrame(locals_space_size());
365 365
366 // 2. Optionally check if the number of arguments matches. We check the 366 // 2. Optionally check if the number of arguments matches. We check the
367 // number of passed arguments when we have to copy them due to the 367 // number of passed arguments when we have to copy them due to the
368 // presence of optional named parameters. No such checking code is 368 // presence of optional named parameters. No such checking code is
369 // generated if only fixed parameters are declared, unless we are in debug 369 // generated if only fixed parameters are declared, unless we are in debug
370 // mode or unless we are compiling a closure. 370 // mode or unless we are compiling a closure.
371 if (num_copied_params == 0) { 371 if (num_copied_params == 0) {
372 ASSERT(num_opt_params == 0);
372 #if defined(DEBUG) 373 #if defined(DEBUG)
373 const bool check_arguments = true; // Always check arguments in debug mode. 374 const bool check_arguments = true; // Always check arguments in debug mode.
374 #else 375 #else
375 // The number of arguments passed to closure functions must always be 376 // The number of arguments passed to closure functions must always be
376 // checked here, because no resolving stub (normally responsible for the 377 // checked here, because no resolving stub (normally responsible for the
377 // check) is involved in closure calls. 378 // check) is involved in closure calls.
378 const bool check_arguments = function.IsClosureFunction(); 379 const bool check_arguments = function.IsClosureFunction();
379 #endif 380 #endif
380 if (check_arguments) { 381 if (check_arguments) {
381 // Check that num_fixed <= argc <= num_params. 382 // Check that num_fixed <= argc <= num_params.
382 Label argc_in_range; 383 Label argc_in_range;
383 // Total number of args is the first Smi in args descriptor array (EDX). 384 // Total number of args is the first Smi in args descriptor array (EDX).
384 __ movl(EAX, FieldAddress(EDX, Array::data_offset())); 385 __ movl(EAX, FieldAddress(EDX, Array::data_offset()));
385 if (num_opt_params == 0) { 386 __ cmpl(EAX, Immediate(Smi::RawValue(num_fixed_params)));
386 __ cmpl(EAX, Immediate(Smi::RawValue(num_fixed_params))); 387 __ j(EQUAL, &argc_in_range, Assembler::kNearJump);
387 __ j(EQUAL, &argc_in_range, Assembler::kNearJump);
388 } else {
389 __ subl(EAX, Immediate(Smi::RawValue(num_fixed_params)));
390 __ cmpl(EAX, Immediate(Smi::RawValue(num_opt_params)));
391 __ j(BELOW_EQUAL, &argc_in_range, Assembler::kNearJump);
392 }
393 if (function.IsClosureFunction()) { 388 if (function.IsClosureFunction()) {
394 GenerateCallRuntime(AstNode::kNoId, 389 GenerateCallRuntime(AstNode::kNoId,
395 0, 390 0,
396 kClosureArgumentMismatchRuntimeEntry); 391 kClosureArgumentMismatchRuntimeEntry);
397 } else { 392 } else {
398 __ Stop("Wrong number of arguments"); 393 __ Stop("Wrong number of arguments");
399 } 394 }
400 __ Bind(&argc_in_range); 395 __ Bind(&argc_in_range);
401 } 396 }
402 } else { 397 } else {
(...skipping 2255 matching lines...) Expand 10 before | Expand all | Expand 10 after
2658 const Error& error = Error::Handle( 2653 const Error& error = Error::Handle(
2659 Parser::FormatError(script, token_index, "Error", format, args)); 2654 Parser::FormatError(script, token_index, "Error", format, args));
2660 va_end(args); 2655 va_end(args);
2661 Isolate::Current()->long_jump_base()->Jump(1, error); 2656 Isolate::Current()->long_jump_base()->Jump(1, error);
2662 UNREACHABLE(); 2657 UNREACHABLE();
2663 } 2658 }
2664 2659
2665 } // namespace dart 2660 } // namespace dart
2666 2661
2667 #endif // defined TARGET_ARCH_IA32 2662 #endif // defined TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/code_generator_x64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698