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/code_generator.h" | 5 #include "vm/code_generator.h" |
6 | 6 |
7 #include "vm/code_index_table.h" | 7 #include "vm/code_index_table.h" |
8 #include "vm/code_patcher.h" | 8 #include "vm/code_patcher.h" |
9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
10 #include "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 !instantiator.IsTypeArray() || | 214 !instantiator.IsTypeArray() || |
215 (instantiator.Length() != type_arguments.Length())); | 215 (instantiator.Length() != type_arguments.Length())); |
216 type_arguments = TypeArguments::NewInstantiatedTypeArguments(type_arguments, | 216 type_arguments = TypeArguments::NewInstantiatedTypeArguments(type_arguments, |
217 instantiator); | 217 instantiator); |
218 arguments.SetReturn(type_arguments); | 218 arguments.SetReturn(type_arguments); |
219 } | 219 } |
220 | 220 |
221 | 221 |
222 // Allocate a new closure. | 222 // Allocate a new closure. |
223 // Arg0: local function. | 223 // Arg0: local function. |
224 // TODO(regis): Arg1: type arguments of the closure. | 224 // Arg1: type arguments of the closure. |
225 // Return value: newly allocated closure. | 225 // Return value: newly allocated closure. |
226 DEFINE_RUNTIME_ENTRY(AllocateClosure, 1) { | 226 DEFINE_RUNTIME_ENTRY(AllocateClosure, 2) { |
227 ASSERT(arguments.Count() == kAllocateClosureRuntimeEntry.argument_count()); | 227 ASSERT(arguments.Count() == kAllocateClosureRuntimeEntry.argument_count()); |
228 const Function& function = Function::CheckedHandle(arguments.At(0)); | 228 const Function& function = Function::CheckedHandle(arguments.At(0)); |
229 ASSERT(function.IsClosureFunction() && !function.IsImplicitClosureFunction()); | 229 ASSERT(function.IsClosureFunction() && !function.IsImplicitClosureFunction()); |
230 // TODO(regis): Process type arguments unless the closure is static. | 230 const TypeArguments& type_arguments = |
| 231 TypeArguments::CheckedHandle(arguments.At(1)); |
| 232 ASSERT(type_arguments.IsNull() || type_arguments.IsInstantiated()); |
231 // The current context was saved in the Isolate structure when entering the | 233 // The current context was saved in the Isolate structure when entering the |
232 // runtime. | 234 // runtime. |
233 const Context& context = Context::Handle(Isolate::Current()->top_context()); | 235 const Context& context = Context::Handle(Isolate::Current()->top_context()); |
234 ASSERT(!context.IsNull()); | 236 ASSERT(!context.IsNull()); |
235 arguments.SetReturn(Closure::Handle(Closure::New(function, context))); | 237 const Closure& closure = Closure::Handle(Closure::New(function, context)); |
| 238 closure.SetTypeArguments(type_arguments); |
| 239 arguments.SetReturn(closure); |
236 } | 240 } |
237 | 241 |
238 | 242 |
239 // Allocate a new implicit static closure. | 243 // Allocate a new implicit static closure. |
240 // Arg0: local function. | 244 // Arg0: local function. |
241 // Return value: newly allocated closure. | 245 // Return value: newly allocated closure. |
242 DEFINE_RUNTIME_ENTRY(AllocateImplicitStaticClosure, 1) { | 246 DEFINE_RUNTIME_ENTRY(AllocateImplicitStaticClosure, 1) { |
243 ASSERT(arguments.Count() == | 247 ASSERT(arguments.Count() == |
244 kAllocateImplicitStaticClosureRuntimeEntry.argument_count()); | 248 kAllocateImplicitStaticClosureRuntimeEntry.argument_count()); |
245 ObjectStore* object_store = Isolate::Current()->object_store(); | 249 ObjectStore* object_store = Isolate::Current()->object_store(); |
246 ASSERT(object_store != NULL); | 250 ASSERT(object_store != NULL); |
247 const Function& function = Function::CheckedHandle(arguments.At(0)); | 251 const Function& function = Function::CheckedHandle(arguments.At(0)); |
248 ASSERT(function.IsImplicitStaticClosureFunction()); | 252 ASSERT(function.IsImplicitStaticClosureFunction()); |
249 const Context& context = Context::Handle(object_store->empty_context()); | 253 const Context& context = Context::Handle(object_store->empty_context()); |
250 arguments.SetReturn(Closure::Handle(Closure::New(function, context))); | 254 arguments.SetReturn(Closure::Handle(Closure::New(function, context))); |
251 } | 255 } |
252 | 256 |
253 | 257 |
254 // Allocate a new implicit instance closure. | 258 // Allocate a new implicit instance closure. |
255 // Arg0: local function. | 259 // Arg0: local function. |
256 // Arg1: receiver object. | 260 // Arg1: receiver object. |
257 // TODO(regis): Arg2: type arguments of the closure. | 261 // Arg2: type arguments of the closure. |
258 // Return value: newly allocated closure. | 262 // Return value: newly allocated closure. |
259 DEFINE_RUNTIME_ENTRY(AllocateImplicitInstanceClosure, 2) { | 263 DEFINE_RUNTIME_ENTRY(AllocateImplicitInstanceClosure, 3) { |
260 ASSERT(arguments.Count() == | 264 ASSERT(arguments.Count() == |
261 kAllocateImplicitInstanceClosureRuntimeEntry.argument_count()); | 265 kAllocateImplicitInstanceClosureRuntimeEntry.argument_count()); |
262 const Function& function = Function::CheckedHandle(arguments.At(0)); | 266 const Function& function = Function::CheckedHandle(arguments.At(0)); |
263 ASSERT(function.IsImplicitInstanceClosureFunction()); | 267 ASSERT(function.IsImplicitInstanceClosureFunction()); |
264 const Instance& receiver = Instance::CheckedHandle(arguments.At(1)); | 268 const Instance& receiver = Instance::CheckedHandle(arguments.At(1)); |
| 269 const TypeArguments& type_arguments = |
| 270 TypeArguments::CheckedHandle(arguments.At(2)); |
| 271 ASSERT(type_arguments.IsNull() || type_arguments.IsInstantiated()); |
265 Context& context = Context::Handle(); | 272 Context& context = Context::Handle(); |
266 context = Context::New(1); | 273 context = Context::New(1); |
267 context.SetAt(0, receiver); | 274 context.SetAt(0, receiver); |
268 arguments.SetReturn(Closure::Handle(Closure::New(function, context))); | 275 const Closure& closure = Closure::Handle(Closure::New(function, context)); |
269 // TODO(regis): Set type arguments. | 276 closure.SetTypeArguments(type_arguments); |
| 277 arguments.SetReturn(closure); |
270 } | 278 } |
271 | 279 |
272 | 280 |
273 // Allocate a new context large enough to hold the given number of variables. | 281 // Allocate a new context large enough to hold the given number of variables. |
274 // Arg0: number of variables. | 282 // Arg0: number of variables. |
275 // Return value: newly allocated context. | 283 // Return value: newly allocated context. |
276 DEFINE_RUNTIME_ENTRY(AllocateContext, 1) { | 284 DEFINE_RUNTIME_ENTRY(AllocateContext, 1) { |
277 CHECK_STACK_ALIGNMENT; | 285 CHECK_STACK_ALIGNMENT; |
278 ASSERT(arguments.Count() == kAllocateContextRuntimeEntry.argument_count()); | 286 ASSERT(arguments.Count() == kAllocateContextRuntimeEntry.argument_count()); |
279 const Smi& num_variables = Smi::CheckedHandle(arguments.At(0)); | 287 const Smi& num_variables = Smi::CheckedHandle(arguments.At(0)); |
(...skipping 712 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
992 } | 1000 } |
993 } | 1001 } |
994 } | 1002 } |
995 // The cache is null terminated, therefore the loop above should never | 1003 // The cache is null terminated, therefore the loop above should never |
996 // terminate by itself. | 1004 // terminate by itself. |
997 UNREACHABLE(); | 1005 UNREACHABLE(); |
998 return Code::null(); | 1006 return Code::null(); |
999 } | 1007 } |
1000 | 1008 |
1001 } // namespace dart | 1009 } // namespace dart |
OLD | NEW |