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

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

Issue 1020893004: Be less aggressive in sharing contexts between scopes so that sibling contexts (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 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
« no previous file with comments | « runtime/vm/flow_graph_builder.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 #include "platform/globals.h" 5 #include "platform/globals.h"
6 6
7 #include "vm/assembler.h" 7 #include "vm/assembler.h"
8 #include "vm/class_finalizer.h" 8 #include "vm/class_finalizer.h"
9 #include "vm/dart_api_impl.h" 9 #include "vm/dart_api_impl.h"
10 #include "vm/dart_entry.h" 10 #include "vm/dart_entry.h"
(...skipping 2455 matching lines...) Expand 10 before | Expand all | Expand 10 after
2466 test_only = false; // Please, insert alias. 2466 test_only = false; // Please, insert alias.
2467 var_c = local_scope->LookupVariable(c, test_only); 2467 var_c = local_scope->LookupVariable(c, test_only);
2468 EXPECT(var_c->is_captured()); 2468 EXPECT(var_c->is_captured());
2469 2469
2470 EXPECT_EQ(3, local_scope->num_variables()); // a, b, and c alias. 2470 EXPECT_EQ(3, local_scope->num_variables()); // a, b, and c alias.
2471 EXPECT_EQ(2, local_scope->NumCapturedVariables()); // a, c alias. 2471 EXPECT_EQ(2, local_scope->NumCapturedVariables()); // a, c alias.
2472 2472
2473 const int first_parameter_index = 0; 2473 const int first_parameter_index = 0;
2474 const int num_parameters = 0; 2474 const int num_parameters = 0;
2475 const int first_frame_index = -1; 2475 const int first_frame_index = -1;
2476 LocalScope* loop_owner = parent_scope;
2477 LocalScope* context_owner = NULL; // No context allocated yet.
2478 bool found_captured_vars = false; 2476 bool found_captured_vars = false;
2479 int next_frame_index = parent_scope->AllocateVariables(first_parameter_index, 2477 int next_frame_index = parent_scope->AllocateVariables(first_parameter_index,
2480 num_parameters, 2478 num_parameters,
2481 first_frame_index, 2479 first_frame_index,
2482 loop_owner, 2480 NULL,
2483 &context_owner,
2484 &found_captured_vars); 2481 &found_captured_vars);
2485 EXPECT_EQ(first_frame_index, next_frame_index); // a and c not in frame. 2482 EXPECT_EQ(first_frame_index, next_frame_index); // a and c not in frame.
2486 EXPECT_EQ(parent_scope, context_owner); // parent_scope allocated a context.
2487 const intptr_t parent_scope_context_level = 1; 2483 const intptr_t parent_scope_context_level = 1;
2488 EXPECT_EQ(parent_scope_context_level, parent_scope->context_level()); 2484 EXPECT_EQ(parent_scope_context_level, parent_scope->context_level());
2489 EXPECT(found_captured_vars); 2485 EXPECT(found_captured_vars);
2490 2486
2491 const intptr_t local_scope_context_level = 5; 2487 const intptr_t local_scope_context_level = 5;
2492 const ContextScope& context_scope = ContextScope::Handle( 2488 const ContextScope& context_scope = ContextScope::Handle(
2493 local_scope->PreserveOuterScope(local_scope_context_level)); 2489 local_scope->PreserveOuterScope(local_scope_context_level));
2494 LocalScope* outer_scope = LocalScope::RestoreOuterScope(context_scope); 2490 LocalScope* outer_scope = LocalScope::RestoreOuterScope(context_scope);
2495 EXPECT_EQ(2, outer_scope->num_variables()); 2491 EXPECT_EQ(2, outer_scope->num_variables());
2496 2492
(...skipping 1981 matching lines...) Expand 10 before | Expand all | Expand 10 after
4478 EXPECT_VALID(h_result); 4474 EXPECT_VALID(h_result);
4479 Integer& result = Integer::Handle(); 4475 Integer& result = Integer::Handle();
4480 result ^= Api::UnwrapHandle(h_result); 4476 result ^= Api::UnwrapHandle(h_result);
4481 String& foo = String::Handle(String::New("foo")); 4477 String& foo = String::Handle(String::New("foo"));
4482 Integer& expected = Integer::Handle(); 4478 Integer& expected = Integer::Handle();
4483 expected ^= foo.HashCode(); 4479 expected ^= foo.HashCode();
4484 EXPECT(result.IsIdenticalTo(expected)); 4480 EXPECT(result.IsIdenticalTo(expected));
4485 } 4481 }
4486 4482
4487 } // namespace dart 4483 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_builder.cc ('k') | runtime/vm/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698