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

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

Issue 9921017: Intrinsify methods early. Fix some bugs in trinsified code, mark one precision-related bug as SKIP … (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 8 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/code_generator_ia32.h ('k') | runtime/vm/intrinsifier_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 "vm/globals.h" // Needed here to get TARGET_ARCH_IA32. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32.
6 #if defined(TARGET_ARCH_IA32) 6 #if defined(TARGET_ARCH_IA32)
7 7
8 #include "vm/code_generator.h" 8 #include "vm/code_generator.h"
9 9
10 #include "lib/error.h" 10 #include "lib/error.h"
11 #include "vm/ast_printer.h" 11 #include "vm/ast_printer.h"
12 #include "vm/class_finalizer.h" 12 #include "vm/class_finalizer.h"
13 #include "vm/code_descriptors.h" 13 #include "vm/code_descriptors.h"
14 #include "vm/dart_entry.h" 14 #include "vm/dart_entry.h"
15 #include "vm/debugger.h" 15 #include "vm/debugger.h"
16 #include "vm/intrinsifier.h"
16 #include "vm/longjump.h" 17 #include "vm/longjump.h"
17 #include "vm/object.h" 18 #include "vm/object.h"
18 #include "vm/object_store.h" 19 #include "vm/object_store.h"
19 #include "vm/parser.h" 20 #include "vm/parser.h"
20 #include "vm/resolver.h" 21 #include "vm/resolver.h"
21 #include "vm/stub_code.h" 22 #include "vm/stub_code.h"
22 23
23 namespace dart { 24 namespace dart {
24 25
25 DEFINE_FLAG(bool, print_ast, false, "Print abstract syntax tree."); 26 DEFINE_FLAG(bool, print_ast, false, "Print abstract syntax tree.");
26 DEFINE_FLAG(bool, print_scopes, false, "Print scopes of local variables."); 27 DEFINE_FLAG(bool, print_scopes, false, "Print scopes of local variables.");
27 DEFINE_FLAG(bool, trace_functions, false, "Trace entry of each function."); 28 DEFINE_FLAG(bool, trace_functions, false, "Trace entry of each function.");
28 DEFINE_FLAG(bool, print_ic_in_optimized, false, 29 DEFINE_FLAG(bool, print_ic_in_optimized, false,
29 "Debugging helper to identify potential performance pitfalls."); 30 "Debugging helper to identify potential performance pitfalls.");
30 DECLARE_FLAG(int, optimization_counter_threshold); 31 DECLARE_FLAG(int, optimization_counter_threshold);
31 DECLARE_FLAG(bool, enable_type_checks); 32 DECLARE_FLAG(bool, enable_type_checks);
32 DECLARE_FLAG(bool, trace_compiler); 33 DECLARE_FLAG(bool, trace_compiler);
34 DECLARE_FLAG(bool, intrinsify);
35 DECLARE_FLAG(bool, trace_functions);
36
33 37
34 #define __ assembler_-> 38 #define __ assembler_->
35 39
36 40
37 CodeGeneratorState::CodeGeneratorState(CodeGenerator* codegen) 41 CodeGeneratorState::CodeGeneratorState(CodeGenerator* codegen)
38 : StackResource(Isolate::Current()), 42 : StackResource(Isolate::Current()),
39 codegen_(codegen), 43 codegen_(codegen),
40 parent_(codegen->state()) { 44 parent_(codegen->state()) {
41 if (parent_ != NULL) { 45 if (parent_ != NULL) {
42 root_node_ = parent_->root_node_; 46 root_node_ = parent_->root_node_;
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 context_level_(0) { 119 context_level_(0) {
116 ASSERT(assembler_ != NULL); 120 ASSERT(assembler_ != NULL);
117 ASSERT(parsed_function.node_sequence() != NULL); 121 ASSERT(parsed_function.node_sequence() != NULL);
118 ASSERT(Isolate::Current()->long_jump_base()->IsSafeToJump()); 122 ASSERT(Isolate::Current()->long_jump_base()->IsSafeToJump());
119 pc_descriptors_list_ = new DescriptorList(); 123 pc_descriptors_list_ = new DescriptorList();
120 // We do not build any stack maps in the unoptimizing compiler. 124 // We do not build any stack maps in the unoptimizing compiler.
121 exception_handlers_list_ = new CodeGenerator::HandlerList(); 125 exception_handlers_list_ = new CodeGenerator::HandlerList();
122 } 126 }
123 127
124 128
129 void CodeGenerator::IntrinsifyGetter() {
130 // TOS: return address.
131 // +1 : receiver.
132 // Sequence node has one return node, its input is oad field node.
133 const SequenceNode& sequence_node = *parsed_function_.node_sequence();
134 ASSERT(sequence_node.length() == 1);
135 ASSERT(sequence_node.NodeAt(0)->IsReturnNode());
136 const ReturnNode& return_node = *sequence_node.NodeAt(0)->AsReturnNode();
137 ASSERT(return_node.value()->IsLoadInstanceFieldNode());
138 const LoadInstanceFieldNode& load_node =
139 *return_node.value()->AsLoadInstanceFieldNode();
140 __ movl(EAX, Address(ESP, 1 * kWordSize));
141 __ movl(EAX, FieldAddress(EAX, load_node.field().Offset()));
142 __ ret();
143 }
144
145
146 void CodeGenerator::IntrinsifySetter() {
147 // TOS: return address.
148 // +1 : value
149 // +2 : receiver.
150 // Sequence node has one store node and one return NULL node.
151 const SequenceNode& sequence_node = *parsed_function_.node_sequence();
152 ASSERT(sequence_node.length() == 2);
153 ASSERT(sequence_node.NodeAt(0)->IsStoreInstanceFieldNode());
154 ASSERT(sequence_node.NodeAt(1)->IsReturnNode());
155 const StoreInstanceFieldNode& store_node =
156 *sequence_node.NodeAt(0)->AsStoreInstanceFieldNode();
157 __ movl(EAX, Address(ESP, 2 * kWordSize)); // Receiver.
158 __ movl(EBX, Address(ESP, 1 * kWordSize)); // Value.
159 __ StoreIntoObject(EAX, FieldAddress(EAX, store_node.field().Offset()), EBX);
160 const Immediate raw_null =
161 Immediate(reinterpret_cast<intptr_t>(Object::null()));
162 __ movl(EAX, raw_null);
163 __ ret();
164 }
165
166
167
168 bool CodeGenerator::TryIntrinsify() {
169 if (!CanOptimize()) return false;
170 if (FLAG_intrinsify && !FLAG_trace_functions) {
171 if ((parsed_function_.function().kind() == RawFunction::kImplicitGetter)) {
172 IntrinsifyGetter();
173 return true;
174 }
175 // Intrinsification skips arguments checks, therefore disable if in checked
176 // mode.
177 if ((parsed_function_.function().kind() == RawFunction::kImplicitSetter) &&
178 !FLAG_enable_type_checks) {
179 IntrinsifySetter();
180 return true;
181 }
182 }
183 // Even if an intrinsified version of the function was successfully
184 // generated, it may fall through to the non-intrinsified method body.
185 if (!FLAG_trace_functions) {
186 return Intrinsifier::Intrinsify(parsed_function().function(), assembler_);
187 }
188 return false;
189 }
190
191
125 bool CodeGenerator::IsResultNeeded(AstNode* node) const { 192 bool CodeGenerator::IsResultNeeded(AstNode* node) const {
126 return !state()->IsRootNode(node); 193 return !state()->IsRootNode(node);
127 } 194 }
128 195
129 196
130 // NOTE: First 5 bytes of the code may be patched with a jump instruction. Do 197 // NOTE: First 5 bytes of the code may be patched with a jump instruction. Do
131 // not emit any objects in the first 5 bytes. 198 // not emit any objects in the first 5 bytes.
132 void CodeGenerator::GenerateCode() { 199 void CodeGenerator::GenerateCode() {
133 CodeGeneratorState codegen_state(this); 200 CodeGeneratorState codegen_state(this);
134 if (FLAG_print_scopes && FLAG_print_ast) { 201 if (FLAG_print_scopes && FLAG_print_ast) {
(...skipping 2635 matching lines...) Expand 10 before | Expand all | Expand 10 after
2770 const Error& error = Error::Handle( 2837 const Error& error = Error::Handle(
2771 Parser::FormatError(script, token_index, "Error", format, args)); 2838 Parser::FormatError(script, token_index, "Error", format, args));
2772 va_end(args); 2839 va_end(args);
2773 Isolate::Current()->long_jump_base()->Jump(1, error); 2840 Isolate::Current()->long_jump_base()->Jump(1, error);
2774 UNREACHABLE(); 2841 UNREACHABLE();
2775 } 2842 }
2776 2843
2777 } // namespace dart 2844 } // namespace dart
2778 2845
2779 #endif // defined TARGET_ARCH_IA32 2846 #endif // defined TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « runtime/vm/code_generator_ia32.h ('k') | runtime/vm/intrinsifier_ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698