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

Side by Side Diff: src/compiler/js-typed-lowering.cc

Issue 2763533002: [WIP] JSForInLowering and JSForInHasOwnProperty.
Patch Set: Hack around the issue with indices not being available always. Created 3 years, 9 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-typed-lowering.h ('k') | src/compiler/opcodes.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-typed-lowering.h" 5 #include "src/compiler/js-typed-lowering.h"
6 6
7 #include "src/ast/modules.h" 7 #include "src/ast/modules.h"
8 #include "src/builtins/builtins-utils.h" 8 #include "src/builtins/builtins-utils.h"
9 #include "src/code-factory.h" 9 #include "src/code-factory.h"
10 #include "src/compilation-dependencies.h" 10 #include "src/compilation-dependencies.h"
(...skipping 2121 matching lines...) Expand 10 before | Expand all | Expand 10 after
2132 NodeProperties::ChangeOp( 2132 NodeProperties::ChangeOp(
2133 node, 2133 node,
2134 javascript()->Call(p.arity(), p.frequency(), p.feedback(), convert_mode, 2134 javascript()->Call(p.arity(), p.frequency(), p.feedback(), convert_mode,
2135 p.tail_call_mode())); 2135 p.tail_call_mode()));
2136 return Changed(node); 2136 return Changed(node);
2137 } 2137 }
2138 2138
2139 return NoChange(); 2139 return NoChange();
2140 } 2140 }
2141 2141
2142
2143 Reduction JSTypedLowering::ReduceJSForInNext(Node* node) {
2144 DCHECK_EQ(IrOpcode::kJSForInNext, node->opcode());
2145 Node* receiver = NodeProperties::GetValueInput(node, 0);
2146 Node* cache_array = NodeProperties::GetValueInput(node, 1);
2147 Node* cache_type = NodeProperties::GetValueInput(node, 2);
2148 Node* index = NodeProperties::GetValueInput(node, 3);
2149 Node* context = NodeProperties::GetContextInput(node);
2150 Node* frame_state = NodeProperties::GetFrameStateInput(node);
2151 Node* effect = NodeProperties::GetEffectInput(node);
2152 Node* control = NodeProperties::GetControlInput(node);
2153
2154 // We know that the {index} is in Unsigned32 range here, otherwise executing
2155 // the JSForInNext wouldn't be valid. Unfortunately due to OSR and generators
2156 // this is not always reflected in the types, hence we might need to rename
2157 // the {index} here.
2158 if (!NodeProperties::GetType(index)->Is(Type::Unsigned32())) {
2159 index = graph()->NewNode(common()->TypeGuard(Type::Unsigned32()), index,
2160 control);
2161 }
2162
2163 // Load the next {key} from the {cache_array}.
2164 Node* key = effect = graph()->NewNode(
2165 simplified()->LoadElement(AccessBuilder::ForFixedArrayElement()),
2166 cache_array, index, effect, control);
2167
2168 // Load the map of the {receiver}.
2169 Node* receiver_map = effect =
2170 graph()->NewNode(simplified()->LoadField(AccessBuilder::ForMap()),
2171 receiver, effect, control);
2172
2173 // Check if the expected map still matches that of the {receiver}.
2174 Node* check0 = graph()->NewNode(simplified()->ReferenceEqual(), receiver_map,
2175 cache_type);
2176 Node* branch0 =
2177 graph()->NewNode(common()->Branch(BranchHint::kTrue), check0, control);
2178
2179 Node* if_true0 = graph()->NewNode(common()->IfTrue(), branch0);
2180 Node* etrue0;
2181 Node* vtrue0;
2182 {
2183 // Don't need filtering since expected map still matches that of the
2184 // {receiver}.
2185 etrue0 = effect;
2186 vtrue0 = key;
2187 }
2188
2189 Node* if_false0 = graph()->NewNode(common()->IfFalse(), branch0);
2190 Node* efalse0;
2191 Node* vfalse0;
2192 {
2193 // Filter the {key} to check if it's still a valid property of the
2194 // {receiver} (does the ToName conversion implicitly).
2195 Callable const callable = CodeFactory::ForInFilter(isolate());
2196 CallDescriptor const* const desc = Linkage::GetStubCallDescriptor(
2197 isolate(), graph()->zone(), callable.descriptor(), 0,
2198 CallDescriptor::kNeedsFrameState);
2199 vfalse0 = efalse0 = if_false0 = graph()->NewNode(
2200 common()->Call(desc), jsgraph()->HeapConstant(callable.code()), key,
2201 receiver, context, frame_state, effect, if_false0);
2202
2203 // Update potential {IfException} uses of {node} to point to the ahove
2204 // ForInFilter stub call node instead.
2205 Node* if_exception = nullptr;
2206 if (NodeProperties::IsExceptionalCall(node, &if_exception)) {
2207 if_false0 = graph()->NewNode(common()->IfSuccess(), vfalse0);
2208 NodeProperties::ReplaceControlInput(if_exception, vfalse0);
2209 NodeProperties::ReplaceEffectInput(if_exception, efalse0);
2210 Revisit(if_exception);
2211 }
2212 }
2213
2214 control = graph()->NewNode(common()->Merge(2), if_true0, if_false0);
2215 effect = graph()->NewNode(common()->EffectPhi(2), etrue0, efalse0, control);
2216 ReplaceWithValue(node, node, effect, control);
2217
2218 // Morph the {node} into a Phi.
2219 node->ReplaceInput(0, vtrue0);
2220 node->ReplaceInput(1, vfalse0);
2221 node->ReplaceInput(2, control);
2222 node->TrimInputCount(3);
2223 NodeProperties::ChangeOp(node,
2224 common()->Phi(MachineRepresentation::kTagged, 2));
2225 return Changed(node);
2226 }
2227
2228 Reduction JSTypedLowering::ReduceJSLoadMessage(Node* node) { 2142 Reduction JSTypedLowering::ReduceJSLoadMessage(Node* node) {
2229 DCHECK_EQ(IrOpcode::kJSLoadMessage, node->opcode()); 2143 DCHECK_EQ(IrOpcode::kJSLoadMessage, node->opcode());
2230 ExternalReference const ref = 2144 ExternalReference const ref =
2231 ExternalReference::address_of_pending_message_obj(isolate()); 2145 ExternalReference::address_of_pending_message_obj(isolate());
2232 node->ReplaceInput(0, jsgraph()->ExternalConstant(ref)); 2146 node->ReplaceInput(0, jsgraph()->ExternalConstant(ref));
2233 NodeProperties::ChangeOp( 2147 NodeProperties::ChangeOp(
2234 node, simplified()->LoadField(AccessBuilder::ForExternalTaggedValue())); 2148 node, simplified()->LoadField(AccessBuilder::ForExternalTaggedValue()));
2235 return Changed(node); 2149 return Changed(node);
2236 } 2150 }
2237 2151
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
2386 case IrOpcode::kJSStoreModule: 2300 case IrOpcode::kJSStoreModule:
2387 return ReduceJSStoreModule(node); 2301 return ReduceJSStoreModule(node);
2388 case IrOpcode::kJSConvertReceiver: 2302 case IrOpcode::kJSConvertReceiver:
2389 return ReduceJSConvertReceiver(node); 2303 return ReduceJSConvertReceiver(node);
2390 case IrOpcode::kJSConstruct: 2304 case IrOpcode::kJSConstruct:
2391 return ReduceJSConstruct(node); 2305 return ReduceJSConstruct(node);
2392 case IrOpcode::kJSCallForwardVarargs: 2306 case IrOpcode::kJSCallForwardVarargs:
2393 return ReduceJSCallForwardVarargs(node); 2307 return ReduceJSCallForwardVarargs(node);
2394 case IrOpcode::kJSCall: 2308 case IrOpcode::kJSCall:
2395 return ReduceJSCall(node); 2309 return ReduceJSCall(node);
2396 case IrOpcode::kJSForInNext:
2397 return ReduceJSForInNext(node);
2398 case IrOpcode::kJSLoadMessage: 2310 case IrOpcode::kJSLoadMessage:
2399 return ReduceJSLoadMessage(node); 2311 return ReduceJSLoadMessage(node);
2400 case IrOpcode::kJSStoreMessage: 2312 case IrOpcode::kJSStoreMessage:
2401 return ReduceJSStoreMessage(node); 2313 return ReduceJSStoreMessage(node);
2402 case IrOpcode::kJSGeneratorStore: 2314 case IrOpcode::kJSGeneratorStore:
2403 return ReduceJSGeneratorStore(node); 2315 return ReduceJSGeneratorStore(node);
2404 case IrOpcode::kJSGeneratorRestoreContinuation: 2316 case IrOpcode::kJSGeneratorRestoreContinuation:
2405 return ReduceJSGeneratorRestoreContinuation(node); 2317 return ReduceJSGeneratorRestoreContinuation(node);
2406 case IrOpcode::kJSGeneratorRestoreRegister: 2318 case IrOpcode::kJSGeneratorRestoreRegister:
2407 return ReduceJSGeneratorRestoreRegister(node); 2319 return ReduceJSGeneratorRestoreRegister(node);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
2448 } 2360 }
2449 2361
2450 2362
2451 CompilationDependencies* JSTypedLowering::dependencies() const { 2363 CompilationDependencies* JSTypedLowering::dependencies() const {
2452 return dependencies_; 2364 return dependencies_;
2453 } 2365 }
2454 2366
2455 } // namespace compiler 2367 } // namespace compiler
2456 } // namespace internal 2368 } // namespace internal
2457 } // namespace v8 2369 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/js-typed-lowering.h ('k') | src/compiler/opcodes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698