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

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

Issue 10928160: Limit the maximum number of formal parameters (32K fixed and 32K optional) (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 3 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/class_finalizer.cc ('k') | runtime/vm/compiler.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) 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 "platform/assert.h" 5 #include "platform/assert.h"
6 #include "vm/globals.h" 6 #include "vm/globals.h"
7 #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64) 7 #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64)
8 8
9 #include "vm/ast.h" 9 #include "vm/ast.h"
10 #include "vm/assembler.h" 10 #include "vm/assembler.h"
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 const int num_opt_params = 1; 209 const int num_opt_params = 1;
210 const int num_params = num_fixed_params + num_opt_params; 210 const int num_params = num_fixed_params + num_opt_params;
211 LocalScope* local_scope = node_seq->scope(); 211 LocalScope* local_scope = node_seq->scope();
212 local_scope->AddVariable(NewTestLocalVariable("a")); 212 local_scope->AddVariable(NewTestLocalVariable("a"));
213 local_scope->AddVariable(NewTestLocalVariable("b")); 213 local_scope->AddVariable(NewTestLocalVariable("b"));
214 ASSERT(local_scope->num_variables() == num_params); 214 ASSERT(local_scope->num_variables() == num_params);
215 const Array& default_values = Array::ZoneHandle(Array::New(num_opt_params)); 215 const Array& default_values = Array::ZoneHandle(Array::New(num_opt_params));
216 default_values.SetAt(0, Smi::ZoneHandle(Smi::New(1))); // b = 1. 216 default_values.SetAt(0, Smi::ZoneHandle(Smi::New(1))); // b = 1.
217 test->set_default_parameter_values(default_values); 217 test->set_default_parameter_values(default_values);
218 const Function& function = test->function(); 218 const Function& function = test->function();
219 function.SetNumberOfParameters(num_fixed_params, num_opt_params, true); 219 function.set_num_fixed_parameters(num_fixed_params);
220 function.SetNumOptionalParameters(num_opt_params, true);
220 const bool has_opt_params = true; 221 const bool has_opt_params = true;
221 const String& native_name = 222 const String& native_name =
222 String::ZoneHandle(Symbols::New("TestSmiSub")); 223 String::ZoneHandle(Symbols::New("TestSmiSub"));
223 NativeFunction native_function = 224 NativeFunction native_function =
224 reinterpret_cast<NativeFunction>(TestSmiSub); 225 reinterpret_cast<NativeFunction>(TestSmiSub);
225 node_seq->Add(new ReturnNode(kPos, 226 node_seq->Add(new ReturnNode(kPos,
226 new NativeBodyNode(kPos, 227 new NativeBodyNode(kPos,
227 native_name, 228 native_name,
228 native_function, 229 native_function,
229 num_params, 230 num_params,
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 local_scope->AddVariable(NewTestLocalVariable("c")); 380 local_scope->AddVariable(NewTestLocalVariable("c"));
380 local_scope->AddVariable(NewTestLocalVariable("d")); 381 local_scope->AddVariable(NewTestLocalVariable("d"));
381 local_scope->AddVariable(NewTestLocalVariable("e")); 382 local_scope->AddVariable(NewTestLocalVariable("e"));
382 ASSERT(local_scope->num_variables() == num_params); 383 ASSERT(local_scope->num_variables() == num_params);
383 const Array& default_values = Array::ZoneHandle(Array::New(num_opt_params)); 384 const Array& default_values = Array::ZoneHandle(Array::New(num_opt_params));
384 default_values.SetAt(0, Smi::ZoneHandle(Smi::New(10))); 385 default_values.SetAt(0, Smi::ZoneHandle(Smi::New(10)));
385 default_values.SetAt(1, Smi::ZoneHandle(Smi::New(21))); 386 default_values.SetAt(1, Smi::ZoneHandle(Smi::New(21)));
386 default_values.SetAt(2, Smi::ZoneHandle(Smi::New(-32))); 387 default_values.SetAt(2, Smi::ZoneHandle(Smi::New(-32)));
387 test->set_default_parameter_values(default_values); 388 test->set_default_parameter_values(default_values);
388 const Function& function = test->function(); 389 const Function& function = test->function();
389 function.SetNumberOfParameters(num_fixed_params, num_opt_params, true); 390 function.set_num_fixed_parameters(num_fixed_params);
391 function.SetNumOptionalParameters(num_opt_params, true);
390 function.set_parameter_types(Array::Handle(Array::New(num_params))); 392 function.set_parameter_types(Array::Handle(Array::New(num_params)));
391 function.set_parameter_names(Array::Handle(Array::New(num_params))); 393 function.set_parameter_names(Array::Handle(Array::New(num_params)));
392 const Type& param_type = Type::Handle(Type::DynamicType()); 394 const Type& param_type = Type::Handle(Type::DynamicType());
393 for (int i = 0; i < num_params - 1; i++) { 395 for (int i = 0; i < num_params - 1; i++) {
394 function.SetParameterTypeAt(i, param_type); 396 function.SetParameterTypeAt(i, param_type);
395 } 397 }
396 const bool has_opt_params = true; 398 const bool has_opt_params = true;
397 const String& native_name = 399 const String& native_name =
398 String::ZoneHandle(Symbols::New("TestSmiSum")); 400 String::ZoneHandle(Symbols::New("TestSmiSum"));
399 NativeFunction native_function = 401 NativeFunction native_function =
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 app_lib ^= libs.At(num_libs - 1); 511 app_lib ^= libs.At(num_libs - 1);
510 ASSERT(!app_lib.IsNull()); 512 ASSERT(!app_lib.IsNull());
511 const Class& cls = Class::Handle( 513 const Class& cls = Class::Handle(
512 app_lib.LookupClass(String::Handle(Symbols::New("A")))); 514 app_lib.LookupClass(String::Handle(Symbols::New("A"))));
513 EXPECT_EQ(cls.raw(), result.clazz()); 515 EXPECT_EQ(cls.raw(), result.clazz());
514 } 516 }
515 517
516 } // namespace dart 518 } // namespace dart
517 519
518 #endif // defined TARGET_ARCH_IA32 || defined(TARGET_ARCH_X64) 520 #endif // defined TARGET_ARCH_IA32 || defined(TARGET_ARCH_X64)
OLDNEW
« no previous file with comments | « runtime/vm/class_finalizer.cc ('k') | runtime/vm/compiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698