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

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

Issue 800433004: Use a typed array for the irregexp stack. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: whitespace Created 5 years, 11 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) 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.h" 5 #include "vm/regexp_assembler.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 18 matching lines...) Expand all
29 29
30 #define PRINT(arg) if (FLAG_trace_irregexp) { Print(arg); } 30 #define PRINT(arg) if (FLAG_trace_irregexp) { Print(arg); }
31 31
32 namespace dart { 32 namespace dart {
33 33
34 DEFINE_FLAG(bool, trace_irregexp, false, "Trace irregexps"); 34 DEFINE_FLAG(bool, trace_irregexp, false, "Trace irregexps");
35 35
36 36
37 static const intptr_t kInvalidTryIndex = CatchClauseNode::kInvalidTryIndex; 37 static const intptr_t kInvalidTryIndex = CatchClauseNode::kInvalidTryIndex;
38 static const intptr_t kNoSourcePos = Scanner::kNoSourcePos; 38 static const intptr_t kNoSourcePos = Scanner::kNoSourcePos;
39 static const intptr_t kMinStackSize = 512;
39 40
40 41
41 void PrintUtf16(uint16_t c) { 42 void PrintUtf16(uint16_t c) {
42 const char* format = (0x20 <= c && c <= 0x7F) ? 43 const char* format = (0x20 <= c && c <= 0x7F) ?
43 "%c" : (c <= 0xff) ? "\\x%02x" : "\\u%04x"; 44 "%c" : (c <= 0xff) ? "\\x%02x" : "\\u%04x";
44 OS::Print(format, c); 45 OS::Print(format, c);
45 } 46 }
46 47
47 48
48 /* 49 /*
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 intptr_t capture_count, 84 intptr_t capture_count,
84 const ParsedFunction* parsed_function, 85 const ParsedFunction* parsed_function,
85 const ZoneGrowableArray<const ICData*>& ic_data_array, 86 const ZoneGrowableArray<const ICData*>& ic_data_array,
86 Isolate* isolate) 87 Isolate* isolate)
87 : RegExpMacroAssembler(isolate), 88 : RegExpMacroAssembler(isolate),
88 specialization_cid_(specialization_cid), 89 specialization_cid_(specialization_cid),
89 parsed_function_(parsed_function), 90 parsed_function_(parsed_function),
90 ic_data_array_(ic_data_array), 91 ic_data_array_(ic_data_array),
91 current_instruction_(NULL), 92 current_instruction_(NULL),
92 stack_(NULL), 93 stack_(NULL),
94 stack_tip_(NULL),
93 current_character_(NULL), 95 current_character_(NULL),
94 current_position_(NULL), 96 current_position_(NULL),
95 string_param_(NULL), 97 string_param_(NULL),
96 string_param_length_(NULL), 98 string_param_length_(NULL),
97 start_index_param_(NULL), 99 start_index_param_(NULL),
98 registers_count_(0), 100 registers_count_(0),
99 saved_registers_count_((capture_count + 1) * 2), 101 saved_registers_count_((capture_count + 1) * 2),
100 stack_array_(GrowableObjectArray::ZoneHandle( 102 stack_array_cell_(Array::ZoneHandle(isolate, Array::New(1, Heap::kOld))),
101 isolate, GrowableObjectArray::New(16, Heap::kOld))),
102 // The registers array is allocated at a fixed size after assembly. 103 // The registers array is allocated at a fixed size after assembly.
103 registers_array_(TypedData::ZoneHandle(isolate, TypedData::null())) { 104 registers_array_(TypedData::ZoneHandle(isolate, TypedData::null())) {
104 switch (specialization_cid) { 105 switch (specialization_cid) {
105 case kOneByteStringCid: 106 case kOneByteStringCid:
106 case kExternalOneByteStringCid: mode_ = ASCII; break; 107 case kExternalOneByteStringCid: mode_ = ASCII; break;
107 case kTwoByteStringCid: 108 case kTwoByteStringCid:
108 case kExternalTwoByteStringCid: mode_ = UC16; break; 109 case kExternalTwoByteStringCid: mode_ = UC16; break;
109 default: UNREACHABLE(); 110 default: UNREACHABLE();
110 } 111 }
111 112
112 InitializeLocals(); 113 InitializeLocals();
113 114
115 // Allocate an initial stack backing of the minimum stack size. The stack
116 // 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.
118 stack_array_cell_.SetAt(0, TypedData::Handle(isolate,
119 TypedData::New(kTypedDataInt32ArrayCid, kMinStackSize / 4, Heap::kOld)));
120
114 // Create and generate all preset blocks. 121 // Create and generate all preset blocks.
115 entry_block_ = 122 entry_block_ =
116 new(isolate) GraphEntryInstr( 123 new(isolate) GraphEntryInstr(
117 parsed_function_, 124 parsed_function_,
118 new(isolate) TargetEntryInstr(block_id_.Alloc(), kInvalidTryIndex), 125 new(isolate) TargetEntryInstr(block_id_.Alloc(), kInvalidTryIndex),
119 Isolate::kNoDeoptId); 126 Isolate::kNoDeoptId);
120 start_block_ = 127 start_block_ =
121 new(isolate) JoinEntryInstr(block_id_.Alloc(), kInvalidTryIndex); 128 new(isolate) JoinEntryInstr(block_id_.Alloc(), kInvalidTryIndex);
122 success_block_ = 129 success_block_ =
123 new(isolate) JoinEntryInstr(block_id_.Alloc(), kInvalidTryIndex); 130 new(isolate) JoinEntryInstr(block_id_.Alloc(), kInvalidTryIndex);
(...skipping 21 matching lines...) Expand all
145 IRRegExpMacroAssembler::~IRRegExpMacroAssembler() { } 152 IRRegExpMacroAssembler::~IRRegExpMacroAssembler() { }
146 153
147 154
148 void IRRegExpMacroAssembler::InitializeLocals() { 155 void IRRegExpMacroAssembler::InitializeLocals() {
149 // All generated functions are expected to have a current-context variable. 156 // All generated functions are expected to have a current-context variable.
150 // This variable is unused in irregexp functions. 157 // This variable is unused in irregexp functions.
151 parsed_function_->current_context_var()->set_index(GetNextLocalIndex()); 158 parsed_function_->current_context_var()->set_index(GetNextLocalIndex());
152 159
153 // Create local variables and parameters. 160 // Create local variables and parameters.
154 stack_ = Local(Symbols::stack()); 161 stack_ = Local(Symbols::stack());
162 stack_tip_ = Local(Symbols::stack_tip());
Vyacheslav Egorov (Google) 2015/01/20 16:26:24 Any reason for not calling it stack_pointer_ or st
zerny-google 2015/01/21 12:03:11 Done.
155 registers_ = Local(Symbols::position_registers()); 163 registers_ = Local(Symbols::position_registers());
156 current_character_ = Local(Symbols::current_character()); 164 current_character_ = Local(Symbols::current_character());
157 current_position_ = Local(Symbols::current_position()); 165 current_position_ = Local(Symbols::current_position());
158 string_param_length_ = Local(Symbols::string_param_length()); 166 string_param_length_ = Local(Symbols::string_param_length());
159 capture_length_ = Local(Symbols::capture_length()); 167 capture_length_ = Local(Symbols::capture_length());
160 match_start_index_ = Local(Symbols::match_start_index()); 168 match_start_index_ = Local(Symbols::match_start_index());
161 capture_start_index_ = Local(Symbols::capture_start_index()); 169 capture_start_index_ = Local(Symbols::capture_start_index());
162 match_end_index_ = Local(Symbols::match_end_index()); 170 match_end_index_ = Local(Symbols::match_end_index());
163 char_in_capture_ = Local(Symbols::char_in_capture()); 171 char_in_capture_ = Local(Symbols::char_in_capture());
164 char_in_match_ = Local(Symbols::char_in_match()); 172 char_in_match_ = Local(Symbols::char_in_match());
(...skipping 25 matching lines...) Expand all
190 PushArgumentInstr* length_push = PushLocal(string_param_length_); 198 PushArgumentInstr* length_push = PushLocal(string_param_length_);
191 199
192 StoreLocal(current_position_, Bind(Sub(start_index_push, length_push))); 200 StoreLocal(current_position_, Bind(Sub(start_index_push, length_push)));
193 201
194 // Generate a local list variable to represent "registers" and 202 // Generate a local list variable to represent "registers" and
195 // initialize capture registers (others remain garbage). 203 // initialize capture registers (others remain garbage).
196 StoreLocal(registers_, Bind(new(I) ConstantInstr(registers_array_))); 204 StoreLocal(registers_, Bind(new(I) ConstantInstr(registers_array_)));
197 ClearRegisters(0, saved_registers_count_ - 1); 205 ClearRegisters(0, saved_registers_count_ - 1);
198 206
199 // Generate a local list variable to represent the backtracking stack. 207 // Generate a local list variable to represent the backtracking stack.
200 StoreLocal(stack_, Bind(new(I) ConstantInstr(stack_array_))); 208 PushArgumentInstr* stack_cell_push =
201 PushArgumentInstr* stack_push = PushLocal(stack_); 209 PushArgument(Bind(new(I) ConstantInstr(stack_array_cell_)));
202 PushArgumentInstr* zero_push = PushArgument(Bind(Uint64Constant(0))); 210 StoreLocal(stack_, Bind(InstanceCall(
203 Do(InstanceCall(InstanceCallDescriptor( 211 InstanceCallDescriptor::FromToken(Token::kINDEX),
204 Library::PrivateCoreLibName(Symbols::_setLength())), 212 stack_cell_push,
205 stack_push, 213 PushArgument(Bind(Uint64Constant(0))))));
206 zero_push)); 214 StoreLocal(stack_tip_, Bind(Int64Constant(-1)));
207 215
208 // Jump to the start block. 216 // Jump to the start block.
209 current_instruction_->Goto(start_block_); 217 current_instruction_->Goto(start_block_);
210 } 218 }
211 219
212 220
213 void IRRegExpMacroAssembler::GenerateBacktrackBlock() { 221 void IRRegExpMacroAssembler::GenerateBacktrackBlock() {
214 set_current_instruction(backtrack_block_); 222 set_current_instruction(backtrack_block_);
215 TAG(); 223 TAG();
216 CheckPreemption(); 224 CheckPreemption();
217 225
218 const intptr_t entries_count = entry_block_->indirect_entries().length(); 226 const intptr_t entries_count = entry_block_->indirect_entries().length();
219 227
220 TypedData& offsets = TypedData::ZoneHandle(I, 228 TypedData& offsets = TypedData::ZoneHandle(I,
221 TypedData::New(kTypedDataInt32ArrayCid, entries_count, Heap::kOld)); 229 TypedData::New(kTypedDataInt32ArrayCid, entries_count, Heap::kOld));
222 230
223 PushArgumentInstr* block_offsets_push = 231 PushArgumentInstr* block_offsets_push =
224 PushArgument(Bind(new(I) ConstantInstr(offsets))); 232 PushArgument(Bind(new(I) ConstantInstr(offsets)));
225 PushArgumentInstr* block_id_push = PushArgument(PopStack()); 233 PushArgumentInstr* block_id_push = PushArgument(Bind(PopStack()));
226 234
227 Value* offset_value = 235 Value* offset_value =
228 Bind(InstanceCall(InstanceCallDescriptor::FromToken(Token::kINDEX), 236 Bind(InstanceCall(InstanceCallDescriptor::FromToken(Token::kINDEX),
229 block_offsets_push, 237 block_offsets_push,
230 block_id_push)); 238 block_id_push));
231 239
232 backtrack_goto_ = new(I) IndirectGotoInstr(&offsets, offset_value); 240 backtrack_goto_ = new(I) IndirectGotoInstr(&offsets, offset_value);
233 CloseBlockWith(backtrack_goto_); 241 CloseBlockWith(backtrack_goto_);
234 242
235 // Add an edge from the "indirect" goto to each of the targets. 243 // Add an edge from the "indirect" goto to each of the targets.
(...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after
890 Uint64Constant(limit)), 898 Uint64Constant(limit)),
891 on_less); 899 on_less);
892 } 900 }
893 901
894 902
895 void IRRegExpMacroAssembler::CheckGreedyLoop(BlockLabel* on_equal) { 903 void IRRegExpMacroAssembler::CheckGreedyLoop(BlockLabel* on_equal) {
896 TAG(); 904 TAG();
897 905
898 BlockLabel fallthrough; 906 BlockLabel fallthrough;
899 907
900 PushArgumentInstr* stack_push = PushLocal(stack_); 908 Definition* stack_tip_def = PeekStack();
Vyacheslav Egorov (Google) 2015/01/20 16:26:24 Definition* peeked_def stack_tip_def is confusin
zerny-google 2015/01/21 12:03:11 Yes. It this is caused by trying to match the name
901 Definition* stack_tip_def = InstanceCall(
902 InstanceCallDescriptor(String::ZoneHandle(
903 I, Field::GetterSymbol(Symbols::last()))),
904 stack_push);
905 Definition* cur_pos_def = LoadLocal(current_position_); 909 Definition* cur_pos_def = LoadLocal(current_position_);
906
907 BranchOrBacktrack(Comparison(kNE, stack_tip_def, cur_pos_def), 910 BranchOrBacktrack(Comparison(kNE, stack_tip_def, cur_pos_def),
908 &fallthrough); 911 &fallthrough);
909 912
910 // Pop, throwing away the value. 913 // Pop, throwing away the value.
911 stack_push = PushLocal(stack_); 914 Do(PopStack());
912 Do(InstanceCall(InstanceCallDescriptor(Symbols::removeLast()),
913 stack_push));
914 915
915 BranchOrBacktrack(NULL, on_equal); 916 BranchOrBacktrack(NULL, on_equal);
916 917
917 BindBlock(&fallthrough); 918 BindBlock(&fallthrough);
918 } 919 }
919 920
920 921
921 void IRRegExpMacroAssembler::CheckNotBackReferenceIgnoreCase( 922 void IRRegExpMacroAssembler::CheckNotBackReferenceIgnoreCase(
922 intptr_t start_reg, 923 intptr_t start_reg,
923 BlockLabel* on_no_match) { 924 BlockLabel* on_no_match) {
(...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after
1520 ASSERT(cp_offset < (1<<30)); // Be sane! (And ensure negation works) 1521 ASSERT(cp_offset < (1<<30)); // Be sane! (And ensure negation works)
1521 if (check_bounds) { 1522 if (check_bounds) {
1522 CheckPosition(cp_offset + characters - 1, on_end_of_input); 1523 CheckPosition(cp_offset + characters - 1, on_end_of_input);
1523 } 1524 }
1524 LoadCurrentCharacterUnchecked(cp_offset, characters); 1525 LoadCurrentCharacterUnchecked(cp_offset, characters);
1525 } 1526 }
1526 1527
1527 1528
1528 void IRRegExpMacroAssembler::PopCurrentPosition() { 1529 void IRRegExpMacroAssembler::PopCurrentPosition() {
1529 TAG(); 1530 TAG();
1530 StoreLocal(current_position_, PopStack()); 1531 StoreLocal(current_position_, Bind(PopStack()));
1531 } 1532 }
1532 1533
1533 1534
1534 void IRRegExpMacroAssembler::PopRegister(intptr_t reg) { 1535 void IRRegExpMacroAssembler::PopRegister(intptr_t reg) {
1535 TAG(); 1536 TAG();
1536 ASSERT(reg < registers_count_); 1537 ASSERT(reg < registers_count_);
1537 PushArgumentInstr* registers_push = PushLocal(registers_); 1538 PushArgumentInstr* registers_push = PushLocal(registers_);
1538 PushArgumentInstr* index_push = PushRegisterIndex(reg); 1539 PushArgumentInstr* index_push = PushRegisterIndex(reg);
1539 PushArgumentInstr* pop_push = PushArgument(PopStack()); 1540 PushArgumentInstr* pop_push = PushArgument(Bind(PopStack()));
1540 StoreRegister(registers_push, index_push, pop_push); 1541 StoreRegister(registers_push, index_push, pop_push);
1541 } 1542 }
1542 1543
1543 1544
1544 void IRRegExpMacroAssembler::PushStack(Definition *definition) { 1545 void IRRegExpMacroAssembler::PushStack(Definition *definition) {
1545 PushArgumentInstr* stack_push = PushLocal(stack_); 1546 PushArgumentInstr* stack_push = PushLocal(stack_);
1547 PushArgumentInstr* stack_tip_push = PushLocal(stack_tip_);
1548 StoreLocal(stack_tip_,
1549 Bind(Add(stack_tip_push,
1550 PushArgument(Bind(Uint64Constant(1))))));
1551 stack_tip_push = PushLocal(stack_tip_);
1552 // TODO(zerny): bind value and push could break stack discipline.
1546 PushArgumentInstr* value_push = PushArgument(Bind(definition)); 1553 PushArgumentInstr* value_push = PushArgument(Bind(definition));
1547 Do(InstanceCall(InstanceCallDescriptor(Symbols::add()), 1554 Do(InstanceCall(InstanceCallDescriptor::FromToken(Token::kASSIGN_INDEX),
1548 stack_push, 1555 stack_push,
1556 stack_tip_push,
1549 value_push)); 1557 value_push));
1550 } 1558 }
1551 1559
1552 1560
1553 Value* IRRegExpMacroAssembler::PopStack() { 1561 Definition* IRRegExpMacroAssembler::PopStack() {
1554 PushArgumentInstr* stack_push = PushLocal(stack_); 1562 PushArgumentInstr* stack_push = PushLocal(stack_);
1555 return Bind(InstanceCall(InstanceCallDescriptor(Symbols::removeLast()), 1563 PushArgumentInstr* stack_tip_push1 = PushLocal(stack_tip_);
1556 stack_push)); 1564 PushArgumentInstr* stack_tip_push2 = PushLocal(stack_tip_);
1565 StoreLocal(stack_tip_,
1566 Bind(Sub(stack_tip_push2, PushArgument(Bind(Uint64Constant(1))))));
1567 return InstanceCall(InstanceCallDescriptor::FromToken(Token::kINDEX),
1568 stack_push,
1569 stack_tip_push1);
1557 } 1570 }
1558 1571
1559 1572
1573 Definition* IRRegExpMacroAssembler::PeekStack() {
1574 PushArgumentInstr* stack_push = PushLocal(stack_);
1575 PushArgumentInstr* stack_tip_push = PushLocal(stack_tip_);
1576 return InstanceCall(InstanceCallDescriptor::FromToken(Token::kINDEX),
1577 stack_push,
1578 stack_tip_push);
1579 }
1580
1581
1560 // Pushes the location corresponding to label to the backtracking stack. 1582 // Pushes the location corresponding to label to the backtracking stack.
1561 void IRRegExpMacroAssembler::PushBacktrack(BlockLabel* label) { 1583 void IRRegExpMacroAssembler::PushBacktrack(BlockLabel* label) {
1562 TAG(); 1584 TAG();
1563 1585
1564 // Ensure that targets of indirect jumps are never accessed through a 1586 // Ensure that targets of indirect jumps are never accessed through a
1565 // normal control flow instructions by creating a new block for each backtrack 1587 // normal control flow instructions by creating a new block for each backtrack
1566 // target. 1588 // target.
1567 IndirectEntryInstr* indirect_target = IndirectWithJoinGoto(label->block()); 1589 IndirectEntryInstr* indirect_target = IndirectWithJoinGoto(label->block());
1568 1590
1569 // Add a fake edge from the graph entry for data flow analysis. 1591 // Add a fake edge from the graph entry for data flow analysis.
1570 entry_block_->AddIndirectEntry(indirect_target); 1592 entry_block_->AddIndirectEntry(indirect_target);
1571 1593
1572 ConstantInstr* offset = Uint64Constant(indirect_target->indirect_id()); 1594 ConstantInstr* offset = Uint64Constant(indirect_target->indirect_id());
1573 PushStack(offset); 1595 PushStack(offset);
1596 CheckStackLimit();
1574 } 1597 }
1575 1598
1576 1599
1577 void IRRegExpMacroAssembler::PushCurrentPosition() { 1600 void IRRegExpMacroAssembler::PushCurrentPosition() {
1578 TAG(); 1601 TAG();
1579 PushStack(LoadLocal(current_position_)); 1602 PushStack(LoadLocal(current_position_));
1580 } 1603 }
1581 1604
1582 1605
1583 void IRRegExpMacroAssembler::PushRegister(intptr_t reg) { 1606 void IRRegExpMacroAssembler::PushRegister(intptr_t reg) {
1584 TAG(); 1607 TAG();
1608 // TODO(zerny): Refactor PushStack so it can be reused here.
1585 PushArgumentInstr* stack_push = PushLocal(stack_); 1609 PushArgumentInstr* stack_push = PushLocal(stack_);
1610 PushArgumentInstr* stack_tip_push = PushLocal(stack_tip_);
1611 StoreLocal(stack_tip_,
1612 Bind(Add(stack_tip_push,
1613 PushArgument(Bind(Uint64Constant(1))))));
1614 stack_tip_push = PushLocal(stack_tip_);
1615 // TODO(zerny): bind value and push could break stack discipline.
1586 PushArgumentInstr* value_push = PushArgument(LoadRegister(reg)); 1616 PushArgumentInstr* value_push = PushArgument(LoadRegister(reg));
1587 Do(InstanceCall(InstanceCallDescriptor(Symbols::add()), 1617 Do(InstanceCall(InstanceCallDescriptor::FromToken(Token::kASSIGN_INDEX),
1588 stack_push, 1618 stack_push,
1619 stack_tip_push,
1589 value_push)); 1620 value_push));
1621 CheckStackLimit();
1590 } 1622 }
1591 1623
1592 1624
1625 // Checks that (stack.capacity - stack_limit_slack) > stack_tip.
1626 // This ensures that up to stack_limit_slack stack pushes can be
1627 // done without exhausting the stack space. If the check fails the
1628 // stack will be grown.
1629 void IRRegExpMacroAssembler::CheckStackLimit() {
1630 TAG();
1631 PushArgumentInstr* stack_push = PushLocal(stack_);
1632 PushArgumentInstr* length_push = PushArgument(Bind(InstanceCall(
1633 InstanceCallDescriptor(
1634 String::ZoneHandle(Field::GetterSymbol(Symbols::Length()))),
1635 stack_push)));
1636 PushArgumentInstr* capacity_push = PushArgument(Bind(Sub(
1637 length_push,
1638 PushArgument(Bind(Uint64Constant(stack_limit_slack()))))));
1639 PushArgumentInstr* stack_tip_push = PushLocal(stack_tip_);
1640 BranchInstr* branch = new(I) BranchInstr(
1641 Comparison(kGT, capacity_push, stack_tip_push));
1642 CloseBlockWith(branch);
1643
1644 BlockLabel grow_stack;
1645 BlockLabel fallthrough;
1646 *branch->true_successor_address() =
1647 TargetWithJoinGoto(fallthrough.block());
1648 *branch->false_successor_address() =
1649 TargetWithJoinGoto(grow_stack.block());
1650
1651 BindBlock(&grow_stack);
1652 GrowStack();
1653
1654 BindBlock(&fallthrough);
1655 }
1656
1657
1658 void IRRegExpMacroAssembler::GrowStack() {
1659 TAG();
1660 Value* stack_val = Bind(LoadLocal(stack_));
1661 StoreLocal(stack_, Bind(new(I) GrowTypedDataInstr(stack_val)));
Vyacheslav Egorov (Google) 2015/01/20 16:26:24 Consider passing stack_cell into GrowTypedDataInst
zerny-google 2015/01/21 12:03:11 Done.
1662
1663 // Cache the newly allocated backing for subsequent matches.
1664 PushArgumentInstr* stack_cell_push =
1665 PushArgument(Bind(new(I) ConstantInstr(stack_array_cell_)));
1666 PushArgumentInstr* zero_index = PushArgument(Bind(Uint64Constant(0)));
1667 PushArgumentInstr* stack_push = PushLocal(stack_);
1668 Do(InstanceCall(InstanceCallDescriptor::FromToken(Token::kASSIGN_INDEX),
1669 stack_cell_push,
1670 zero_index,
1671 stack_push));
1672 }
1673
1674
1593 void IRRegExpMacroAssembler::ReadCurrentPositionFromRegister(intptr_t reg) { 1675 void IRRegExpMacroAssembler::ReadCurrentPositionFromRegister(intptr_t reg) {
1594 TAG(); 1676 TAG();
1595 StoreLocal(current_position_, LoadRegister(reg)); 1677 StoreLocal(current_position_, LoadRegister(reg));
1596 } 1678 }
1597 1679
1598 // Resets the size of the stack to the value stored in reg. 1680 // Resets the tip of the stack to the value stored in reg.
1599 void IRRegExpMacroAssembler::ReadStackPointerFromRegister(intptr_t reg) { 1681 void IRRegExpMacroAssembler::ReadStackPointerFromRegister(intptr_t reg) {
1600 TAG(); 1682 TAG();
1601 ASSERT(reg < registers_count_); 1683 ASSERT(reg < registers_count_);
1602 1684 StoreLocal(stack_tip_, LoadRegister(reg));
1603 PushArgumentInstr* stack_push = PushLocal(stack_);
1604 PushArgumentInstr* length_push = PushArgument(LoadRegister(reg));
1605
1606 Do(InstanceCall(
1607 InstanceCallDescriptor(
1608 String::ZoneHandle(I, Field::SetterSymbol(Symbols::Length()))),
1609 stack_push,
1610 length_push));
1611 } 1685 }
1612 1686
1613 void IRRegExpMacroAssembler::SetCurrentPositionFromEnd(intptr_t by) { 1687 void IRRegExpMacroAssembler::SetCurrentPositionFromEnd(intptr_t by) {
1614 TAG(); 1688 TAG();
1615 1689
1616 BlockLabel after_position; 1690 BlockLabel after_position;
1617 1691
1618 Definition* cur_pos_def = LoadLocal(current_position_); 1692 Definition* cur_pos_def = LoadLocal(current_position_);
1619 Definition* by_value_def = Int64Constant(-by); 1693 Definition* by_value_def = Int64Constant(-by);
1620 1694
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
1682 StoreRegister(registers_push, index_push, value_push); 1756 StoreRegister(registers_push, index_push, value_push);
1683 } 1757 }
1684 } 1758 }
1685 1759
1686 1760
1687 void IRRegExpMacroAssembler::WriteStackPointerToRegister(intptr_t reg) { 1761 void IRRegExpMacroAssembler::WriteStackPointerToRegister(intptr_t reg) {
1688 TAG(); 1762 TAG();
1689 1763
1690 PushArgumentInstr* registers_push = PushLocal(registers_); 1764 PushArgumentInstr* registers_push = PushLocal(registers_);
1691 PushArgumentInstr* index_push = PushRegisterIndex(reg); 1765 PushArgumentInstr* index_push = PushRegisterIndex(reg);
1692 PushArgumentInstr* stack_push = PushLocal(stack_); 1766 PushArgumentInstr* tip_push = PushLocal(stack_tip_);
1693 PushArgumentInstr* length_push = 1767 StoreRegister(registers_push, index_push, tip_push);
1694 PushArgument(Bind(InstanceCall(InstanceCallDescriptor(
1695 String::ZoneHandle(I, Field::GetterSymbol(Symbols::Length()))),
1696 stack_push)));
1697 StoreRegister(registers_push, index_push, length_push);
1698 } 1768 }
1699 1769
1700 1770
1701 // Private methods: 1771 // Private methods:
1702 1772
1703 1773
1704 void IRRegExpMacroAssembler::CheckPosition(intptr_t cp_offset, 1774 void IRRegExpMacroAssembler::CheckPosition(intptr_t cp_offset,
1705 BlockLabel* on_outside_input) { 1775 BlockLabel* on_outside_input) {
1706 TAG(); 1776 TAG();
1707 Definition* curpos_def = LoadLocal(current_position_); 1777 Definition* curpos_def = LoadLocal(current_position_);
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
1865 index_val, 1935 index_val,
1866 characters, 1936 characters,
1867 specialization_cid_, 1937 specialization_cid_,
1868 Scanner::kNoSourcePos)); 1938 Scanner::kNoSourcePos));
1869 } 1939 }
1870 1940
1871 1941
1872 #undef __ 1942 #undef __
1873 1943
1874 } // namespace dart 1944 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698