| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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_DBC) | 6 #if defined(TARGET_ARCH_DBC) |
| 7 | 7 |
| 8 #include "vm/assembler.h" | 8 #include "vm/assembler.h" |
| 9 #include "vm/stack_frame.h" |
| 9 #include "vm/unit_test.h" | 10 #include "vm/unit_test.h" |
| 10 | 11 |
| 11 namespace dart { | 12 namespace dart { |
| 12 | 13 |
| 13 static RawObject* ExecuteTest(const Code& code) { | 14 static RawObject* ExecuteTest(const Code& code) { |
| 14 Thread* thread = Thread::Current(); | 15 Thread* thread = Thread::Current(); |
| 15 TransitionToGenerated transition(thread); | 16 TransitionToGenerated transition(thread); |
| 16 return Simulator::Current()->Call( | 17 return Simulator::Current()->Call( |
| 17 code, | 18 code, |
| 18 Array::Handle(ArgumentsDescriptor::New(0)), | 19 Array::Handle(ArgumentsDescriptor::New(0)), |
| (...skipping 16 matching lines...) Expand all Loading... |
| 35 __ PushConstant(Smi::Handle(Smi::New(42))); | 36 __ PushConstant(Smi::Handle(Smi::New(42))); |
| 36 __ ReturnTOS(); | 37 __ ReturnTOS(); |
| 37 } | 38 } |
| 38 | 39 |
| 39 | 40 |
| 40 ASSEMBLER_TEST_RUN(Simple, test) { | 41 ASSEMBLER_TEST_RUN(Simple, test) { |
| 41 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code())); | 42 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code())); |
| 42 } | 43 } |
| 43 | 44 |
| 44 | 45 |
| 46 // Called from assembler_test.cc. |
| 47 // FP[-kParamEndSlotFromFp - 1]: growable array |
| 48 // FP[-kParamEndSlotFromFp - 2]: value |
| 49 ASSEMBLER_TEST_GENERATE(StoreIntoObject, assembler) { |
| 50 __ Frame(2); |
| 51 __ Move(0, -kParamEndSlotFromFp - 1); |
| 52 __ Move(1, -kParamEndSlotFromFp - 2); |
| 53 __ StoreField(0, GrowableObjectArray::data_offset() / kWordSize, 1); |
| 54 __ Return(0); |
| 55 } |
| 56 |
| 57 |
| 45 // - AddTOS; SubTOS; MulTOS; BitOrTOS; BitAndTOS; EqualTOS; LessThanTOS; | 58 // - AddTOS; SubTOS; MulTOS; BitOrTOS; BitAndTOS; EqualTOS; LessThanTOS; |
| 46 // GreaterThanTOS; | 59 // GreaterThanTOS; |
| 47 // | 60 // |
| 48 // Smi fast-path for a corresponding method. Checks if SP[0] and SP[-1] are | 61 // Smi fast-path for a corresponding method. Checks if SP[0] and SP[-1] are |
| 49 // both smis and result of SP[0] <op> SP[-1] is a smi - if this is true | 62 // both smis and result of SP[0] <op> SP[-1] is a smi - if this is true |
| 50 // then pops operands and pushes result on the stack and skips the next | 63 // then pops operands and pushes result on the stack and skips the next |
| 51 // instruction (which implements a slow path fallback). | 64 // instruction (which implements a slow path fallback). |
| 52 ASSEMBLER_TEST_GENERATE(AddTOS, assembler) { | 65 ASSEMBLER_TEST_GENERATE(AddTOS, assembler) { |
| 53 __ PushConstant(Smi::Handle(Smi::New(-42))); | 66 __ PushConstant(Smi::Handle(Smi::New(-42))); |
| 54 __ PushConstant(Smi::Handle(Smi::New(84))); | 67 __ PushConstant(Smi::Handle(Smi::New(84))); |
| (...skipping 956 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1011 const Object& obj = EXECUTE_TEST_CODE_OBJECT(test->code()); | 1024 const Object& obj = EXECUTE_TEST_CODE_OBJECT(test->code()); |
| 1012 EXPECT(obj.IsArray()); | 1025 EXPECT(obj.IsArray()); |
| 1013 Array& array = Array::Handle(); | 1026 Array& array = Array::Handle(); |
| 1014 array ^= obj.raw(); | 1027 array ^= obj.raw(); |
| 1015 EXPECT_EQ(10, array.Length()); | 1028 EXPECT_EQ(10, array.Length()); |
| 1016 } | 1029 } |
| 1017 | 1030 |
| 1018 } // namespace dart | 1031 } // namespace dart |
| 1019 | 1032 |
| 1020 #endif // defined(TARGET_ARCH_DBC) | 1033 #endif // defined(TARGET_ARCH_DBC) |
| OLD | NEW |