| Index: runtime/vm/code_generator_test.cc
|
| diff --git a/runtime/vm/code_generator_test.cc b/runtime/vm/code_generator_test.cc
|
| index aac931182efef3aaf06d2dee6e4ee46e50fc83b1..2cdc6fbcc24c54ef5521f4a67a6e3301659bfeac 100644
|
| --- a/runtime/vm/code_generator_test.cc
|
| +++ b/runtime/vm/code_generator_test.cc
|
| @@ -192,58 +192,6 @@ CODEGEN_TEST_GENERATE(BinaryOpCodegen, test) {
|
| CODEGEN_TEST_RUN(BinaryOpCodegen, Double::New(2.5));
|
|
|
|
|
| -// Tested Dart code:
|
| -// int dec(int a, [int b = 1]) native: "TestSmiSub";
|
| -// The native entry TestSmiSub implements dec natively.
|
| -CODEGEN_TEST_GENERATE(NativeDecCodegen, test) {
|
| - // A NativeBodyNode, preceded by an EnterNode and followed by a ReturnNode,
|
| - // implements the body of a native Dart function. Let's take this native
|
| - // function as an example: int dec(int a, int b = 1) native;
|
| - // Since this function has an optional parameter, its prologue will copy
|
| - // incoming parameters to locals.
|
| - SequenceNode* node_seq = test->node_sequence();
|
| - const int num_fixed_params = 1;
|
| - const int num_opt_params = 1;
|
| - const int num_params = num_fixed_params + num_opt_params;
|
| - LocalScope* local_scope = node_seq->scope();
|
| - local_scope->InsertParameterAt(0, NewTestLocalVariable("a"));
|
| - local_scope->InsertParameterAt(1, NewTestLocalVariable("b"));
|
| - ASSERT(local_scope->num_variables() == num_params);
|
| - ZoneGrowableArray<const Instance*>* default_values =
|
| - new ZoneGrowableArray<const Instance*>(num_opt_params);
|
| - default_values->Add(&Smi::ZoneHandle(Smi::New(1))); // b = 1.
|
| - test->set_default_parameter_values(default_values);
|
| - const Function& function = test->function();
|
| - function.set_is_native(true);
|
| - function.set_num_fixed_parameters(num_fixed_params);
|
| - function.SetNumOptionalParameters(num_opt_params, true);
|
| - const String& native_name =
|
| - String::ZoneHandle(Symbols::New("TestSmiSub"));
|
| - NativeFunction native_function =
|
| - reinterpret_cast<NativeFunction>(TestSmiSub);
|
| - node_seq->Add(
|
| - new ReturnNode(kPos,
|
| - new NativeBodyNode(kPos,
|
| - function,
|
| - native_name,
|
| - native_function,
|
| - local_scope,
|
| - false /* not bootstrap native */)));
|
| -}
|
| -
|
| -
|
| -// Tested Dart code:
|
| -// return dec(5);
|
| -CODEGEN_TEST2_GENERATE(StaticDecCallCodegen, function, test) {
|
| - SequenceNode* node_seq = test->node_sequence();
|
| - ArgumentListNode* arguments = new ArgumentListNode(kPos);
|
| - arguments->Add(new LiteralNode(kPos, Smi::ZoneHandle(Smi::New(5))));
|
| - node_seq->Add(new ReturnNode(kPos,
|
| - new StaticCallNode(kPos, function, arguments)));
|
| -}
|
| -CODEGEN_TEST2_RUN(StaticDecCallCodegen, NativeDecCodegen, Smi::New(4))
|
| -
|
| -
|
| CODEGEN_TEST_GENERATE(SmiUnaryOpCodegen, test) {
|
| SequenceNode* node_seq = test->node_sequence();
|
| LiteralNode* a = new LiteralNode(kPos, Smi::ZoneHandle(Smi::New(12)));
|
| @@ -368,159 +316,6 @@ CODEGEN_TEST_GENERATE(InstanceCallCodegen, test) {
|
| CODEGEN_TEST_RUN(InstanceCallCodegen, Smi::New(42))
|
|
|
|
|
| -// Tested Dart code:
|
| -// int sum(int a, int b,
|
| -// [int c = 10, int d = 21, int e = -32]) native: "TestSmiSum";
|
| -// The native entry TestSmiSum implements sum natively.
|
| -CODEGEN_TEST_GENERATE(NativeSumCodegen, test) {
|
| - SequenceNode* node_seq = test->node_sequence();
|
| - const int num_fixed_params = 2;
|
| - const int num_opt_params = 3;
|
| - const int num_params = num_fixed_params + num_opt_params;
|
| - LocalScope* local_scope = node_seq->scope();
|
| - local_scope->InsertParameterAt(0, NewTestLocalVariable("a"));
|
| - local_scope->InsertParameterAt(1, NewTestLocalVariable("b"));
|
| - local_scope->InsertParameterAt(2, NewTestLocalVariable("c"));
|
| - local_scope->InsertParameterAt(3, NewTestLocalVariable("d"));
|
| - local_scope->InsertParameterAt(4, NewTestLocalVariable("e"));
|
| - ASSERT(local_scope->num_variables() == num_params);
|
| - ZoneGrowableArray<const Instance*>* default_values =
|
| - new ZoneGrowableArray<const Instance*>(num_opt_params);
|
| - default_values->Add(&Smi::ZoneHandle(Smi::New(10)));
|
| - default_values->Add(&Smi::ZoneHandle(Smi::New(21)));
|
| - default_values->Add(&Smi::ZoneHandle(Smi::New(-32)));
|
| - test->set_default_parameter_values(default_values);
|
| - const Function& function = test->function();
|
| - function.set_is_native(true);
|
| - function.set_num_fixed_parameters(num_fixed_params);
|
| - function.SetNumOptionalParameters(num_opt_params, true);
|
| - function.set_parameter_types(Array::Handle(Array::New(num_params)));
|
| - function.set_parameter_names(Array::Handle(Array::New(num_params)));
|
| - const Type& param_type = Type::Handle(Type::DynamicType());
|
| - for (int i = 0; i < num_params; i++) {
|
| - function.SetParameterTypeAt(i, param_type);
|
| - }
|
| - const String& native_name =
|
| - String::ZoneHandle(Symbols::New("TestSmiSum"));
|
| - NativeFunction native_function =
|
| - reinterpret_cast<NativeFunction>(TestSmiSum);
|
| - node_seq->Add(
|
| - new ReturnNode(kPos,
|
| - new NativeBodyNode(kPos,
|
| - function,
|
| - native_name,
|
| - native_function,
|
| - local_scope,
|
| - false /* Not bootstrap native */)));
|
| -}
|
| -
|
| -
|
| -// Tested Dart code, calling function sum declared above:
|
| -// return sum(1, 3);
|
| -// Optional arguments are not passed and hence are set to their default values.
|
| -CODEGEN_TEST2_GENERATE(StaticSumCallNoOptCodegen, function, test) {
|
| - SequenceNode* node_seq = test->node_sequence();
|
| - ArgumentListNode* arguments = new ArgumentListNode(kPos);
|
| - arguments->Add(new LiteralNode(kPos, Smi::ZoneHandle(Smi::New(1))));
|
| - arguments->Add(new LiteralNode(kPos, Smi::ZoneHandle(Smi::New(3))));
|
| - node_seq->Add(new ReturnNode(kPos,
|
| - new StaticCallNode(kPos, function, arguments)));
|
| -}
|
| -CODEGEN_TEST2_RUN(StaticSumCallNoOptCodegen,
|
| - NativeSumCodegen,
|
| - Smi::New(1 + 3 + 10 + 21 - 32))
|
| -
|
| -
|
| -// Tested Dart code, calling function sum declared above:
|
| -// return sum(1, 3, 5);
|
| -// Only one out of three optional arguments is passed in; the second and third
|
| -// arguments are hence set to their default values.
|
| -CODEGEN_TEST2_GENERATE(StaticSumCallOneOptCodegen, function, test) {
|
| - SequenceNode* node_seq = test->node_sequence();
|
| - ArgumentListNode* arguments = new ArgumentListNode(kPos);
|
| - arguments->Add(new LiteralNode(kPos, Smi::ZoneHandle(Smi::New(1))));
|
| - arguments->Add(new LiteralNode(kPos, Smi::ZoneHandle(Smi::New(3))));
|
| - arguments->Add(new LiteralNode(kPos, Smi::ZoneHandle(Smi::New(5))));
|
| - node_seq->Add(new ReturnNode(kPos,
|
| - new StaticCallNode(kPos, function, arguments)));
|
| -}
|
| -CODEGEN_TEST2_RUN(StaticSumCallOneOptCodegen,
|
| - NativeSumCodegen,
|
| - Smi::New(1 + 3 + 5 + 21 - 32))
|
| -
|
| -
|
| -// Tested Dart code, calling function sum declared above:
|
| -// return sum(0, 1, 1, 2, 3);
|
| -// Optional arguments are passed in.
|
| -CODEGEN_TEST2_GENERATE(StaticSumCallTenFiboCodegen, function, test) {
|
| - SequenceNode* node_seq = test->node_sequence();
|
| - ArgumentListNode* arguments = new ArgumentListNode(kPos);
|
| - arguments->Add(new LiteralNode(kPos, Smi::ZoneHandle(Smi::New(0))));
|
| - arguments->Add(new LiteralNode(kPos, Smi::ZoneHandle(Smi::New(1))));
|
| - arguments->Add(new LiteralNode(kPos, Smi::ZoneHandle(Smi::New(1))));
|
| - arguments->Add(new LiteralNode(kPos, Smi::ZoneHandle(Smi::New(2))));
|
| - arguments->Add(new LiteralNode(kPos, Smi::ZoneHandle(Smi::New(3))));
|
| - node_seq->Add(new ReturnNode(kPos,
|
| - new StaticCallNode(kPos, function, arguments)));
|
| -}
|
| -CODEGEN_TEST2_RUN(
|
| - StaticSumCallTenFiboCodegen,
|
| - NativeSumCodegen,
|
| - Smi::New(0 + 1 + 1 + 2 + 3))
|
| -
|
| -
|
| -// Tested Dart code:
|
| -// int sum(a, b, c) native: "TestNonNullSmiSum";
|
| -// The native entry TestNonNullSmiSum implements sum natively.
|
| -CODEGEN_TEST_GENERATE(NativeNonNullSumCodegen, test) {
|
| - SequenceNode* node_seq = test->node_sequence();
|
| - const int num_params = 3;
|
| - LocalScope* local_scope = node_seq->scope();
|
| - local_scope->InsertParameterAt(0, NewTestLocalVariable("a"));
|
| - local_scope->InsertParameterAt(1, NewTestLocalVariable("b"));
|
| - local_scope->InsertParameterAt(2, NewTestLocalVariable("c"));
|
| - ASSERT(local_scope->num_variables() == num_params);
|
| - const Function& function = test->function();
|
| - function.set_is_native(true);
|
| - function.set_num_fixed_parameters(num_params);
|
| - ASSERT(!function.HasOptionalParameters());
|
| - function.set_parameter_types(Array::Handle(Array::New(num_params)));
|
| - function.set_parameter_names(Array::Handle(Array::New(num_params)));
|
| - const Type& param_type = Type::Handle(Type::DynamicType());
|
| - for (int i = 0; i < num_params; i++) {
|
| - function.SetParameterTypeAt(i, param_type);
|
| - }
|
| - const String& native_name =
|
| - String::ZoneHandle(Symbols::New("TestNonNullSmiSum"));
|
| - NativeFunction native_function =
|
| - reinterpret_cast<NativeFunction>(TestNonNullSmiSum);
|
| - node_seq->Add(
|
| - new ReturnNode(kPos,
|
| - new NativeBodyNode(kPos,
|
| - function,
|
| - native_name,
|
| - native_function,
|
| - local_scope,
|
| - false /* Not bootstrap native */)));
|
| -}
|
| -
|
| -
|
| -// Tested Dart code, calling function sum declared above:
|
| -// return sum(1, null, 3);
|
| -CODEGEN_TEST2_GENERATE(StaticNonNullSumCallCodegen, function, test) {
|
| - SequenceNode* node_seq = test->node_sequence();
|
| - ArgumentListNode* arguments = new ArgumentListNode(kPos);
|
| - arguments->Add(new LiteralNode(kPos, Smi::ZoneHandle(Smi::New(1))));
|
| - arguments->Add(new LiteralNode(kPos, Instance::ZoneHandle()));
|
| - arguments->Add(new LiteralNode(kPos, Smi::ZoneHandle(Smi::New(3))));
|
| - node_seq->Add(new ReturnNode(kPos,
|
| - new StaticCallNode(kPos, function, arguments)));
|
| -}
|
| -CODEGEN_TEST2_RUN(StaticNonNullSumCallCodegen,
|
| - NativeNonNullSumCodegen,
|
| - Smi::New(1 + 3))
|
| -
|
| -
|
| // Test allocation of dart objects.
|
| CODEGEN_TEST_GENERATE(AllocateNewObjectCodegen, test) {
|
| const char* kScriptChars =
|
|
|