| 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/intrinsifier.h" | 7 #include "vm/intrinsifier.h" |
| 8 #include "vm/flags.h" | 8 #include "vm/flags.h" |
| 9 #include "vm/object.h" | 9 #include "vm/object.h" |
| 10 #include "vm/symbols.h" | 10 #include "vm/symbols.h" |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 *ic_data_array, | 131 *ic_data_array, |
| 132 NULL, // NULL = not inlining. | 132 NULL, // NULL = not inlining. |
| 133 Isolate::kNoDeoptId); // No OSR id. | 133 Isolate::kNoDeoptId); // No OSR id. |
| 134 | 134 |
| 135 intptr_t block_id = builder.AllocateBlockId(); | 135 intptr_t block_id = builder.AllocateBlockId(); |
| 136 TargetEntryInstr* normal_entry = | 136 TargetEntryInstr* normal_entry = |
| 137 new TargetEntryInstr(block_id, | 137 new TargetEntryInstr(block_id, |
| 138 CatchClauseNode::kInvalidTryIndex); | 138 CatchClauseNode::kInvalidTryIndex); |
| 139 GraphEntryInstr* graph_entry = new GraphEntryInstr( | 139 GraphEntryInstr* graph_entry = new GraphEntryInstr( |
| 140 parsed_function, normal_entry, Isolate::kNoDeoptId); // No OSR id. | 140 parsed_function, normal_entry, Isolate::kNoDeoptId); // No OSR id. |
| 141 FlowGraph* graph = new FlowGraph(builder, graph_entry, block_id); | 141 FlowGraph* graph = new FlowGraph(parsed_function, graph_entry, block_id); |
| 142 const Function& function = parsed_function->function(); | 142 const Function& function = parsed_function->function(); |
| 143 switch (function.recognized_kind()) { | 143 switch (function.recognized_kind()) { |
| 144 #define EMIT_CASE(test_class_name, test_function_name, enum_name, fp) \ | 144 #define EMIT_CASE(test_class_name, test_function_name, enum_name, fp) \ |
| 145 case MethodRecognizer::k##enum_name: \ | 145 case MethodRecognizer::k##enum_name: \ |
| 146 ASSERT(function.CheckSourceFingerprint(fp)); \ | 146 ASSERT(function.CheckSourceFingerprint(fp)); \ |
| 147 if (!Build_##enum_name(graph)) return false; \ | 147 if (!Build_##enum_name(graph)) return false; \ |
| 148 break; | 148 break; |
| 149 | 149 |
| 150 GRAPH_INTRINSICS_LIST(EMIT_CASE); | 150 GRAPH_INTRINSICS_LIST(EMIT_CASE); |
| 151 default: | 151 default: |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 | 243 |
| 244 Definition* AddParameter(intptr_t index) { | 244 Definition* AddParameter(intptr_t index) { |
| 245 intptr_t adjustment = Intrinsifier::ParameterSlotFromSp(); | 245 intptr_t adjustment = Intrinsifier::ParameterSlotFromSp(); |
| 246 return AddToInitialDefinitions( | 246 return AddToInitialDefinitions( |
| 247 new ParameterInstr(adjustment + index, | 247 new ParameterInstr(adjustment + index, |
| 248 flow_graph_->graph_entry(), | 248 flow_graph_->graph_entry(), |
| 249 SPREG)); | 249 SPREG)); |
| 250 } | 250 } |
| 251 | 251 |
| 252 intptr_t TokenPos() { | 252 intptr_t TokenPos() { |
| 253 return flow_graph_->parsed_function().function().token_pos(); | 253 return flow_graph_->parsed_function()->function().token_pos(); |
| 254 } | 254 } |
| 255 | 255 |
| 256 private: | 256 private: |
| 257 FlowGraph* flow_graph_; | 257 FlowGraph* flow_graph_; |
| 258 BlockEntryInstr* entry_; | 258 BlockEntryInstr* entry_; |
| 259 Instruction* current_; | 259 Instruction* current_; |
| 260 }; | 260 }; |
| 261 | 261 |
| 262 | 262 |
| 263 static void PrepareIndexedOp(BlockBuilder* builder, | 263 static void PrepareIndexedOp(BlockBuilder* builder, |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 TargetEntryInstr* normal_entry = graph_entry->normal_entry(); | 431 TargetEntryInstr* normal_entry = graph_entry->normal_entry(); |
| 432 BlockBuilder builder(flow_graph, normal_entry); | 432 BlockBuilder builder(flow_graph, normal_entry); |
| 433 | 433 |
| 434 Definition* value = builder.AddParameter(1); | 434 Definition* value = builder.AddParameter(1); |
| 435 Definition* index = builder.AddParameter(2); | 435 Definition* index = builder.AddParameter(2); |
| 436 Definition* array = builder.AddParameter(3); | 436 Definition* array = builder.AddParameter(3); |
| 437 | 437 |
| 438 PrepareIndexedOp(&builder, array, index, TypedData::length_offset()); | 438 PrepareIndexedOp(&builder, array, index, TypedData::length_offset()); |
| 439 | 439 |
| 440 const ICData& value_check = ICData::ZoneHandle(ICData::New( | 440 const ICData& value_check = ICData::ZoneHandle(ICData::New( |
| 441 flow_graph->parsed_function().function(), | 441 flow_graph->parsed_function()->function(), |
| 442 String::Handle(flow_graph->parsed_function().function().name()), | 442 String::Handle(flow_graph->parsed_function()->function().name()), |
| 443 Object::empty_array(), // Dummy args. descr. | 443 Object::empty_array(), // Dummy args. descr. |
| 444 Isolate::kNoDeoptId, | 444 Isolate::kNoDeoptId, |
| 445 1)); | 445 1)); |
| 446 value_check.AddReceiverCheck(kDoubleCid, | 446 value_check.AddReceiverCheck(kDoubleCid, |
| 447 flow_graph->parsed_function().function()); | 447 flow_graph->parsed_function()->function()); |
| 448 builder.AddInstruction( | 448 builder.AddInstruction( |
| 449 new CheckClassInstr(new Value(value), | 449 new CheckClassInstr(new Value(value), |
| 450 Isolate::kNoDeoptId, | 450 Isolate::kNoDeoptId, |
| 451 value_check, | 451 value_check, |
| 452 builder.TokenPos())); | 452 builder.TokenPos())); |
| 453 Definition* double_value = builder.AddDefinition( | 453 Definition* double_value = builder.AddDefinition( |
| 454 UnboxInstr::Create(kUnboxedDouble, | 454 UnboxInstr::Create(kUnboxedDouble, |
| 455 new Value(value), | 455 new Value(value), |
| 456 Isolate::kNoDeoptId)); | 456 Isolate::kNoDeoptId)); |
| 457 // Manually adjust reaching type because there is no type propagation | 457 // Manually adjust reaching type because there is no type propagation |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 560 new LoadFieldInstr(new Value(backing_store), | 560 new LoadFieldInstr(new Value(backing_store), |
| 561 Array::length_offset(), | 561 Array::length_offset(), |
| 562 Type::ZoneHandle(), | 562 Type::ZoneHandle(), |
| 563 builder.TokenPos())); | 563 builder.TokenPos())); |
| 564 builder.AddIntrinsicReturn(new Value(capacity)); | 564 builder.AddIntrinsicReturn(new Value(capacity)); |
| 565 return true; | 565 return true; |
| 566 } | 566 } |
| 567 | 567 |
| 568 | 568 |
| 569 } // namespace dart | 569 } // namespace dart |
| OLD | NEW |