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

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

Issue 678763004: Make CTX allocatable by the register allocator. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: incorporated latest comments Created 6 years, 1 month 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
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 7
8 #include "vm/ast.h" 8 #include "vm/ast.h"
9 #include "vm/assembler.h" 9 #include "vm/assembler.h"
10 #include "vm/code_descriptors.h" 10 #include "vm/code_descriptors.h"
11 #include "vm/compiler.h" 11 #include "vm/compiler.h"
12 #include "vm/dart_entry.h" 12 #include "vm/dart_entry.h"
13 #include "vm/native_entry.h" 13 #include "vm/native_entry.h"
14 #include "vm/parser.h" 14 #include "vm/parser.h"
15 #include "vm/symbols.h" 15 #include "vm/symbols.h"
16 #include "vm/unit_test.h" 16 #include "vm/unit_test.h"
17 17
18 namespace dart { 18 namespace dart {
19 19
20 static const intptr_t kPos = Scanner::kNoSourcePos; 20 static const intptr_t kPos = Scanner::kNoSourcePos;
21 21
22 22
23 CODEGEN_TEST_GENERATE(StackmapCodegen, test) { 23 CODEGEN_TEST_GENERATE(StackmapCodegen, test) {
24 Assembler assembler;
25 const String& function_name = String::ZoneHandle(Symbols::New("test"));
26 Class& cls = Class::ZoneHandle();
27 const Script& script = Script::Handle();
28 cls = Class::New(function_name, script, Scanner::kNoSourcePos);
29 const Function& function = Function::ZoneHandle(
30 Function::New(function_name, RawFunction::kRegularFunction,
31 true, false, false, false, false, cls, 0));
32 function.set_result_type(Type::Handle(Type::DynamicType()));
33 const Array& functions = Array::Handle(Array::New(1));
34 functions.SetAt(0, function);
35 cls.SetFunctions(functions);
36 Library& lib = Library::Handle(Library::CoreLibrary());
37 lib.AddClass(cls);
38 ParsedFunction* parsed_function = 24 ParsedFunction* parsed_function =
39 new ParsedFunction(Isolate::Current(), function); 25 new ParsedFunction(Isolate::Current(), test->function());
40 LiteralNode* l = new LiteralNode(kPos, Smi::ZoneHandle(Smi::New(1))); 26 LiteralNode* l = new LiteralNode(kPos, Smi::ZoneHandle(Smi::New(1)));
41 test->node_sequence()->Add(new ReturnNode(kPos, l)); 27 test->node_sequence()->Add(new ReturnNode(kPos, l));
42 l = new LiteralNode(kPos, Smi::ZoneHandle(Smi::New(2))); 28 l = new LiteralNode(kPos, Smi::ZoneHandle(Smi::New(2)));
43 test->node_sequence()->Add(new ReturnNode(kPos, l)); 29 test->node_sequence()->Add(new ReturnNode(kPos, l));
44 l = new LiteralNode(kPos, Smi::ZoneHandle(Smi::New(3))); 30 l = new LiteralNode(kPos, Smi::ZoneHandle(Smi::New(3)));
45 test->node_sequence()->Add(new ReturnNode(kPos, l)); 31 test->node_sequence()->Add(new ReturnNode(kPos, l));
46 parsed_function->SetNodeSequence(test->node_sequence()); 32 parsed_function->SetNodeSequence(test->node_sequence());
47 parsed_function->set_instantiator(NULL); 33 parsed_function->set_instantiator(NULL);
48 parsed_function->set_default_parameter_values(Object::null_array()); 34 parsed_function->set_default_parameter_values(Object::null_array());
35 parsed_function->EnsureExpressionTemp();
36 test->node_sequence()->scope()->AddVariable(
37 parsed_function->expression_temp_var());
38 test->node_sequence()->scope()->AddVariable(
39 parsed_function->current_context_var());
49 parsed_function->AllocateVariables(); 40 parsed_function->AllocateVariables();
50 bool retval; 41 bool retval;
51 Isolate* isolate = Isolate::Current(); 42 Isolate* isolate = Isolate::Current();
52 EXPECT(isolate != NULL); 43 EXPECT(isolate != NULL);
53 LongJumpScope jump; 44 LongJumpScope jump;
54 if (setjmp(*jump.Set()) == 0) { 45 if (setjmp(*jump.Set()) == 0) {
55 // Build a stackmap table and some stackmap table entries. 46 // Build a stackmap table and some stackmap table entries.
56 const intptr_t kStackSlotCount = 11; 47 const intptr_t kStackSlotCount = 11;
57 StackmapTableBuilder* stackmap_table_builder = new StackmapTableBuilder(); 48 StackmapTableBuilder* stackmap_table_builder = new StackmapTableBuilder();
58 EXPECT(stackmap_table_builder != NULL); 49 EXPECT(stackmap_table_builder != NULL);
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 false, false, true }; 117 false, false, true };
127 for (intptr_t i = 0; i < kStackSlotCount; ++i) { 118 for (intptr_t i = 0; i < kStackSlotCount; ++i) {
128 EXPECT_EQ(expectation3[i], stack_bitmap->Get(i)); 119 EXPECT_EQ(expectation3[i], stack_bitmap->Get(i));
129 } 120 }
130 // Add a stack map entry at pc offset 3. 121 // Add a stack map entry at pc offset 3.
131 stackmap_table_builder->AddEntry(3, stack_bitmap, 0); 122 stackmap_table_builder->AddEntry(3, stack_bitmap, 0);
132 123
133 const Error& error = 124 const Error& error =
134 Error::Handle(Compiler::CompileParsedFunction(parsed_function)); 125 Error::Handle(Compiler::CompileParsedFunction(parsed_function));
135 EXPECT(error.IsNull()); 126 EXPECT(error.IsNull());
136 const Code& code = Code::Handle(function.CurrentCode()); 127 const Code& code = Code::Handle(test->function().CurrentCode());
137 128
138 const Array& stack_maps = 129 const Array& stack_maps =
139 Array::Handle(stackmap_table_builder->FinalizeStackmaps(code)); 130 Array::Handle(stackmap_table_builder->FinalizeStackmaps(code));
140 code.set_stackmaps(stack_maps); 131 code.set_stackmaps(stack_maps);
141 const Array& stack_map_list = Array::Handle(code.stackmaps()); 132 const Array& stack_map_list = Array::Handle(code.stackmaps());
142 EXPECT(!stack_map_list.IsNull()); 133 EXPECT(!stack_map_list.IsNull());
143 Stackmap& stack_map = Stackmap::Handle(); 134 Stackmap& stack_map = Stackmap::Handle();
144 EXPECT_EQ(4, stack_map_list.Length()); 135 EXPECT_EQ(4, stack_map_list.Length());
145 136
146 // Validate the first stack map entry. 137 // Validate the first stack map entry.
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 264
274 // Now invoke 'A.moo' and it will trigger a GC when the native function 265 // Now invoke 'A.moo' and it will trigger a GC when the native function
275 // is called, this should then cause the stack map of function 'A.foo' 266 // is called, this should then cause the stack map of function 'A.foo'
276 // to be traversed and the appropriate objects visited. 267 // to be traversed and the appropriate objects visited.
277 const Object& result = Object::Handle( 268 const Object& result = Object::Handle(
278 DartEntry::InvokeFunction(function_foo, Object::empty_array())); 269 DartEntry::InvokeFunction(function_foo, Object::empty_array()));
279 EXPECT(!result.IsError()); 270 EXPECT(!result.IsError());
280 } 271 }
281 272
282 } // namespace dart 273 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/lib/mirrors.cc ('k') | runtime/vm/compiler.cc » ('j') | runtime/vm/debugger.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698