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

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

Issue 12335102: Compile and simulate first dart function on arm generated from ast. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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
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) || \
8 defined(TARGET_ARCH_X64) || \
9 defined(TARGET_ARCH_ARM)
8 10
9 #include "vm/ast.h" 11 #include "vm/ast.h"
10 #include "vm/assembler.h" 12 #include "vm/assembler.h"
11 #include "vm/class_finalizer.h" 13 #include "vm/class_finalizer.h"
12 #include "vm/code_generator.h" 14 #include "vm/code_generator.h"
13 #include "vm/compiler.h" 15 #include "vm/compiler.h"
14 #include "vm/dart_entry.h" 16 #include "vm/dart_entry.h"
15 #include "vm/native_entry.h" 17 #include "vm/native_entry.h"
16 #include "vm/native_entry_test.h" 18 #include "vm/native_entry_test.h"
17 #include "vm/symbols.h" 19 #include "vm/symbols.h"
18 #include "vm/unit_test.h" 20 #include "vm/unit_test.h"
19 #include "vm/virtual_memory.h" 21 #include "vm/virtual_memory.h"
20 22
21 namespace dart { 23 namespace dart {
22 24
23 static const intptr_t kPos = Scanner::kDummyTokenIndex; 25 static const intptr_t kPos = Scanner::kDummyTokenIndex;
24 26
25 27
26 // Helper to allocate and return a LocalVariable.
27 static LocalVariable* NewTestLocalVariable(const char* name) {
28 const String& variable_name = String::ZoneHandle(Symbols::New(name));
29 const Type& variable_type = Type::ZoneHandle(Type::DynamicType());
30 return new LocalVariable(kPos, variable_name, variable_type);
31 }
32
33
34 CODEGEN_TEST_GENERATE(SimpleReturnCodegen, test) { 28 CODEGEN_TEST_GENERATE(SimpleReturnCodegen, test) {
35 test->node_sequence()->Add(new ReturnNode(kPos)); 29 test->node_sequence()->Add(new ReturnNode(kPos));
36 } 30 }
37 CODEGEN_TEST_RUN(SimpleReturnCodegen, Instance::null()) 31 CODEGEN_TEST_RUN(SimpleReturnCodegen, Instance::null())
38 32
39 33
34 #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64)
35
36
40 CODEGEN_TEST_GENERATE(SmiReturnCodegen, test) { 37 CODEGEN_TEST_GENERATE(SmiReturnCodegen, test) {
41 LiteralNode* l = new LiteralNode(kPos, Smi::ZoneHandle(Smi::New(3))); 38 LiteralNode* l = new LiteralNode(kPos, Smi::ZoneHandle(Smi::New(3)));
42 test->node_sequence()->Add(new ReturnNode(kPos, l)); 39 test->node_sequence()->Add(new ReturnNode(kPos, l));
43 } 40 }
44 CODEGEN_TEST_RUN(SmiReturnCodegen, Smi::New(3)) 41 CODEGEN_TEST_RUN(SmiReturnCodegen, Smi::New(3))
45 42
46 43
47 CODEGEN_TEST2_GENERATE(SimpleStaticCallCodegen, function, test) { 44 CODEGEN_TEST2_GENERATE(SimpleStaticCallCodegen, function, test) {
48 // Wrap the SmiReturnCodegen test above as a static function and call it. 45 // Wrap the SmiReturnCodegen test above as a static function and call it.
49 ArgumentListNode* no_arguments = new ArgumentListNode(kPos); 46 ArgumentListNode* no_arguments = new ArgumentListNode(kPos);
50 test->node_sequence()->Add( 47 test->node_sequence()->Add(
51 new ReturnNode(kPos, new StaticCallNode(kPos, function, no_arguments))); 48 new ReturnNode(kPos, new StaticCallNode(kPos, function, no_arguments)));
52 } 49 }
53 CODEGEN_TEST2_RUN(SimpleStaticCallCodegen, SmiReturnCodegen, Smi::New(3)) 50 CODEGEN_TEST2_RUN(SimpleStaticCallCodegen, SmiReturnCodegen, Smi::New(3))
54 51
55 52
53 // Helper to allocate and return a LocalVariable.
54 static LocalVariable* NewTestLocalVariable(const char* name) {
55 const String& variable_name = String::ZoneHandle(Symbols::New(name));
56 const Type& variable_type = Type::ZoneHandle(Type::DynamicType());
57 return new LocalVariable(kPos, variable_name, variable_type);
58 }
59
60
56 CODEGEN_TEST_GENERATE(ReturnParameterCodegen, test) { 61 CODEGEN_TEST_GENERATE(ReturnParameterCodegen, test) {
57 SequenceNode* node_seq = test->node_sequence(); 62 SequenceNode* node_seq = test->node_sequence();
58 const int num_params = 1; 63 const int num_params = 1;
59 LocalVariable* parameter = NewTestLocalVariable("parameter"); 64 LocalVariable* parameter = NewTestLocalVariable("parameter");
60 LocalScope* local_scope = node_seq->scope(); 65 LocalScope* local_scope = node_seq->scope();
61 local_scope->AddVariable(parameter); 66 local_scope->AddVariable(parameter);
62 ASSERT(local_scope->num_variables() == num_params); 67 ASSERT(local_scope->num_variables() == num_params);
63 const Function& function = test->function(); 68 const Function& function = test->function();
64 function.set_num_fixed_parameters(num_params); 69 function.set_num_fixed_parameters(num_params);
65 ASSERT(!function.HasOptionalParameters()); 70 ASSERT(!function.HasOptionalParameters());
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 // App lib is the last one that was loaded. 558 // App lib is the last one that was loaded.
554 intptr_t num_libs = libs.Length(); 559 intptr_t num_libs = libs.Length();
555 Library& app_lib = Library::Handle(); 560 Library& app_lib = Library::Handle();
556 app_lib ^= libs.At(num_libs - 1); 561 app_lib ^= libs.At(num_libs - 1);
557 ASSERT(!app_lib.IsNull()); 562 ASSERT(!app_lib.IsNull());
558 const Class& cls = Class::Handle( 563 const Class& cls = Class::Handle(
559 app_lib.LookupClass(String::Handle(Symbols::New("A")))); 564 app_lib.LookupClass(String::Handle(Symbols::New("A"))));
560 EXPECT_EQ(cls.raw(), result.clazz()); 565 EXPECT_EQ(cls.raw(), result.clazz());
561 } 566 }
562 567
568 #endif
srdjan 2013/02/26 23:23:09 Add comment to both endif-s what they are (similar
regis 2013/02/27 00:19:26 Done.
569
563 } // namespace dart 570 } // namespace dart
564 571
565 #endif // defined TARGET_ARCH_IA32 || defined(TARGET_ARCH_X64) 572 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698