| Index: src/compiler/js-typed-lowering.cc
|
| diff --git a/src/compiler/js-typed-lowering.cc b/src/compiler/js-typed-lowering.cc
|
| index 628e7e07b69b1ae2ec4560e6c41058d2abdd58c5..1bb1414b6a0c0b56d3ea304c8971eaa8c8046682 100644
|
| --- a/src/compiler/js-typed-lowering.cc
|
| +++ b/src/compiler/js-typed-lowering.cc
|
| @@ -1189,12 +1189,16 @@ Reduction JSTypedLowering::ReduceJSCreateLiteralObject(Node* node) {
|
| Reduction JSTypedLowering::ReduceJSCreateWithContext(Node* node) {
|
| DCHECK_EQ(IrOpcode::kJSCreateWithContext, node->opcode());
|
| Node* const input = NodeProperties::GetValueInput(node, 0);
|
| + Node* const closure = NodeProperties::GetValueInput(node, 1);
|
| Type* input_type = NodeProperties::GetBounds(input).upper;
|
| - if (FLAG_turbo_allocate && input_type->Is(Type::Receiver())) {
|
| + // The closure can be NumberConstant(0) if the closure is global code
|
| + // (rather than a function). We exclude that case here.
|
| + // TODO(jarin) Find a better way to check that the closure is a function.
|
| + if (FLAG_turbo_allocate && input_type->Is(Type::Receiver()) &&
|
| + closure->opcode() != IrOpcode::kNumberConstant) {
|
| // JSCreateWithContext(o:receiver, f)
|
| Node* const effect = NodeProperties::GetEffectInput(node);
|
| Node* const control = NodeProperties::GetControlInput(node);
|
| - Node* const closure = NodeProperties::GetValueInput(node, 1);
|
| Node* const context = NodeProperties::GetContextInput(node);
|
| Node* const load = graph()->NewNode(
|
| simplified()->LoadField(
|
| @@ -1223,15 +1227,19 @@ Reduction JSTypedLowering::ReduceJSCreateWithContext(Node* node) {
|
| Reduction JSTypedLowering::ReduceJSCreateBlockContext(Node* node) {
|
| DCHECK_EQ(IrOpcode::kJSCreateBlockContext, node->opcode());
|
| Node* const input = NodeProperties::GetValueInput(node, 0);
|
| + Node* const closure = NodeProperties::GetValueInput(node, 1);
|
| HeapObjectMatcher minput(input);
|
| DCHECK(minput.HasValue()); // TODO(mstarzinger): Make ScopeInfo static.
|
| int context_length =
|
| Handle<ScopeInfo>::cast(minput.Value().handle())->ContextLength();
|
| - if (FLAG_turbo_allocate && context_length < kBlockContextAllocationLimit) {
|
| + // The closure can be NumberConstant(0) if the closure is global code
|
| + // (rather than a function). We exclude that case here.
|
| + // TODO(jarin) Find a better way to check that the closure is a function.
|
| + if (FLAG_turbo_allocate && context_length < kBlockContextAllocationLimit &&
|
| + closure->opcode() != IrOpcode::kNumberConstant) {
|
| // JSCreateBlockContext(s:scope[length < limit], f)
|
| Node* const effect = NodeProperties::GetEffectInput(node);
|
| Node* const control = NodeProperties::GetControlInput(node);
|
| - Node* const closure = NodeProperties::GetValueInput(node, 1);
|
| Node* const context = NodeProperties::GetContextInput(node);
|
| Node* const load = graph()->NewNode(
|
| simplified()->LoadField(
|
|
|