Chromium Code Reviews| 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..20a8dbafbfe750b0979c1b124394ba48deddf18f 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,61 @@ 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->InsertInput(graph()->zone(), 0, stub_code); |
| + node->RemoveInput(4); |
|
mvstanton
2015/04/21 12:59:14
nit: a comment would be nice on the RemoveInput...
Michael Starzinger
2015/04/21 13:48:36
Done. Also moved it up to before "InsertInput" so
|
| + 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)); |
| + 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(); |