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

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

Issue 221133002: Begins work on ARM64, first assembler test. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: adds files Created 6 years, 8 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/unit_test.h ('k') | runtime/vm/vm_sources.gypi » ('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/unit_test.h"
6
5 #include <stdio.h> 7 #include <stdio.h>
6 8
7 #include "vm/unit_test.h"
8
9 #include "bin/builtin.h" 9 #include "bin/builtin.h"
10 #include "bin/dartutils.h" 10 #include "bin/dartutils.h"
11 11
12 #include "platform/globals.h"
12 #include "vm/assembler.h" 13 #include "vm/assembler.h"
13 #include "vm/ast_printer.h" 14 #include "vm/ast_printer.h"
14 #include "vm/compiler.h" 15 #include "vm/compiler.h"
15 #include "vm/dart_api_impl.h" 16 #include "vm/dart_api_impl.h"
16 #include "vm/disassembler.h" 17 #include "vm/disassembler.h"
17 #include "vm/parser.h" 18 #include "vm/parser.h"
18 #include "vm/symbols.h" 19 #include "vm/symbols.h"
19 #include "vm/virtual_memory.h" 20 #include "vm/virtual_memory.h"
20 21
21 using dart::bin::Builtin; 22 using dart::bin::Builtin;
22 using dart::bin::DartUtils; 23 using dart::bin::DartUtils;
23 24
24 namespace dart { 25 namespace dart {
25 26
26 DECLARE_FLAG(bool, disassemble); 27 DECLARE_FLAG(bool, disassemble);
27 28
28
29 TestCaseBase* TestCaseBase::first_ = NULL; 29 TestCaseBase* TestCaseBase::first_ = NULL;
30 TestCaseBase* TestCaseBase::tail_ = NULL; 30 TestCaseBase* TestCaseBase::tail_ = NULL;
31 31
32 32
33 TestCaseBase::TestCaseBase(const char* name) : next_(NULL), name_(name) { 33 TestCaseBase::TestCaseBase(const char* name) : next_(NULL), name_(name) {
34 if (first_ == NULL) { 34 if (first_ == NULL) {
35 first_ = this; 35 first_ = this;
36 } else { 36 } else {
37 tail_->next_ = this; 37 tail_->next_ = this;
38 } 38 }
39 tail_ = this; 39 tail_ = this;
40 } 40 }
41 41
42 42
43 void TestCaseBase::RunAll() { 43 void TestCaseBase::RunAll() {
44 TestCaseBase* test = first_; 44 TestCaseBase* test = first_;
45 while (test != NULL) { 45 while (test != NULL) {
46 test->RunTest(); 46 test->RunTest();
47 test = test->next_; 47 test = test->next_;
48 } 48 }
49 } 49 }
50 50
51 // TODO(zra): Remove when tests that need these functions are ready to enable.
52 #if !defined(TARGET_ARCH_ARM64)
51 53
52 static Dart_Handle LibraryTagHandler(Dart_LibraryTag tag, 54 static Dart_Handle LibraryTagHandler(Dart_LibraryTag tag,
53 Dart_Handle library, 55 Dart_Handle library,
54 Dart_Handle url) { 56 Dart_Handle url) {
55 if (!Dart_IsLibrary(library)) { 57 if (!Dart_IsLibrary(library)) {
56 return Dart_NewApiError("not a library"); 58 return Dart_NewApiError("not a library");
57 } 59 }
58 if (!Dart_IsString(url)) { 60 if (!Dart_IsString(url)) {
59 return Dart_NewApiError("url is not a string"); 61 return Dart_NewApiError("url is not a string");
60 } 62 }
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 137
136 Dart_Handle TestCase::library_handler(Dart_LibraryTag tag, 138 Dart_Handle TestCase::library_handler(Dart_LibraryTag tag,
137 Dart_Handle library, 139 Dart_Handle library,
138 Dart_Handle url) { 140 Dart_Handle url) {
139 if (tag == Dart_kCanonicalizeUrl) { 141 if (tag == Dart_kCanonicalizeUrl) {
140 return url; 142 return url;
141 } 143 }
142 return Api::Success(); 144 return Api::Success();
143 } 145 }
144 146
147 #endif
145 148
146 void AssemblerTest::Assemble() { 149 void AssemblerTest::Assemble() {
147 const String& function_name = String::ZoneHandle(Symbols::New(name_)); 150 const String& function_name = String::ZoneHandle(Symbols::New(name_));
148 const Class& cls = Class::ZoneHandle( 151 const Class& cls = Class::ZoneHandle(
149 Class::New(function_name, Script::Handle(), Scanner::kNoSourcePos)); 152 Class::New(function_name, Script::Handle(), Scanner::kNoSourcePos));
150 const Library& lib = Library::ZoneHandle(Library::New(function_name)); 153 const Library& lib = Library::ZoneHandle(Library::New(function_name));
151 cls.set_library(lib); 154 cls.set_library(lib);
152 Function& function = Function::ZoneHandle( 155 Function& function = Function::ZoneHandle(
153 Function::New(function_name, RawFunction::kRegularFunction, 156 Function::New(function_name, RawFunction::kRegularFunction,
154 true, false, false, false, false, cls, 0)); 157 true, false, false, false, false, cls, 0));
155 code_ = Code::FinalizeCode(function, assembler_); 158 code_ = Code::FinalizeCode(function, assembler_);
156 if (FLAG_disassemble) { 159 if (FLAG_disassemble) {
157 OS::Print("Code for test '%s' {\n", name_); 160 OS::Print("Code for test '%s' {\n", name_);
158 const Instructions& instructions = 161 const Instructions& instructions =
159 Instructions::Handle(code_.instructions()); 162 Instructions::Handle(code_.instructions());
160 uword start = instructions.EntryPoint(); 163 uword start = instructions.EntryPoint();
161 Disassembler::Disassemble(start, start + assembler_->CodeSize()); 164 Disassembler::Disassemble(start, start + assembler_->CodeSize());
162 OS::Print("}\n"); 165 OS::Print("}\n");
163 } 166 }
164 const Instructions& instructions = Instructions::Handle(code_.instructions()); 167 const Instructions& instructions = Instructions::Handle(code_.instructions());
165 entry_ = instructions.EntryPoint(); 168 entry_ = instructions.EntryPoint();
166 } 169 }
167 170
168 171
172 // TODO(zra): Remove once supported.
173 #if !defined(TARGET_ARCH_ARM64)
174
169 CodeGenTest::CodeGenTest(const char* name) 175 CodeGenTest::CodeGenTest(const char* name)
170 : function_(Function::ZoneHandle()), 176 : function_(Function::ZoneHandle()),
171 node_sequence_(new SequenceNode(Scanner::kNoSourcePos, 177 node_sequence_(new SequenceNode(Scanner::kNoSourcePos,
172 new LocalScope(NULL, 0, 0))), 178 new LocalScope(NULL, 0, 0))),
173 default_parameter_values_(Array::ZoneHandle()) { 179 default_parameter_values_(Array::ZoneHandle()) {
174 ASSERT(name != NULL); 180 ASSERT(name != NULL);
175 const String& function_name = String::ZoneHandle(Symbols::New(name)); 181 const String& function_name = String::ZoneHandle(Symbols::New(name));
176 // Add function to a class and that class to the class dictionary so that 182 // Add function to a class and that class to the class dictionary so that
177 // frame walking can be used. 183 // frame walking can be used.
178 const Class& cls = Class::ZoneHandle( 184 const Class& cls = Class::ZoneHandle(
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 232
227 233
228 bool CompilerTest::TestCompileFunction(const Function& function) { 234 bool CompilerTest::TestCompileFunction(const Function& function) {
229 Isolate* isolate = Isolate::Current(); 235 Isolate* isolate = Isolate::Current();
230 ASSERT(isolate != NULL); 236 ASSERT(isolate != NULL);
231 ASSERT(ClassFinalizer::AllClassesFinalized()); 237 ASSERT(ClassFinalizer::AllClassesFinalized());
232 const Error& error = Error::Handle(Compiler::CompileFunction(function)); 238 const Error& error = Error::Handle(Compiler::CompileFunction(function));
233 return error.IsNull(); 239 return error.IsNull();
234 } 240 }
235 241
242 #endif // !defined(TARGET_ARCH_ARM64)
243
236 } // namespace dart 244 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/unit_test.h ('k') | runtime/vm/vm_sources.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698