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

Side by Side Diff: runtime/vm/regexp_assembler_ir.cc

Issue 2904733003: Revert "Shuffle around deopt id allocation to give the flow graph builder a chance to record other … (Closed)
Patch Set: Created 3 years, 7 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
« no previous file with comments | « runtime/vm/regexp_assembler_ir.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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/regexp_assembler_ir.h" 5 #include "vm/regexp_assembler_ir.h"
6 6
7 #include "vm/bit_vector.h" 7 #include "vm/bit_vector.h"
8 #include "vm/compiler.h" 8 #include "vm/compiler.h"
9 #include "vm/dart_entry.h" 9 #include "vm/dart_entry.h"
10 #include "vm/flow_graph_builder.h" 10 #include "vm/flow_graph_builder.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 * during processing, and convert them to standard indexes when copying them 73 * during processing, and convert them to standard indexes when copying them
74 * to matches_param_ on successful match. 74 * to matches_param_ on successful match.
75 */ 75 */
76 IRRegExpMacroAssembler::IRRegExpMacroAssembler( 76 IRRegExpMacroAssembler::IRRegExpMacroAssembler(
77 intptr_t specialization_cid, 77 intptr_t specialization_cid,
78 intptr_t capture_count, 78 intptr_t capture_count,
79 const ParsedFunction* parsed_function, 79 const ParsedFunction* parsed_function,
80 const ZoneGrowableArray<const ICData*>& ic_data_array, 80 const ZoneGrowableArray<const ICData*>& ic_data_array,
81 Zone* zone) 81 Zone* zone)
82 : RegExpMacroAssembler(zone), 82 : RegExpMacroAssembler(zone),
83 thread_(Thread::Current()),
84 specialization_cid_(specialization_cid), 83 specialization_cid_(specialization_cid),
85 parsed_function_(parsed_function), 84 parsed_function_(parsed_function),
86 ic_data_array_(ic_data_array), 85 ic_data_array_(ic_data_array),
87 current_instruction_(NULL), 86 current_instruction_(NULL),
88 stack_(NULL), 87 stack_(NULL),
89 stack_pointer_(NULL), 88 stack_pointer_(NULL),
90 current_character_(NULL), 89 current_character_(NULL),
91 current_position_(NULL), 90 current_position_(NULL),
92 string_param_(NULL), 91 string_param_(NULL),
93 string_param_length_(NULL), 92 string_param_length_(NULL),
(...skipping 22 matching lines...) Expand all
116 // backing is indirectly referred to so we can reuse it on subsequent matches 115 // backing is indirectly referred to so we can reuse it on subsequent matches
117 // even in the case where the backing has been enlarged and thus reallocated. 116 // even in the case where the backing has been enlarged and thus reallocated.
118 stack_array_cell_.SetAt( 117 stack_array_cell_.SetAt(
119 0, 118 0,
120 TypedData::Handle(zone, TypedData::New(kTypedDataInt32ArrayCid, 119 TypedData::Handle(zone, TypedData::New(kTypedDataInt32ArrayCid,
121 kMinStackSize / 4, Heap::kOld))); 120 kMinStackSize / 4, Heap::kOld)));
122 121
123 // Create and generate all preset blocks. 122 // Create and generate all preset blocks.
124 entry_block_ = new (zone) GraphEntryInstr( 123 entry_block_ = new (zone) GraphEntryInstr(
125 *parsed_function_, 124 *parsed_function_,
126 new (zone) TargetEntryInstr(block_id_.Alloc(), kInvalidTryIndex, 125 new (zone) TargetEntryInstr(block_id_.Alloc(), kInvalidTryIndex),
127 GetNextDeoptId()),
128 Compiler::kNoOSRDeoptId); 126 Compiler::kNoOSRDeoptId);
129 start_block_ = new (zone) 127 start_block_ = new (zone) JoinEntryInstr(block_id_.Alloc(), kInvalidTryIndex);
130 JoinEntryInstr(block_id_.Alloc(), kInvalidTryIndex, GetNextDeoptId()); 128 success_block_ =
131 success_block_ = new (zone) 129 new (zone) JoinEntryInstr(block_id_.Alloc(), kInvalidTryIndex);
132 JoinEntryInstr(block_id_.Alloc(), kInvalidTryIndex, GetNextDeoptId()); 130 backtrack_block_ =
133 backtrack_block_ = new (zone) 131 new (zone) JoinEntryInstr(block_id_.Alloc(), kInvalidTryIndex);
134 JoinEntryInstr(block_id_.Alloc(), kInvalidTryIndex, GetNextDeoptId()); 132 exit_block_ = new (zone) JoinEntryInstr(block_id_.Alloc(), kInvalidTryIndex);
135 exit_block_ = new (zone)
136 JoinEntryInstr(block_id_.Alloc(), kInvalidTryIndex, GetNextDeoptId());
137 133
138 GenerateEntryBlock(); 134 GenerateEntryBlock();
139 GenerateSuccessBlock(); 135 GenerateSuccessBlock();
140 GenerateExitBlock(); 136 GenerateExitBlock();
141 137
142 blocks_.Add(entry_block_); 138 blocks_.Add(entry_block_);
143 blocks_.Add(entry_block_->normal_entry()); 139 blocks_.Add(entry_block_->normal_entry());
144 blocks_.Add(start_block_); 140 blocks_.Add(start_block_);
145 blocks_.Add(success_block_); 141 blocks_.Add(success_block_);
146 blocks_.Add(backtrack_block_); 142 blocks_.Add(backtrack_block_);
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 } 245 }
250 246
251 247
252 void IRRegExpMacroAssembler::GenerateSuccessBlock() { 248 void IRRegExpMacroAssembler::GenerateSuccessBlock() {
253 set_current_instruction(success_block_); 249 set_current_instruction(success_block_);
254 TAG(); 250 TAG();
255 251
256 Value* type = Bind(new (Z) ConstantInstr( 252 Value* type = Bind(new (Z) ConstantInstr(
257 TypeArguments::ZoneHandle(Z, TypeArguments::null()))); 253 TypeArguments::ZoneHandle(Z, TypeArguments::null())));
258 Value* length = Bind(Uint64Constant(saved_registers_count_)); 254 Value* length = Bind(Uint64Constant(saved_registers_count_));
259 Value* array = Bind(new (Z) CreateArrayInstr(TokenPosition::kNoSource, type, 255 Value* array =
260 length, GetNextDeoptId())); 256 Bind(new (Z) CreateArrayInstr(TokenPosition::kNoSource, type, length));
261 StoreLocal(result_, array); 257 StoreLocal(result_, array);
262 258
263 // Store captured offsets in the `matches` parameter. 259 // Store captured offsets in the `matches` parameter.
264 for (intptr_t i = 0; i < saved_registers_count_; i++) { 260 for (intptr_t i = 0; i < saved_registers_count_; i++) {
265 PushArgumentInstr* matches_push = PushLocal(result_); 261 PushArgumentInstr* matches_push = PushLocal(result_);
266 PushArgumentInstr* index_push = PushArgument(Bind(Uint64Constant(i))); 262 PushArgumentInstr* index_push = PushArgument(Bind(Uint64Constant(i)));
267 263
268 // Convert negative offsets from the end of the string to string indices. 264 // Convert negative offsets from the end of the string to string indices.
269 // TODO(zerny): use positive offsets from the get-go. 265 // TODO(zerny): use positive offsets from the get-go.
270 PushArgumentInstr* offset_push = PushArgument(LoadRegister(i)); 266 PushArgumentInstr* offset_push = PushArgument(LoadRegister(i));
271 PushArgumentInstr* len_push = PushLocal(string_param_length_); 267 PushArgumentInstr* len_push = PushLocal(string_param_length_);
272 PushArgumentInstr* value_push = 268 PushArgumentInstr* value_push =
273 PushArgument(Bind(Add(offset_push, len_push))); 269 PushArgument(Bind(Add(offset_push, len_push)));
274 270
275 Do(InstanceCall(InstanceCallDescriptor::FromToken(Token::kASSIGN_INDEX), 271 Do(InstanceCall(InstanceCallDescriptor::FromToken(Token::kASSIGN_INDEX),
276 matches_push, index_push, value_push)); 272 matches_push, index_push, value_push));
277 } 273 }
278 274
279 // Print the result if tracing. 275 // Print the result if tracing.
280 PRINT(PushLocal(result_)); 276 PRINT(PushLocal(result_));
281 277
282 // Return true on success. 278 // Return true on success.
283 AppendInstruction(new (Z) ReturnInstr( 279 AppendInstruction(
284 TokenPosition::kNoSource, Bind(LoadLocal(result_)), GetNextDeoptId())); 280 new (Z) ReturnInstr(TokenPosition::kNoSource, Bind(LoadLocal(result_))));
285 } 281 }
286 282
287 283
288 void IRRegExpMacroAssembler::GenerateExitBlock() { 284 void IRRegExpMacroAssembler::GenerateExitBlock() {
289 set_current_instruction(exit_block_); 285 set_current_instruction(exit_block_);
290 TAG(); 286 TAG();
291 287
292 // Return false on failure. 288 // Return false on failure.
293 AppendInstruction(new (Z) ReturnInstr( 289 AppendInstruction(
294 TokenPosition::kNoSource, Bind(LoadLocal(result_)), GetNextDeoptId())); 290 new (Z) ReturnInstr(TokenPosition::kNoSource, Bind(LoadLocal(result_))));
295 } 291 }
296 292
297 293
298 void IRRegExpMacroAssembler::FinalizeRegistersArray() { 294 void IRRegExpMacroAssembler::FinalizeRegistersArray() {
299 ASSERT(registers_count_ >= saved_registers_count_); 295 ASSERT(registers_count_ >= saved_registers_count_);
300 registers_array_ = 296 registers_array_ =
301 TypedData::New(kTypedDataInt32ArrayCid, registers_count_, Heap::kOld); 297 TypedData::New(kTypedDataInt32ArrayCid, registers_count_, Heap::kOld);
302 } 298 }
303 299
304 300
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 default: 482 default:
487 UNREACHABLE(); 483 UNREACHABLE();
488 } 484 }
489 485
490 ASSERT(intermediate_operator != Token::kILLEGAL); 486 ASSERT(intermediate_operator != Token::kILLEGAL);
491 487
492 Value* lhs_value = Bind(InstanceCall( 488 Value* lhs_value = Bind(InstanceCall(
493 InstanceCallDescriptor::FromToken(intermediate_operator), lhs, rhs)); 489 InstanceCallDescriptor::FromToken(intermediate_operator), lhs, rhs));
494 Value* rhs_value = Bind(BoolConstant(true)); 490 Value* rhs_value = Bind(BoolConstant(true));
495 491
496 return new (Z) 492 return new (Z) StrictCompareInstr(TokenPosition::kNoSource, strict_comparison,
497 StrictCompareInstr(TokenPosition::kNoSource, strict_comparison, lhs_value, 493 lhs_value, rhs_value, true);
498 rhs_value, true, GetNextDeoptId());
499 } 494 }
500 495
501 ComparisonInstr* IRRegExpMacroAssembler::Comparison(ComparisonKind kind, 496 ComparisonInstr* IRRegExpMacroAssembler::Comparison(ComparisonKind kind,
502 Definition* lhs, 497 Definition* lhs,
503 Definition* rhs) { 498 Definition* rhs) {
504 PushArgumentInstr* lhs_push = PushArgument(Bind(lhs)); 499 PushArgumentInstr* lhs_push = PushArgument(Bind(lhs));
505 PushArgumentInstr* rhs_push = PushArgument(Bind(rhs)); 500 PushArgumentInstr* rhs_push = PushArgument(Bind(rhs));
506 return Comparison(kind, lhs_push, rhs_push); 501 return Comparison(kind, lhs_push, rhs_push);
507 } 502 }
508 503
(...skipping 27 matching lines...) Expand all
536 arguments->Add(arg2); 531 arguments->Add(arg2);
537 532
538 return StaticCall(function, arguments); 533 return StaticCall(function, arguments);
539 } 534 }
540 535
541 536
542 StaticCallInstr* IRRegExpMacroAssembler::StaticCall( 537 StaticCallInstr* IRRegExpMacroAssembler::StaticCall(
543 const Function& function, 538 const Function& function,
544 ZoneGrowableArray<PushArgumentInstr*>* arguments) const { 539 ZoneGrowableArray<PushArgumentInstr*>* arguments) const {
545 const intptr_t kTypeArgsLen = 0; 540 const intptr_t kTypeArgsLen = 0;
546 return new (Z) StaticCallInstr(TokenPosition::kNoSource, function, 541 return new (Z)
547 kTypeArgsLen, Object::null_array(), arguments, 542 StaticCallInstr(TokenPosition::kNoSource, function, kTypeArgsLen,
548 ic_data_array_, GetNextDeoptId()); 543 Object::null_array(), arguments, ic_data_array_);
549 } 544 }
550 545
551 546
552 InstanceCallInstr* IRRegExpMacroAssembler::InstanceCall( 547 InstanceCallInstr* IRRegExpMacroAssembler::InstanceCall(
553 const InstanceCallDescriptor& desc, 548 const InstanceCallDescriptor& desc,
554 PushArgumentInstr* arg1) const { 549 PushArgumentInstr* arg1) const {
555 ZoneGrowableArray<PushArgumentInstr*>* arguments = 550 ZoneGrowableArray<PushArgumentInstr*>* arguments =
556 new (Z) ZoneGrowableArray<PushArgumentInstr*>(1); 551 new (Z) ZoneGrowableArray<PushArgumentInstr*>(1);
557 arguments->Add(arg1); 552 arguments->Add(arg1);
558 553
(...skipping 26 matching lines...) Expand all
585 arguments->Add(arg3); 580 arguments->Add(arg3);
586 581
587 return InstanceCall(desc, arguments); 582 return InstanceCall(desc, arguments);
588 } 583 }
589 584
590 585
591 InstanceCallInstr* IRRegExpMacroAssembler::InstanceCall( 586 InstanceCallInstr* IRRegExpMacroAssembler::InstanceCall(
592 const InstanceCallDescriptor& desc, 587 const InstanceCallDescriptor& desc,
593 ZoneGrowableArray<PushArgumentInstr*>* arguments) const { 588 ZoneGrowableArray<PushArgumentInstr*>* arguments) const {
594 const intptr_t kTypeArgsLen = 0; 589 const intptr_t kTypeArgsLen = 0;
595 return new (Z) InstanceCallInstr( 590 return new (Z)
596 TokenPosition::kNoSource, desc.name, desc.token_kind, arguments, 591 InstanceCallInstr(TokenPosition::kNoSource, desc.name, desc.token_kind,
597 kTypeArgsLen, Object::null_array(), desc.checked_argument_count, 592 arguments, kTypeArgsLen, Object::null_array(),
598 ic_data_array_, GetNextDeoptId()); 593 desc.checked_argument_count, ic_data_array_);
599 } 594 }
600 595
601 596
602 LoadLocalInstr* IRRegExpMacroAssembler::LoadLocal(LocalVariable* local) const { 597 LoadLocalInstr* IRRegExpMacroAssembler::LoadLocal(LocalVariable* local) const {
603 return new (Z) LoadLocalInstr(*local, TokenPosition::kNoSource); 598 return new (Z) LoadLocalInstr(*local, TokenPosition::kNoSource);
604 } 599 }
605 600
606 601
607 void IRRegExpMacroAssembler::StoreLocal(LocalVariable* local, Value* value) { 602 void IRRegExpMacroAssembler::StoreLocal(LocalVariable* local, Value* value) {
608 Do(new (Z) StoreLocalInstr(*local, value, TokenPosition::kNoSource)); 603 Do(new (Z) StoreLocalInstr(*local, value, TokenPosition::kNoSource));
(...skipping 960 matching lines...) Expand 10 before | Expand all | Expand 10 after
1569 void IRRegExpMacroAssembler::CheckStackLimit() { 1564 void IRRegExpMacroAssembler::CheckStackLimit() {
1570 TAG(); 1565 TAG();
1571 PushArgumentInstr* stack_push = PushLocal(stack_); 1566 PushArgumentInstr* stack_push = PushLocal(stack_);
1572 PushArgumentInstr* length_push = PushArgument( 1567 PushArgumentInstr* length_push = PushArgument(
1573 Bind(InstanceCall(InstanceCallDescriptor(String::ZoneHandle( 1568 Bind(InstanceCall(InstanceCallDescriptor(String::ZoneHandle(
1574 Field::GetterSymbol(Symbols::Length()))), 1569 Field::GetterSymbol(Symbols::Length()))),
1575 stack_push))); 1570 stack_push)));
1576 PushArgumentInstr* capacity_push = PushArgument(Bind(Sub( 1571 PushArgumentInstr* capacity_push = PushArgument(Bind(Sub(
1577 length_push, PushArgument(Bind(Uint64Constant(stack_limit_slack())))))); 1572 length_push, PushArgument(Bind(Uint64Constant(stack_limit_slack()))))));
1578 PushArgumentInstr* stack_pointer_push = PushLocal(stack_pointer_); 1573 PushArgumentInstr* stack_pointer_push = PushLocal(stack_pointer_);
1579 BranchInstr* branch = new (Z) BranchInstr( 1574 BranchInstr* branch =
1580 Comparison(kGT, capacity_push, stack_pointer_push), GetNextDeoptId()); 1575 new (Z) BranchInstr(Comparison(kGT, capacity_push, stack_pointer_push));
1581 CloseBlockWith(branch); 1576 CloseBlockWith(branch);
1582 1577
1583 BlockLabel grow_stack; 1578 BlockLabel grow_stack;
1584 BlockLabel fallthrough; 1579 BlockLabel fallthrough;
1585 *branch->true_successor_address() = TargetWithJoinGoto(fallthrough.block()); 1580 *branch->true_successor_address() = TargetWithJoinGoto(fallthrough.block());
1586 *branch->false_successor_address() = TargetWithJoinGoto(grow_stack.block()); 1581 *branch->false_successor_address() = TargetWithJoinGoto(grow_stack.block());
1587 1582
1588 BindBlock(&grow_stack); 1583 BindBlock(&grow_stack);
1589 GrowStack(); 1584 GrowStack();
1590 1585
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
1726 JoinEntryInstr* true_successor_block = backtrack_block_; 1721 JoinEntryInstr* true_successor_block = backtrack_block_;
1727 if (true_successor != NULL) { 1722 if (true_successor != NULL) {
1728 true_successor->SetLinked(); 1723 true_successor->SetLinked();
1729 true_successor_block = true_successor->block(); 1724 true_successor_block = true_successor->block();
1730 } 1725 }
1731 ASSERT(true_successor_block != NULL); 1726 ASSERT(true_successor_block != NULL);
1732 1727
1733 // If the condition is not true, fall through to a new block. 1728 // If the condition is not true, fall through to a new block.
1734 BlockLabel fallthrough; 1729 BlockLabel fallthrough;
1735 1730
1736 BranchInstr* branch = new (Z) BranchInstr(comparison, GetNextDeoptId()); 1731 BranchInstr* branch = new (Z) BranchInstr(comparison);
1737 *branch->true_successor_address() = TargetWithJoinGoto(true_successor_block); 1732 *branch->true_successor_address() = TargetWithJoinGoto(true_successor_block);
1738 *branch->false_successor_address() = TargetWithJoinGoto(fallthrough.block()); 1733 *branch->false_successor_address() = TargetWithJoinGoto(fallthrough.block());
1739 1734
1740 CloseBlockWith(branch); 1735 CloseBlockWith(branch);
1741 BindBlock(&fallthrough); 1736 BindBlock(&fallthrough);
1742 } 1737 }
1743 1738
1744 1739
1745 TargetEntryInstr* IRRegExpMacroAssembler::TargetWithJoinGoto( 1740 TargetEntryInstr* IRRegExpMacroAssembler::TargetWithJoinGoto(
1746 JoinEntryInstr* dst) { 1741 JoinEntryInstr* dst) {
1747 TargetEntryInstr* target = new (Z) 1742 TargetEntryInstr* target =
1748 TargetEntryInstr(block_id_.Alloc(), kInvalidTryIndex, GetNextDeoptId()); 1743 new (Z) TargetEntryInstr(block_id_.Alloc(), kInvalidTryIndex);
1749 blocks_.Add(target); 1744 blocks_.Add(target);
1750 1745
1751 target->AppendInstruction(new (Z) GotoInstr(dst, GetNextDeoptId())); 1746 target->AppendInstruction(new (Z) GotoInstr(dst));
1752 1747
1753 return target; 1748 return target;
1754 } 1749 }
1755 1750
1756 1751
1757 IndirectEntryInstr* IRRegExpMacroAssembler::IndirectWithJoinGoto( 1752 IndirectEntryInstr* IRRegExpMacroAssembler::IndirectWithJoinGoto(
1758 JoinEntryInstr* dst) { 1753 JoinEntryInstr* dst) {
1759 IndirectEntryInstr* target = 1754 IndirectEntryInstr* target = new (Z) IndirectEntryInstr(
1760 new (Z) IndirectEntryInstr(block_id_.Alloc(), indirect_id_.Alloc(), 1755 block_id_.Alloc(), indirect_id_.Alloc(), kInvalidTryIndex);
1761 kInvalidTryIndex, GetNextDeoptId());
1762 blocks_.Add(target); 1756 blocks_.Add(target);
1763 1757
1764 target->AppendInstruction(new (Z) GotoInstr(dst, GetNextDeoptId())); 1758 target->AppendInstruction(new (Z) GotoInstr(dst));
1765 1759
1766 return target; 1760 return target;
1767 } 1761 }
1768 1762
1769 1763
1770 void IRRegExpMacroAssembler::CheckPreemption() { 1764 void IRRegExpMacroAssembler::CheckPreemption() {
1771 TAG(); 1765 TAG();
1772 AppendInstruction(new (Z) CheckStackOverflowInstr(TokenPosition::kNoSource, 0, 1766 AppendInstruction(new (Z)
1773 GetNextDeoptId())); 1767 CheckStackOverflowInstr(TokenPosition::kNoSource, 0));
1774 } 1768 }
1775 1769
1776 1770
1777 Definition* IRRegExpMacroAssembler::Add(PushArgumentInstr* lhs, 1771 Definition* IRRegExpMacroAssembler::Add(PushArgumentInstr* lhs,
1778 PushArgumentInstr* rhs) { 1772 PushArgumentInstr* rhs) {
1779 return InstanceCall(InstanceCallDescriptor::FromToken(Token::kADD), lhs, rhs); 1773 return InstanceCall(InstanceCallDescriptor::FromToken(Token::kADD), lhs, rhs);
1780 } 1774 }
1781 1775
1782 1776
1783 Definition* IRRegExpMacroAssembler::Sub(PushArgumentInstr* lhs, 1777 Definition* IRRegExpMacroAssembler::Sub(PushArgumentInstr* lhs,
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
1852 1846
1853 return Bind(new (Z) LoadCodeUnitsInstr(pattern_val, index_val, characters, 1847 return Bind(new (Z) LoadCodeUnitsInstr(pattern_val, index_val, characters,
1854 specialization_cid_, 1848 specialization_cid_,
1855 TokenPosition::kNoSource)); 1849 TokenPosition::kNoSource));
1856 } 1850 }
1857 1851
1858 1852
1859 #undef __ 1853 #undef __
1860 1854
1861 } // namespace dart 1855 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/regexp_assembler_ir.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698