Commit 4eb41ba7 authored by bmeurer's avatar bmeurer Committed by Commit bot

[turbofan] Split JSGlobalObjectSpecialization into separate class.

The JSNativeContextSpecialization class is getting rather huge with all
the stuff related to property and element access going in. Splitting off
the global object related stuff into JSGlobalObjectSpecialization seems
like a natural separation, especially since the global object
specialization is sort of separate issue anyway.  This is neutral
functionality- and performance-wise.

R=jarin@chromium.org
BUG=v8:4470
LOG=n

Review URL: https://codereview.chromium.org/1417043006

Cr-Commit-Position: refs/heads/master@{#31748}
parent 1ca66908
...@@ -767,6 +767,8 @@ source_set("v8_base") { ...@@ -767,6 +767,8 @@ source_set("v8_base") {
"src/compiler/js-frame-specialization.h", "src/compiler/js-frame-specialization.h",
"src/compiler/js-generic-lowering.cc", "src/compiler/js-generic-lowering.cc",
"src/compiler/js-generic-lowering.h", "src/compiler/js-generic-lowering.h",
"src/compiler/js-global-object-specialization.cc",
"src/compiler/js-global-object-specialization.h",
"src/compiler/js-graph.cc", "src/compiler/js-graph.cc",
"src/compiler/js-graph.h", "src/compiler/js-graph.h",
"src/compiler/js-inlining.cc", "src/compiler/js-inlining.cc",
......
This diff is collapsed.
// Copyright 2015 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef V8_COMPILER_JS_GLOBAL_OBJECT_SPECIALIZATION_H_
#define V8_COMPILER_JS_GLOBAL_OBJECT_SPECIALIZATION_H_
#include "src/base/flags.h"
#include "src/compiler/graph-reducer.h"
namespace v8 {
namespace internal {
// Forward declarations.
class CompilationDependencies;
class ScriptContextTable;
class TypeCache;
namespace compiler {
// Forward declarations.
class CommonOperatorBuilder;
class JSGraph;
class JSOperatorBuilder;
class SimplifiedOperatorBuilder;
// Specializes a given JSGraph to a given global object, potentially constant
// folding some {JSLoadGlobal} nodes or strength reducing some {JSStoreGlobal}
// nodes.
class JSGlobalObjectSpecialization final : public AdvancedReducer {
public:
// Flags that control the mode of operation.
enum Flag {
kNoFlags = 0u,
kDeoptimizationEnabled = 1u << 0,
};
typedef base::Flags<Flag> Flags;
JSGlobalObjectSpecialization(Editor* editor, JSGraph* jsgraph, Flags flags,
Handle<JSGlobalObject> global_object,
CompilationDependencies* dependencies);
Reduction Reduce(Node* node) final;
private:
Reduction ReduceJSLoadGlobal(Node* node);
Reduction ReduceJSStoreGlobal(Node* node);
struct ScriptContextTableLookupResult;
bool LookupInScriptContextTable(Handle<Name> name,
ScriptContextTableLookupResult* result);
Graph* graph() const;
JSGraph* jsgraph() const { return jsgraph_; }
Isolate* isolate() const;
CommonOperatorBuilder* common() const;
JSOperatorBuilder* javascript() const;
SimplifiedOperatorBuilder* simplified() const;
Flags flags() const { return flags_; }
Handle<JSGlobalObject> global_object() const { return global_object_; }
Handle<ScriptContextTable> script_context_table() const {
return script_context_table_;
}
CompilationDependencies* dependencies() const { return dependencies_; }
JSGraph* const jsgraph_;
Flags const flags_;
Handle<JSGlobalObject> global_object_;
Handle<ScriptContextTable> script_context_table_;
CompilationDependencies* const dependencies_;
TypeCache const& type_cache_;
DISALLOW_COPY_AND_ASSIGN(JSGlobalObjectSpecialization);
};
DEFINE_OPERATORS_FOR_FLAGS(JSGlobalObjectSpecialization::Flags)
} // namespace compiler
} // namespace internal
} // namespace v8
#endif // V8_COMPILER_JS_GLOBAL_OBJECT_SPECIALIZATION_H_
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "src/compiler/common-operator-reducer.h" #include "src/compiler/common-operator-reducer.h"
#include "src/compiler/dead-code-elimination.h" #include "src/compiler/dead-code-elimination.h"
#include "src/compiler/graph-reducer.h" #include "src/compiler/graph-reducer.h"
#include "src/compiler/js-global-object-specialization.h"
#include "src/compiler/js-native-context-specialization.h" #include "src/compiler/js-native-context-specialization.h"
#include "src/compiler/js-operator.h" #include "src/compiler/js-operator.h"
#include "src/compiler/node-matchers.h" #include "src/compiler/node-matchers.h"
...@@ -390,15 +391,22 @@ Reduction JSInliner::ReduceJSCallFunction(Node* node, ...@@ -390,15 +391,22 @@ Reduction JSInliner::ReduceJSCallFunction(Node* node,
jsgraph.common()); jsgraph.common());
CommonOperatorReducer common_reducer(&graph_reducer, &graph, CommonOperatorReducer common_reducer(&graph_reducer, &graph,
jsgraph.common(), jsgraph.machine()); jsgraph.common(), jsgraph.machine());
JSGlobalObjectSpecialization global_object_specialization(
&graph_reducer, &jsgraph,
info.is_deoptimization_enabled()
? JSGlobalObjectSpecialization::kDeoptimizationEnabled
: JSGlobalObjectSpecialization::kNoFlags,
handle(info.global_object(), info.isolate()), info_->dependencies());
JSNativeContextSpecialization native_context_specialization( JSNativeContextSpecialization native_context_specialization(
&graph_reducer, &jsgraph, &graph_reducer, &jsgraph,
info.is_deoptimization_enabled() info.is_deoptimization_enabled()
? JSNativeContextSpecialization::kDeoptimizationEnabled ? JSNativeContextSpecialization::kDeoptimizationEnabled
: JSNativeContextSpecialization::kNoFlags, : JSNativeContextSpecialization::kNoFlags,
handle(info.global_object(), info.isolate()), info_->dependencies(), handle(info.global_object()->native_context(), info.isolate()),
local_zone_); info_->dependencies(), local_zone_);
graph_reducer.AddReducer(&dead_code_elimination); graph_reducer.AddReducer(&dead_code_elimination);
graph_reducer.AddReducer(&common_reducer); graph_reducer.AddReducer(&common_reducer);
graph_reducer.AddReducer(&global_object_specialization);
graph_reducer.AddReducer(&native_context_specialization); graph_reducer.AddReducer(&native_context_specialization);
graph_reducer.ReduceGraph(); graph_reducer.ReduceGraph();
} }
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
#include "src/base/flags.h" #include "src/base/flags.h"
#include "src/compiler/access-info.h" #include "src/compiler/access-info.h"
#include "src/compiler/graph-reducer.h" #include "src/compiler/graph-reducer.h"
#include "src/compiler/simplified-operator.h"
namespace v8 { namespace v8 {
namespace internal { namespace internal {
...@@ -27,6 +26,7 @@ class CommonOperatorBuilder; ...@@ -27,6 +26,7 @@ class CommonOperatorBuilder;
class JSGraph; class JSGraph;
class JSOperatorBuilder; class JSOperatorBuilder;
class MachineOperatorBuilder; class MachineOperatorBuilder;
class SimplifiedOperatorBuilder;
// Specializes a given JSGraph to a given native context, potentially constant // Specializes a given JSGraph to a given native context, potentially constant
...@@ -43,7 +43,7 @@ class JSNativeContextSpecialization final : public AdvancedReducer { ...@@ -43,7 +43,7 @@ class JSNativeContextSpecialization final : public AdvancedReducer {
typedef base::Flags<Flag> Flags; typedef base::Flags<Flag> Flags;
JSNativeContextSpecialization(Editor* editor, JSGraph* jsgraph, Flags flags, JSNativeContextSpecialization(Editor* editor, JSGraph* jsgraph, Flags flags,
Handle<JSGlobalObject> global_object, Handle<Context> native_context,
CompilationDependencies* dependencies, CompilationDependencies* dependencies,
Zone* zone); Zone* zone);
...@@ -51,20 +51,11 @@ class JSNativeContextSpecialization final : public AdvancedReducer { ...@@ -51,20 +51,11 @@ class JSNativeContextSpecialization final : public AdvancedReducer {
private: private:
Reduction ReduceJSCallFunction(Node* node); Reduction ReduceJSCallFunction(Node* node);
Reduction ReduceJSLoadGlobal(Node* node);
Reduction ReduceJSStoreGlobal(Node* node);
Reduction ReduceJSLoadNamed(Node* node); Reduction ReduceJSLoadNamed(Node* node);
Reduction ReduceJSStoreNamed(Node* node); Reduction ReduceJSStoreNamed(Node* node);
Reduction ReduceJSLoadProperty(Node* node); Reduction ReduceJSLoadProperty(Node* node);
Reduction ReduceJSStoreProperty(Node* node); Reduction ReduceJSStoreProperty(Node* node);
Reduction Replace(Node* node, Node* value, Node* effect = nullptr,
Node* control = nullptr) {
ReplaceWithValue(node, value, effect, control);
return Changed(value);
}
Reduction Replace(Node* node, Handle<Object> value);
Reduction ReduceElementAccess(Node* node, Node* index, Node* value, Reduction ReduceElementAccess(Node* node, Node* index, Node* value,
MapHandleList const& receiver_maps, MapHandleList const& receiver_maps,
AccessMode access_mode, AccessMode access_mode,
...@@ -79,10 +70,6 @@ class JSNativeContextSpecialization final : public AdvancedReducer { ...@@ -79,10 +70,6 @@ class JSNativeContextSpecialization final : public AdvancedReducer {
LanguageMode language_mode, LanguageMode language_mode,
Node* index = nullptr); Node* index = nullptr);
struct ScriptContextTableLookupResult;
bool LookupInScriptContextTable(Handle<Name> name,
ScriptContextTableLookupResult* result);
// Adds stability dependencies on all prototypes of every class in // Adds stability dependencies on all prototypes of every class in
// {receiver_type} up to (and including) the {holder}. // {receiver_type} up to (and including) the {holder}.
void AssumePrototypesStable(Type* receiver_type, Handle<JSObject> holder); void AssumePrototypesStable(Type* receiver_type, Handle<JSObject> holder);
...@@ -100,7 +87,6 @@ class JSNativeContextSpecialization final : public AdvancedReducer { ...@@ -100,7 +87,6 @@ class JSNativeContextSpecialization final : public AdvancedReducer {
SimplifiedOperatorBuilder* simplified() const; SimplifiedOperatorBuilder* simplified() const;
MachineOperatorBuilder* machine() const; MachineOperatorBuilder* machine() const;
Flags flags() const { return flags_; } Flags flags() const { return flags_; }
Handle<JSGlobalObject> global_object() const { return global_object_; }
Handle<Context> native_context() const { return native_context_; } Handle<Context> native_context() const { return native_context_; }
CompilationDependencies* dependencies() const { return dependencies_; } CompilationDependencies* dependencies() const { return dependencies_; }
Zone* zone() const { return zone_; } Zone* zone() const { return zone_; }
...@@ -108,7 +94,6 @@ class JSNativeContextSpecialization final : public AdvancedReducer { ...@@ -108,7 +94,6 @@ class JSNativeContextSpecialization final : public AdvancedReducer {
JSGraph* const jsgraph_; JSGraph* const jsgraph_;
Flags const flags_; Flags const flags_;
Handle<JSGlobalObject> global_object_;
Handle<Context> native_context_; Handle<Context> native_context_;
CompilationDependencies* const dependencies_; CompilationDependencies* const dependencies_;
Zone* const zone_; Zone* const zone_;
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include "src/compiler/js-context-specialization.h" #include "src/compiler/js-context-specialization.h"
#include "src/compiler/js-frame-specialization.h" #include "src/compiler/js-frame-specialization.h"
#include "src/compiler/js-generic-lowering.h" #include "src/compiler/js-generic-lowering.h"
#include "src/compiler/js-global-object-specialization.h"
#include "src/compiler/js-inlining-heuristic.h" #include "src/compiler/js-inlining-heuristic.h"
#include "src/compiler/js-intrinsic-lowering.h" #include "src/compiler/js-intrinsic-lowering.h"
#include "src/compiler/js-native-context-specialization.h" #include "src/compiler/js-native-context-specialization.h"
...@@ -500,15 +501,24 @@ struct NativeContextSpecializationPhase { ...@@ -500,15 +501,24 @@ struct NativeContextSpecializationPhase {
data->common()); data->common());
CommonOperatorReducer common_reducer(&graph_reducer, data->graph(), CommonOperatorReducer common_reducer(&graph_reducer, data->graph(),
data->common(), data->machine()); data->common(), data->machine());
JSGlobalObjectSpecialization global_object_specialization(
&graph_reducer, data->jsgraph(),
data->info()->is_deoptimization_enabled()
? JSGlobalObjectSpecialization::kDeoptimizationEnabled
: JSGlobalObjectSpecialization::kNoFlags,
handle(data->info()->global_object(), data->isolate()),
data->info()->dependencies());
JSNativeContextSpecialization native_context_specialization( JSNativeContextSpecialization native_context_specialization(
&graph_reducer, data->jsgraph(), &graph_reducer, data->jsgraph(),
data->info()->is_deoptimization_enabled() data->info()->is_deoptimization_enabled()
? JSNativeContextSpecialization::kDeoptimizationEnabled ? JSNativeContextSpecialization::kDeoptimizationEnabled
: JSNativeContextSpecialization::kNoFlags, : JSNativeContextSpecialization::kNoFlags,
handle(data->info()->global_object(), data->isolate()), handle(data->info()->global_object()->native_context(),
data->isolate()),
data->info()->dependencies(), temp_zone); data->info()->dependencies(), temp_zone);
AddReducer(data, &graph_reducer, &dead_code_elimination); AddReducer(data, &graph_reducer, &dead_code_elimination);
AddReducer(data, &graph_reducer, &common_reducer); AddReducer(data, &graph_reducer, &common_reducer);
AddReducer(data, &graph_reducer, &global_object_specialization);
AddReducer(data, &graph_reducer, &native_context_specialization); AddReducer(data, &graph_reducer, &native_context_specialization);
graph_reducer.ReduceGraph(); graph_reducer.ReduceGraph();
} }
......
...@@ -526,6 +526,8 @@ ...@@ -526,6 +526,8 @@
'../../src/compiler/js-frame-specialization.h', '../../src/compiler/js-frame-specialization.h',
'../../src/compiler/js-generic-lowering.cc', '../../src/compiler/js-generic-lowering.cc',
'../../src/compiler/js-generic-lowering.h', '../../src/compiler/js-generic-lowering.h',
'../../src/compiler/js-global-object-specialization.cc',
'../../src/compiler/js-global-object-specialization.h',
'../../src/compiler/js-graph.cc', '../../src/compiler/js-graph.cc',
'../../src/compiler/js-graph.h', '../../src/compiler/js-graph.h',
'../../src/compiler/js-inlining.cc', '../../src/compiler/js-inlining.cc',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment