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

Unified Diff: src/compiler/js-intrinsic-lowering.cc

Issue 1097963002: [turbofan] Use FastCloneShallow[Array|Object]Stub if possible. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Addressed comments. 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-intrinsic-lowering.h ('k') | src/compiler/linkage.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/js-intrinsic-lowering.cc
diff --git a/src/compiler/js-intrinsic-lowering.cc b/src/compiler/js-intrinsic-lowering.cc
index 6795317cffd34e72c4293f825c4baa9211c05ee7..7b6c878e040e5c14383882fe4dce1bd25550b68c 100644
--- a/src/compiler/js-intrinsic-lowering.cc
+++ b/src/compiler/js-intrinsic-lowering.cc
@@ -7,8 +7,10 @@
#include <stack>
+#include "src/code-factory.h"
#include "src/compiler/access-builder.h"
#include "src/compiler/js-graph.h"
+#include "src/compiler/linkage.h"
#include "src/compiler/node-matchers.h"
#include "src/compiler/node-properties.h"
@@ -28,6 +30,10 @@ Reduction JSIntrinsicLowering::Reduce(Node* node) {
switch (f->function_id) {
case Runtime::kInlineConstructDouble:
return ReduceConstructDouble(node);
+ case Runtime::kInlineCreateArrayLiteral:
+ return ReduceCreateArrayLiteral(node);
+ case Runtime::kInlineCreateObjectLiteral:
+ return ReduceCreateObjectLiteral(node);
case Runtime::kInlineDeoptimizeNow:
return ReduceDeoptimizeNow(node);
case Runtime::kInlineDoubleHi:
@@ -94,6 +100,62 @@ Reduction JSIntrinsicLowering::ReduceConstructDouble(Node* node) {
}
+Reduction JSIntrinsicLowering::ReduceCreateArrayLiteral(Node* node) {
+ HeapObjectMatcher<FixedArray> mconst(NodeProperties::GetValueInput(node, 2));
+ NumberMatcher mflags(NodeProperties::GetValueInput(node, 3));
+ int length = mconst.Value().handle()->length();
+ int flags = FastD2I(mflags.Value());
+
+ // Use the FastCloneShallowArrayStub only for shallow boilerplates up to the
+ // initial length limit for arrays with "fast" elements kind.
+ if ((flags & ArrayLiteral::kShallowElements) != 0 &&
+ length < JSObject::kInitialMaxFastElementArray) {
+ Isolate* isolate = jsgraph()->isolate();
+ Callable callable = CodeFactory::FastCloneShallowArray(isolate);
+ CallDescriptor* desc = Linkage::GetStubCallDescriptor(
+ isolate, graph()->zone(), callable.descriptor(), 0,
+ FLAG_turbo_deoptimization ? CallDescriptor::kNeedsFrameState
+ : CallDescriptor::kNoFlags);
+ const Operator* new_op = common()->Call(desc);
+ Node* stub_code = jsgraph()->HeapConstant(callable.code());
+ node->RemoveInput(3); // Remove flags input from node.
+ node->InsertInput(graph()->zone(), 0, stub_code);
+ node->set_op(new_op);
+ return Changed(node);
+ }
+
+ return NoChange();
+}
+
+
+Reduction JSIntrinsicLowering::ReduceCreateObjectLiteral(Node* node) {
+ HeapObjectMatcher<FixedArray> mconst(NodeProperties::GetValueInput(node, 2));
+ NumberMatcher mflags(NodeProperties::GetValueInput(node, 3));
+ // Constants are pairs, see ObjectLiteral::properties_count().
+ int length = mconst.Value().handle()->length() / 2;
+ int flags = FastD2I(mflags.Value());
+
+ // Use the FastCloneShallowObjectStub only for shallow boilerplates without
+ // elements up to the number of properties that the stubs can handle.
+ if ((flags & ObjectLiteral::kShallowProperties) != 0 &&
+ length <= FastCloneShallowObjectStub::kMaximumClonedProperties) {
+ Isolate* isolate = jsgraph()->isolate();
+ Callable callable = CodeFactory::FastCloneShallowObject(isolate, length);
+ CallDescriptor* desc = Linkage::GetStubCallDescriptor(
+ isolate, graph()->zone(), callable.descriptor(), 0,
+ FLAG_turbo_deoptimization ? CallDescriptor::kNeedsFrameState
+ : CallDescriptor::kNoFlags);
+ const Operator* new_op = common()->Call(desc);
+ Node* stub_code = jsgraph()->HeapConstant(callable.code());
+ node->InsertInput(graph()->zone(), 0, stub_code);
+ node->set_op(new_op);
+ return Changed(node);
+ }
+
+ return NoChange();
+}
+
+
Reduction JSIntrinsicLowering::ReduceDeoptimizeNow(Node* node) {
if (!FLAG_turbo_deoptimization) return NoChange();
« no previous file with comments | « src/compiler/js-intrinsic-lowering.h ('k') | src/compiler/linkage.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698