| 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_api_impl.h" | 10 #include "vm/dart_api_impl.h" |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 const Closure& closure = Closure::Handle(Closure::New(function, context)); | 280 const Closure& closure = Closure::Handle(Closure::New(function, context)); |
| 281 closure.SetTypeArguments(type_arguments); | 281 closure.SetTypeArguments(type_arguments); |
| 282 arguments.SetReturn(closure); | 282 arguments.SetReturn(closure); |
| 283 } | 283 } |
| 284 | 284 |
| 285 | 285 |
| 286 // Allocate a new context large enough to hold the given number of variables. | 286 // Allocate a new context large enough to hold the given number of variables. |
| 287 // Arg0: number of variables. | 287 // Arg0: number of variables. |
| 288 // Return value: newly allocated context. | 288 // Return value: newly allocated context. |
| 289 DEFINE_RUNTIME_ENTRY(AllocateContext, 1) { | 289 DEFINE_RUNTIME_ENTRY(AllocateContext, 1) { |
| 290 CHECK_STACK_ALIGNMENT; | |
| 291 ASSERT(arguments.Count() == kAllocateContextRuntimeEntry.argument_count()); | 290 ASSERT(arguments.Count() == kAllocateContextRuntimeEntry.argument_count()); |
| 292 const Smi& num_variables = Smi::CheckedHandle(arguments.At(0)); | 291 const Smi& num_variables = Smi::CheckedHandle(arguments.At(0)); |
| 293 arguments.SetReturn(Context::Handle(Context::New(num_variables.Value()))); | 292 arguments.SetReturn(Context::Handle(Context::New(num_variables.Value()))); |
| 294 } | 293 } |
| 295 | 294 |
| 296 | 295 |
| 297 // Make a copy of the given context, including the values of the captured | 296 // Make a copy of the given context, including the values of the captured |
| 298 // variables. | 297 // variables. |
| 299 // Arg0: the context to be cloned. | 298 // Arg0: the context to be cloned. |
| 300 // Return value: newly allocated context. | 299 // Return value: newly allocated context. |
| 301 DEFINE_RUNTIME_ENTRY(CloneContext, 1) { | 300 DEFINE_RUNTIME_ENTRY(CloneContext, 1) { |
| 302 CHECK_STACK_ALIGNMENT; | |
| 303 ASSERT(arguments.Count() == kCloneContextRuntimeEntry.argument_count()); | 301 ASSERT(arguments.Count() == kCloneContextRuntimeEntry.argument_count()); |
| 304 const Context& ctx = Context::CheckedHandle(arguments.At(0)); | 302 const Context& ctx = Context::CheckedHandle(arguments.At(0)); |
| 305 Context& cloned_ctx = Context::Handle(Context::New(ctx.num_variables())); | 303 Context& cloned_ctx = Context::Handle(Context::New(ctx.num_variables())); |
| 306 cloned_ctx.set_parent(Context::Handle(ctx.parent())); | 304 cloned_ctx.set_parent(Context::Handle(ctx.parent())); |
| 307 for (int i = 0; i < ctx.num_variables(); i++) { | 305 for (int i = 0; i < ctx.num_variables(); i++) { |
| 308 cloned_ctx.SetAt(i, Instance::Handle(ctx.At(i))); | 306 cloned_ctx.SetAt(i, Instance::Handle(ctx.At(i))); |
| 309 } | 307 } |
| 310 arguments.SetReturn(cloned_ctx); | 308 arguments.SetReturn(cloned_ctx); |
| 311 } | 309 } |
| 312 | 310 |
| (...skipping 727 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1040 } | 1038 } |
| 1041 } | 1039 } |
| 1042 } | 1040 } |
| 1043 // The cache is null terminated, therefore the loop above should never | 1041 // The cache is null terminated, therefore the loop above should never |
| 1044 // terminate by itself. | 1042 // terminate by itself. |
| 1045 UNREACHABLE(); | 1043 UNREACHABLE(); |
| 1046 return Code::null(); | 1044 return Code::null(); |
| 1047 } | 1045 } |
| 1048 | 1046 |
| 1049 } // namespace dart | 1047 } // namespace dart |
| OLD | NEW |