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

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

Issue 2535753004: [turbofan] Add appropriate types to express Callable. (Closed)
Patch Set: Add spec comments. Created 4 years 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/api-natives.cc ('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 1313 matching lines...) Expand 10 before | Expand all | Expand 10 after
1324 } 1324 }
1325 } 1325 }
1326 return NoChange(); 1326 return NoChange();
1327 } 1327 }
1328 1328
1329 Reduction JSTypedLowering::ReduceJSOrdinaryHasInstance(Node* node) { 1329 Reduction JSTypedLowering::ReduceJSOrdinaryHasInstance(Node* node) {
1330 DCHECK_EQ(IrOpcode::kJSOrdinaryHasInstance, node->opcode()); 1330 DCHECK_EQ(IrOpcode::kJSOrdinaryHasInstance, node->opcode());
1331 Node* constructor = NodeProperties::GetValueInput(node, 0); 1331 Node* constructor = NodeProperties::GetValueInput(node, 0);
1332 Type* constructor_type = NodeProperties::GetType(constructor); 1332 Type* constructor_type = NodeProperties::GetType(constructor);
1333 Node* object = NodeProperties::GetValueInput(node, 1); 1333 Node* object = NodeProperties::GetValueInput(node, 1);
1334 Type* object_type = NodeProperties::GetType(object);
1334 Node* context = NodeProperties::GetContextInput(node); 1335 Node* context = NodeProperties::GetContextInput(node);
1335 Node* frame_state = NodeProperties::GetFrameStateInput(node); 1336 Node* frame_state = NodeProperties::GetFrameStateInput(node);
1336 Node* effect = NodeProperties::GetEffectInput(node); 1337 Node* effect = NodeProperties::GetEffectInput(node);
1337 Node* control = NodeProperties::GetControlInput(node); 1338 Node* control = NodeProperties::GetControlInput(node);
1338 1339
1340 // Check if the {constructor} cannot be callable.
1341 // See ES6 section 7.3.19 OrdinaryHasInstance ( C, O ) step 1.
1342 if (!constructor_type->Maybe(Type::Callable())) {
1343 Node* value = jsgraph()->FalseConstant();
1344 ReplaceWithValue(node, value, effect, control);
1345 return Replace(value);
1346 }
1347
1348 // If the {constructor} cannot be a JSBoundFunction and then {object}
1349 // cannot be a JSReceiver, then this can be constant-folded to false.
1350 // See ES6 section 7.3.19 OrdinaryHasInstance ( C, O ) step 2 and 3.
1351 if (!object_type->Maybe(Type::Receiver()) &&
1352 !constructor_type->Maybe(Type::BoundFunction())) {
1353 Node* value = jsgraph()->FalseConstant();
1354 ReplaceWithValue(node, value, effect, control);
1355 return Replace(value);
1356 }
1357
1339 // Check if the {constructor} is a (known) JSFunction. 1358 // Check if the {constructor} is a (known) JSFunction.
1340 if (!constructor_type->IsHeapConstant() || 1359 if (!constructor_type->IsHeapConstant() ||
1341 !constructor_type->AsHeapConstant()->Value()->IsJSFunction()) { 1360 !constructor_type->AsHeapConstant()->Value()->IsJSFunction()) {
1342 return NoChange(); 1361 return NoChange();
1343 } 1362 }
1344 Handle<JSFunction> function = 1363 Handle<JSFunction> function =
1345 Handle<JSFunction>::cast(constructor_type->AsHeapConstant()->Value()); 1364 Handle<JSFunction>::cast(constructor_type->AsHeapConstant()->Value());
1346 1365
1347 // Check if the {function} already has an initial map (i.e. the 1366 // Check if the {function} already has an initial map (i.e. the
1348 // {function} has been used as a constructor at least once). 1367 // {function} has been used as a constructor at least once).
(...skipping 937 matching lines...) Expand 10 before | Expand all | Expand 10 after
2286 } 2305 }
2287 2306
2288 2307
2289 CompilationDependencies* JSTypedLowering::dependencies() const { 2308 CompilationDependencies* JSTypedLowering::dependencies() const {
2290 return dependencies_; 2309 return dependencies_;
2291 } 2310 }
2292 2311
2293 } // namespace compiler 2312 } // namespace compiler
2294 } // namespace internal 2313 } // namespace internal
2295 } // namespace v8 2314 } // namespace v8
OLDNEW
« no previous file with comments | « src/api-natives.cc ('k') | src/compiler/opcodes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698