OLD | NEW |
1 // Copyright (c) 2015, the Fletch project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dartino 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.md file. | 3 // BSD-style license that can be found in the LICENSE.md file. |
4 | 4 |
5 #include "src/vm/fletch_relocation_api_impl.h" | 5 #include "src/vm/fletch_relocation_api_impl.h" |
6 #include "src/vm/object_memory.h" | 6 #include "src/vm/object_memory.h" |
7 #include "src/vm/program.h" | 7 #include "src/vm/program.h" |
8 #include "src/vm/program_info_block.h" | 8 #include "src/vm/program_info_block.h" |
9 #include "src/vm/program_relocator.h" | 9 #include "src/vm/program_relocator.h" |
10 | 10 |
11 size_t FletchGetProgramSize(FletchProgram program) { | 11 size_t FletchGetProgramSize(FletchProgram program) { |
12 fletch::Program* fletch_program = reinterpret_cast<fletch::Program*>(program); | 12 fletch::Program* fletch_program = reinterpret_cast<fletch::Program*>(program); |
13 return fletch_program->program_heap_size() + sizeof(fletch::ProgramInfoBlock); | 13 return fletch_program->program_heap_size() + sizeof(fletch::ProgramInfoBlock); |
14 } | 14 } |
15 | 15 |
16 int FletchRelocateProgram(FletchProgram program, void* target, uintptr_t base) { | 16 int FletchRelocateProgram(FletchProgram program, void* target, uintptr_t base) { |
17 if (base % fletch::kPageSize != 0) return -1; | 17 if (base % fletch::kPageSize != 0) return -1; |
18 fletch::Program* fletch_program = reinterpret_cast<fletch::Program*>(program); | 18 fletch::Program* fletch_program = reinterpret_cast<fletch::Program*>(program); |
19 fletch::ProgramHeapRelocator relocator( | 19 fletch::ProgramHeapRelocator relocator( |
20 fletch_program, reinterpret_cast<uint8*>(target), base); | 20 fletch_program, reinterpret_cast<uint8*>(target), base); |
21 return relocator.Relocate(); | 21 return relocator.Relocate(); |
22 } | 22 } |
OLD | NEW |