| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/code-factory.h" | 5 #include "src/code-factory.h" |
| 6 #include "src/code-stubs.h" | 6 #include "src/code-stubs.h" |
| 7 #include "src/compiler/common-operator.h" | 7 #include "src/compiler/common-operator.h" |
| 8 #include "src/compiler/js-generic-lowering.h" | 8 #include "src/compiler/js-generic-lowering.h" |
| 9 #include "src/compiler/js-graph.h" | 9 #include "src/compiler/js-graph.h" |
| 10 #include "src/compiler/machine-operator.h" | 10 #include "src/compiler/machine-operator.h" |
| (...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 548 | 548 |
| 549 | 549 |
| 550 void JSGenericLowering::LowerJSCreateIterResultObject(Node* node) { | 550 void JSGenericLowering::LowerJSCreateIterResultObject(Node* node) { |
| 551 ReplaceWithRuntimeCall(node, Runtime::kCreateIterResultObject); | 551 ReplaceWithRuntimeCall(node, Runtime::kCreateIterResultObject); |
| 552 } | 552 } |
| 553 | 553 |
| 554 | 554 |
| 555 void JSGenericLowering::LowerJSCreateLiteralArray(Node* node) { | 555 void JSGenericLowering::LowerJSCreateLiteralArray(Node* node) { |
| 556 CreateLiteralParameters const& p = CreateLiteralParametersOf(node->op()); | 556 CreateLiteralParameters const& p = CreateLiteralParametersOf(node->op()); |
| 557 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node); | 557 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node); |
| 558 int const length = Handle<FixedArray>::cast(p.constant())->length(); | |
| 559 node->InsertInput(zone(), 1, jsgraph()->SmiConstant(p.index())); | 558 node->InsertInput(zone(), 1, jsgraph()->SmiConstant(p.index())); |
| 560 node->InsertInput(zone(), 2, jsgraph()->HeapConstant(p.constant())); | 559 node->InsertInput(zone(), 2, jsgraph()->HeapConstant(p.constant())); |
| 561 | 560 |
| 562 // Use the FastCloneShallowArrayStub only for shallow boilerplates up to the | 561 // Use the FastCloneShallowArrayStub only for shallow boilerplates up to the |
| 563 // initial length limit for arrays with "fast" elements kind. | 562 // initial length limit for arrays with "fast" elements kind. |
| 564 if ((p.flags() & ArrayLiteral::kShallowElements) != 0 && | 563 if ((p.flags() & ArrayLiteral::kShallowElements) != 0 && |
| 565 length < JSArray::kInitialMaxFastElementArray) { | 564 p.length() < JSArray::kInitialMaxFastElementArray) { |
| 566 Callable callable = CodeFactory::FastCloneShallowArray(isolate()); | 565 Callable callable = CodeFactory::FastCloneShallowArray(isolate()); |
| 567 ReplaceWithStubCall(node, callable, flags); | 566 ReplaceWithStubCall(node, callable, flags); |
| 568 } else { | 567 } else { |
| 569 node->InsertInput(zone(), 3, jsgraph()->SmiConstant(p.flags())); | 568 node->InsertInput(zone(), 3, jsgraph()->SmiConstant(p.flags())); |
| 570 ReplaceWithRuntimeCall(node, Runtime::kCreateArrayLiteral); | 569 ReplaceWithRuntimeCall(node, Runtime::kCreateArrayLiteral); |
| 571 } | 570 } |
| 572 } | 571 } |
| 573 | 572 |
| 574 | 573 |
| 575 void JSGenericLowering::LowerJSCreateLiteralObject(Node* node) { | 574 void JSGenericLowering::LowerJSCreateLiteralObject(Node* node) { |
| 576 CreateLiteralParameters const& p = CreateLiteralParametersOf(node->op()); | 575 CreateLiteralParameters const& p = CreateLiteralParametersOf(node->op()); |
| 577 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node); | 576 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node); |
| 578 // Constants are pairs, see ObjectLiteral::properties_count(). | |
| 579 int const length = Handle<FixedArray>::cast(p.constant())->length() / 2; | |
| 580 node->InsertInput(zone(), 1, jsgraph()->SmiConstant(p.index())); | 577 node->InsertInput(zone(), 1, jsgraph()->SmiConstant(p.index())); |
| 581 node->InsertInput(zone(), 2, jsgraph()->HeapConstant(p.constant())); | 578 node->InsertInput(zone(), 2, jsgraph()->HeapConstant(p.constant())); |
| 582 node->InsertInput(zone(), 3, jsgraph()->SmiConstant(p.flags())); | 579 node->InsertInput(zone(), 3, jsgraph()->SmiConstant(p.flags())); |
| 583 | 580 |
| 584 // Use the FastCloneShallowObjectStub only for shallow boilerplates without | 581 // Use the FastCloneShallowObjectStub only for shallow boilerplates without |
| 585 // elements up to the number of properties that the stubs can handle. | 582 // elements up to the number of properties that the stubs can handle. |
| 586 if ((p.flags() & ObjectLiteral::kShallowProperties) != 0 && | 583 if ((p.flags() & ObjectLiteral::kShallowProperties) != 0 && |
| 587 length <= FastCloneShallowObjectStub::kMaximumClonedProperties) { | 584 p.length() <= FastCloneShallowObjectStub::kMaximumClonedProperties) { |
| 588 Callable callable = CodeFactory::FastCloneShallowObject(isolate(), length); | 585 Callable callable = |
| 586 CodeFactory::FastCloneShallowObject(isolate(), p.length()); |
| 589 ReplaceWithStubCall(node, callable, flags); | 587 ReplaceWithStubCall(node, callable, flags); |
| 590 } else { | 588 } else { |
| 591 ReplaceWithRuntimeCall(node, Runtime::kCreateObjectLiteral); | 589 ReplaceWithRuntimeCall(node, Runtime::kCreateObjectLiteral); |
| 592 } | 590 } |
| 593 } | 591 } |
| 594 | 592 |
| 595 | 593 |
| 596 void JSGenericLowering::LowerJSCreateLiteralRegExp(Node* node) { | 594 void JSGenericLowering::LowerJSCreateLiteralRegExp(Node* node) { |
| 597 CreateLiteralParameters const& p = CreateLiteralParametersOf(node->op()); | 595 CreateLiteralParameters const& p = CreateLiteralParametersOf(node->op()); |
| 598 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node); | 596 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node); |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 776 } | 774 } |
| 777 | 775 |
| 778 | 776 |
| 779 MachineOperatorBuilder* JSGenericLowering::machine() const { | 777 MachineOperatorBuilder* JSGenericLowering::machine() const { |
| 780 return jsgraph()->machine(); | 778 return jsgraph()->machine(); |
| 781 } | 779 } |
| 782 | 780 |
| 783 } // namespace compiler | 781 } // namespace compiler |
| 784 } // namespace internal | 782 } // namespace internal |
| 785 } // namespace v8 | 783 } // namespace v8 |
| OLD | NEW |