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

Side by Side Diff: src/compiler/typer.cc

Issue 1965293002: [turbofan] Unify function prototype constant folding. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 7 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
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/typer.h" 5 #include "src/compiler/typer.h"
6 6
7 #include "src/base/flags.h" 7 #include "src/base/flags.h"
8 #include "src/bootstrapper.h" 8 #include "src/bootstrapper.h"
9 #include "src/compilation-dependencies.h" 9 #include "src/compilation-dependencies.h"
10 #include "src/compiler/common-operator.h" 10 #include "src/compiler/common-operator.h"
(...skipping 1329 matching lines...) Expand 10 before | Expand all | Expand 10 after
1340 return Type::Any(); 1340 return Type::Any();
1341 } 1341 }
1342 1342
1343 1343
1344 Type* Typer::Visitor::TypeJSLoadProperty(Node* node) { 1344 Type* Typer::Visitor::TypeJSLoadProperty(Node* node) {
1345 return TypeBinaryOp(node, JSLoadPropertyTyper); 1345 return TypeBinaryOp(node, JSLoadPropertyTyper);
1346 } 1346 }
1347 1347
1348 1348
1349 Type* Typer::Visitor::TypeJSLoadNamed(Node* node) { 1349 Type* Typer::Visitor::TypeJSLoadNamed(Node* node) {
1350 Factory* const f = isolate()->factory();
1351 Handle<Name> name = NamedAccessOf(node->op()).name();
1352 if (name.is_identical_to(f->prototype_string())) {
1353 Type* receiver = Operand(node, 0);
1354 if (receiver->Is(Type::None())) return Type::None();
1355 if (receiver->IsConstant() &&
1356 receiver->AsConstant()->Value()->IsJSFunction()) {
1357 Handle<JSFunction> function =
1358 Handle<JSFunction>::cast(receiver->AsConstant()->Value());
1359 if (function->has_prototype()) {
1360 // We need to add a code dependency on the initial map of the {function}
1361 // in order to be notified about changes to "prototype" of {function},
1362 // so we can only infer a constant type if deoptimization is enabled.
1363 if (flags() & kDeoptimizationEnabled) {
1364 JSFunction::EnsureHasInitialMap(function);
1365 Handle<Map> initial_map(function->initial_map(), isolate());
1366 dependencies()->AssumeInitialMapCantChange(initial_map);
1367 return Type::Constant(handle(initial_map->prototype(), isolate()),
1368 zone());
1369 }
1370 }
1371 } else if (receiver->IsClass() &&
1372 receiver->AsClass()->Map()->IsJSFunctionMap()) {
1373 Handle<Map> map = receiver->AsClass()->Map();
1374 return map->has_non_instance_prototype() ? Type::Primitive()
1375 : Type::Receiver();
1376 }
1377 }
1378 return Type::Any(); 1350 return Type::Any();
1379 } 1351 }
1380 1352
1381 1353
1382 Type* Typer::Visitor::TypeJSLoadGlobal(Node* node) { return Type::Any(); } 1354 Type* Typer::Visitor::TypeJSLoadGlobal(Node* node) { return Type::Any(); }
1383 1355
1384 1356
1385 // Returns a somewhat larger range if we previously assigned 1357 // Returns a somewhat larger range if we previously assigned
1386 // a (smaller) range to this node. This is used to speed up 1358 // a (smaller) range to this node. This is used to speed up
1387 // the fixpoint calculation in case there appears to be a loop 1359 // the fixpoint calculation in case there appears to be a loop
(...skipping 1205 matching lines...) Expand 10 before | Expand all | Expand 10 after
2593 } 2565 }
2594 if (Type::IsInteger(*value)) { 2566 if (Type::IsInteger(*value)) {
2595 return Type::Range(value->Number(), value->Number(), zone()); 2567 return Type::Range(value->Number(), value->Number(), zone());
2596 } 2568 }
2597 return Type::Constant(value, zone()); 2569 return Type::Constant(value, zone());
2598 } 2570 }
2599 2571
2600 } // namespace compiler 2572 } // namespace compiler
2601 } // namespace internal 2573 } // namespace internal
2602 } // namespace v8 2574 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/js-typed-lowering.cc ('k') | test/unittests/compiler/js-typed-lowering-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698