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

Side by Side Diff: runtime/vm/intermediate_language.h

Issue 539153002: Port and integrate the irregexp engine from V8 (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Port remaining V8 regexp tests and fix exposed bugs. Created 6 years, 2 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
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 #ifndef VM_INTERMEDIATE_LANGUAGE_H_ 5 #ifndef VM_INTERMEDIATE_LANGUAGE_H_
6 #define VM_INTERMEDIATE_LANGUAGE_H_ 6 #define VM_INTERMEDIATE_LANGUAGE_H_
7 7
8 #include "vm/allocation.h" 8 #include "vm/allocation.h"
9 #include "vm/ast.h" 9 #include "vm/ast.h"
10 #include "vm/growable_array.h" 10 #include "vm/growable_array.h"
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 416
417 // Instructions. 417 // Instructions.
418 418
419 // M is a single argument macro. It is applied to each concrete instruction 419 // M is a single argument macro. It is applied to each concrete instruction
420 // type name. The concrete instruction classes are the name with Instr 420 // type name. The concrete instruction classes are the name with Instr
421 // concatenated. 421 // concatenated.
422 #define FOR_EACH_INSTRUCTION(M) \ 422 #define FOR_EACH_INSTRUCTION(M) \
423 M(GraphEntry) \ 423 M(GraphEntry) \
424 M(JoinEntry) \ 424 M(JoinEntry) \
425 M(TargetEntry) \ 425 M(TargetEntry) \
426 M(IndirectEntry) \
426 M(CatchBlockEntry) \ 427 M(CatchBlockEntry) \
427 M(Phi) \ 428 M(Phi) \
428 M(Redefinition) \ 429 M(Redefinition) \
429 M(Parameter) \ 430 M(Parameter) \
430 M(ParallelMove) \ 431 M(ParallelMove) \
431 M(PushArgument) \ 432 M(PushArgument) \
432 M(Return) \ 433 M(Return) \
433 M(Throw) \ 434 M(Throw) \
434 M(ReThrow) \ 435 M(ReThrow) \
435 M(Goto) \ 436 M(Goto) \
437 M(IndirectGoto) \
436 M(Branch) \ 438 M(Branch) \
437 M(AssertAssignable) \ 439 M(AssertAssignable) \
438 M(AssertBoolean) \ 440 M(AssertBoolean) \
439 M(CurrentContext) \ 441 M(CurrentContext) \
440 M(StoreContext) \ 442 M(StoreContext) \
441 M(ClosureCall) \ 443 M(ClosureCall) \
442 M(InstanceCall) \ 444 M(InstanceCall) \
443 M(PolymorphicInstanceCall) \ 445 M(PolymorphicInstanceCall) \
444 M(StaticCall) \ 446 M(StaticCall) \
445 M(LoadLocal) \ 447 M(LoadLocal) \
446 M(PushTemp) \ 448 M(PushTemp) \
447 M(DropTemps) \ 449 M(DropTemps) \
448 M(StoreLocal) \ 450 M(StoreLocal) \
449 M(StrictCompare) \ 451 M(StrictCompare) \
450 M(EqualityCompare) \ 452 M(EqualityCompare) \
451 M(RelationalOp) \ 453 M(RelationalOp) \
452 M(NativeCall) \ 454 M(NativeCall) \
453 M(DebugStepCheck) \ 455 M(DebugStepCheck) \
454 M(LoadIndexed) \ 456 M(LoadIndexed) \
457 M(LoadCodeUnits) \
455 M(StoreIndexed) \ 458 M(StoreIndexed) \
456 M(StoreInstanceField) \ 459 M(StoreInstanceField) \
457 M(InitStaticField) \ 460 M(InitStaticField) \
458 M(LoadStaticField) \ 461 M(LoadStaticField) \
459 M(StoreStaticField) \ 462 M(StoreStaticField) \
460 M(BooleanNegate) \ 463 M(BooleanNegate) \
461 M(InstanceOf) \ 464 M(InstanceOf) \
462 M(CreateArray) \ 465 M(CreateArray) \
463 M(AllocateObject) \ 466 M(AllocateObject) \
464 M(LoadField) \ 467 M(LoadField) \
(...skipping 19 matching lines...) Expand all
484 M(FloatToDouble) \ 487 M(FloatToDouble) \
485 M(CheckClass) \ 488 M(CheckClass) \
486 M(CheckClassId) \ 489 M(CheckClassId) \
487 M(CheckSmi) \ 490 M(CheckSmi) \
488 M(Constant) \ 491 M(Constant) \
489 M(UnboxedConstant) \ 492 M(UnboxedConstant) \
490 M(CheckEitherNonSmi) \ 493 M(CheckEitherNonSmi) \
491 M(BinaryDoubleOp) \ 494 M(BinaryDoubleOp) \
492 M(MathUnary) \ 495 M(MathUnary) \
493 M(MathMinMax) \ 496 M(MathMinMax) \
497 M(CaseInsensitiveCompareUC16) \
494 M(UnboxDouble) \ 498 M(UnboxDouble) \
495 M(BoxDouble) \ 499 M(BoxDouble) \
496 M(BoxFloat32x4) \ 500 M(BoxFloat32x4) \
497 M(UnboxFloat32x4) \ 501 M(UnboxFloat32x4) \
498 M(BoxInt32x4) \ 502 M(BoxInt32x4) \
499 M(UnboxInt32x4) \ 503 M(UnboxInt32x4) \
500 M(UnboxInteger) \ 504 M(UnboxInteger) \
501 M(BoxInteger) \ 505 M(BoxInteger) \
502 M(BinaryMintOp) \ 506 M(BinaryMintOp) \
503 M(ShiftMintOp) \ 507 M(ShiftMintOp) \
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
879 friend class Int32x4BoolConstructorInstr; 883 friend class Int32x4BoolConstructorInstr;
880 friend class Int32x4GetFlagInstr; 884 friend class Int32x4GetFlagInstr;
881 friend class Int32x4SetFlagInstr; 885 friend class Int32x4SetFlagInstr;
882 friend class Int32x4SelectInstr; 886 friend class Int32x4SelectInstr;
883 friend class Int32x4ToFloat32x4Instr; 887 friend class Int32x4ToFloat32x4Instr;
884 friend class BinaryInt32x4OpInstr; 888 friend class BinaryInt32x4OpInstr;
885 friend class BinaryFloat64x2OpInstr; 889 friend class BinaryFloat64x2OpInstr;
886 friend class UnaryDoubleOpInstr; 890 friend class UnaryDoubleOpInstr;
887 friend class MathUnaryInstr; 891 friend class MathUnaryInstr;
888 friend class MathMinMaxInstr; 892 friend class MathMinMaxInstr;
893 friend class CaseInsensitiveCompareUC16Instr;
Florian Schneider 2014/10/01 17:04:13 Not needed?
jgruber1 2014/10/03 18:59:51 Done, unneeded now that deopt_id_ is not accessed
889 friend class CheckClassInstr; 894 friend class CheckClassInstr;
890 friend class CheckClassIdInstr; 895 friend class CheckClassIdInstr;
891 friend class GuardFieldInstr; 896 friend class GuardFieldInstr;
892 friend class CheckSmiInstr; 897 friend class CheckSmiInstr;
893 friend class CheckArrayBoundInstr; 898 friend class CheckArrayBoundInstr;
894 friend class CheckEitherNonSmiInstr; 899 friend class CheckEitherNonSmiInstr;
895 friend class LICM; 900 friend class LICM;
896 friend class DoubleToSmiInstr; 901 friend class DoubleToSmiInstr;
897 friend class DoubleToDoubleInstr; 902 friend class DoubleToDoubleInstr;
898 friend class DoubleToFloatInstr; 903 friend class DoubleToFloatInstr;
899 friend class FloatToDoubleInstr; 904 friend class FloatToDoubleInstr;
900 friend class InvokeMathCFunctionInstr; 905 friend class InvokeMathCFunctionInstr;
901 friend class MergedMathInstr; 906 friend class MergedMathInstr;
902 friend class FlowGraphOptimizer; 907 friend class FlowGraphOptimizer;
903 friend class LoadIndexedInstr; 908 friend class LoadIndexedInstr;
909 friend class LoadCodeUnitsInstr;
904 friend class StoreIndexedInstr; 910 friend class StoreIndexedInstr;
905 friend class StoreInstanceFieldInstr; 911 friend class StoreInstanceFieldInstr;
906 friend class ComparisonInstr; 912 friend class ComparisonInstr;
907 friend class TargetEntryInstr; 913 friend class TargetEntryInstr;
914 friend class IndirectEntryInstr;
Florian Schneider 2014/10/01 17:04:13 Not needed?
jgruber1 2014/10/03 18:59:51 Done.
908 friend class JoinEntryInstr; 915 friend class JoinEntryInstr;
909 friend class InstanceOfInstr; 916 friend class InstanceOfInstr;
910 friend class PolymorphicInstanceCallInstr; 917 friend class PolymorphicInstanceCallInstr;
911 friend class SmiToDoubleInstr; 918 friend class SmiToDoubleInstr;
912 friend class MintToDoubleInstr; 919 friend class MintToDoubleInstr;
913 friend class DoubleToIntegerInstr; 920 friend class DoubleToIntegerInstr;
914 friend class BranchSimplifier; 921 friend class BranchSimplifier;
915 friend class BlockEntryInstr; 922 friend class BlockEntryInstr;
916 friend class RelationalOpInstr; 923 friend class RelationalOpInstr;
917 friend class EqualityCompareInstr; 924 friend class EqualityCompareInstr;
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
1180 return const_cast<BlockEntryInstr*>(this); 1187 return const_cast<BlockEntryInstr*>(this);
1181 } 1188 }
1182 1189
1183 // Helper to mutate the graph during inlining. This block should be 1190 // Helper to mutate the graph during inlining. This block should be
1184 // replaced with new_block as a predecessor of all of this block's 1191 // replaced with new_block as a predecessor of all of this block's
1185 // successors. 1192 // successors.
1186 void ReplaceAsPredecessorWith(BlockEntryInstr* new_block); 1193 void ReplaceAsPredecessorWith(BlockEntryInstr* new_block);
1187 1194
1188 void set_block_id(intptr_t block_id) { block_id_ = block_id; } 1195 void set_block_id(intptr_t block_id) { block_id_ = block_id; }
1189 1196
1197 intptr_t offset() const { return offset_; }
1198 void set_offset(intptr_t offset) { offset_ = offset; }
1199
1190 // For all instruction in this block: Remove all inputs (including in the 1200 // For all instruction in this block: Remove all inputs (including in the
1191 // environment) from their definition's use lists for all instructions. 1201 // environment) from their definition's use lists for all instructions.
1192 void ClearAllInstructions(); 1202 void ClearAllInstructions();
1193 1203
1194 DEFINE_INSTRUCTION_TYPE_CHECK(BlockEntry) 1204 DEFINE_INSTRUCTION_TYPE_CHECK(BlockEntry)
1195 1205
1196 protected: 1206 protected:
1197 BlockEntryInstr(intptr_t block_id, intptr_t try_index) 1207 BlockEntryInstr(intptr_t block_id, intptr_t try_index)
1198 : block_id_(block_id), 1208 : block_id_(block_id),
1199 try_index_(try_index), 1209 try_index_(try_index),
1200 preorder_number_(-1), 1210 preorder_number_(-1),
1201 postorder_number_(-1), 1211 postorder_number_(-1),
1202 dominator_(NULL), 1212 dominator_(NULL),
1203 dominated_blocks_(1), 1213 dominated_blocks_(1),
1204 last_instruction_(NULL), 1214 last_instruction_(NULL),
1215 offset_(-1),
1205 parallel_move_(NULL), 1216 parallel_move_(NULL),
1206 loop_info_(NULL) { } 1217 loop_info_(NULL) { }
1207 1218
1208 private: 1219 private:
1209 virtual void RawSetInputAt(intptr_t i, Value* value) { UNREACHABLE(); } 1220 virtual void RawSetInputAt(intptr_t i, Value* value) { UNREACHABLE(); }
1210 1221
1211 virtual void ClearPredecessors() = 0; 1222 virtual void ClearPredecessors() = 0;
1212 virtual void AddPredecessor(BlockEntryInstr* predecessor) = 0; 1223 virtual void AddPredecessor(BlockEntryInstr* predecessor) = 0;
1213 1224
1214 void set_dominator(BlockEntryInstr* instr) { dominator_ = instr; } 1225 void set_dominator(BlockEntryInstr* instr) { dominator_ = instr; }
1215 1226
1216 intptr_t block_id_; 1227 intptr_t block_id_;
1217 const intptr_t try_index_; 1228 const intptr_t try_index_;
1218 intptr_t preorder_number_; 1229 intptr_t preorder_number_;
1219 intptr_t postorder_number_; 1230 intptr_t postorder_number_;
1220 // Starting and ending lifetime positions for this block. Used by 1231 // Starting and ending lifetime positions for this block. Used by
1221 // the linear scan register allocator. 1232 // the linear scan register allocator.
1222 intptr_t start_pos_; 1233 intptr_t start_pos_;
1223 intptr_t end_pos_; 1234 intptr_t end_pos_;
1224 BlockEntryInstr* dominator_; // Immediate dominator, NULL for graph entry. 1235 BlockEntryInstr* dominator_; // Immediate dominator, NULL for graph entry.
1225 // TODO(fschneider): Optimize the case of one child to save space. 1236 // TODO(fschneider): Optimize the case of one child to save space.
1226 GrowableArray<BlockEntryInstr*> dominated_blocks_; 1237 GrowableArray<BlockEntryInstr*> dominated_blocks_;
1227 Instruction* last_instruction_; 1238 Instruction* last_instruction_;
1228 1239
1240 // Offset of this block from the start of the emitted code.
1241 intptr_t offset_;
1242
1229 // Parallel move that will be used by linear scan register allocator to 1243 // Parallel move that will be used by linear scan register allocator to
1230 // connect live ranges at the start of the block. 1244 // connect live ranges at the start of the block.
1231 ParallelMoveInstr* parallel_move_; 1245 ParallelMoveInstr* parallel_move_;
1232 1246
1233 // Bit vector containg loop blocks for a loop header indexed by block 1247 // Bit vector containg loop blocks for a loop header indexed by block
1234 // preorder number. 1248 // preorder number.
1235 BitVector* loop_info_; 1249 BitVector* loop_info_;
1236 1250
1237 DISALLOW_COPY_AND_ASSIGN(BlockEntryInstr); 1251 DISALLOW_COPY_AND_ASSIGN(BlockEntryInstr);
1238 }; 1252 };
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
1299 UNREACHABLE(); 1313 UNREACHABLE();
1300 return NULL; 1314 return NULL;
1301 } 1315 }
1302 virtual intptr_t SuccessorCount() const; 1316 virtual intptr_t SuccessorCount() const;
1303 virtual BlockEntryInstr* SuccessorAt(intptr_t index) const; 1317 virtual BlockEntryInstr* SuccessorAt(intptr_t index) const;
1304 1318
1305 void AddCatchEntry(CatchBlockEntryInstr* entry) { catch_entries_.Add(entry); } 1319 void AddCatchEntry(CatchBlockEntryInstr* entry) { catch_entries_.Add(entry); }
1306 1320
1307 CatchBlockEntryInstr* GetCatchEntry(intptr_t index); 1321 CatchBlockEntryInstr* GetCatchEntry(intptr_t index);
1308 1322
1323 void AddIndirectEntry(IndirectEntryInstr* entry) {
1324 indirect_entries_.Add(entry);
1325 }
1326
1309 GrowableArray<Definition*>* initial_definitions() { 1327 GrowableArray<Definition*>* initial_definitions() {
1310 return &initial_definitions_; 1328 return &initial_definitions_;
1311 } 1329 }
1312 ConstantInstr* constant_null(); 1330 ConstantInstr* constant_null();
1313 1331
1314 bool IsCompiledForOsr() const { return osr_id_ != Isolate::kNoDeoptId; } 1332 bool IsCompiledForOsr() const { return osr_id_ != Isolate::kNoDeoptId; }
1315 1333
1316 intptr_t entry_count() const { return entry_count_; } 1334 intptr_t entry_count() const { return entry_count_; }
1317 void set_entry_count(intptr_t count) { entry_count_ = count; } 1335 void set_entry_count(intptr_t count) { entry_count_ = count; }
1318 1336
(...skipping 14 matching lines...) Expand all
1333 TargetEntryInstr* normal_entry() const { return normal_entry_; } 1351 TargetEntryInstr* normal_entry() const { return normal_entry_; }
1334 1352
1335 const ParsedFunction& parsed_function() const { 1353 const ParsedFunction& parsed_function() const {
1336 return *parsed_function_; 1354 return *parsed_function_;
1337 } 1355 }
1338 1356
1339 const GrowableArray<CatchBlockEntryInstr*>& catch_entries() const { 1357 const GrowableArray<CatchBlockEntryInstr*>& catch_entries() const {
1340 return catch_entries_; 1358 return catch_entries_;
1341 } 1359 }
1342 1360
1361 const GrowableArray<IndirectEntryInstr*>& indirect_entries() const {
1362 return indirect_entries_;
1363 }
1364
1343 virtual void PrintTo(BufferFormatter* f) const; 1365 virtual void PrintTo(BufferFormatter* f) const;
1344 1366
1345 private: 1367 private:
1346 virtual void ClearPredecessors() {} 1368 virtual void ClearPredecessors() {}
1347 virtual void AddPredecessor(BlockEntryInstr* predecessor) { UNREACHABLE(); } 1369 virtual void AddPredecessor(BlockEntryInstr* predecessor) { UNREACHABLE(); }
1348 1370
1349 const ParsedFunction* parsed_function_; 1371 const ParsedFunction* parsed_function_;
1350 TargetEntryInstr* normal_entry_; 1372 TargetEntryInstr* normal_entry_;
1351 GrowableArray<CatchBlockEntryInstr*> catch_entries_; 1373 GrowableArray<CatchBlockEntryInstr*> catch_entries_;
1374 // Indirect targets are blocks reachable only through indirect gotos.
1375 GrowableArray<IndirectEntryInstr*> indirect_entries_;
1352 GrowableArray<Definition*> initial_definitions_; 1376 GrowableArray<Definition*> initial_definitions_;
1353 const intptr_t osr_id_; 1377 const intptr_t osr_id_;
1354 intptr_t entry_count_; 1378 intptr_t entry_count_;
1355 intptr_t spill_slot_count_; 1379 intptr_t spill_slot_count_;
1356 intptr_t fixed_slot_count_; // For try-catch in optimized code. 1380 intptr_t fixed_slot_count_; // For try-catch in optimized code.
1357 1381
1358 DISALLOW_COPY_AND_ASSIGN(GraphEntryInstr); 1382 DISALLOW_COPY_AND_ASSIGN(GraphEntryInstr);
1359 }; 1383 };
1360 1384
1361 1385
(...skipping 25 matching lines...) Expand all
1387 virtual void PrintTo(BufferFormatter* f) const; 1411 virtual void PrintTo(BufferFormatter* f) const;
1388 1412
1389 virtual EffectSet Effects() const { return EffectSet::None(); } 1413 virtual EffectSet Effects() const { return EffectSet::None(); }
1390 virtual EffectSet Dependencies() const { return EffectSet::None(); } 1414 virtual EffectSet Dependencies() const { return EffectSet::None(); }
1391 1415
1392 private: 1416 private:
1393 // Classes that have access to predecessors_ when inlining. 1417 // Classes that have access to predecessors_ when inlining.
1394 friend class BlockEntryInstr; 1418 friend class BlockEntryInstr;
1395 friend class InlineExitCollector; 1419 friend class InlineExitCollector;
1396 friend class PolymorphicInliner; 1420 friend class PolymorphicInliner;
1421 friend class IndirectEntryInstr; // Access in il_printer.cc.
1397 1422
1398 // Direct access to phis_ in order to resize it due to phi elimination. 1423 // Direct access to phis_ in order to resize it due to phi elimination.
1399 friend class ConstantPropagator; 1424 friend class ConstantPropagator;
1400 friend class DeadCodeElimination; 1425 friend class DeadCodeElimination;
1401 1426
1402 virtual void ClearPredecessors() { predecessors_.Clear(); } 1427 virtual void ClearPredecessors() { predecessors_.Clear(); }
1403 virtual void AddPredecessor(BlockEntryInstr* predecessor); 1428 virtual void AddPredecessor(BlockEntryInstr* predecessor);
1404 1429
1405 GrowableArray<BlockEntryInstr*> predecessors_; 1430 GrowableArray<BlockEntryInstr*> predecessors_;
1406 ZoneGrowableArray<PhiInstr*>* phis_; 1431 ZoneGrowableArray<PhiInstr*>* phis_;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
1466 predecessor_ = predecessor; 1491 predecessor_ = predecessor;
1467 } 1492 }
1468 1493
1469 BlockEntryInstr* predecessor_; 1494 BlockEntryInstr* predecessor_;
1470 double edge_weight_; 1495 double edge_weight_;
1471 1496
1472 DISALLOW_COPY_AND_ASSIGN(TargetEntryInstr); 1497 DISALLOW_COPY_AND_ASSIGN(TargetEntryInstr);
1473 }; 1498 };
1474 1499
1475 1500
1501 class IndirectEntryInstr : public JoinEntryInstr {
1502 public:
1503 IndirectEntryInstr(intptr_t block_id,
1504 intptr_t indirect_id,
1505 intptr_t try_index)
1506 : JoinEntryInstr(block_id, try_index),
1507 indirect_id_(indirect_id) { }
1508
1509 DECLARE_INSTRUCTION(IndirectEntry)
1510
1511 virtual void PrintTo(BufferFormatter* f) const;
1512
1513 intptr_t indirect_id() const { return indirect_id_; }
1514
1515 private:
1516 const intptr_t indirect_id_;
1517 };
1518
1519
1476 class CatchBlockEntryInstr : public BlockEntryInstr { 1520 class CatchBlockEntryInstr : public BlockEntryInstr {
1477 public: 1521 public:
1478 CatchBlockEntryInstr(intptr_t block_id, 1522 CatchBlockEntryInstr(intptr_t block_id,
1479 intptr_t try_index, 1523 intptr_t try_index,
1480 const Array& handler_types, 1524 const Array& handler_types,
1481 intptr_t catch_try_index, 1525 intptr_t catch_try_index,
1482 const LocalVariable& exception_var, 1526 const LocalVariable& exception_var,
1483 const LocalVariable& stacktrace_var, 1527 const LocalVariable& stacktrace_var,
1484 bool needs_stacktrace) 1528 bool needs_stacktrace)
1485 : BlockEntryInstr(block_id, try_index), 1529 : BlockEntryInstr(block_id, try_index),
(...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after
2134 private: 2178 private:
2135 JoinEntryInstr* successor_; 2179 JoinEntryInstr* successor_;
2136 double edge_weight_; 2180 double edge_weight_;
2137 2181
2138 // Parallel move that will be used by linear scan register allocator to 2182 // Parallel move that will be used by linear scan register allocator to
2139 // connect live ranges at the end of the block and resolve phis. 2183 // connect live ranges at the end of the block and resolve phis.
2140 ParallelMoveInstr* parallel_move_; 2184 ParallelMoveInstr* parallel_move_;
2141 }; 2185 };
2142 2186
2143 2187
2188 // As a high level description, an indirect goto takes the indirect_id of an
2189 // indirect entry as a parameter, and jumps to that location.
2190 //
2191 // In more detail: in order to preserve split-edge form, an intermediate target
2192 // entry consisting of a goto to the final indirect entry is inserted on
2193 // each possible indirect goto -> indirect entry edge. These target entries are
2194 // accessible through successors_.
2195 //
2196 // Byte offsets of all possible indirect targets are stored in the offsets_
2197 // array and are looked up at runtime.
2198 class IndirectGotoInstr : public TemplateInstruction<1> {
2199 public:
2200 IndirectGotoInstr(GrowableObjectArray* offsets,
Florian Schneider 2014/10/01 17:04:13 Can this be NULL? If not, just pass a const Growab
jgruber1 2014/10/03 18:59:51 No, but it is modified in SetOffsetCount() and Set
2201 Value* offset_from_start)
2202 : offset_from_start_(offset_from_start),
2203 offsets_(*offsets) {
2204 inputs_[0] = offset_from_start_;
Vyacheslav Egorov (Google) 2014/10/01 20:13:21 please add a comment explaining why you can't SetI
jgruber1 2014/10/03 18:59:51 Done, changed to SetInputAt().
2205 offset_from_start_->set_instruction(this);
2206 offset_from_start_->set_use_index(0);
2207 }
2208
2209 DECLARE_INSTRUCTION(IndirectGoto)
2210
2211 virtual intptr_t ArgumentCount() const { return 0; }
2212
2213 void AddSuccessor(TargetEntryInstr* successor) {
2214 ASSERT(successor->next()->IsGoto());
2215 ASSERT(successor->next()->AsGoto()->successor()->IsIndirectEntry());
2216 successors_.Add(successor);
2217 }
2218
2219 virtual intptr_t SuccessorCount() const { return successors_.length(); }
2220 virtual TargetEntryInstr* SuccessorAt(intptr_t index) const {
2221 ASSERT(index < SuccessorCount());
2222 return successors_[index];
2223 }
2224
2225 virtual bool CanDeoptimize() const { return false; }
2226 virtual bool CanBecomeDeoptimizationTarget() const { return false; }
2227
2228 virtual EffectSet Effects() const { return EffectSet::None(); }
2229
2230 virtual void PrintTo(BufferFormatter* f) const;
2231
2232 virtual bool MayThrow() const { return false; }
2233
2234 const GrowableObjectArray& offsets() const { return offsets_; }
2235 void SetOffsetCount(Isolate* isolate, intptr_t count) {
2236 if (offsets_.Capacity() < count) {
2237 offsets_.Grow(count, Heap::kOld);
2238 }
2239 if (offsets_.Length() < count) {
2240 offsets_.SetLength(count);
2241 }
2242 }
2243 void SetOffsetAt(Isolate* isolate, intptr_t index, intptr_t offset) {
2244 offsets_.SetAt(index, Smi::ZoneHandle(isolate, Smi::New(offset)));
2245 }
2246
2247 private:
2248 Value* offset_from_start_;
Florian Schneider 2014/10/02 11:58:12 Remove this member. SetInputAt(0,...) already stor
jgruber1 2014/10/03 18:59:51 Done.
2249
2250 GrowableArray<TargetEntryInstr*> successors_;
2251 GrowableObjectArray& offsets_;
2252 };
2253
2254
2144 class ComparisonInstr : public TemplateDefinition<2> { 2255 class ComparisonInstr : public TemplateDefinition<2> {
2145 public: 2256 public:
2146 Value* left() const { return inputs_[0]; } 2257 Value* left() const { return inputs_[0]; }
2147 Value* right() const { return inputs_[1]; } 2258 Value* right() const { return inputs_[1]; }
2148 2259
2149 virtual intptr_t token_pos() const { return token_pos_; } 2260 virtual intptr_t token_pos() const { return token_pos_; }
2150 Token::Kind kind() const { return kind_; } 2261 Token::Kind kind() const { return kind_; }
2151 2262
2152 virtual ComparisonInstr* CopyWithNewOperands(Value* left, Value* right) = 0; 2263 virtual ComparisonInstr* CopyWithNewOperands(Value* left, Value* right) = 0;
2153 2264
(...skipping 1606 matching lines...) Expand 10 before | Expand all | Expand 10 after
3760 3871
3761 private: 3872 private:
3762 const intptr_t index_scale_; 3873 const intptr_t index_scale_;
3763 const intptr_t class_id_; 3874 const intptr_t class_id_;
3764 const intptr_t token_pos_; 3875 const intptr_t token_pos_;
3765 3876
3766 DISALLOW_COPY_AND_ASSIGN(LoadIndexedInstr); 3877 DISALLOW_COPY_AND_ASSIGN(LoadIndexedInstr);
3767 }; 3878 };
3768 3879
3769 3880
3881 // Loads the specified number of code units from the given string, packing
3882 // multiple code units into a single datatype. In essence, this is a specialized
3883 // version of LoadIndexedInstr which accepts only string targets may load
3884 // multiple elements at once. The result datatype differs depending on the
3885 // string type, element count, and architecture; if possible, the result is
3886 // packed into a Smi, falling back to a Mint otherwise.
3887 // TODO(jgruber): Add support for loading into UnboxedInt32x4.
3888 class LoadCodeUnitsInstr : public TemplateDefinition<2> {
3889 public:
3890 LoadCodeUnitsInstr(Value* array,
3891 Value* index,
3892 intptr_t index_scale,
3893 intptr_t element_count,
3894 intptr_t class_id,
3895 intptr_t deopt_id,
3896 intptr_t token_pos)
3897 : index_scale_(index_scale),
3898 class_id_(class_id),
3899 token_pos_(token_pos),
3900 element_count_(element_count) {
3901 ASSERT(class_id == kOneByteStringCid || class_id == kTwoByteStringCid);
3902 SetInputAt(0, array);
3903 SetInputAt(1, index);
3904 deopt_id_ = deopt_id;
Vyacheslav Egorov (Google) 2014/10/01 20:13:21 I don't think it can deoptimize.
jgruber1 2014/10/03 18:59:51 Done.
3905 }
3906
3907 intptr_t token_pos() const { return token_pos_; }
3908
3909 DECLARE_INSTRUCTION(LoadCodeUnits)
3910 virtual CompileType ComputeType() const;
3911
3912 bool IsExternal() const {
3913 return array()->definition()->representation() == kUntagged;
3914 }
3915
3916 Value* array() const { return inputs_[0]; }
3917 Value* index() const { return inputs_[1]; }
3918 intptr_t index_scale() const { return index_scale_; }
3919 intptr_t class_id() const { return class_id_; }
3920 intptr_t element_count() const { return element_count_; }
3921
3922 virtual bool CanDeoptimize() const {
3923 return deopt_id_ != Isolate::kNoDeoptId;
3924 }
3925
3926 virtual Representation representation() const;
3927 virtual void InferRange(RangeAnalysis* analysis, Range* range);
3928
3929 virtual bool AllowsCSE() const { return false; }
3930 virtual EffectSet Effects() const { return EffectSet::None(); }
3931 virtual EffectSet Dependencies() const { return EffectSet::All(); }
3932 virtual bool AttributesEqual(Instruction* other) const;
3933
3934 virtual bool MayThrow() const { return false; }
3935
3936 private:
3937 const intptr_t index_scale_;
3938 const intptr_t class_id_;
3939 const intptr_t token_pos_;
3940 const intptr_t element_count_;
3941
3942 DISALLOW_COPY_AND_ASSIGN(LoadCodeUnitsInstr);
3943 };
3944
3945
3770 class StringFromCharCodeInstr : public TemplateDefinition<1> { 3946 class StringFromCharCodeInstr : public TemplateDefinition<1> {
3771 public: 3947 public:
3772 StringFromCharCodeInstr(Value* char_code, intptr_t cid) : cid_(cid) { 3948 StringFromCharCodeInstr(Value* char_code, intptr_t cid) : cid_(cid) {
3773 ASSERT(char_code != NULL); 3949 ASSERT(char_code != NULL);
3774 ASSERT(char_code->definition()->IsLoadIndexed()); 3950 ASSERT(char_code->definition()->IsLoadIndexed());
3775 ASSERT(char_code->definition()->AsLoadIndexed()->class_id() == 3951 ASSERT(char_code->definition()->AsLoadIndexed()->class_id() ==
3776 kOneByteStringCid); 3952 kOneByteStringCid);
3777 SetInputAt(0, char_code); 3953 SetInputAt(0, char_code);
3778 } 3954 }
3779 3955
(...skipping 1208 matching lines...) Expand 10 before | Expand all | Expand 10 after
4988 5164
4989 static const char* KindToCString(MathUnaryKind kind); 5165 static const char* KindToCString(MathUnaryKind kind);
4990 5166
4991 private: 5167 private:
4992 const MathUnaryKind kind_; 5168 const MathUnaryKind kind_;
4993 5169
4994 DISALLOW_COPY_AND_ASSIGN(MathUnaryInstr); 5170 DISALLOW_COPY_AND_ASSIGN(MathUnaryInstr);
4995 }; 5171 };
4996 5172
4997 5173
5174 // Calls into the runtime and performs a case-insensitive comparison of the
5175 // UTF16 strings (i.e. TwoByteString or ExternalTwoByteString) located at
5176 // str[lhs_index:lhs_index + length] and str[rhs_index:rhs_index + length].
5177 //
5178 // TODO(jgruber): Remove this once (if) functions inherited from unibrow
5179 // are moved to dart code.
5180 class CaseInsensitiveCompareUC16Instr : public TemplateDefinition<4> {
5181 public:
5182 CaseInsensitiveCompareUC16Instr(
5183 Value* str,
5184 Value* lhs_index,
5185 Value* rhs_index,
5186 Value* length,
5187 intptr_t cid,
5188 intptr_t deopt_id)
5189 : cid_(cid) {
5190 ASSERT(cid == kTwoByteStringCid || cid == kExternalTwoByteStringCid);
5191 ASSERT(index_scale() == 2);
5192 SetInputAt(0, str);
5193 SetInputAt(1, lhs_index);
5194 SetInputAt(2, rhs_index);
5195 SetInputAt(3, length);
5196 deopt_id_ = deopt_id;
Florian Schneider 2014/10/01 17:04:13 Not needed, since it can't deoptimize and also can
jgruber1 2014/10/03 18:59:51 Done.
5197 }
5198
5199 Value* str() const { return inputs_[0]; }
5200 Value* lhs_index() const { return inputs_[1]; }
5201 Value* rhs_index() const { return inputs_[2]; }
5202 Value* length() const { return inputs_[3]; }
5203
5204 const RuntimeEntry& TargetFunction() const;
5205 bool IsExternal() const { return cid_ == kExternalTwoByteStringCid; }
5206 intptr_t class_id() const { return cid_; }
5207 intptr_t index_scale() const { return Instance::ElementSizeFor(cid_); }
5208
5209 virtual void PrintOperandsTo(BufferFormatter* f) const;
5210
5211 virtual bool CanDeoptimize() const { return false; }
5212
5213 virtual Representation representation() const {
5214 return kTagged;
5215 }
5216
5217 DECLARE_INSTRUCTION(CaseInsensitiveCompareUC16)
5218 virtual CompileType ComputeType() const;
5219
5220 virtual bool AllowsCSE() const { return true; }
5221 virtual EffectSet Effects() const { return EffectSet::None(); }
5222 virtual EffectSet Dependencies() const { return EffectSet::None(); }
5223
5224 virtual bool MayThrow() const { return false; }
5225
5226 Definition* Canonicalize(FlowGraph* flow_graph);
5227
5228 private:
5229 const intptr_t cid_;
5230
5231 DISALLOW_COPY_AND_ASSIGN(CaseInsensitiveCompareUC16Instr);
5232 };
5233
5234
4998 // Represents Math's static min and max functions. 5235 // Represents Math's static min and max functions.
4999 class MathMinMaxInstr : public TemplateDefinition<2> { 5236 class MathMinMaxInstr : public TemplateDefinition<2> {
5000 public: 5237 public:
5001 MathMinMaxInstr(MethodRecognizer::Kind op_kind, 5238 MathMinMaxInstr(MethodRecognizer::Kind op_kind,
5002 Value* left_value, 5239 Value* left_value,
5003 Value* right_value, 5240 Value* right_value,
5004 intptr_t deopt_id, 5241 intptr_t deopt_id,
5005 intptr_t result_cid) 5242 intptr_t result_cid)
5006 : op_kind_(op_kind), result_cid_(result_cid) { 5243 : op_kind_(op_kind), result_cid_(result_cid) {
5007 ASSERT((result_cid == kSmiCid) || (result_cid == kDoubleCid)); 5244 ASSERT((result_cid == kSmiCid) || (result_cid == kDoubleCid));
(...skipping 3354 matching lines...) Expand 10 before | Expand all | Expand 10 after
8362 Isolate* isolate, bool opt) const { \ 8599 Isolate* isolate, bool opt) const { \
8363 UNIMPLEMENTED(); \ 8600 UNIMPLEMENTED(); \
8364 return NULL; \ 8601 return NULL; \
8365 } \ 8602 } \
8366 void Name::EmitNativeCode(FlowGraphCompiler* compiler) { UNIMPLEMENTED(); } 8603 void Name::EmitNativeCode(FlowGraphCompiler* compiler) { UNIMPLEMENTED(); }
8367 8604
8368 8605
8369 } // namespace dart 8606 } // namespace dart
8370 8607
8371 #endif // VM_INTERMEDIATE_LANGUAGE_H_ 8608 #endif // VM_INTERMEDIATE_LANGUAGE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698