Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(464)

Side by Side Diff: runtime/vm/code_generator.cc

Issue 8234016: Inline allocation of implicit closures. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/code_generator.h ('k') | runtime/vm/code_generator_ia32.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 // TODO(regis): Arg1: type arguments of the closure.
225 // TODO(regis): Arg2: type arguments of the instantiator.
226 // Return value: newly allocated closure. 225 // Return value: newly allocated closure.
227 DEFINE_RUNTIME_ENTRY(AllocateClosure, 1) { 226 DEFINE_RUNTIME_ENTRY(AllocateClosure, 1) {
228 ASSERT(arguments.Count() == kAllocateClosureRuntimeEntry.argument_count()); 227 ASSERT(arguments.Count() == kAllocateClosureRuntimeEntry.argument_count());
229 const Function& function = Function::CheckedHandle(arguments.At(0)); 228 const Function& function = Function::CheckedHandle(arguments.At(0));
229 ASSERT(function.IsClosureFunction() && !function.IsImplicitClosureFunction());
230 // TODO(regis): Process type arguments unless the closure is static. 230 // TODO(regis): Process type arguments unless the closure is static.
231 // The current context was saved in the Isolate structure when entering the 231 // The current context was saved in the Isolate structure when entering the
232 // runtime. 232 // runtime.
233 const Context& context = Context::Handle(Isolate::Current()->top_context()); 233 const Context& context = Context::Handle(Isolate::Current()->top_context());
234 ASSERT(!context.IsNull()); 234 ASSERT(!context.IsNull());
235 arguments.SetReturn(Closure::Handle(Closure::New(function, context))); 235 arguments.SetReturn(Closure::Handle(Closure::New(function, context)));
236 } 236 }
237 237
238 238
239 // Allocate a new static implicit closure. 239 // Allocate a new implicit static closure.
240 // Arg0: local function. 240 // Arg0: local function.
241 // Return value: newly allocated closure. 241 // Return value: newly allocated closure.
242 DEFINE_RUNTIME_ENTRY(AllocateStaticImplicitClosure, 1) { 242 DEFINE_RUNTIME_ENTRY(AllocateImplicitStaticClosure, 1) {
243 ASSERT(arguments.Count() == 243 ASSERT(arguments.Count() ==
244 kAllocateStaticImplicitClosureRuntimeEntry.argument_count()); 244 kAllocateImplicitStaticClosureRuntimeEntry.argument_count());
245 ObjectStore* object_store = Isolate::Current()->object_store(); 245 ObjectStore* object_store = Isolate::Current()->object_store();
246 ASSERT(object_store != NULL); 246 ASSERT(object_store != NULL);
247 const Function& function = Function::CheckedHandle(arguments.At(0)); 247 const Function& function = Function::CheckedHandle(arguments.At(0));
248 ASSERT(function.is_static()); // Closure functions are always static for now. 248 ASSERT(function.IsImplicitStaticClosureFunction());
249 const Context& context = Context::Handle(object_store->empty_context()); 249 const Context& context = Context::Handle(object_store->empty_context());
250 arguments.SetReturn(Closure::Handle(Closure::New(function, context))); 250 arguments.SetReturn(Closure::Handle(Closure::New(function, context)));
251 } 251 }
252 252
253 253
254 // Allocate a new implicit closure. 254 // Allocate a new implicit instance closure.
255 // Arg0: local function. 255 // Arg0: local function.
256 // Arg1: receiver object. 256 // Arg1: receiver object.
257 // TODO(regis): Arg2: type arguments of the closure. 257 // TODO(regis): Arg2: type arguments of the closure.
258 // TODO(regis): Arg3: type arguments of the instantiator.
259 // Return value: newly allocated closure. 258 // Return value: newly allocated closure.
260 DEFINE_RUNTIME_ENTRY(AllocateImplicitClosure, 2) { 259 DEFINE_RUNTIME_ENTRY(AllocateImplicitInstanceClosure, 2) {
261 ASSERT(arguments.Count() == 260 ASSERT(arguments.Count() ==
262 kAllocateImplicitClosureRuntimeEntry.argument_count()); 261 kAllocateImplicitInstanceClosureRuntimeEntry.argument_count());
263 const Function& function = Function::CheckedHandle(arguments.At(0)); 262 const Function& function = Function::CheckedHandle(arguments.At(0));
264 ASSERT(function.is_static()); // Closure functions are always static for now. 263 ASSERT(function.IsImplicitInstanceClosureFunction());
265 const Instance& receiver = Instance::CheckedHandle(arguments.At(1)); 264 const Instance& receiver = Instance::CheckedHandle(arguments.At(1));
266 Context& context = Context::Handle(); 265 Context& context = Context::Handle();
267 context = Context::New(1); 266 context = Context::New(1);
268 context.SetAt(0, receiver); 267 context.SetAt(0, receiver);
269 arguments.SetReturn(Closure::Handle(Closure::New(function, context))); 268 arguments.SetReturn(Closure::Handle(Closure::New(function, context)));
270 // TODO(regis): Set type arguments. 269 // TODO(regis): Set type arguments.
271 } 270 }
272 271
273 272
274 // Allocate a new context large enough to hold the given number of variables. 273 // Allocate a new context large enough to hold the given number of variables.
(...skipping 714 matching lines...) Expand 10 before | Expand all | Expand 10 after
989 } 988 }
990 } 989 }
991 } 990 }
992 // The cache is null terminated, therefore the loop above should never 991 // The cache is null terminated, therefore the loop above should never
993 // terminate by itself. 992 // terminate by itself.
994 UNREACHABLE(); 993 UNREACHABLE();
995 return Code::null(); 994 return Code::null();
996 } 995 }
997 996
998 } // namespace dart 997 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/code_generator.h ('k') | runtime/vm/code_generator_ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698