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

Unified Diff: src/compiler/typer.cc

Issue 1077343002: [turbofan] Optimize loads of global constants in JSTypedLowering. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/compiler/js-typed-lowering.cc ('k') | src/factory.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/typer.cc
diff --git a/src/compiler/typer.cc b/src/compiler/typer.cc
index ae8f14c9acdd5ce3f6c3b431e54491311c1b71a7..ce6a1a156c17b3130647bca4d941283a58308f87 100644
--- a/src/compiler/typer.cc
+++ b/src/compiler/typer.cc
@@ -1444,18 +1444,21 @@ Bounds Typer::Visitor::TypeJSInstanceOf(Node* node) {
Bounds Typer::Visitor::TypeJSLoadContext(Node* node) {
+ ContextAccess access = OpParameter<ContextAccess>(node);
Bounds outer = Operand(node, 0);
Type* context_type = outer.upper;
+ Type* upper = (access.index() == Context::GLOBAL_OBJECT_INDEX)
+ ? Type::GlobalObject()
+ : Type::Any();
if (context_type->Is(Type::None())) {
// Upper bound of context is not yet known.
- return Bounds(Type::None(), Type::Any());
+ return Bounds(Type::None(), upper);
}
DCHECK(context_type->Maybe(Type::Internal()));
// TODO(rossberg): More precisely, instead of the above assertion, we should
// back-propagate the constraint that it has to be a subtype of Internal.
- ContextAccess access = OpParameter<ContextAccess>(node);
MaybeHandle<Context> context;
if (context_type->IsConstant()) {
context = Handle<Context>::cast(context_type->AsConstant()->Value());
@@ -1463,8 +1466,6 @@ Bounds Typer::Visitor::TypeJSLoadContext(Node* node) {
// Walk context chain (as far as known), mirroring dynamic lookup.
// Since contexts are mutable, the information is only useful as a lower
// bound.
- // TODO(rossberg): Could use scope info to fix upper bounds for constant
- // bindings if we know that this code is never shared.
for (size_t i = access.depth(); i > 0; --i) {
if (context_type->IsContext()) {
context_type = context_type->AsContext()->Outer();
@@ -1475,15 +1476,13 @@ Bounds Typer::Visitor::TypeJSLoadContext(Node* node) {
context = handle(context.ToHandleChecked()->previous(), isolate());
}
}
- if (context.is_null()) {
- return Bounds::Unbounded(zone());
- } else {
- Handle<Object> value =
+ Type* lower = Type::None();
+ if (!context.is_null()) {
+ lower = TypeConstant(
handle(context.ToHandleChecked()->get(static_cast<int>(access.index())),
- isolate());
- Type* lower = TypeConstant(value);
- return Bounds(lower, Type::Any());
+ isolate()));
}
+ return Bounds(lower, upper);
}
« no previous file with comments | « src/compiler/js-typed-lowering.cc ('k') | src/factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698