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