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/runtime_entry.h" | 5 #include "vm/runtime_entry.h" |
6 | 6 |
7 #include "vm/object.h" | 7 #include "vm/object.h" |
8 #include "vm/symbols.h" | 8 #include "vm/symbols.h" |
9 #include "vm/verifier.h" | 9 #include "vm/verifier.h" |
10 | 10 |
(...skipping 18 matching lines...) Expand all Loading... |
29 function.SetCode(code); | 29 function.SetCode(code); |
30 return function; | 30 return function; |
31 } | 31 } |
32 | 32 |
33 | 33 |
34 // A runtime call for test purposes. | 34 // A runtime call for test purposes. |
35 // Arg0: a smi. | 35 // Arg0: a smi. |
36 // Arg1: a smi. | 36 // Arg1: a smi. |
37 // Result: a smi representing arg0 - arg1. | 37 // Result: a smi representing arg0 - arg1. |
38 DEFINE_RUNTIME_ENTRY(TestSmiSub, 2) { | 38 DEFINE_RUNTIME_ENTRY(TestSmiSub, 2) { |
39 ASSERT(arguments.Count() == kTestSmiSubRuntimeEntry.argument_count()); | 39 ASSERT(arguments.ArgCount() == kTestSmiSubRuntimeEntry.argument_count()); |
40 const Smi& left = Smi::CheckedHandle(arguments.At(0)); | 40 const Smi& left = Smi::CheckedHandle(arguments.ArgAt(0)); |
41 const Smi& right = Smi::CheckedHandle(arguments.At(1)); | 41 const Smi& right = Smi::CheckedHandle(arguments.ArgAt(1)); |
42 // Ignoring overflow in the calculation below. | 42 // Ignoring overflow in the calculation below. |
43 intptr_t result = left.Value() - right.Value(); | 43 intptr_t result = left.Value() - right.Value(); |
44 arguments.SetReturn(Smi::Handle(Smi::New(result))); | 44 arguments.SetReturn(Smi::Handle(Smi::New(result))); |
45 } | 45 } |
46 | 46 |
47 | 47 |
48 // A leaf runtime call for test purposes. | 48 // A leaf runtime call for test purposes. |
49 // arg0: a smi. | 49 // arg0: a smi. |
50 // arg1: a smi. | 50 // arg1: a smi. |
51 // returns a smi representing arg0 + arg1. | 51 // returns a smi representing arg0 + arg1. |
52 DEFINE_LEAF_RUNTIME_ENTRY(RawObject*, TestLeafSmiAdd, | 52 DEFINE_LEAF_RUNTIME_ENTRY(RawObject*, TestLeafSmiAdd, |
53 RawObject* arg0, RawObject* arg1) { | 53 RawObject* arg0, RawObject* arg1) { |
54 // Ignoring overflow in the calculation below and using the internal | 54 // Ignoring overflow in the calculation below and using the internal |
55 // representation of Smi directly without using any handlized code. | 55 // representation of Smi directly without using any handlized code. |
56 intptr_t result = reinterpret_cast<intptr_t>(arg0) + | 56 intptr_t result = reinterpret_cast<intptr_t>(arg0) + |
57 reinterpret_cast<intptr_t>(arg1); | 57 reinterpret_cast<intptr_t>(arg1); |
58 return reinterpret_cast<RawObject*>(result); | 58 return reinterpret_cast<RawObject*>(result); |
59 } | 59 } |
60 END_LEAF_RUNTIME_ENTRY | 60 END_LEAF_RUNTIME_ENTRY |
61 | 61 |
62 } // namespace dart | 62 } // namespace dart |
OLD | NEW |