1 | // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
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. |
4 | |
5 | #include "vm/globals.h" |
6 | #if defined(TARGET_ARCH_X64) |
7 | |
8 | #include "vm/runtime_entry.h" |
9 | |
10 | #if !defined(DART_PRECOMPILED_RUNTIME) |
11 | #include "vm/compiler/assembler/assembler.h" |
12 | #include "vm/stub_code.h" |
13 | #endif // !defined(DART_PRECOMPILED_RUNTIME) |
14 | |
15 | namespace dart { |
16 | |
17 | #define __ assembler-> |
18 | |
19 | uword RuntimeEntry::GetEntryPoint() const { |
20 | return reinterpret_cast<uword>(function()); |
21 | } |
22 | |
23 | #if !defined(DART_PRECOMPILED_RUNTIME) |
24 | // Generate code to call into the stub which will call the runtime |
25 | // function. Input for the stub is as follows: |
26 | // RSP : points to the arguments and return value array. |
27 | // RBX : address of the runtime function to call. |
28 | // R10 : number of arguments to the call. |
29 | void RuntimeEntry::CallInternal(const RuntimeEntry* runtime_entry, |
30 | compiler::Assembler* assembler, |
31 | intptr_t argument_count) { |
32 | if (runtime_entry->is_leaf()) { |
33 | ASSERT(argument_count == runtime_entry->argument_count()); |
34 | COMPILE_ASSERT(CallingConventions::kVolatileCpuRegisters & (1 << RAX)); |
35 | __ movq(RAX, |
36 | compiler::Address(THR, Thread::OffsetFromThread(runtime_entry))); |
37 | __ movq(compiler::Assembler::VMTagAddress(), RAX); |
38 | __ CallCFunction(RAX); |
39 | __ movq(compiler::Assembler::VMTagAddress(), |
40 | compiler::Immediate(VMTag::kDartCompiledTagId)); |
41 | ASSERT((CallingConventions::kCalleeSaveCpuRegisters & (1 << THR)) != 0); |
42 | ASSERT((CallingConventions::kCalleeSaveCpuRegisters & (1 << PP)) != 0); |
43 | } else { |
44 | // Argument count is not checked here, but in the runtime entry for a more |
45 | // informative error message. |
46 | __ movq(RBX, |
47 | compiler::Address(THR, Thread::OffsetFromThread(runtime_entry))); |
48 | __ LoadImmediate(R10, compiler::Immediate(argument_count)); |
49 | __ CallToRuntime(); |
50 | } |
51 | } |
52 | #endif // !defined(DART_PRECOMPILED_RUNTIME) |
53 | |
54 | } // namespace dart |
55 | |
56 | #endif // defined TARGET_ARCH_X64 |
57 | |