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/compilation-dependencies.h" | 6 #include "src/compilation-dependencies.h" |
7 #include "src/compiler/access-builder.h" | 7 #include "src/compiler/access-builder.h" |
8 #include "src/compiler/js-graph.h" | 8 #include "src/compiler/js-graph.h" |
9 #include "src/compiler/js-typed-lowering.h" | 9 #include "src/compiler/js-typed-lowering.h" |
10 #include "src/compiler/linkage.h" | 10 #include "src/compiler/linkage.h" |
(...skipping 1327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1338 Type* const target_type = NodeProperties::GetType(target); | 1338 Type* const target_type = NodeProperties::GetType(target); |
1339 Node* const new_target = NodeProperties::GetValueInput(node, 1); | 1339 Node* const new_target = NodeProperties::GetValueInput(node, 1); |
1340 Node* const effect = NodeProperties::GetEffectInput(node); | 1340 Node* const effect = NodeProperties::GetEffectInput(node); |
1341 // TODO(turbofan): Add support for NewTarget passed to JSCreate. | 1341 // TODO(turbofan): Add support for NewTarget passed to JSCreate. |
1342 if (target != new_target) return NoChange(); | 1342 if (target != new_target) return NoChange(); |
1343 // Extract constructor function. | 1343 // Extract constructor function. |
1344 if (target_type->IsConstant() && | 1344 if (target_type->IsConstant() && |
1345 target_type->AsConstant()->Value()->IsJSFunction()) { | 1345 target_type->AsConstant()->Value()->IsJSFunction()) { |
1346 Handle<JSFunction> constructor = | 1346 Handle<JSFunction> constructor = |
1347 Handle<JSFunction>::cast(target_type->AsConstant()->Value()); | 1347 Handle<JSFunction>::cast(target_type->AsConstant()->Value()); |
| 1348 // Check that function is a constructor. |
| 1349 if (!constructor->IsConstructor()) return NoChange(); |
1348 // Force completion of inobject slack tracking before | 1350 // Force completion of inobject slack tracking before |
1349 // generating code to finalize the instance size. | 1351 // generating code to finalize the instance size. |
1350 if (constructor->IsInobjectSlackTrackingInProgress()) { | 1352 if (constructor->IsInobjectSlackTrackingInProgress()) { |
1351 constructor->CompleteInobjectSlackTracking(); | 1353 constructor->CompleteInobjectSlackTracking(); |
1352 } | 1354 } |
1353 | 1355 |
1354 // TODO(bmeurer): We fall back to the runtime in case we cannot inline | 1356 // TODO(bmeurer): We fall back to the runtime in case we cannot inline |
1355 // the allocation here, which is sort of expensive. We should think about | 1357 // the allocation here, which is sort of expensive. We should think about |
1356 // a soft fallback to some NewObjectCodeStub. | 1358 // a soft fallback to some NewObjectCodeStub. |
1357 if (IsAllocationInlineable(constructor)) { | 1359 if (IsAllocationInlineable(constructor)) { |
(...skipping 1008 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2366 } | 2368 } |
2367 | 2369 |
2368 | 2370 |
2369 CompilationDependencies* JSTypedLowering::dependencies() const { | 2371 CompilationDependencies* JSTypedLowering::dependencies() const { |
2370 return dependencies_; | 2372 return dependencies_; |
2371 } | 2373 } |
2372 | 2374 |
2373 } // namespace compiler | 2375 } // namespace compiler |
2374 } // namespace internal | 2376 } // namespace internal |
2375 } // namespace v8 | 2377 } // namespace v8 |
OLD | NEW |