| 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/compiler/js-generic-lowering.h" | 5 #include "src/compiler/js-generic-lowering.h" |
| 6 | 6 |
| 7 #include "src/ast/ast.h" | 7 #include "src/ast/ast.h" |
| 8 #include "src/builtins/builtins-constructor.h" | 8 #include "src/builtins/builtins-constructor.h" |
| 9 #include "src/code-factory.h" | 9 #include "src/code-factory.h" |
| 10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
| (...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 } | 385 } |
| 386 | 386 |
| 387 | 387 |
| 388 void JSGenericLowering::LowerJSCreateFunctionContext(Node* node) { | 388 void JSGenericLowering::LowerJSCreateFunctionContext(Node* node) { |
| 389 const CreateFunctionContextParameters& parameters = | 389 const CreateFunctionContextParameters& parameters = |
| 390 CreateFunctionContextParametersOf(node->op()); | 390 CreateFunctionContextParametersOf(node->op()); |
| 391 int slot_count = parameters.slot_count(); | 391 int slot_count = parameters.slot_count(); |
| 392 ScopeType scope_type = parameters.scope_type(); | 392 ScopeType scope_type = parameters.scope_type(); |
| 393 CallDescriptor::Flags flags = FrameStateFlagForCall(node); | 393 CallDescriptor::Flags flags = FrameStateFlagForCall(node); |
| 394 | 394 |
| 395 if (slot_count <= | 395 if (slot_count <= ConstructorBuiltins::MaximumFunctionContextSlots()) { |
| 396 ConstructorBuiltinsAssembler::MaximumFunctionContextSlots()) { | |
| 397 Callable callable = | 396 Callable callable = |
| 398 CodeFactory::FastNewFunctionContext(isolate(), scope_type); | 397 CodeFactory::FastNewFunctionContext(isolate(), scope_type); |
| 399 node->InsertInput(zone(), 1, jsgraph()->Int32Constant(slot_count)); | 398 node->InsertInput(zone(), 1, jsgraph()->Int32Constant(slot_count)); |
| 400 ReplaceWithStubCall(node, callable, flags); | 399 ReplaceWithStubCall(node, callable, flags); |
| 401 } else { | 400 } else { |
| 402 node->InsertInput(zone(), 1, jsgraph()->SmiConstant(scope_type)); | 401 node->InsertInput(zone(), 1, jsgraph()->SmiConstant(scope_type)); |
| 403 ReplaceWithRuntimeCall(node, Runtime::kNewFunctionContext); | 402 ReplaceWithRuntimeCall(node, Runtime::kNewFunctionContext); |
| 404 } | 403 } |
| 405 } | 404 } |
| 406 | 405 |
| 407 | 406 |
| 408 void JSGenericLowering::LowerJSCreateIterResultObject(Node* node) { | 407 void JSGenericLowering::LowerJSCreateIterResultObject(Node* node) { |
| 409 ReplaceWithRuntimeCall(node, Runtime::kCreateIterResultObject); | 408 ReplaceWithRuntimeCall(node, Runtime::kCreateIterResultObject); |
| 410 } | 409 } |
| 411 | 410 |
| 412 void JSGenericLowering::LowerJSCreateKeyValueArray(Node* node) { | 411 void JSGenericLowering::LowerJSCreateKeyValueArray(Node* node) { |
| 413 ReplaceWithRuntimeCall(node, Runtime::kCreateKeyValueArray); | 412 ReplaceWithRuntimeCall(node, Runtime::kCreateKeyValueArray); |
| 414 } | 413 } |
| 415 | 414 |
| 416 void JSGenericLowering::LowerJSCreateLiteralArray(Node* node) { | 415 void JSGenericLowering::LowerJSCreateLiteralArray(Node* node) { |
| 417 CreateLiteralParameters const& p = CreateLiteralParametersOf(node->op()); | 416 CreateLiteralParameters const& p = CreateLiteralParametersOf(node->op()); |
| 418 CallDescriptor::Flags flags = FrameStateFlagForCall(node); | 417 CallDescriptor::Flags flags = FrameStateFlagForCall(node); |
| 419 node->InsertInput(zone(), 1, jsgraph()->SmiConstant(p.index())); | 418 node->InsertInput(zone(), 1, jsgraph()->SmiConstant(p.index())); |
| 420 node->InsertInput(zone(), 2, jsgraph()->HeapConstant(p.constant())); | 419 node->InsertInput(zone(), 2, jsgraph()->HeapConstant(p.constant())); |
| 421 | 420 |
| 422 // Use the FastCloneShallowArray builtin only for shallow boilerplates without | 421 // Use the FastCloneShallowArray builtin only for shallow boilerplates without |
| 423 // properties up to the number of elements that the stubs can handle. | 422 // properties up to the number of elements that the stubs can handle. |
| 424 if ((p.flags() & ArrayLiteral::kShallowElements) != 0 && | 423 if ((p.flags() & ArrayLiteral::kShallowElements) != 0 && |
| 425 p.length() < | 424 p.length() < ConstructorBuiltins::kMaximumClonedShallowArrayElements) { |
| 426 ConstructorBuiltinsAssembler::kMaximumClonedShallowArrayElements) { | |
| 427 Callable callable = CodeFactory::FastCloneShallowArray( | 425 Callable callable = CodeFactory::FastCloneShallowArray( |
| 428 isolate(), DONT_TRACK_ALLOCATION_SITE); | 426 isolate(), DONT_TRACK_ALLOCATION_SITE); |
| 429 ReplaceWithStubCall(node, callable, flags); | 427 ReplaceWithStubCall(node, callable, flags); |
| 430 } else { | 428 } else { |
| 431 node->InsertInput(zone(), 3, jsgraph()->SmiConstant(p.flags())); | 429 node->InsertInput(zone(), 3, jsgraph()->SmiConstant(p.flags())); |
| 432 ReplaceWithRuntimeCall(node, Runtime::kCreateArrayLiteral); | 430 ReplaceWithRuntimeCall(node, Runtime::kCreateArrayLiteral); |
| 433 } | 431 } |
| 434 } | 432 } |
| 435 | 433 |
| 436 | 434 |
| 437 void JSGenericLowering::LowerJSCreateLiteralObject(Node* node) { | 435 void JSGenericLowering::LowerJSCreateLiteralObject(Node* node) { |
| 438 CreateLiteralParameters const& p = CreateLiteralParametersOf(node->op()); | 436 CreateLiteralParameters const& p = CreateLiteralParametersOf(node->op()); |
| 439 CallDescriptor::Flags flags = FrameStateFlagForCall(node); | 437 CallDescriptor::Flags flags = FrameStateFlagForCall(node); |
| 440 node->InsertInput(zone(), 1, jsgraph()->SmiConstant(p.index())); | 438 node->InsertInput(zone(), 1, jsgraph()->SmiConstant(p.index())); |
| 441 node->InsertInput(zone(), 2, jsgraph()->HeapConstant(p.constant())); | 439 node->InsertInput(zone(), 2, jsgraph()->HeapConstant(p.constant())); |
| 442 node->InsertInput(zone(), 3, jsgraph()->SmiConstant(p.flags())); | 440 node->InsertInput(zone(), 3, jsgraph()->SmiConstant(p.flags())); |
| 443 | 441 |
| 444 // Use the FastCloneShallowObject builtin only for shallow boilerplates | 442 // Use the FastCloneShallowObject builtin only for shallow boilerplates |
| 445 // without elements up to the number of properties that the stubs can handle. | 443 // without elements up to the number of properties that the stubs can handle. |
| 446 if ((p.flags() & ObjectLiteral::kShallowProperties) != 0 && | 444 if ((p.flags() & ObjectLiteral::kShallowProperties) != 0 && |
| 447 p.length() <= | 445 p.length() <= |
| 448 ConstructorBuiltinsAssembler::kMaximumClonedShallowObjectProperties) { | 446 ConstructorBuiltins::kMaximumClonedShallowObjectProperties) { |
| 449 Callable callable = | 447 Callable callable = |
| 450 CodeFactory::FastCloneShallowObject(isolate(), p.length()); | 448 CodeFactory::FastCloneShallowObject(isolate(), p.length()); |
| 451 ReplaceWithStubCall(node, callable, flags); | 449 ReplaceWithStubCall(node, callable, flags); |
| 452 } else { | 450 } else { |
| 453 ReplaceWithRuntimeCall(node, Runtime::kCreateObjectLiteral); | 451 ReplaceWithRuntimeCall(node, Runtime::kCreateObjectLiteral); |
| 454 } | 452 } |
| 455 } | 453 } |
| 456 | 454 |
| 457 | 455 |
| 458 void JSGenericLowering::LowerJSCreateLiteralRegExp(Node* node) { | 456 void JSGenericLowering::LowerJSCreateLiteralRegExp(Node* node) { |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 704 } | 702 } |
| 705 | 703 |
| 706 | 704 |
| 707 MachineOperatorBuilder* JSGenericLowering::machine() const { | 705 MachineOperatorBuilder* JSGenericLowering::machine() const { |
| 708 return jsgraph()->machine(); | 706 return jsgraph()->machine(); |
| 709 } | 707 } |
| 710 | 708 |
| 711 } // namespace compiler | 709 } // namespace compiler |
| 712 } // namespace internal | 710 } // namespace internal |
| 713 } // namespace v8 | 711 } // namespace v8 |
| OLD | NEW |