OLD | NEW |
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 <stdio.h> | 5 #include <stdio.h> |
6 | 6 |
7 #include "vm/unit_test.h" | 7 #include "vm/unit_test.h" |
8 | 8 |
9 #include "vm/assembler.h" | 9 #include "vm/assembler.h" |
10 #include "vm/ast_printer.h" | 10 #include "vm/ast_printer.h" |
11 #include "vm/code_generator.h" | 11 #include "vm/code_generator.h" |
12 #include "vm/code_index_table.h" | |
13 #include "vm/compiler.h" | 12 #include "vm/compiler.h" |
14 #include "vm/dart_api_impl.h" | 13 #include "vm/dart_api_impl.h" |
15 #include "vm/disassembler.h" | 14 #include "vm/disassembler.h" |
16 #include "vm/longjump.h" | 15 #include "vm/longjump.h" |
17 #include "vm/parser.h" | 16 #include "vm/parser.h" |
18 #include "vm/virtual_memory.h" | 17 #include "vm/virtual_memory.h" |
19 | 18 |
20 | 19 |
21 namespace dart { | 20 namespace dart { |
22 | 21 |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 Code::Handle(Code::FinalizeCode(function_fullname, &assembler)); | 166 Code::Handle(Code::FinalizeCode(function_fullname, &assembler)); |
168 if (FLAG_disassemble) { | 167 if (FLAG_disassemble) { |
169 OS::Print("Code for function '%s' {\n", function_fullname); | 168 OS::Print("Code for function '%s' {\n", function_fullname); |
170 const Instructions& instructions = | 169 const Instructions& instructions = |
171 Instructions::Handle(code.instructions()); | 170 Instructions::Handle(code.instructions()); |
172 uword start = instructions.EntryPoint(); | 171 uword start = instructions.EntryPoint(); |
173 Disassembler::Disassemble(start, start + assembler.CodeSize()); | 172 Disassembler::Disassemble(start, start + assembler.CodeSize()); |
174 OS::Print("}\n"); | 173 OS::Print("}\n"); |
175 } | 174 } |
176 function_.SetCode(code); | 175 function_.SetCode(code); |
177 CodeIndexTable* code_index_table = isolate->code_index_table(); | |
178 ASSERT(code_index_table != NULL); | |
179 code_index_table->AddCode(code); | |
180 retval = true; | 176 retval = true; |
181 } else { | 177 } else { |
182 retval = false; | 178 retval = false; |
183 } | 179 } |
184 EXPECT(retval); | 180 EXPECT(retval); |
185 isolate->set_long_jump_base(base); | 181 isolate->set_long_jump_base(base); |
186 } | 182 } |
187 | 183 |
188 | 184 |
189 bool CompilerTest::TestCompileScript(const Library& library, | 185 bool CompilerTest::TestCompileScript(const Library& library, |
190 const Script& script) { | 186 const Script& script) { |
191 Isolate* isolate = Isolate::Current(); | 187 Isolate* isolate = Isolate::Current(); |
192 ASSERT(isolate != NULL); | 188 ASSERT(isolate != NULL); |
193 const Error& error = Error::Handle(Compiler::Compile(library, script)); | 189 const Error& error = Error::Handle(Compiler::Compile(library, script)); |
194 return error.IsNull(); | 190 return error.IsNull(); |
195 } | 191 } |
196 | 192 |
197 | 193 |
198 bool CompilerTest::TestCompileFunction(const Function& function) { | 194 bool CompilerTest::TestCompileFunction(const Function& function) { |
199 Isolate* isolate = Isolate::Current(); | 195 Isolate* isolate = Isolate::Current(); |
200 ASSERT(isolate != NULL); | 196 ASSERT(isolate != NULL); |
201 const Error& error = Error::Handle(Compiler::CompileFunction(function)); | 197 const Error& error = Error::Handle(Compiler::CompileFunction(function)); |
202 return error.IsNull(); | 198 return error.IsNull(); |
203 } | 199 } |
204 | 200 |
205 } // namespace dart | 201 } // namespace dart |
OLD | NEW |