Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 1264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1275 data_.u_submatch_stack_pointer_register.reg); | 1275 data_.u_submatch_stack_pointer_register.reg); |
| 1276 break; | 1276 break; |
| 1277 default: | 1277 default: |
| 1278 UNREACHABLE(); | 1278 UNREACHABLE(); |
| 1279 return false; | 1279 return false; |
| 1280 } | 1280 } |
| 1281 return on_success()->GoTo(compiler); | 1281 return on_success()->GoTo(compiler); |
| 1282 } | 1282 } |
| 1283 | 1283 |
| 1284 | 1284 |
| 1285 bool BackReferenceNode::Emit(RegExpCompiler* compiler) { | |
| 1286 RegExpMacroAssembler* macro = compiler->macro_assembler(); | |
| 1287 Bind(macro); | |
| 1288 // Check whether the registers are uninitialized and always | |
| 1289 // succeed if they are. | |
| 1290 macro->IfRegisterLT(start_reg_, 0, on_success()->label()); | |
| 1291 macro->IfRegisterLT(end_reg_, 0, on_success()->label()); | |
| 1292 ASSERT(start_reg_ + 1 == end_reg_); | |
|
Christian Plesner Hansen
2008/11/21 11:16:39
ASSERT_EQ
| |
| 1293 macro->CheckNotBackReference(start_reg_, on_failure_->label()); | |
| 1294 return on_success()->GoTo(compiler); | |
| 1295 } | |
| 1296 | |
| 1297 | |
| 1285 // ------------------------------------------------------------------- | 1298 // ------------------------------------------------------------------- |
| 1286 // Dot/dotty output | 1299 // Dot/dotty output |
| 1287 | 1300 |
| 1288 | 1301 |
| 1289 #ifdef DEBUG | 1302 #ifdef DEBUG |
| 1290 | 1303 |
| 1291 | 1304 |
| 1292 class DotPrinter: public NodeVisitor { | 1305 class DotPrinter: public NodeVisitor { |
| 1293 public: | 1306 public: |
| 1294 DotPrinter() : stream_(&alloc_) { } | 1307 DotPrinter() : stream_(&alloc_) { } |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1438 UNREACHABLE(); | 1451 UNREACHABLE(); |
| 1439 } | 1452 } |
| 1440 } | 1453 } |
| 1441 stream()->Add("\", shape=box, peripheries=2];\n"); | 1454 stream()->Add("\", shape=box, peripheries=2];\n"); |
| 1442 stream()->Add(" n%p -> n%p;\n", that, that->on_success()); | 1455 stream()->Add(" n%p -> n%p;\n", that, that->on_success()); |
| 1443 Visit(that->on_success()); | 1456 Visit(that->on_success()); |
| 1444 PrintOnFailure(that, that->on_failure()); | 1457 PrintOnFailure(that, that->on_failure()); |
| 1445 } | 1458 } |
| 1446 | 1459 |
| 1447 | 1460 |
| 1448 void DotPrinter::VisitBackreference(BackreferenceNode* that) { | 1461 void DotPrinter::VisitBackReference(BackReferenceNode* that) { |
| 1449 stream()->Add(" n%p [label=\"$%i..$%i\", shape=doubleoctagon];\n", | 1462 stream()->Add(" n%p [label=\"$%i..$%i\", shape=doubleoctagon];\n", |
| 1450 that, | 1463 that, |
| 1451 that->start_register(), | 1464 that->start_register(), |
| 1452 that->end_register()); | 1465 that->end_register()); |
| 1453 stream()->Add(" n%p -> n%p;\n", that, that->on_success()); | 1466 stream()->Add(" n%p -> n%p;\n", that, that->on_success()); |
| 1454 Visit(that->on_success()); | 1467 Visit(that->on_success()); |
| 1455 PrintOnFailure(that, that->on_failure()); | 1468 PrintOnFailure(that, that->on_failure()); |
| 1456 } | 1469 } |
| 1457 | 1470 |
| 1458 | 1471 |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1671 info.follows_word_interest = true; | 1684 info.follows_word_interest = true; |
| 1672 break; | 1685 break; |
| 1673 case END_OF_LINE: case END_OF_INPUT: | 1686 case END_OF_LINE: case END_OF_INPUT: |
| 1674 // This is wrong but has the effect of making the compiler abort. | 1687 // This is wrong but has the effect of making the compiler abort. |
| 1675 info.follows_start_interest = true; | 1688 info.follows_start_interest = true; |
| 1676 } | 1689 } |
| 1677 return on_success->PropagateInterest(&info); | 1690 return on_success->PropagateInterest(&info); |
| 1678 } | 1691 } |
| 1679 | 1692 |
| 1680 | 1693 |
| 1681 RegExpNode* RegExpBackreference::ToNode(RegExpCompiler* compiler, | 1694 RegExpNode* RegExpBackReference::ToNode(RegExpCompiler* compiler, |
| 1682 RegExpNode* on_success, | 1695 RegExpNode* on_success, |
| 1683 RegExpNode* on_failure) { | 1696 RegExpNode* on_failure) { |
| 1684 return new BackreferenceNode(RegExpCapture::StartRegister(index()), | 1697 return new BackReferenceNode(RegExpCapture::StartRegister(index()), |
| 1685 RegExpCapture::EndRegister(index()), | 1698 RegExpCapture::EndRegister(index()), |
| 1686 on_success, | 1699 on_success, |
| 1687 on_failure); | 1700 on_failure); |
| 1688 } | 1701 } |
| 1689 | 1702 |
| 1690 | 1703 |
| 1691 RegExpNode* RegExpEmpty::ToNode(RegExpCompiler* compiler, | 1704 RegExpNode* RegExpEmpty::ToNode(RegExpCompiler* compiler, |
| 1692 RegExpNode* on_success, | 1705 RegExpNode* on_success, |
| 1693 RegExpNode* on_failure) { | 1706 RegExpNode* on_failure) { |
| 1694 return on_success; | 1707 return on_success; |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1929 } | 1942 } |
| 1930 return choice; | 1943 return choice; |
| 1931 } | 1944 } |
| 1932 | 1945 |
| 1933 | 1946 |
| 1934 RegExpNode* EndNode::PropagateInterest(NodeInfo* info) { | 1947 RegExpNode* EndNode::PropagateInterest(NodeInfo* info) { |
| 1935 return PropagateToEndpoint(this, info); | 1948 return PropagateToEndpoint(this, info); |
| 1936 } | 1949 } |
| 1937 | 1950 |
| 1938 | 1951 |
| 1939 RegExpNode* BackreferenceNode::PropagateInterest(NodeInfo* info) { | 1952 RegExpNode* BackReferenceNode::PropagateInterest(NodeInfo* info) { |
| 1940 return PropagateToEndpoint(this, info); | 1953 return PropagateToEndpoint(this, info); |
| 1941 } | 1954 } |
| 1942 | 1955 |
| 1943 | 1956 |
| 1944 RegExpNode* TextNode::PropagateInterest(NodeInfo* info) { | 1957 RegExpNode* TextNode::PropagateInterest(NodeInfo* info) { |
| 1945 return PropagateToEndpoint(this, info); | 1958 return PropagateToEndpoint(this, info); |
| 1946 } | 1959 } |
| 1947 | 1960 |
| 1948 | 1961 |
| 1949 // ------------------------------------------------------------------- | 1962 // ------------------------------------------------------------------- |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2139 info->determine_start |= node->info()->prev_determine_start(); | 2152 info->determine_start |= node->info()->prev_determine_start(); |
| 2140 } | 2153 } |
| 2141 if (!that->table_calculated()) { | 2154 if (!that->table_calculated()) { |
| 2142 DispatchTableConstructor cons(that->table()); | 2155 DispatchTableConstructor cons(that->table()); |
| 2143 cons.BuildTable(that); | 2156 cons.BuildTable(that); |
| 2144 } | 2157 } |
| 2145 EnsureAnalyzed(that->on_failure()); | 2158 EnsureAnalyzed(that->on_failure()); |
| 2146 } | 2159 } |
| 2147 | 2160 |
| 2148 | 2161 |
| 2149 void Analysis::VisitBackreference(BackreferenceNode* that) { | 2162 void Analysis::VisitBackReference(BackReferenceNode* that) { |
| 2150 EnsureAnalyzed(that->on_success()); | 2163 EnsureAnalyzed(that->on_success()); |
| 2151 EnsureAnalyzed(that->on_failure()); | 2164 EnsureAnalyzed(that->on_failure()); |
| 2152 } | 2165 } |
| 2153 | 2166 |
| 2154 | 2167 |
| 2155 // ------------------------------------------------------------------- | 2168 // ------------------------------------------------------------------- |
| 2156 // Dispatch table construction | 2169 // Dispatch table construction |
| 2157 | 2170 |
| 2158 | 2171 |
| 2159 void DispatchTableConstructor::VisitEnd(EndNode* that) { | 2172 void DispatchTableConstructor::VisitEnd(EndNode* that) { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2196 if (!node->table_calculated()) { | 2209 if (!node->table_calculated()) { |
| 2197 DispatchTableConstructor constructor(node->table()); | 2210 DispatchTableConstructor constructor(node->table()); |
| 2198 constructor.BuildTable(node); | 2211 constructor.BuildTable(node); |
| 2199 } | 2212 } |
| 2200 ASSERT(node->table_calculated()); | 2213 ASSERT(node->table_calculated()); |
| 2201 AddDispatchRange adder(this); | 2214 AddDispatchRange adder(this); |
| 2202 node->table()->ForEach(&adder); | 2215 node->table()->ForEach(&adder); |
| 2203 } | 2216 } |
| 2204 | 2217 |
| 2205 | 2218 |
| 2206 void DispatchTableConstructor::VisitBackreference(BackreferenceNode* that) { | 2219 void DispatchTableConstructor::VisitBackReference(BackReferenceNode* that) { |
| 2207 // TODO(plesner): What should this do? | 2220 // TODO(plesner): Find the node that we refer back to and propagate its start |
| 2221 // set back to here. For now we just accept anything. | |
| 2222 AddRange(CharacterRange::Everything()); | |
| 2223 RegExpNode* next = that->on_success(); | |
| 2224 that->info()->determine_newline = next->info()->prev_determine_newline(); | |
|
Christian Plesner Hansen
2008/11/21 11:16:39
Propagating this stuff is not the dispatch table c
| |
| 2225 that->info()->determine_word = next->info()->prev_determine_word(); | |
| 2226 that->info()->determine_start = next->info()->prev_determine_start(); | |
| 2208 } | 2227 } |
| 2209 | 2228 |
| 2210 | 2229 |
| 2211 | 2230 |
| 2212 static int CompareRangeByFrom(const CharacterRange* a, | 2231 static int CompareRangeByFrom(const CharacterRange* a, |
| 2213 const CharacterRange* b) { | 2232 const CharacterRange* b) { |
| 2214 return Spaceship<uc16>(a->from(), b->from()); | 2233 return Spaceship<uc16>(a->from(), b->from()); |
| 2215 } | 2234 } |
| 2216 | 2235 |
| 2217 | 2236 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2300 } | 2319 } |
| 2301 | 2320 |
| 2302 RegExpMacroAssembler::RegExpMacroAssembler() { | 2321 RegExpMacroAssembler::RegExpMacroAssembler() { |
| 2303 } | 2322 } |
| 2304 | 2323 |
| 2305 RegExpMacroAssembler::~RegExpMacroAssembler() { | 2324 RegExpMacroAssembler::~RegExpMacroAssembler() { |
| 2306 } | 2325 } |
| 2307 | 2326 |
| 2308 | 2327 |
| 2309 }} // namespace v8::internal | 2328 }} // namespace v8::internal |
| OLD | NEW |