| 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" |
| 11 #include "vm/native_entry_test.h" | 11 #include "vm/native_entry_test.h" |
| 12 #include "vm/object.h" | 12 #include "vm/object.h" |
| 13 #include "vm/runtime_entry.h" | 13 #include "vm/runtime_entry.h" |
| 14 #include "vm/stub_code.h" | 14 #include "vm/stub_code.h" |
| 15 #include "vm/symbols.h" | 15 #include "vm/symbols.h" |
| 16 #include "vm/unit_test.h" | 16 #include "vm/unit_test.h" |
| 17 | 17 |
| 18 #define __ assembler-> | 18 #define __ assembler-> |
| 19 | 19 |
| 20 namespace dart { | 20 namespace dart { |
| 21 | 21 |
| 22 DECLARE_RUNTIME_ENTRY(TestSmiSub); | 22 DECLARE_RUNTIME_ENTRY(TestSmiSub); |
| 23 DECLARE_LEAF_RUNTIME_ENTRY(RawObject*, TestLeafSmiAdd, RawObject*, RawObject*); | 23 DECLARE_LEAF_RUNTIME_ENTRY(RawObject*, TestLeafSmiAdd, RawObject*, RawObject*); |
| 24 | 24 |
| 25 | 25 |
| 26 static Function* CreateFunction(const char* name) { | 26 static Function* CreateFunction(const char* name) { |
| 27 const String& class_name = String::Handle(Symbols::New("ownerClass")); |
| 28 const Script& script = Script::Handle(); |
| 29 const Class& owner_class = |
| 30 Class::Handle(Class::New(class_name, script, Scanner::kDummyTokenIndex)); |
| 27 const String& function_name = String::ZoneHandle(Symbols::New(name)); | 31 const String& function_name = String::ZoneHandle(Symbols::New(name)); |
| 28 Function& function = Function::ZoneHandle( | 32 Function& function = Function::ZoneHandle( |
| 29 Function::New(function_name, RawFunction::kRegularFunction, | 33 Function::New(function_name, RawFunction::kRegularFunction, |
| 30 true, false, false, false, 0)); | 34 true, false, false, false, owner_class, 0)); |
| 31 return &function; | 35 return &function; |
| 32 } | 36 } |
| 33 | 37 |
| 34 | 38 |
| 35 // Test calls to stub code which calls into the runtime. | 39 // Test calls to stub code which calls into the runtime. |
| 36 static void GenerateCallToCallRuntimeStub(Assembler* assembler, | 40 static void GenerateCallToCallRuntimeStub(Assembler* assembler, |
| 37 int value1, int value2) { | 41 int value1, int value2) { |
| 38 const int argc = 2; | 42 const int argc = 2; |
| 39 const Smi& smi1 = Smi::ZoneHandle(Smi::New(value1)); | 43 const Smi& smi1 = Smi::ZoneHandle(Smi::New(value1)); |
| 40 const Smi& smi2 = Smi::ZoneHandle(Smi::New(value2)); | 44 const Smi& smi2 = Smi::ZoneHandle(Smi::New(value2)); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 67 *CreateFunction("Test_CallRuntimeStubCode"), &_assembler_)); | 71 *CreateFunction("Test_CallRuntimeStubCode"), &_assembler_)); |
| 68 const Function& function = RegisterFakeFunction(kName, code); | 72 const Function& function = RegisterFakeFunction(kName, code); |
| 69 GrowableArray<const Object*> arguments; | 73 GrowableArray<const Object*> arguments; |
| 70 const Array& kNoArgumentNames = Array::Handle(); | 74 const Array& kNoArgumentNames = Array::Handle(); |
| 71 Smi& result = Smi::Handle(); | 75 Smi& result = Smi::Handle(); |
| 72 result ^= DartEntry::InvokeStatic(function, arguments, kNoArgumentNames); | 76 result ^= DartEntry::InvokeStatic(function, arguments, kNoArgumentNames); |
| 73 EXPECT_EQ((value1 - value2), result.Value()); | 77 EXPECT_EQ((value1 - value2), result.Value()); |
| 74 } | 78 } |
| 75 | 79 |
| 76 | 80 |
| 77 // Test calls to stub code which calls into the runtime. | 81 // Test calls to stub code which calls into a leaf runtime entry. |
| 78 static void GenerateCallToCallLeafRuntimeStub(Assembler* assembler, | 82 static void GenerateCallToCallLeafRuntimeStub(Assembler* assembler, |
| 79 int value1, | 83 int value1, |
| 80 int value2) { | 84 int value2) { |
| 81 const Smi& smi1 = Smi::ZoneHandle(Smi::New(value1)); | 85 const Smi& smi1 = Smi::ZoneHandle(Smi::New(value1)); |
| 82 const Smi& smi2 = Smi::ZoneHandle(Smi::New(value2)); | 86 const Smi& smi2 = Smi::ZoneHandle(Smi::New(value2)); |
| 83 __ enter(Immediate(0)); | 87 __ enter(Immediate(0)); |
| 84 __ ReserveAlignedFrameSpace(0); | 88 __ ReserveAlignedFrameSpace(0); |
| 85 __ LoadObject(RDI, smi1); // Set up argument 1 smi1. | 89 __ LoadObject(RDI, smi1); // Set up argument 1 smi1. |
| 86 __ LoadObject(RSI, smi2); // Set up argument 2 smi2. | 90 __ LoadObject(RSI, smi2); // Set up argument 2 smi2. |
| 87 __ CallRuntime(kTestLeafSmiAddRuntimeEntry); // Call SmiAdd runtime func. | 91 __ CallRuntime(kTestLeafSmiAddRuntimeEntry); // Call SmiAdd runtime func. |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 GrowableArray<const Object*> arguments; | 157 GrowableArray<const Object*> arguments; |
| 154 const Array& kNoArgumentNames = Array::Handle(); | 158 const Array& kNoArgumentNames = Array::Handle(); |
| 155 Smi& result = Smi::Handle(); | 159 Smi& result = Smi::Handle(); |
| 156 result ^= DartEntry::InvokeStatic(function, arguments, kNoArgumentNames); | 160 result ^= DartEntry::InvokeStatic(function, arguments, kNoArgumentNames); |
| 157 EXPECT_EQ((value1 - value2), result.Value()); | 161 EXPECT_EQ((value1 - value2), result.Value()); |
| 158 } | 162 } |
| 159 | 163 |
| 160 } // namespace dart | 164 } // namespace dart |
| 161 | 165 |
| 162 #endif // defined TARGET_ARCH_X64 | 166 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |