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

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

Issue 266783002: Save the entry context for a function that has captured loop variables. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 7 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/object.cc ('k') | runtime/vm/parser.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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 // TODO(zra): Remove when tests are ready to enable. 5 // TODO(zra): Remove when tests are ready to enable.
6 #include "platform/globals.h" 6 #include "platform/globals.h"
7 7
8 #include "vm/assembler.h" 8 #include "vm/assembler.h"
9 #include "vm/bigint_operations.h" 9 #include "vm/bigint_operations.h"
10 #include "vm/class_finalizer.h" 10 #include "vm/class_finalizer.h"
(...skipping 2343 matching lines...) Expand 10 before | Expand all | Expand 10 after
2354 EXPECT(var_c->is_captured()); 2354 EXPECT(var_c->is_captured());
2355 2355
2356 EXPECT_EQ(3, local_scope->num_variables()); // a, b, and c alias. 2356 EXPECT_EQ(3, local_scope->num_variables()); // a, b, and c alias.
2357 EXPECT_EQ(2, local_scope->NumCapturedVariables()); // a, c alias. 2357 EXPECT_EQ(2, local_scope->NumCapturedVariables()); // a, c alias.
2358 2358
2359 const int first_parameter_index = 0; 2359 const int first_parameter_index = 0;
2360 const int num_parameters = 0; 2360 const int num_parameters = 0;
2361 const int first_frame_index = -1; 2361 const int first_frame_index = -1;
2362 LocalScope* loop_owner = parent_scope; 2362 LocalScope* loop_owner = parent_scope;
2363 LocalScope* context_owner = NULL; // No context allocated yet. 2363 LocalScope* context_owner = NULL; // No context allocated yet.
2364 bool found_captured_vars = false;
2364 int next_frame_index = parent_scope->AllocateVariables(first_parameter_index, 2365 int next_frame_index = parent_scope->AllocateVariables(first_parameter_index,
2365 num_parameters, 2366 num_parameters,
2366 first_frame_index, 2367 first_frame_index,
2367 loop_owner, 2368 loop_owner,
2368 &context_owner); 2369 &context_owner,
2370 &found_captured_vars);
2369 EXPECT_EQ(first_frame_index, next_frame_index); // a and c not in frame. 2371 EXPECT_EQ(first_frame_index, next_frame_index); // a and c not in frame.
2370 EXPECT_EQ(parent_scope, context_owner); // parent_scope allocated a context. 2372 EXPECT_EQ(parent_scope, context_owner); // parent_scope allocated a context.
2371 const intptr_t parent_scope_context_level = 1; 2373 const intptr_t parent_scope_context_level = 1;
2372 EXPECT_EQ(parent_scope_context_level, parent_scope->context_level()); 2374 EXPECT_EQ(parent_scope_context_level, parent_scope->context_level());
2375 EXPECT(found_captured_vars);
2373 2376
2374 const intptr_t local_scope_context_level = 5; 2377 const intptr_t local_scope_context_level = 5;
2375 const ContextScope& context_scope = ContextScope::Handle( 2378 const ContextScope& context_scope = ContextScope::Handle(
2376 local_scope->PreserveOuterScope(local_scope_context_level)); 2379 local_scope->PreserveOuterScope(local_scope_context_level));
2377 LocalScope* outer_scope = LocalScope::RestoreOuterScope(context_scope); 2380 LocalScope* outer_scope = LocalScope::RestoreOuterScope(context_scope);
2378 EXPECT_EQ(2, outer_scope->num_variables()); 2381 EXPECT_EQ(2, outer_scope->num_variables());
2379 2382
2380 var_a = outer_scope->LocalLookupVariable(a); 2383 var_a = outer_scope->LocalLookupVariable(a);
2381 EXPECT(var_a->is_captured()); 2384 EXPECT(var_a->is_captured());
2382 EXPECT_EQ(0, var_a->index()); // First index. 2385 EXPECT_EQ(0, var_a->index()); // First index.
(...skipping 1626 matching lines...) Expand 10 before | Expand all | Expand 10 after
4009 4012
4010 4013
4011 TEST_CASE(PrintJSON) { 4014 TEST_CASE(PrintJSON) {
4012 Heap* heap = Isolate::Current()->heap(); 4015 Heap* heap = Isolate::Current()->heap();
4013 heap->CollectAllGarbage(); 4016 heap->CollectAllGarbage();
4014 JSONTypeVerifier verifier; 4017 JSONTypeVerifier verifier;
4015 heap->IterateObjects(&verifier); 4018 heap->IterateObjects(&verifier);
4016 } 4019 }
4017 4020
4018 } // namespace dart 4021 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.cc ('k') | runtime/vm/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698