OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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-intrinsic-lowering.h" | 5 #include "src/compiler/js-intrinsic-lowering.h" |
6 | 6 |
7 #include <stack> | 7 #include <stack> |
8 | 8 |
9 #include "src/code-factory.h" | 9 #include "src/code-factory.h" |
10 #include "src/compiler/access-builder.h" | 10 #include "src/compiler/access-builder.h" |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 ConvertReceiverMode::kAny, | 307 ConvertReceiverMode::kAny, |
308 TailCallMode::kDisallow)); | 308 TailCallMode::kDisallow)); |
309 return Changed(node); | 309 return Changed(node); |
310 } | 310 } |
311 | 311 |
312 Reduction JSIntrinsicLowering::ReduceNewObject(Node* node) { | 312 Reduction JSIntrinsicLowering::ReduceNewObject(Node* node) { |
313 return Change(node, CodeFactory::FastNewObject(isolate()), 0); | 313 return Change(node, CodeFactory::FastNewObject(isolate()), 0); |
314 } | 314 } |
315 | 315 |
316 Reduction JSIntrinsicLowering::ReduceGetSuperConstructor(Node* node) { | 316 Reduction JSIntrinsicLowering::ReduceGetSuperConstructor(Node* node) { |
317 Node* target = NodeProperties::GetValueInput(node, 0); | 317 Node* active_function = NodeProperties::GetValueInput(node, 0); |
318 // The prototype of subclass constructors is non-writable, non-configurable | 318 Node* effect = NodeProperties::GetEffectInput(node); |
319 // in ES6, so we don't need to do any checking, but we can just load (or even | 319 Node* control = NodeProperties::GetControlInput(node); |
320 // constant-fold) the prototype from the {target}. | 320 Node* active_function_map = effect = |
321 HeapObjectMatcher m(target); | 321 graph()->NewNode(simplified()->LoadField(AccessBuilder::ForMap()), |
322 if (m.HasValue()) { | 322 active_function, effect, control); |
323 Handle<JSFunction> target_function = Handle<JSFunction>::cast(m.Value()); | 323 return Change(node, simplified()->LoadField(AccessBuilder::ForMapPrototype()), |
324 Node* value = jsgraph()->HeapConstant(handle( | 324 active_function_map, effect, control); |
325 JSFunction::cast(target_function->map()->prototype()), isolate())); | |
326 ReplaceWithValue(node, value); | |
327 return Replace(value); | |
328 } else { | |
329 Node* effect = NodeProperties::GetEffectInput(node); | |
330 Node* control = NodeProperties::GetControlInput(node); | |
331 Node* target_map = effect = | |
332 graph()->NewNode(simplified()->LoadField(AccessBuilder::ForMap()), | |
333 target, effect, control); | |
334 return Change(node, | |
335 simplified()->LoadField(AccessBuilder::ForMapPrototype()), | |
336 target_map, effect, control); | |
337 } | |
338 } | 325 } |
339 | 326 |
340 Reduction JSIntrinsicLowering::Change(Node* node, const Operator* op, Node* a, | 327 Reduction JSIntrinsicLowering::Change(Node* node, const Operator* op, Node* a, |
341 Node* b) { | 328 Node* b) { |
342 RelaxControls(node); | 329 RelaxControls(node); |
343 node->ReplaceInput(0, a); | 330 node->ReplaceInput(0, a); |
344 node->ReplaceInput(1, b); | 331 node->ReplaceInput(1, b); |
345 node->TrimInputCount(2); | 332 node->TrimInputCount(2); |
346 NodeProperties::ChangeOp(node, op); | 333 NodeProperties::ChangeOp(node, op); |
347 return Changed(node); | 334 return Changed(node); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 return jsgraph_->javascript(); | 386 return jsgraph_->javascript(); |
400 } | 387 } |
401 | 388 |
402 SimplifiedOperatorBuilder* JSIntrinsicLowering::simplified() const { | 389 SimplifiedOperatorBuilder* JSIntrinsicLowering::simplified() const { |
403 return jsgraph()->simplified(); | 390 return jsgraph()->simplified(); |
404 } | 391 } |
405 | 392 |
406 } // namespace compiler | 393 } // namespace compiler |
407 } // namespace internal | 394 } // namespace internal |
408 } // namespace v8 | 395 } // namespace v8 |
OLD | NEW |