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

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

Issue 10786003: Ensure objects emitted in code are allocated in old space. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: address review comments Created 8 years, 5 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/bigint_operations.cc ('k') | runtime/vm/flow_graph_compiler_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) 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 #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64) 7 #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64)
8 8
9 #include "vm/ast.h" 9 #include "vm/ast.h"
10 #include "vm/assembler.h" 10 #include "vm/assembler.h"
11 #include "vm/class_finalizer.h" 11 #include "vm/class_finalizer.h"
12 #include "vm/code_generator.h" 12 #include "vm/code_generator.h"
13 #include "vm/compiler.h" 13 #include "vm/compiler.h"
14 #include "vm/dart_entry.h" 14 #include "vm/dart_entry.h"
15 #include "vm/native_entry.h" 15 #include "vm/native_entry.h"
16 #include "vm/native_entry_test.h" 16 #include "vm/native_entry_test.h"
17 #include "vm/unit_test.h" 17 #include "vm/unit_test.h"
18 #include "vm/virtual_memory.h" 18 #include "vm/virtual_memory.h"
19 19
20 namespace dart { 20 namespace dart {
21 21
22 static const intptr_t kPos = Scanner::kDummyTokenIndex; 22 static const intptr_t kPos = Scanner::kDummyTokenIndex;
23 23
24 24
25 // Helper to allocate and return a LocalVariable. 25 // Helper to allocate and return a LocalVariable.
26 static LocalVariable* NewTestLocalVariable(const char* name) { 26 static LocalVariable* NewTestLocalVariable(const char* name) {
27 const String& variable_name = String::ZoneHandle(String::New(name)); 27 const String& variable_name = String::ZoneHandle(String::NewSymbol(name));
28 const Type& variable_type = Type::ZoneHandle(Type::DynamicType()); 28 const Type& variable_type = Type::ZoneHandle(Type::DynamicType());
29 return new LocalVariable(kPos, variable_name, variable_type); 29 return new LocalVariable(kPos, variable_name, variable_type);
30 } 30 }
31 31
32 32
33 CODEGEN_TEST_GENERATE(SimpleReturnCodegen, test) { 33 CODEGEN_TEST_GENERATE(SimpleReturnCodegen, test) {
34 test->node_sequence()->Add(new ReturnNode(kPos)); 34 test->node_sequence()->Add(new ReturnNode(kPos));
35 } 35 }
36 CODEGEN_TEST_RUN(SimpleReturnCodegen, Instance::null()) 36 CODEGEN_TEST_RUN(SimpleReturnCodegen, Instance::null())
37 37
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 LiteralNode* a = new LiteralNode(kPos, Smi::ZoneHandle(Smi::New(3))); 122 LiteralNode* a = new LiteralNode(kPos, Smi::ZoneHandle(Smi::New(3)));
123 LiteralNode* b = new LiteralNode(kPos, Smi::ZoneHandle(Smi::New(2))); 123 LiteralNode* b = new LiteralNode(kPos, Smi::ZoneHandle(Smi::New(2)));
124 BinaryOpNode* add_node = new BinaryOpNode(kPos, Token::kADD, a, b); 124 BinaryOpNode* add_node = new BinaryOpNode(kPos, Token::kADD, a, b);
125 node_seq->Add(new ReturnNode(kPos, add_node)); 125 node_seq->Add(new ReturnNode(kPos, add_node));
126 } 126 }
127 CODEGEN_TEST_RUN(SmiAddCodegen, Smi::New(5)) 127 CODEGEN_TEST_RUN(SmiAddCodegen, Smi::New(5))
128 128
129 129
130 CODEGEN_TEST_GENERATE(GenericAddCodegen, test) { 130 CODEGEN_TEST_GENERATE(GenericAddCodegen, test) {
131 SequenceNode* node_seq = test->node_sequence(); 131 SequenceNode* node_seq = test->node_sequence();
132 LiteralNode* a = new LiteralNode(kPos, Double::ZoneHandle(Double::New(12.2))); 132 LiteralNode* a =
133 new LiteralNode(kPos, Double::ZoneHandle(Double::New(12.2, Heap::kOld)));
133 LiteralNode* b = new LiteralNode(kPos, Smi::ZoneHandle(Smi::New(2))); 134 LiteralNode* b = new LiteralNode(kPos, Smi::ZoneHandle(Smi::New(2)));
134 BinaryOpNode* add_node_1 = new BinaryOpNode(kPos, Token::kADD, a, b); 135 BinaryOpNode* add_node_1 = new BinaryOpNode(kPos, Token::kADD, a, b);
135 LiteralNode* c = new LiteralNode(kPos, Double::ZoneHandle(Double::New(0.8))); 136 LiteralNode* c =
137 new LiteralNode(kPos, Double::ZoneHandle(Double::New(0.8, Heap::kOld)));
136 BinaryOpNode* add_node_2 = new BinaryOpNode(kPos, Token::kADD, add_node_1, c); 138 BinaryOpNode* add_node_2 = new BinaryOpNode(kPos, Token::kADD, add_node_1, c);
137 node_seq->Add(new ReturnNode(kPos, add_node_2)); 139 node_seq->Add(new ReturnNode(kPos, add_node_2));
138 } 140 }
139 CODEGEN_TEST_RUN(GenericAddCodegen, Double::New(15.0)) 141 CODEGEN_TEST_RUN(GenericAddCodegen, Double::New(15.0))
140 142
141 143
142 CODEGEN_TEST_GENERATE(SmiBinaryOpCodegen, test) { 144 CODEGEN_TEST_GENERATE(SmiBinaryOpCodegen, test) {
143 SequenceNode* node_seq = test->node_sequence(); 145 SequenceNode* node_seq = test->node_sequence();
144 LiteralNode* a = new LiteralNode(kPos, Smi::ZoneHandle(Smi::New(4))); 146 LiteralNode* a = new LiteralNode(kPos, Smi::ZoneHandle(Smi::New(4)));
145 LiteralNode* b = new LiteralNode(kPos, Smi::ZoneHandle(Smi::New(2))); 147 LiteralNode* b = new LiteralNode(kPos, Smi::ZoneHandle(Smi::New(2)));
(...skipping 26 matching lines...) Expand all
172 LiteralNode* a = new LiteralNode(kPos, bool_true); 174 LiteralNode* a = new LiteralNode(kPos, bool_true);
173 LiteralNode* b = new LiteralNode(kPos, bool_false); 175 LiteralNode* b = new LiteralNode(kPos, bool_false);
174 BinaryOpNode* and_node = new BinaryOpNode(kPos, Token::kAND, a, b); 176 BinaryOpNode* and_node = new BinaryOpNode(kPos, Token::kAND, a, b);
175 node_seq->Add(new ReturnNode(kPos, and_node)); 177 node_seq->Add(new ReturnNode(kPos, and_node));
176 } 178 }
177 CODEGEN_TEST_RUN(BoolAndCodegen, Bool::False()) 179 CODEGEN_TEST_RUN(BoolAndCodegen, Bool::False())
178 180
179 181
180 CODEGEN_TEST_GENERATE(BinaryOpCodegen, test) { 182 CODEGEN_TEST_GENERATE(BinaryOpCodegen, test) {
181 SequenceNode* node_seq = test->node_sequence(); 183 SequenceNode* node_seq = test->node_sequence();
182 LiteralNode* a = new LiteralNode(kPos, Double::ZoneHandle(Double::New(12))); 184 LiteralNode* a =
185 new LiteralNode(kPos, Double::ZoneHandle(Double::New(12, Heap::kOld)));
183 LiteralNode* b = new LiteralNode(kPos, Smi::ZoneHandle(Smi::New(2))); 186 LiteralNode* b = new LiteralNode(kPos, Smi::ZoneHandle(Smi::New(2)));
184 LiteralNode* c = new LiteralNode(kPos, Double::ZoneHandle(Double::New(0.5))); 187 LiteralNode* c =
188 new LiteralNode(kPos, Double::ZoneHandle(Double::New(0.5, Heap::kOld)));
185 BinaryOpNode* sub_node = new BinaryOpNode(kPos, Token::kSUB, a, b); 189 BinaryOpNode* sub_node = new BinaryOpNode(kPos, Token::kSUB, a, b);
186 BinaryOpNode* mul_node = new BinaryOpNode(kPos, Token::kMUL, sub_node, c); 190 BinaryOpNode* mul_node = new BinaryOpNode(kPos, Token::kMUL, sub_node, c);
187 BinaryOpNode* div_node = new BinaryOpNode(kPos, Token::kDIV, mul_node, b); 191 BinaryOpNode* div_node = new BinaryOpNode(kPos, Token::kDIV, mul_node, b);
188 node_seq->Add(new ReturnNode(kPos, div_node)); 192 node_seq->Add(new ReturnNode(kPos, div_node));
189 } 193 }
190 CODEGEN_TEST_RUN(BinaryOpCodegen, Double::New(2.5)); 194 CODEGEN_TEST_RUN(BinaryOpCodegen, Double::New(2.5));
191 195
192 196
193 // Tested Dart code: 197 // Tested Dart code:
194 // int dec(int a, int b = 1) native: "TestSmiSub"; 198 // int dec(int a, int b = 1) native: "TestSmiSub";
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 SequenceNode* node_seq = test->node_sequence(); 248 SequenceNode* node_seq = test->node_sequence();
245 LiteralNode* a = new LiteralNode(kPos, Smi::ZoneHandle(Smi::New(12))); 249 LiteralNode* a = new LiteralNode(kPos, Smi::ZoneHandle(Smi::New(12)));
246 UnaryOpNode* neg_node = new UnaryOpNode(kPos, Token::kSUB, a); 250 UnaryOpNode* neg_node = new UnaryOpNode(kPos, Token::kSUB, a);
247 node_seq->Add(new ReturnNode(kPos, neg_node)); 251 node_seq->Add(new ReturnNode(kPos, neg_node));
248 } 252 }
249 CODEGEN_TEST_RUN(SmiUnaryOpCodegen, Smi::New(-12)) 253 CODEGEN_TEST_RUN(SmiUnaryOpCodegen, Smi::New(-12))
250 254
251 255
252 CODEGEN_TEST_GENERATE(DoubleUnaryOpCodegen, test) { 256 CODEGEN_TEST_GENERATE(DoubleUnaryOpCodegen, test) {
253 SequenceNode* node_seq = test->node_sequence(); 257 SequenceNode* node_seq = test->node_sequence();
254 LiteralNode* a = new LiteralNode(kPos, Double::ZoneHandle(Double::New(12.0))); 258 LiteralNode* a =
259 new LiteralNode(kPos, Double::ZoneHandle(Double::New(12.0, Heap::kOld)));
255 UnaryOpNode* neg_node = new UnaryOpNode(kPos, Token::kSUB, a); 260 UnaryOpNode* neg_node = new UnaryOpNode(kPos, Token::kSUB, a);
256 node_seq->Add(new ReturnNode(kPos, neg_node)); 261 node_seq->Add(new ReturnNode(kPos, neg_node));
257 } 262 }
258 CODEGEN_TEST_RUN(DoubleUnaryOpCodegen, Double::New(-12.0)) 263 CODEGEN_TEST_RUN(DoubleUnaryOpCodegen, Double::New(-12.0))
259 264
260 265
261 static Library& MakeTestLibrary(const char* url) { 266 static Library& MakeTestLibrary(const char* url) {
262 const String& lib_url = String::ZoneHandle(String::NewSymbol(url)); 267 const String& lib_url = String::ZoneHandle(String::NewSymbol(url));
263 Library& lib = Library::ZoneHandle(Library::New(lib_url)); 268 Library& lib = Library::ZoneHandle(Library::New(lib_url));
264 lib.Register(); 269 lib.Register();
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 app_lib ^= libs.At(num_libs - 1); 504 app_lib ^= libs.At(num_libs - 1);
500 ASSERT(!app_lib.IsNull()); 505 ASSERT(!app_lib.IsNull());
501 const Class& cls = Class::Handle( 506 const Class& cls = Class::Handle(
502 app_lib.LookupClass(String::Handle(String::NewSymbol("A")))); 507 app_lib.LookupClass(String::Handle(String::NewSymbol("A"))));
503 EXPECT_EQ(cls.raw(), result.clazz()); 508 EXPECT_EQ(cls.raw(), result.clazz());
504 } 509 }
505 510
506 } // namespace dart 511 } // namespace dart
507 512
508 #endif // defined TARGET_ARCH_IA32 || defined(TARGET_ARCH_X64) 513 #endif // defined TARGET_ARCH_IA32 || defined(TARGET_ARCH_X64)
OLDNEW
« no previous file with comments | « runtime/vm/bigint_operations.cc ('k') | runtime/vm/flow_graph_compiler_ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698