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/ast-graph-builder.h" | 5 #include "src/compiler/ast-graph-builder.h" |
6 | 6 |
7 #include "src/compiler.h" | 7 #include "src/compiler.h" |
8 #include "src/compiler/ast-loop-assignment-analyzer.h" | 8 #include "src/compiler/ast-loop-assignment-analyzer.h" |
9 #include "src/compiler/control-builders.h" | 9 #include "src/compiler/control-builders.h" |
10 #include "src/compiler/linkage.h" | 10 #include "src/compiler/linkage.h" |
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
454 InitializeAstVisitor(info->isolate()); | 454 InitializeAstVisitor(info->isolate()); |
455 } | 455 } |
456 | 456 |
457 | 457 |
458 Node* AstGraphBuilder::GetFunctionClosureForContext() { | 458 Node* AstGraphBuilder::GetFunctionClosureForContext() { |
459 Scope* closure_scope = current_scope()->ClosureScope(); | 459 Scope* closure_scope = current_scope()->ClosureScope(); |
460 if (closure_scope->is_script_scope() || | 460 if (closure_scope->is_script_scope() || |
461 closure_scope->is_module_scope()) { | 461 closure_scope->is_module_scope()) { |
462 // Contexts nested in the native context have a canonical empty function as | 462 // Contexts nested in the native context have a canonical empty function as |
463 // their closure, not the anonymous closure containing the global code. | 463 // their closure, not the anonymous closure containing the global code. |
464 // Pass a SMI sentinel and let the runtime look up the empty function. | 464 return BuildLoadNativeContextField(Context::CLOSURE_INDEX); |
465 return jsgraph()->SmiConstant(0); | |
466 } else { | 465 } else { |
467 DCHECK(closure_scope->is_function_scope()); | 466 DCHECK(closure_scope->is_function_scope()); |
468 return GetFunctionClosure(); | 467 return GetFunctionClosure(); |
469 } | 468 } |
470 } | 469 } |
471 | 470 |
472 | 471 |
473 Node* AstGraphBuilder::GetFunctionClosure() { | 472 Node* AstGraphBuilder::GetFunctionClosure() { |
474 if (!function_closure_.is_set()) { | 473 if (!function_closure_.is_set()) { |
475 int index = Linkage::kJSCallClosureParamIndex; | 474 int index = Linkage::kJSCallClosureParamIndex; |
(...skipping 3829 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4305 // Phi does not exist yet, introduce one. | 4304 // Phi does not exist yet, introduce one. |
4306 value = NewPhi(inputs, value, control); | 4305 value = NewPhi(inputs, value, control); |
4307 value->ReplaceInput(inputs - 1, other); | 4306 value->ReplaceInput(inputs - 1, other); |
4308 } | 4307 } |
4309 return value; | 4308 return value; |
4310 } | 4309 } |
4311 | 4310 |
4312 } // namespace compiler | 4311 } // namespace compiler |
4313 } // namespace internal | 4312 } // namespace internal |
4314 } // namespace v8 | 4313 } // namespace v8 |
OLD | NEW |