OLD | NEW |
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" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 locals_space_size_(-1), | 65 locals_space_size_(-1), |
66 state_(NULL), | 66 state_(NULL), |
67 pc_descriptors_list_(NULL), | 67 pc_descriptors_list_(NULL), |
68 stackmap_builder_(NULL), | 68 stackmap_builder_(NULL), |
69 exception_handlers_list_(NULL), | 69 exception_handlers_list_(NULL), |
70 try_index_(CatchClauseNode::kInvalidTryIndex), | 70 try_index_(CatchClauseNode::kInvalidTryIndex), |
71 context_level_(0) { | 71 context_level_(0) { |
72 ASSERT(assembler_ != NULL); | 72 ASSERT(assembler_ != NULL); |
73 ASSERT(parsed_function.node_sequence() != NULL); | 73 ASSERT(parsed_function.node_sequence() != NULL); |
74 ASSERT(Isolate::Current()->long_jump_base()->IsSafeToJump()); | 74 ASSERT(Isolate::Current()->long_jump_base()->IsSafeToJump()); |
| 75 } |
| 76 |
| 77 |
| 78 void CodeGenerator::InitGenerator() { |
75 pc_descriptors_list_ = new DescriptorList(); | 79 pc_descriptors_list_ = new DescriptorList(); |
76 // We do not build any stack maps in the unoptimizing compiler. | 80 // We do not build any stack maps in the unoptimizing compiler. |
77 exception_handlers_list_ = new ExceptionHandlerList(); | 81 exception_handlers_list_ = new ExceptionHandlerList(); |
78 } | 82 } |
79 | 83 |
80 | 84 |
81 void CodeGenerator::IntrinsifyGetter() { | 85 void CodeGenerator::IntrinsifyGetter() { |
82 // TOS: return address. | 86 // TOS: return address. |
83 // +1 : receiver. | 87 // +1 : receiver. |
84 // Sequence node has one return node, its input is oad field node. | 88 // Sequence node has one return node, its input is oad field node. |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 | 145 |
142 | 146 |
143 bool CodeGenerator::IsResultNeeded(AstNode* node) const { | 147 bool CodeGenerator::IsResultNeeded(AstNode* node) const { |
144 return !state()->IsRootNode(node); | 148 return !state()->IsRootNode(node); |
145 } | 149 } |
146 | 150 |
147 | 151 |
148 // NOTE: First 5 bytes of the code may be patched with a jump instruction. Do | 152 // NOTE: First 5 bytes of the code may be patched with a jump instruction. Do |
149 // not emit any objects in the first 5 bytes. | 153 // not emit any objects in the first 5 bytes. |
150 void CodeGenerator::GenerateCode() { | 154 void CodeGenerator::GenerateCode() { |
| 155 InitGenerator(); |
151 CodeGeneratorState codegen_state(this); | 156 CodeGeneratorState codegen_state(this); |
152 if (FLAG_print_scopes && FLAG_print_ast) { | 157 if (FLAG_print_scopes && FLAG_print_ast) { |
153 // Print the function scope before code generation. | 158 // Print the function scope before code generation. |
154 AstPrinter::PrintFunctionScope(parsed_function_); | 159 AstPrinter::PrintFunctionScope(parsed_function_); |
155 } | 160 } |
156 if (FLAG_print_ast) { | 161 if (FLAG_print_ast) { |
157 // Print the function ast before code generation. | 162 // Print the function ast before code generation. |
158 AstPrinter::PrintFunctionNodes(parsed_function_); | 163 AstPrinter::PrintFunctionNodes(parsed_function_); |
159 } | 164 } |
160 if (FLAG_trace_functions) { | 165 if (FLAG_trace_functions) { |
(...skipping 2793 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2954 const Error& error = Error::Handle( | 2959 const Error& error = Error::Handle( |
2955 Parser::FormatError(script, token_index, "Error", format, args)); | 2960 Parser::FormatError(script, token_index, "Error", format, args)); |
2956 va_end(args); | 2961 va_end(args); |
2957 Isolate::Current()->long_jump_base()->Jump(1, error); | 2962 Isolate::Current()->long_jump_base()->Jump(1, error); |
2958 UNREACHABLE(); | 2963 UNREACHABLE(); |
2959 } | 2964 } |
2960 | 2965 |
2961 } // namespace dart | 2966 } // namespace dart |
2962 | 2967 |
2963 #endif // defined TARGET_ARCH_IA32 | 2968 #endif // defined TARGET_ARCH_IA32 |
OLD | NEW |