Commit 052dc9e0 authored by bmeurer's avatar bmeurer Committed by Commit bot

[turbofan] Lower object and array literals in JSCreateLowering.

This adds initial support for inline allocation of object and array
literals to the JSCreateLowering pass. It's basically identical to
what Crankshaft does.

This also unstages the TurboFan escape analysis, as the lowering seems
to trigger a bunch of bugs in it; those bugs will be fixed separately,
and we will re-enable escape analysis afterwards.

R=jarin@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#33972}
parent e59af013
This diff is collapsed.
...@@ -11,6 +11,7 @@ namespace v8 { ...@@ -11,6 +11,7 @@ namespace v8 {
namespace internal { namespace internal {
// Forward declarations. // Forward declarations.
class AllocationSiteUsageContext;
class CompilationDependencies; class CompilationDependencies;
class Factory; class Factory;
...@@ -29,10 +30,13 @@ class SimplifiedOperatorBuilder; ...@@ -29,10 +30,13 @@ class SimplifiedOperatorBuilder;
class JSCreateLowering final : public AdvancedReducer { class JSCreateLowering final : public AdvancedReducer {
public: public:
JSCreateLowering(Editor* editor, CompilationDependencies* dependencies, JSCreateLowering(Editor* editor, CompilationDependencies* dependencies,
JSGraph* jsgraph) JSGraph* jsgraph, MaybeHandle<LiteralsArray> literals_array,
Zone* zone)
: AdvancedReducer(editor), : AdvancedReducer(editor),
dependencies_(dependencies), dependencies_(dependencies),
jsgraph_(jsgraph) {} jsgraph_(jsgraph),
literals_array_(literals_array),
zone_(zone) {}
~JSCreateLowering() final {} ~JSCreateLowering() final {}
Reduction Reduce(Node* node) final; Reduction Reduce(Node* node) final;
...@@ -42,6 +46,7 @@ class JSCreateLowering final : public AdvancedReducer { ...@@ -42,6 +46,7 @@ class JSCreateLowering final : public AdvancedReducer {
Reduction ReduceJSCreateArguments(Node* node); Reduction ReduceJSCreateArguments(Node* node);
Reduction ReduceJSCreateArray(Node* node); Reduction ReduceJSCreateArray(Node* node);
Reduction ReduceJSCreateIterResultObject(Node* node); Reduction ReduceJSCreateIterResultObject(Node* node);
Reduction ReduceJSCreateLiteral(Node* node);
Reduction ReduceJSCreateFunctionContext(Node* node); Reduction ReduceJSCreateFunctionContext(Node* node);
Reduction ReduceJSCreateWithContext(Node* node); Reduction ReduceJSCreateWithContext(Node* node);
Reduction ReduceJSCreateCatchContext(Node* node); Reduction ReduceJSCreateCatchContext(Node* node);
...@@ -58,6 +63,17 @@ class JSCreateLowering final : public AdvancedReducer { ...@@ -58,6 +63,17 @@ class JSCreateLowering final : public AdvancedReducer {
Node* AllocateElements(Node* effect, Node* control, Node* AllocateElements(Node* effect, Node* control,
ElementsKind elements_kind, int capacity, ElementsKind elements_kind, int capacity,
PretenureFlag pretenure); PretenureFlag pretenure);
Node* AllocateFastLiteral(Node* effect, Node* control,
Handle<JSObject> boilerplate,
AllocationSiteUsageContext* site_context);
Node* AllocateFastLiteralElements(Node* effect, Node* control,
Handle<JSObject> boilerplate,
PretenureFlag pretenure,
AllocationSiteUsageContext* site_context);
Node* AllocateMutableHeapNumber(double value, Node* effect, Node* control);
// Infers the LiteralsArray to use for a given {node}.
MaybeHandle<LiteralsArray> GetSpecializationLiterals(Node* node);
Factory* factory() const; Factory* factory() const;
Graph* graph() const; Graph* graph() const;
...@@ -68,9 +84,12 @@ class JSCreateLowering final : public AdvancedReducer { ...@@ -68,9 +84,12 @@ class JSCreateLowering final : public AdvancedReducer {
SimplifiedOperatorBuilder* simplified() const; SimplifiedOperatorBuilder* simplified() const;
MachineOperatorBuilder* machine() const; MachineOperatorBuilder* machine() const;
CompilationDependencies* dependencies() const { return dependencies_; } CompilationDependencies* dependencies() const { return dependencies_; }
Zone* zone() const { return zone_; }
CompilationDependencies* const dependencies_; CompilationDependencies* const dependencies_;
JSGraph* const jsgraph_; JSGraph* const jsgraph_;
MaybeHandle<LiteralsArray> const literals_array_;
Zone* const zone_;
}; };
} // namespace compiler } // namespace compiler
......
...@@ -613,8 +613,13 @@ struct TypedLoweringPhase { ...@@ -613,8 +613,13 @@ struct TypedLoweringPhase {
data->common()); data->common());
LoadElimination load_elimination(&graph_reducer); LoadElimination load_elimination(&graph_reducer);
JSBuiltinReducer builtin_reducer(&graph_reducer, data->jsgraph()); JSBuiltinReducer builtin_reducer(&graph_reducer, data->jsgraph());
MaybeHandle<LiteralsArray> literals_array =
data->info()->is_native_context_specializing()
? handle(data->info()->closure()->literals(), data->isolate())
: MaybeHandle<LiteralsArray>();
JSCreateLowering create_lowering( JSCreateLowering create_lowering(
&graph_reducer, data->info()->dependencies(), data->jsgraph()); &graph_reducer, data->info()->dependencies(), data->jsgraph(),
literals_array, temp_zone);
JSTypedLowering::Flags typed_lowering_flags = JSTypedLowering::kNoFlags; JSTypedLowering::Flags typed_lowering_flags = JSTypedLowering::kNoFlags;
if (data->info()->is_deoptimization_enabled()) { if (data->info()->is_deoptimization_enabled()) {
typed_lowering_flags |= JSTypedLowering::kDeoptimizationEnabled; typed_lowering_flags |= JSTypedLowering::kDeoptimizationEnabled;
......
...@@ -420,7 +420,6 @@ DEFINE_BOOL(omit_map_checks_for_leaf_maps, true, ...@@ -420,7 +420,6 @@ DEFINE_BOOL(omit_map_checks_for_leaf_maps, true,
DEFINE_BOOL(turbo, false, "enable TurboFan compiler") DEFINE_BOOL(turbo, false, "enable TurboFan compiler")
DEFINE_IMPLICATION(turbo, turbo_asm_deoptimization) DEFINE_IMPLICATION(turbo, turbo_asm_deoptimization)
DEFINE_IMPLICATION(turbo, turbo_inlining) DEFINE_IMPLICATION(turbo, turbo_inlining)
DEFINE_IMPLICATION(turbo, turbo_escape)
DEFINE_BOOL(turbo_shipping, true, "enable TurboFan compiler on subset") DEFINE_BOOL(turbo_shipping, true, "enable TurboFan compiler on subset")
DEFINE_BOOL(turbo_greedy_regalloc, false, "use the greedy register allocator") DEFINE_BOOL(turbo_greedy_regalloc, false, "use the greedy register allocator")
DEFINE_BOOL(turbo_sp_frame_access, false, DEFINE_BOOL(turbo_sp_frame_access, false,
......
...@@ -38,7 +38,8 @@ class JSCreateLoweringTest : public TypedGraphTest { ...@@ -38,7 +38,8 @@ class JSCreateLoweringTest : public TypedGraphTest {
&machine); &machine);
// TODO(titzer): mock the GraphReducer here for better unit testing. // TODO(titzer): mock the GraphReducer here for better unit testing.
GraphReducer graph_reducer(zone(), graph()); GraphReducer graph_reducer(zone(), graph());
JSCreateLowering reducer(&graph_reducer, &deps_, &jsgraph); JSCreateLowering reducer(&graph_reducer, &deps_, &jsgraph,
MaybeHandle<LiteralsArray>(), zone());
return reducer.Reduce(node); return reducer.Reduce(node);
} }
......
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