OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 #ifndef VM_NATIVE_ARGUMENTS_H_ | 5 #ifndef VM_NATIVE_ARGUMENTS_H_ |
6 #define VM_NATIVE_ARGUMENTS_H_ | 6 #define VM_NATIVE_ARGUMENTS_H_ |
7 | 7 |
8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
9 #include "vm/globals.h" | 9 #include "vm/globals.h" |
| 10 #include "vm/handles_impl.h" |
10 #include "vm/simulator.h" | 11 #include "vm/simulator.h" |
11 #include "vm/stub_code.h" | 12 #include "vm/stub_code.h" |
12 | 13 |
13 namespace dart { | 14 namespace dart { |
14 | 15 |
15 // Forward declarations. | 16 // Forward declarations. |
16 class BootstrapNatives; | 17 class BootstrapNatives; |
17 class Isolate; | 18 class Isolate; |
18 class Object; | 19 class Object; |
19 class RawObject; | 20 class RawObject; |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 if ((index == 0) && ToClosureFunction() && ToInstanceFunction()) { | 104 if ((index == 0) && ToClosureFunction() && ToInstanceFunction()) { |
104 // Retrieve the receiver from the context. | 105 // Retrieve the receiver from the context. |
105 const Context& context = Context::Handle(isolate_->top_context()); | 106 const Context& context = Context::Handle(isolate_->top_context()); |
106 return context.At(0); | 107 return context.At(0); |
107 } else { | 108 } else { |
108 const int actual_index = index + NumHiddenArgs(); | 109 const int actual_index = index + NumHiddenArgs(); |
109 return ArgAt(actual_index); | 110 return ArgAt(actual_index); |
110 } | 111 } |
111 } | 112 } |
112 | 113 |
113 void SetReturn(const Object& value) const; | 114 void SetReturn(const Object& value) const { |
| 115 *retval_ = value.raw(); |
| 116 } |
114 | 117 |
115 static intptr_t isolate_offset() { | 118 static intptr_t isolate_offset() { |
116 return OFFSET_OF(NativeArguments, isolate_); | 119 return OFFSET_OF(NativeArguments, isolate_); |
117 } | 120 } |
118 static intptr_t argc_tag_offset() { | 121 static intptr_t argc_tag_offset() { |
119 return OFFSET_OF(NativeArguments, argc_tag_); | 122 return OFFSET_OF(NativeArguments, argc_tag_); |
120 } | 123 } |
121 static intptr_t argv_offset() { return OFFSET_OF(NativeArguments, argv_); } | 124 static intptr_t argv_offset() { return OFFSET_OF(NativeArguments, argv_); } |
122 static intptr_t retval_offset() { | 125 static intptr_t retval_offset() { |
123 return OFFSET_OF(NativeArguments, retval_); | 126 return OFFSET_OF(NativeArguments, retval_); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 class InstanceFunctionBit : public BitField<bool, kInstanceFunctionBit, 1> {}; | 160 class InstanceFunctionBit : public BitField<bool, kInstanceFunctionBit, 1> {}; |
158 class ClosureFunctionBit : public BitField<bool, kClosureFunctionBit, 1> {}; | 161 class ClosureFunctionBit : public BitField<bool, kClosureFunctionBit, 1> {}; |
159 friend class Api; | 162 friend class Api; |
160 friend class BootstrapNatives; | 163 friend class BootstrapNatives; |
161 friend class Simulator; | 164 friend class Simulator; |
162 | 165 |
163 // Since this function is passed a RawObject directly, we need to be | 166 // Since this function is passed a RawObject directly, we need to be |
164 // exceedingly careful when we use it. If there are any other side | 167 // exceedingly careful when we use it. If there are any other side |
165 // effects in the statement that may cause GC, it could lead to | 168 // effects in the statement that may cause GC, it could lead to |
166 // bugs. | 169 // bugs. |
167 void SetReturnUnsafe(RawObject* value) const; | 170 void SetReturnUnsafe(RawObject* value) const { |
| 171 *retval_ = value; |
| 172 } |
168 | 173 |
169 Isolate* isolate_; // Current isolate pointer. | 174 Isolate* isolate_; // Current isolate pointer. |
170 int argc_tag_; // Encodes argument count and invoked native call type. | 175 int argc_tag_; // Encodes argument count and invoked native call type. |
171 RawObject*(*argv_)[]; // Pointer to an array of arguments to runtime call. | 176 RawObject*(*argv_)[]; // Pointer to an array of arguments to runtime call. |
172 RawObject** retval_; // Pointer to the return value area. | 177 RawObject** retval_; // Pointer to the return value area. |
173 }; | 178 }; |
174 | 179 |
175 } // namespace dart | 180 } // namespace dart |
176 | 181 |
177 #endif // VM_NATIVE_ARGUMENTS_H_ | 182 #endif // VM_NATIVE_ARGUMENTS_H_ |
OLD | NEW |