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

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

Issue 11228022: Cache parsed functions when inlining. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: virtual Created 8 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
« no previous file with comments | « no previous file | 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 #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"
(...skipping 18 matching lines...) Expand all
29 cls = Class::New(function_name, script, Scanner::kDummyTokenIndex); 29 cls = Class::New(function_name, script, Scanner::kDummyTokenIndex);
30 const Function& function = Function::Handle( 30 const Function& function = Function::Handle(
31 Function::New(function_name, RawFunction::kRegularFunction, 31 Function::New(function_name, RawFunction::kRegularFunction,
32 true, false, false, false, cls, 0)); 32 true, false, false, false, cls, 0));
33 function.set_result_type(Type::Handle(Type::DynamicType())); 33 function.set_result_type(Type::Handle(Type::DynamicType()));
34 const Array& functions = Array::Handle(Array::New(1)); 34 const Array& functions = Array::Handle(Array::New(1));
35 functions.SetAt(0, function); 35 functions.SetAt(0, function);
36 cls.SetFunctions(functions); 36 cls.SetFunctions(functions);
37 Library& lib = Library::Handle(Library::CoreLibrary()); 37 Library& lib = Library::Handle(Library::CoreLibrary());
38 lib.AddClass(cls); 38 lib.AddClass(cls);
39 ParsedFunction parsed_function(function); 39 ParsedFunction* parsed_function = new ParsedFunction(function);
40 LiteralNode* l = new LiteralNode(kPos, Smi::ZoneHandle(Smi::New(1))); 40 LiteralNode* l = new LiteralNode(kPos, Smi::ZoneHandle(Smi::New(1)));
41 test->node_sequence()->Add(new ReturnNode(kPos, l)); 41 test->node_sequence()->Add(new ReturnNode(kPos, l));
42 l = new LiteralNode(kPos, Smi::ZoneHandle(Smi::New(2))); 42 l = new LiteralNode(kPos, Smi::ZoneHandle(Smi::New(2)));
43 test->node_sequence()->Add(new ReturnNode(kPos, l)); 43 test->node_sequence()->Add(new ReturnNode(kPos, l));
44 l = new LiteralNode(kPos, Smi::ZoneHandle(Smi::New(3))); 44 l = new LiteralNode(kPos, Smi::ZoneHandle(Smi::New(3)));
45 test->node_sequence()->Add(new ReturnNode(kPos, l)); 45 test->node_sequence()->Add(new ReturnNode(kPos, l));
46 parsed_function.SetNodeSequence(test->node_sequence()); 46 parsed_function->SetNodeSequence(test->node_sequence());
47 parsed_function.set_instantiator(NULL); 47 parsed_function->set_instantiator(NULL);
48 parsed_function.set_default_parameter_values(Array::Handle()); 48 parsed_function->set_default_parameter_values(Array::Handle());
49 parsed_function.AllocateVariables(); 49 parsed_function->AllocateVariables();
50 bool retval; 50 bool retval;
51 Isolate* isolate = Isolate::Current(); 51 Isolate* isolate = Isolate::Current();
52 EXPECT(isolate != NULL); 52 EXPECT(isolate != NULL);
53 LongJump* base = isolate->long_jump_base(); 53 LongJump* base = isolate->long_jump_base();
54 LongJump jump; 54 LongJump jump;
55 isolate->set_long_jump_base(&jump); 55 isolate->set_long_jump_base(&jump);
56 if (setjmp(*jump.Set()) == 0) { 56 if (setjmp(*jump.Set()) == 0) {
57 // Build a stackmap table and some stackmap table entries. 57 // Build a stackmap table and some stackmap table entries.
58 const intptr_t kStackSlotCount = 11; 58 const intptr_t kStackSlotCount = 11;
59 StackmapTableBuilder* stackmap_table_builder = new StackmapTableBuilder(); 59 StackmapTableBuilder* stackmap_table_builder = new StackmapTableBuilder();
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 bool expectation3[kStackSlotCount] = 126 bool expectation3[kStackSlotCount] =
127 { true, false, true, true, true, true, false, false, 127 { true, false, true, true, true, true, false, false,
128 false, false, true }; 128 false, false, true };
129 for (intptr_t i = 0; i < kStackSlotCount; ++i) { 129 for (intptr_t i = 0; i < kStackSlotCount; ++i) {
130 EXPECT_EQ(expectation3[i], stack_bitmap->Get(i)); 130 EXPECT_EQ(expectation3[i], stack_bitmap->Get(i));
131 } 131 }
132 // Add a stack map entry at pc offset 3. 132 // Add a stack map entry at pc offset 3.
133 stackmap_table_builder->AddEntry(3, stack_bitmap, 0); 133 stackmap_table_builder->AddEntry(3, stack_bitmap, 0);
134 134
135 const Error& error = 135 const Error& error =
136 Error::Handle(Compiler::CompileParsedFunction(parsed_function)); 136 Error::Handle(Compiler::CompileParsedFunction(*parsed_function));
137 EXPECT(error.IsNull()); 137 EXPECT(error.IsNull());
138 const Code& code = Code::Handle(function.CurrentCode()); 138 const Code& code = Code::Handle(function.CurrentCode());
139 139
140 const Array& stack_maps = 140 const Array& stack_maps =
141 Array::Handle(stackmap_table_builder->FinalizeStackmaps(code)); 141 Array::Handle(stackmap_table_builder->FinalizeStackmaps(code));
142 code.set_stackmaps(stack_maps); 142 code.set_stackmaps(stack_maps);
143 const Array& stack_map_list = Array::Handle(code.stackmaps()); 143 const Array& stack_map_list = Array::Handle(code.stackmaps());
144 EXPECT(!stack_map_list.IsNull()); 144 EXPECT(!stack_map_list.IsNull());
145 Stackmap& stack_map = Stackmap::Handle(); 145 Stackmap& stack_map = Stackmap::Handle();
146 EXPECT_EQ(4, stack_map_list.Length()); 146 EXPECT_EQ(4, stack_map_list.Length());
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 GrowableArray<const Object*> arguments; 280 GrowableArray<const Object*> arguments;
281 const Array& kNoArgumentNames = Array::Handle(); 281 const Array& kNoArgumentNames = Array::Handle();
282 Object& result = Object::Handle(); 282 Object& result = Object::Handle();
283 result = DartEntry::InvokeStatic(function_foo, arguments, kNoArgumentNames); 283 result = DartEntry::InvokeStatic(function_foo, arguments, kNoArgumentNames);
284 EXPECT(!result.IsError()); 284 EXPECT(!result.IsError());
285 } 285 }
286 286
287 } // namespace dart 287 } // namespace dart
288 288
289 #endif // defined TARGET_ARCH_IA32 || defined(TARGET_ARCH_X64) 289 #endif // defined TARGET_ARCH_IA32 || defined(TARGET_ARCH_X64)
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/compiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698