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

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

Issue 8490019: Capturing for loop variables correctly (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years, 1 month 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_api_impl.h" 10 #include "vm/dart_api_impl.h"
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 // Arg0: number of variables. 284 // Arg0: number of variables.
285 // Return value: newly allocated context. 285 // Return value: newly allocated context.
286 DEFINE_RUNTIME_ENTRY(AllocateContext, 1) { 286 DEFINE_RUNTIME_ENTRY(AllocateContext, 1) {
287 CHECK_STACK_ALIGNMENT; 287 CHECK_STACK_ALIGNMENT;
288 ASSERT(arguments.Count() == kAllocateContextRuntimeEntry.argument_count()); 288 ASSERT(arguments.Count() == kAllocateContextRuntimeEntry.argument_count());
289 const Smi& num_variables = Smi::CheckedHandle(arguments.At(0)); 289 const Smi& num_variables = Smi::CheckedHandle(arguments.At(0));
290 arguments.SetReturn(Context::Handle(Context::New(num_variables.Value()))); 290 arguments.SetReturn(Context::Handle(Context::New(num_variables.Value())));
291 } 291 }
292 292
293 293
294 // Make a copy of the given context, including the values of the captured
295 // variables.
296 // Arg0: the context to be cloned.
297 // Return value: newly allocated context.
298 DEFINE_RUNTIME_ENTRY(CloneContext, 1) {
299 CHECK_STACK_ALIGNMENT;
300 ASSERT(arguments.Count() == kCloneContextRuntimeEntry.argument_count());
301 const Context& ctx = Context::CheckedHandle(arguments.At(0));
302 Context& cloned_ctx = Context::Handle(Context::New(ctx.num_variables()));
303 cloned_ctx.set_parent(Context::Handle(ctx.parent()));
304 for (int i = 0; i < ctx.num_variables(); i++) {
305 cloned_ctx.SetAt(i, Instance::Handle(ctx.At(i)));
306 }
307 arguments.SetReturn(cloned_ctx);
308 }
309
310
294 // Check that the given instance is an instance of the given type. 311 // Check that the given instance is an instance of the given type.
295 // Tested instance may not be null, because the null test is inlined. 312 // Tested instance may not be null, because the null test is inlined.
296 // Arg0: instance being checked. 313 // Arg0: instance being checked.
297 // Arg1: type. 314 // Arg1: type.
298 // Arg2: type arguments of the instantiator of the type. 315 // Arg2: type arguments of the instantiator of the type.
299 // Return value: true or false. 316 // Return value: true or false.
300 DEFINE_RUNTIME_ENTRY(Instanceof, 3) { 317 DEFINE_RUNTIME_ENTRY(Instanceof, 3) {
301 ASSERT(arguments.Count() == kInstanceofRuntimeEntry.argument_count()); 318 ASSERT(arguments.Count() == kInstanceofRuntimeEntry.argument_count());
302 const Instance& instance = Instance::CheckedHandle(arguments.At(0)); 319 const Instance& instance = Instance::CheckedHandle(arguments.At(0));
303 const Type& type = Type::CheckedHandle(arguments.At(1)); 320 const Type& type = Type::CheckedHandle(arguments.At(1));
(...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after
964 } 981 }
965 } 982 }
966 } 983 }
967 // The cache is null terminated, therefore the loop above should never 984 // The cache is null terminated, therefore the loop above should never
968 // terminate by itself. 985 // terminate by itself.
969 UNREACHABLE(); 986 UNREACHABLE();
970 return Code::null(); 987 return Code::null();
971 } 988 }
972 989
973 } // namespace dart 990 } // 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