OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 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 | 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/globals.h" | 5 #include "vm/globals.h" |
6 #if defined(TARGET_ARCH_X64) | 6 #if defined(TARGET_ARCH_X64) |
7 | 7 |
8 #include "vm/isolate.h" | 8 #include "vm/isolate.h" |
9 #include "vm/dart_entry.h" | 9 #include "vm/dart_entry.h" |
10 #include "vm/native_entry.h" | 10 #include "vm/native_entry.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 extern const Function& RegisterFakeFunction(const char* name, | 63 extern const Function& RegisterFakeFunction(const char* name, |
64 const Code& code); | 64 const Code& code); |
65 const int value1 = 10; | 65 const int value1 = 10; |
66 const int value2 = 20; | 66 const int value2 = 20; |
67 const char* kName = "Test_CallRuntimeStubCode"; | 67 const char* kName = "Test_CallRuntimeStubCode"; |
68 Assembler _assembler_; | 68 Assembler _assembler_; |
69 GenerateCallToCallRuntimeStub(&_assembler_, value1, value2); | 69 GenerateCallToCallRuntimeStub(&_assembler_, value1, value2); |
70 const Code& code = Code::Handle(Code::FinalizeCode( | 70 const Code& code = Code::Handle(Code::FinalizeCode( |
71 *CreateFunction("Test_CallRuntimeStubCode"), &_assembler_)); | 71 *CreateFunction("Test_CallRuntimeStubCode"), &_assembler_)); |
72 const Function& function = RegisterFakeFunction(kName, code); | 72 const Function& function = RegisterFakeFunction(kName, code); |
73 const Array& args = Array::Handle(Object::empty_array()); | |
74 Smi& result = Smi::Handle(); | 73 Smi& result = Smi::Handle(); |
75 result ^= DartEntry::InvokeStatic(function, args); | 74 result ^= DartEntry::InvokeStatic(function, Object::empty_array()); |
76 EXPECT_EQ((value1 - value2), result.Value()); | 75 EXPECT_EQ((value1 - value2), result.Value()); |
77 } | 76 } |
78 | 77 |
79 | 78 |
80 // Test calls to stub code which calls into a leaf runtime entry. | 79 // Test calls to stub code which calls into a leaf runtime entry. |
81 static void GenerateCallToCallLeafRuntimeStub(Assembler* assembler, | 80 static void GenerateCallToCallLeafRuntimeStub(Assembler* assembler, |
82 int value1, | 81 int value1, |
83 int value2) { | 82 int value2) { |
84 const Smi& smi1 = Smi::ZoneHandle(Smi::New(value1)); | 83 const Smi& smi1 = Smi::ZoneHandle(Smi::New(value1)); |
85 const Smi& smi2 = Smi::ZoneHandle(Smi::New(value2)); | 84 const Smi& smi2 = Smi::ZoneHandle(Smi::New(value2)); |
(...skipping 11 matching lines...) Expand all Loading... |
97 extern const Function& RegisterFakeFunction(const char* name, | 96 extern const Function& RegisterFakeFunction(const char* name, |
98 const Code& code); | 97 const Code& code); |
99 const int value1 = 10; | 98 const int value1 = 10; |
100 const int value2 = 20; | 99 const int value2 = 20; |
101 const char* kName = "Test_CallLeafRuntimeStubCode"; | 100 const char* kName = "Test_CallLeafRuntimeStubCode"; |
102 Assembler _assembler_; | 101 Assembler _assembler_; |
103 GenerateCallToCallLeafRuntimeStub(&_assembler_, value1, value2); | 102 GenerateCallToCallLeafRuntimeStub(&_assembler_, value1, value2); |
104 const Code& code = Code::Handle(Code::FinalizeCode( | 103 const Code& code = Code::Handle(Code::FinalizeCode( |
105 *CreateFunction("Test_CallLeafRuntimeStubCode"), &_assembler_)); | 104 *CreateFunction("Test_CallLeafRuntimeStubCode"), &_assembler_)); |
106 const Function& function = RegisterFakeFunction(kName, code); | 105 const Function& function = RegisterFakeFunction(kName, code); |
107 const Array& args = Array::Handle(Object::empty_array()); | |
108 Smi& result = Smi::Handle(); | 106 Smi& result = Smi::Handle(); |
109 result ^= DartEntry::InvokeStatic(function, args); | 107 result ^= DartEntry::InvokeStatic(function, Object::empty_array()); |
110 EXPECT_EQ((value1 + value2), result.Value()); | 108 EXPECT_EQ((value1 + value2), result.Value()); |
111 } | 109 } |
112 | 110 |
113 } // namespace dart | 111 } // namespace dart |
114 | 112 |
115 #endif // defined TARGET_ARCH_X64 | 113 #endif // defined TARGET_ARCH_X64 |
OLD | NEW |