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/js-type-feedback.h" | 10 #include "src/compiler/js-type-feedback.h" |
(...skipping 1621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1632 case ObjectLiteral::Property::SETTER: { | 1632 case ObjectLiteral::Property::SETTER: { |
1633 Node* attr = jsgraph()->Constant(DONT_ENUM); | 1633 Node* attr = jsgraph()->Constant(DONT_ENUM); |
1634 const Operator* op = javascript()->CallRuntime( | 1634 const Operator* op = javascript()->CallRuntime( |
1635 Runtime::kDefineSetterPropertyUnchecked, 4); | 1635 Runtime::kDefineSetterPropertyUnchecked, 4); |
1636 NewNode(op, receiver, key, value, attr); | 1636 NewNode(op, receiver, key, value, attr); |
1637 break; | 1637 break; |
1638 } | 1638 } |
1639 } | 1639 } |
1640 } | 1640 } |
1641 | 1641 |
1642 // Transform both the class literal and the prototype to fast properties. | 1642 // Set both the prototype and constructor to have fast properties, and also |
1643 const Operator* op = javascript()->CallRuntime(Runtime::kToFastProperties, 1); | 1643 // freeze them in strong mode. |
1644 NewNode(op, environment()->Pop()); // prototype | 1644 environment()->Pop(); // proto |
1645 NewNode(op, environment()->Pop()); // literal | 1645 environment()->Pop(); // literal |
1646 if (is_strong(language_mode())) { | 1646 const Operator* op = javascript()->CallRuntime( |
1647 // TODO(conradw): It would be more efficient to define the properties with | 1647 is_strong(language_mode()) ? Runtime::kFinalizeClassDefinitionStrong |
1648 // the right attributes the first time round. | 1648 : Runtime::kFinalizeClassDefinition, |
1649 // Freeze the prototype. | 1649 2); |
1650 proto = | 1650 literal = NewNode(op, literal, proto); |
1651 NewNode(javascript()->CallRuntime(Runtime::kObjectFreeze, 1), proto); | |
1652 // Freezing the prototype should never deopt. | |
1653 PrepareFrameState(proto, BailoutId::None()); | |
1654 // Freeze the constructor. | |
1655 literal = | |
1656 NewNode(javascript()->CallRuntime(Runtime::kObjectFreeze, 1), literal); | |
1657 // Freezing the constructor should never deopt. | |
1658 PrepareFrameState(literal, BailoutId::None()); | |
1659 } | |
1660 | 1651 |
1661 // Assign to class variable. | 1652 // Assign to class variable. |
1662 if (expr->scope() != NULL) { | 1653 if (expr->scope() != NULL) { |
1663 DCHECK_NOT_NULL(expr->class_variable_proxy()); | 1654 DCHECK_NOT_NULL(expr->class_variable_proxy()); |
1664 Variable* var = expr->class_variable_proxy()->var(); | 1655 Variable* var = expr->class_variable_proxy()->var(); |
1665 FrameStateBeforeAndAfter states(this, BailoutId::None()); | 1656 FrameStateBeforeAndAfter states(this, BailoutId::None()); |
1666 VectorSlotPair feedback = | 1657 VectorSlotPair feedback = |
1667 CreateVectorSlotPair(FLAG_vector_stores && var->IsUnallocated() | 1658 CreateVectorSlotPair(FLAG_vector_stores && var->IsUnallocated() |
1668 ? expr->GetNthSlot(store_slot_index++) | 1659 ? expr->GetNthSlot(store_slot_index++) |
1669 : FeedbackVectorICSlot::Invalid()); | 1660 : FeedbackVectorICSlot::Invalid()); |
(...skipping 2644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4314 // Phi does not exist yet, introduce one. | 4305 // Phi does not exist yet, introduce one. |
4315 value = NewPhi(inputs, value, control); | 4306 value = NewPhi(inputs, value, control); |
4316 value->ReplaceInput(inputs - 1, other); | 4307 value->ReplaceInput(inputs - 1, other); |
4317 } | 4308 } |
4318 return value; | 4309 return value; |
4319 } | 4310 } |
4320 | 4311 |
4321 } // namespace compiler | 4312 } // namespace compiler |
4322 } // namespace internal | 4313 } // namespace internal |
4323 } // namespace v8 | 4314 } // namespace v8 |
OLD | NEW |