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

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

Issue 14942010: Eliminate temporary locals for some expressions (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 6 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/bit_vector.h ('k') | runtime/vm/compiler.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/assert.h" 5 #include "platform/assert.h"
6 #include "vm/globals.h" 6 #include "vm/globals.h"
7 #include "vm/ast.h" 7 #include "vm/ast.h"
8 #include "vm/assembler.h" 8 #include "vm/assembler.h"
9 #include "vm/class_finalizer.h" 9 #include "vm/class_finalizer.h"
10 #include "vm/code_generator.h" 10 #include "vm/code_generator.h"
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 343
344 String& constructor_name = String::Handle(String::New("A.")); 344 String& constructor_name = String::Handle(String::New("A."));
345 Function& constructor = 345 Function& constructor =
346 Function::ZoneHandle(cls.LookupConstructor(constructor_name)); 346 Function::ZoneHandle(cls.LookupConstructor(constructor_name));
347 EXPECT(!constructor.IsNull()); 347 EXPECT(!constructor.IsNull());
348 348
349 // The unit test creates an instance of class A and calls function 'bar'. 349 // The unit test creates an instance of class A and calls function 'bar'.
350 String& function_bar_name = String::ZoneHandle(Symbols::New("bar")); 350 String& function_bar_name = String::ZoneHandle(Symbols::New("bar"));
351 ArgumentListNode* no_arguments = new ArgumentListNode(kPos); 351 ArgumentListNode* no_arguments = new ArgumentListNode(kPos);
352 const TypeArguments& no_type_arguments = TypeArguments::ZoneHandle(); 352 const TypeArguments& no_type_arguments = TypeArguments::ZoneHandle();
353 const LocalVariable* allocated = test->CreateTempConstVariable("alloc");
354 InstanceCallNode* call_bar = new InstanceCallNode( 353 InstanceCallNode* call_bar = new InstanceCallNode(
355 kPos, 354 kPos,
356 new ConstructorCallNode( 355 new ConstructorCallNode(
357 kPos, no_type_arguments, constructor, no_arguments, allocated), 356 kPos, no_type_arguments, constructor, no_arguments),
358 function_bar_name, 357 function_bar_name,
359 no_arguments); 358 no_arguments);
360 359
361 test->node_sequence()->Add(new ReturnNode(kPos, call_bar)); 360 test->node_sequence()->Add(new ReturnNode(kPos, call_bar));
362 } 361 }
363 CODEGEN_TEST_RUN(InstanceCallCodegen, Smi::New(42)) 362 CODEGEN_TEST_RUN(InstanceCallCodegen, Smi::New(42))
364 363
365 364
366 // Tested Dart code: 365 // Tested Dart code:
367 // int sum(int a, int b, 366 // int sum(int a, int b,
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 Class& cls = Class::ZoneHandle(LookupClass(lib, "A")); 527 Class& cls = Class::ZoneHandle(LookupClass(lib, "A"));
529 EXPECT(!cls.IsNull()); 528 EXPECT(!cls.IsNull());
530 529
531 String& constructor_name = String::Handle(String::New("A.")); 530 String& constructor_name = String::Handle(String::New("A."));
532 Function& constructor = 531 Function& constructor =
533 Function::ZoneHandle(cls.LookupConstructor(constructor_name)); 532 Function::ZoneHandle(cls.LookupConstructor(constructor_name));
534 EXPECT(!constructor.IsNull()); 533 EXPECT(!constructor.IsNull());
535 534
536 const TypeArguments& no_type_arguments = TypeArguments::ZoneHandle(); 535 const TypeArguments& no_type_arguments = TypeArguments::ZoneHandle();
537 ArgumentListNode* no_arguments = new ArgumentListNode(kPos); 536 ArgumentListNode* no_arguments = new ArgumentListNode(kPos);
538 const LocalVariable* allocated = test->CreateTempConstVariable("alloc");
539 test->node_sequence()->Add(new ReturnNode(kPos, new ConstructorCallNode( 537 test->node_sequence()->Add(new ReturnNode(kPos, new ConstructorCallNode(
540 kPos, no_type_arguments, constructor, no_arguments, allocated))); 538 kPos, no_type_arguments, constructor, no_arguments)));
541 } 539 }
542 540
543 541
544 CODEGEN_TEST_RAW_RUN(AllocateNewObjectCodegen, function) { 542 CODEGEN_TEST_RAW_RUN(AllocateNewObjectCodegen, function) {
545 const Object& result = Object::Handle( 543 const Object& result = Object::Handle(
546 DartEntry::InvokeFunction(function, Object::empty_array())); 544 DartEntry::InvokeFunction(function, Object::empty_array()));
547 EXPECT(!result.IsError()); 545 EXPECT(!result.IsError());
548 const GrowableObjectArray& libs = GrowableObjectArray::Handle( 546 const GrowableObjectArray& libs = GrowableObjectArray::Handle(
549 Isolate::Current()->object_store()->libraries()); 547 Isolate::Current()->object_store()->libraries());
550 ASSERT(!libs.IsNull()); 548 ASSERT(!libs.IsNull());
551 // App lib is the last one that was loaded. 549 // App lib is the last one that was loaded.
552 intptr_t num_libs = libs.Length(); 550 intptr_t num_libs = libs.Length();
553 Library& app_lib = Library::Handle(); 551 Library& app_lib = Library::Handle();
554 app_lib ^= libs.At(num_libs - 1); 552 app_lib ^= libs.At(num_libs - 1);
555 ASSERT(!app_lib.IsNull()); 553 ASSERT(!app_lib.IsNull());
556 const Class& cls = Class::Handle( 554 const Class& cls = Class::Handle(
557 app_lib.LookupClass(String::Handle(Symbols::New("A")))); 555 app_lib.LookupClass(String::Handle(Symbols::New("A"))));
558 EXPECT_EQ(cls.raw(), result.clazz()); 556 EXPECT_EQ(cls.raw(), result.clazz());
559 } 557 }
560 558
561 } // namespace dart 559 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/bit_vector.h ('k') | runtime/vm/compiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698