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

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

Issue 178233003: Allocate instance closures similarly to regular closures, i.e. without a (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 9 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
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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/assembler.h" 7 #include "vm/assembler.h"
8 #include "vm/ast.h" 8 #include "vm/ast.h"
9 #include "vm/bigint_operations.h" 9 #include "vm/bigint_operations.h"
10 #include "vm/code_patcher.h" 10 #include "vm/code_patcher.h"
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 } 199 }
200 } else { 200 } else {
201 type_arguments = 201 type_arguments =
202 type_arguments.InstantiateAndCanonicalizeFrom(instantiator, NULL); 202 type_arguments.InstantiateAndCanonicalizeFrom(instantiator, NULL);
203 } 203 }
204 ASSERT(type_arguments.IsInstantiated()); 204 ASSERT(type_arguments.IsInstantiated());
205 arguments.SetReturn(type_arguments); 205 arguments.SetReturn(type_arguments);
206 } 206 }
207 207
208 208
209 // TODO(regis): Not used anymore. Delete.
210
211 // Allocate a new closure.
212 // The type argument vector of a closure is always the vector of type parameters
213 // of its signature class, i.e. an uninstantiated identity vector. Therefore,
214 // the instantiator type arguments can be used as the instantiated closure type
215 // arguments and is passed here as the type arguments.
216 // Arg0: local function.
217 // Arg1: type arguments of the closure (i.e. instantiator).
218 // Return value: newly allocated closure.
219 DEFINE_RUNTIME_ENTRY(AllocateClosure, 2) {
220 const Function& function = Function::CheckedHandle(arguments.ArgAt(0));
221 ASSERT(function.IsClosureFunction() && !function.IsImplicitClosureFunction());
222 const TypeArguments& type_arguments =
223 TypeArguments::CheckedHandle(arguments.ArgAt(1));
224 ASSERT(type_arguments.IsNull() || type_arguments.IsInstantiated());
225 // The current context was saved in the Isolate structure when entering the
226 // runtime.
227 const Context& context = Context::Handle(isolate->top_context());
228 ASSERT(!context.IsNull());
229 const Instance& closure = Instance::Handle(Closure::New(function, context));
230 Closure::SetTypeArguments(closure, type_arguments);
231 arguments.SetReturn(closure);
232 }
233
234
235 // Allocate a new implicit instance closure.
236 // Arg0: local function.
237 // Arg1: receiver object.
238 // Arg2: type arguments of the closure.
239 // Return value: newly allocated closure.
240 DEFINE_RUNTIME_ENTRY(AllocateImplicitInstanceClosure, 3) {
241 const Function& function = Function::CheckedHandle(arguments.ArgAt(0));
242 ASSERT(function.IsImplicitInstanceClosureFunction());
243 const Instance& receiver = Instance::CheckedHandle(arguments.ArgAt(1));
244 const TypeArguments& type_arguments =
245 TypeArguments::CheckedHandle(arguments.ArgAt(2));
246 ASSERT(type_arguments.IsNull() || type_arguments.IsInstantiated());
247 Context& context = Context::Handle();
248 context = Context::New(1);
249 context.SetAt(0, receiver);
250 const Instance& closure = Instance::Handle(Closure::New(function, context));
251 Closure::SetTypeArguments(closure, type_arguments);
252 arguments.SetReturn(closure);
253 }
254
255
256 // Allocate a new context large enough to hold the given number of variables. 209 // Allocate a new context large enough to hold the given number of variables.
257 // Arg0: number of variables. 210 // Arg0: number of variables.
258 // Return value: newly allocated context. 211 // Return value: newly allocated context.
259 DEFINE_RUNTIME_ENTRY(AllocateContext, 1) { 212 DEFINE_RUNTIME_ENTRY(AllocateContext, 1) {
260 const Smi& num_variables = Smi::CheckedHandle(arguments.ArgAt(0)); 213 const Smi& num_variables = Smi::CheckedHandle(arguments.ArgAt(0));
261 arguments.SetReturn(Context::Handle(Context::New(num_variables.Value()))); 214 arguments.SetReturn(Context::Handle(Context::New(num_variables.Value())));
262 } 215 }
263 216
264 217
265 // Make a copy of the given context, including the values of the captured 218 // Make a copy of the given context, including the values of the captured
(...skipping 1329 matching lines...) Expand 10 before | Expand all | Expand 10 after
1595 // of the given value. 1548 // of the given value.
1596 // Arg0: Field object; 1549 // Arg0: Field object;
1597 // Arg1: Value that is being stored. 1550 // Arg1: Value that is being stored.
1598 DEFINE_RUNTIME_ENTRY(UpdateFieldCid, 2) { 1551 DEFINE_RUNTIME_ENTRY(UpdateFieldCid, 2) {
1599 const Field& field = Field::CheckedHandle(arguments.ArgAt(0)); 1552 const Field& field = Field::CheckedHandle(arguments.ArgAt(0));
1600 const Object& value = Object::Handle(arguments.ArgAt(1)); 1553 const Object& value = Object::Handle(arguments.ArgAt(1));
1601 field.UpdateGuardedCidAndLength(value); 1554 field.UpdateGuardedCidAndLength(value);
1602 } 1555 }
1603 1556
1604 } // namespace dart 1557 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698