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 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 #undef EMIT_INTRINSIC | 210 #undef EMIT_INTRINSIC |
211 } | 211 } |
212 | 212 |
213 | 213 |
214 static intptr_t CidForRepresentation(Representation rep) { | 214 static intptr_t CidForRepresentation(Representation rep) { |
215 switch (rep) { | 215 switch (rep) { |
216 case kUnboxedDouble: | 216 case kUnboxedDouble: |
217 return kDoubleCid; | 217 return kDoubleCid; |
218 case kUnboxedFloat32x4: | 218 case kUnboxedFloat32x4: |
219 return kFloat32x4Cid; | 219 return kFloat32x4Cid; |
| 220 case kUnboxedUint32: |
| 221 return kDynamicCid; // smi or mint. |
220 default: | 222 default: |
221 UNREACHABLE(); | 223 UNREACHABLE(); |
222 return kIllegalCid; | 224 return kIllegalCid; |
223 } | 225 } |
224 } | 226 } |
225 | 227 |
226 | 228 |
227 class BlockBuilder : public ValueObject { | 229 class BlockBuilder : public ValueObject { |
228 public: | 230 public: |
229 BlockBuilder(FlowGraph* flow_graph, TargetEntryInstr* entry) | 231 BlockBuilder(FlowGraph* flow_graph, TargetEntryInstr* entry) |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 kExternalTypedDataUint8ArrayCid, | 443 kExternalTypedDataUint8ArrayCid, |
442 Isolate::kNoDeoptId, | 444 Isolate::kNoDeoptId, |
443 builder.TokenPos())); | 445 builder.TokenPos())); |
444 // Return null. | 446 // Return null. |
445 Definition* null_def = builder.AddNullDefinition(); | 447 Definition* null_def = builder.AddNullDefinition(); |
446 builder.AddIntrinsicReturn(new Value(null_def)); | 448 builder.AddIntrinsicReturn(new Value(null_def)); |
447 return true; | 449 return true; |
448 } | 450 } |
449 | 451 |
450 | 452 |
| 453 bool Intrinsifier::Build_Uint32ArraySetIndexed(FlowGraph* flow_graph) { |
| 454 GraphEntryInstr* graph_entry = flow_graph->graph_entry(); |
| 455 TargetEntryInstr* normal_entry = graph_entry->normal_entry(); |
| 456 BlockBuilder builder(flow_graph, normal_entry); |
| 457 |
| 458 Definition* value = builder.AddParameter(1); |
| 459 Definition* index = builder.AddParameter(2); |
| 460 Definition* array = builder.AddParameter(3); |
| 461 |
| 462 PrepareIndexedOp(&builder, array, index, TypedData::length_offset()); |
| 463 |
| 464 Definition* unboxed_value = |
| 465 builder.AddUnboxInstr(kUnboxedUint32, new Value(value)); |
| 466 |
| 467 builder.AddInstruction( |
| 468 new StoreIndexedInstr(new Value(array), |
| 469 new Value(index), |
| 470 new Value(unboxed_value), |
| 471 kNoStoreBarrier, |
| 472 4, // index scale |
| 473 kTypedDataUint32ArrayCid, |
| 474 Isolate::kNoDeoptId, |
| 475 builder.TokenPos())); |
| 476 // Return null. |
| 477 Definition* null_def = builder.AddNullDefinition(); |
| 478 builder.AddIntrinsicReturn(new Value(null_def)); |
| 479 return true; |
| 480 } |
| 481 |
| 482 |
| 483 bool Intrinsifier::Build_Uint32ArrayGetIndexed(FlowGraph* flow_graph) { |
| 484 GraphEntryInstr* graph_entry = flow_graph->graph_entry(); |
| 485 TargetEntryInstr* normal_entry = graph_entry->normal_entry(); |
| 486 BlockBuilder builder(flow_graph, normal_entry); |
| 487 |
| 488 Definition* index = builder.AddParameter(1); |
| 489 Definition* array = builder.AddParameter(2); |
| 490 |
| 491 PrepareIndexedOp(&builder, array, index, TypedData::length_offset()); |
| 492 |
| 493 Definition* unboxed_value = builder.AddDefinition( |
| 494 new LoadIndexedInstr(new Value(array), |
| 495 new Value(index), |
| 496 4, // index scale |
| 497 kTypedDataUint32ArrayCid, |
| 498 Isolate::kNoDeoptId, |
| 499 builder.TokenPos())); |
| 500 Definition* result = builder.AddDefinition( |
| 501 BoxInstr::Create(kUnboxedUint32, new Value(unboxed_value))); |
| 502 builder.AddIntrinsicReturn(new Value(result)); |
| 503 return true; |
| 504 } |
| 505 |
| 506 |
451 bool Intrinsifier::Build_Float64ArraySetIndexed(FlowGraph* flow_graph) { | 507 bool Intrinsifier::Build_Float64ArraySetIndexed(FlowGraph* flow_graph) { |
452 if (!FlowGraphCompiler::SupportsUnboxedDoubles()) return false; | 508 if (!FlowGraphCompiler::SupportsUnboxedDoubles()) return false; |
453 | 509 |
454 GraphEntryInstr* graph_entry = flow_graph->graph_entry(); | 510 GraphEntryInstr* graph_entry = flow_graph->graph_entry(); |
455 TargetEntryInstr* normal_entry = graph_entry->normal_entry(); | 511 TargetEntryInstr* normal_entry = graph_entry->normal_entry(); |
456 BlockBuilder builder(flow_graph, normal_entry); | 512 BlockBuilder builder(flow_graph, normal_entry); |
457 | 513 |
458 Definition* value = builder.AddParameter(1); | 514 Definition* value = builder.AddParameter(1); |
459 Definition* index = builder.AddParameter(2); | 515 Definition* index = builder.AddParameter(2); |
460 Definition* array = builder.AddParameter(3); | 516 Definition* array = builder.AddParameter(3); |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
804 new Value(growable_array), | 860 new Value(growable_array), |
805 new Value(length), | 861 new Value(length), |
806 kNoStoreBarrier, | 862 kNoStoreBarrier, |
807 builder.TokenPos())); | 863 builder.TokenPos())); |
808 Definition* null_def = builder.AddNullDefinition(); | 864 Definition* null_def = builder.AddNullDefinition(); |
809 builder.AddIntrinsicReturn(new Value(null_def)); | 865 builder.AddIntrinsicReturn(new Value(null_def)); |
810 return true; | 866 return true; |
811 } | 867 } |
812 | 868 |
813 } // namespace dart | 869 } // namespace dart |
OLD | NEW |