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

Side by Side Diff: src/compiler/js-builtin-reducer.cc

Issue 2638393002: [builtins] Add String.prototype.indexOf fast path in TF (Closed)
Patch Set: hardcode paramater massaging Created 3 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
« no previous file with comments | « src/compiler/js-builtin-reducer.h ('k') | src/interface-descriptors.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/compiler/js-builtin-reducer.h" 5 #include "src/compiler/js-builtin-reducer.h"
6 6
7 #include "src/base/bits.h" 7 #include "src/base/bits.h"
8 #include "src/code-factory.h"
8 #include "src/compilation-dependencies.h" 9 #include "src/compilation-dependencies.h"
9 #include "src/compiler/access-builder.h" 10 #include "src/compiler/access-builder.h"
10 #include "src/compiler/js-graph.h" 11 #include "src/compiler/js-graph.h"
12 #include "src/compiler/linkage.h"
11 #include "src/compiler/node-matchers.h" 13 #include "src/compiler/node-matchers.h"
12 #include "src/compiler/node-properties.h" 14 #include "src/compiler/node-properties.h"
13 #include "src/compiler/simplified-operator.h" 15 #include "src/compiler/simplified-operator.h"
14 #include "src/compiler/type-cache.h" 16 #include "src/compiler/type-cache.h"
15 #include "src/compiler/types.h" 17 #include "src/compiler/types.h"
16 #include "src/objects-inl.h" 18 #include "src/objects-inl.h"
17 19
18 namespace v8 { 20 namespace v8 {
19 namespace internal { 21 namespace internal {
20 namespace compiler { 22 namespace compiler {
(...skipping 1702 matching lines...) Expand 10 before | Expand all | Expand 10 after
1723 1725
1724 ReplaceWithValue(node, value, effect, control); 1726 ReplaceWithValue(node, value, effect, control);
1725 return Replace(value); 1727 return Replace(value);
1726 } 1728 }
1727 } 1729 }
1728 } 1730 }
1729 1731
1730 return NoChange(); 1732 return NoChange();
1731 } 1733 }
1732 1734
1735 // ES6 String.prototype.indexOf(searchString [, position])
1736 // #sec-string.prototype.indexof
1737 Reduction JSBuiltinReducer::ReduceStringIndexOf(Node* node) {
1738 int arg_count = node->op()->ValueInputCount();
1739 if (arg_count != 3 && arg_count != 4) return NoChange();
1740 Node* receiver;
1741 if (!(receiver = GetStringWitness(node))) return NoChange();
1742 Node* search_string = NodeProperties::GetValueInput(node, 2);
1743 if (!NodeProperties::GetType(search_string)->Is(Type::String())) {
1744 return NoChange();
1745 }
1746 // Replace the current JSFunctionCall to String.prototype.indexOf with a
1747 // simple Call to the unchecked StringIndexOf builtin.
1748 Callable callable = CodeFactory::StringIndexOf(isolate());
1749 const CallInterfaceDescriptor& descriptor = callable.descriptor();
1750 CallDescriptor* desc =
1751 Linkage::GetStubCallDescriptor(isolate(), graph()->zone(), descriptor,
1752 descriptor.GetStackParameterCount(),
1753 CallDescriptor::kNoFlags, Operator::kPure);
1754 Node* stub_code = jsgraph()->HeapConstant(callable.code());
1755 // The Call Operator doesn't require an effect nor a control input.
1756 RelaxEffectsAndControls(node);
1757 // Remove framestate since StringIndexOf cannot deopt.
1758 node->RemoveInput(arg_count + 1);
1759 // Remove the control input.
1760 node->RemoveInput(arg_count + 2);
1761 // Replace the JSFunction from the JSFunctionCall node with the CodeStub.
1762 node->ReplaceInput(0, stub_code);
1763 if (arg_count == 3) {
1764 // Insert the missing position argument.
1765 node->InsertInput(graph()->zone(), 3, jsgraph()->ZeroConstant());
1766 }
1767 const Operator* op = common()->Call(desc);
1768 node->TrimInputCount(op->ValueInputCount());
1769 NodeProperties::ChangeOp(node, op);
1770 return Changed(node);
1771 }
1772
1733 Reduction JSBuiltinReducer::ReduceStringIterator(Node* node) { 1773 Reduction JSBuiltinReducer::ReduceStringIterator(Node* node) {
1734 if (Node* receiver = GetStringWitness(node)) { 1774 if (Node* receiver = GetStringWitness(node)) {
1735 Node* effect = NodeProperties::GetEffectInput(node); 1775 Node* effect = NodeProperties::GetEffectInput(node);
1736 Node* control = NodeProperties::GetControlInput(node); 1776 Node* control = NodeProperties::GetControlInput(node);
1737 1777
1738 Node* map = jsgraph()->HeapConstant( 1778 Node* map = jsgraph()->HeapConstant(
1739 handle(native_context()->string_iterator_map(), isolate())); 1779 handle(native_context()->string_iterator_map(), isolate()));
1740 1780
1741 // allocate new iterator 1781 // allocate new iterator
1742 effect = graph()->NewNode( 1782 effect = graph()->NewNode(
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
2094 case kObjectCreate: 2134 case kObjectCreate:
2095 reduction = ReduceObjectCreate(node); 2135 reduction = ReduceObjectCreate(node);
2096 break; 2136 break;
2097 case kStringFromCharCode: 2137 case kStringFromCharCode:
2098 reduction = ReduceStringFromCharCode(node); 2138 reduction = ReduceStringFromCharCode(node);
2099 break; 2139 break;
2100 case kStringCharAt: 2140 case kStringCharAt:
2101 return ReduceStringCharAt(node); 2141 return ReduceStringCharAt(node);
2102 case kStringCharCodeAt: 2142 case kStringCharCodeAt:
2103 return ReduceStringCharCodeAt(node); 2143 return ReduceStringCharCodeAt(node);
2144 case kStringIndexOf:
2145 return ReduceStringIndexOf(node);
2104 case kStringIterator: 2146 case kStringIterator:
2105 return ReduceStringIterator(node); 2147 return ReduceStringIterator(node);
2106 case kStringIteratorNext: 2148 case kStringIteratorNext:
2107 return ReduceStringIteratorNext(node); 2149 return ReduceStringIteratorNext(node);
2108 case kDataViewByteLength: 2150 case kDataViewByteLength:
2109 return ReduceArrayBufferViewAccessor( 2151 return ReduceArrayBufferViewAccessor(
2110 node, JS_DATA_VIEW_TYPE, 2152 node, JS_DATA_VIEW_TYPE,
2111 AccessBuilder::ForJSArrayBufferViewByteLength()); 2153 AccessBuilder::ForJSArrayBufferViewByteLength());
2112 case kDataViewByteOffset: 2154 case kDataViewByteOffset:
2113 return ReduceArrayBufferViewAccessor( 2155 return ReduceArrayBufferViewAccessor(
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
2170 return jsgraph()->simplified(); 2212 return jsgraph()->simplified();
2171 } 2213 }
2172 2214
2173 JSOperatorBuilder* JSBuiltinReducer::javascript() const { 2215 JSOperatorBuilder* JSBuiltinReducer::javascript() const {
2174 return jsgraph()->javascript(); 2216 return jsgraph()->javascript();
2175 } 2217 }
2176 2218
2177 } // namespace compiler 2219 } // namespace compiler
2178 } // namespace internal 2220 } // namespace internal
2179 } // namespace v8 2221 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/js-builtin-reducer.h ('k') | src/interface-descriptors.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698