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 // Class for intrinsifying functions. | 4 // Class for intrinsifying functions. |
5 | 5 |
6 #include "vm/assembler.h" | 6 #include "vm/assembler.h" |
7 #include "vm/compiler.h" | 7 #include "vm/compiler.h" |
8 #include "vm/flags.h" | 8 #include "vm/flags.h" |
9 #include "vm/flow_graph.h" | 9 #include "vm/flow_graph.h" |
10 #include "vm/flow_graph_compiler.h" | 10 #include "vm/flow_graph_compiler.h" |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 } | 257 } |
258 | 258 |
259 Definition* AddParameter(intptr_t index) { | 259 Definition* AddParameter(intptr_t index) { |
260 intptr_t adjustment = Intrinsifier::ParameterSlotFromSp(); | 260 intptr_t adjustment = Intrinsifier::ParameterSlotFromSp(); |
261 return AddToInitialDefinitions( | 261 return AddToInitialDefinitions( |
262 new ParameterInstr(adjustment + index, | 262 new ParameterInstr(adjustment + index, |
263 flow_graph_->graph_entry(), | 263 flow_graph_->graph_entry(), |
264 SPREG)); | 264 SPREG)); |
265 } | 265 } |
266 | 266 |
267 intptr_t TokenPos() { | 267 TokenPosition TokenPos() { |
268 return flow_graph_->function().token_pos(); | 268 return flow_graph_->function().token_pos(); |
269 } | 269 } |
270 | 270 |
271 Definition* AddNullDefinition() { | 271 Definition* AddNullDefinition() { |
272 return AddDefinition( | 272 return AddDefinition( |
273 new ConstantInstr(Object::ZoneHandle(Object::null()))); | 273 new ConstantInstr(Object::ZoneHandle(Object::null()))); |
274 } | 274 } |
275 | 275 |
276 Definition* AddUnboxInstr(Representation rep, Value* value) { | 276 Definition* AddUnboxInstr(Representation rep, Value* value) { |
277 Definition* unboxed_value = AddDefinition( | 277 Definition* unboxed_value = AddDefinition( |
278 UnboxInstr::Create(rep, value, Thread::kNoDeoptId)); | 278 UnboxInstr::Create(rep, value, Thread::kNoDeoptId)); |
279 // Manually adjust reaching type because there is no type propagation | 279 // Manually adjust reaching type because there is no type propagation |
280 // when building intrinsics. | 280 // when building intrinsics. |
281 unboxed_value->AsUnbox()->value()->SetReachingType(ZoneCompileType::Wrap( | 281 unboxed_value->AsUnbox()->value()->SetReachingType(ZoneCompileType::Wrap( |
282 CompileType::FromCid(CidForRepresentation(rep)))); | 282 CompileType::FromCid(CidForRepresentation(rep)))); |
283 return unboxed_value; | 283 return unboxed_value; |
284 } | 284 } |
285 | 285 |
286 private: | 286 private: |
287 FlowGraph* flow_graph_; | 287 FlowGraph* flow_graph_; |
288 BlockEntryInstr* entry_; | 288 BlockEntryInstr* entry_; |
289 Instruction* current_; | 289 Instruction* current_; |
290 }; | 290 }; |
291 | 291 |
292 | 292 |
293 static void PrepareIndexedOp(BlockBuilder* builder, | 293 static void PrepareIndexedOp(BlockBuilder* builder, |
294 Definition* array, | 294 Definition* array, |
295 Definition* index, | 295 Definition* index, |
296 intptr_t length_offset) { | 296 intptr_t length_offset) { |
297 intptr_t token_pos = builder->TokenPos(); | 297 TokenPosition token_pos = builder->TokenPos(); |
298 builder->AddInstruction( | 298 builder->AddInstruction( |
299 new CheckSmiInstr(new Value(index), | 299 new CheckSmiInstr(new Value(index), |
300 Thread::kNoDeoptId, | 300 Thread::kNoDeoptId, |
301 token_pos)); | 301 token_pos)); |
302 | 302 |
303 Definition* length = builder->AddDefinition( | 303 Definition* length = builder->AddDefinition( |
304 new LoadFieldInstr(new Value(array), | 304 new LoadFieldInstr(new Value(array), |
305 length_offset, | 305 length_offset, |
306 Type::ZoneHandle(Type::SmiType()), | 306 Type::ZoneHandle(Type::SmiType()), |
307 Token::kNoSourcePos)); | 307 TokenPosition::kNoSource)); |
308 builder->AddInstruction( | 308 builder->AddInstruction( |
309 new CheckArrayBoundInstr(new Value(length), | 309 new CheckArrayBoundInstr(new Value(length), |
310 new Value(index), | 310 new Value(index), |
311 Thread::kNoDeoptId)); | 311 Thread::kNoDeoptId)); |
312 } | 312 } |
313 | 313 |
314 | 314 |
315 bool Intrinsifier::Build_ObjectArrayGetIndexed(FlowGraph* flow_graph) { | 315 bool Intrinsifier::Build_ObjectArrayGetIndexed(FlowGraph* flow_graph) { |
316 GraphEntryInstr* graph_entry = flow_graph->graph_entry(); | 316 GraphEntryInstr* graph_entry = flow_graph->graph_entry(); |
317 TargetEntryInstr* normal_entry = graph_entry->normal_entry(); | 317 TargetEntryInstr* normal_entry = graph_entry->normal_entry(); |
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
881 new UnaryDoubleOpInstr(Token::kNEGATE, | 881 new UnaryDoubleOpInstr(Token::kNEGATE, |
882 new Value(unboxed_value), | 882 new Value(unboxed_value), |
883 Thread::kNoDeoptId)); | 883 Thread::kNoDeoptId)); |
884 Definition* result = builder.AddDefinition( | 884 Definition* result = builder.AddDefinition( |
885 BoxInstr::Create(kUnboxedDouble, new Value(unboxed_result))); | 885 BoxInstr::Create(kUnboxedDouble, new Value(unboxed_result))); |
886 builder.AddIntrinsicReturn(new Value(result)); | 886 builder.AddIntrinsicReturn(new Value(result)); |
887 return true; | 887 return true; |
888 } | 888 } |
889 | 889 |
890 } // namespace dart | 890 } // namespace dart |
OLD | NEW |