Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(168)

Side by Side Diff: src/compiler/ast-graph-builder.cc

Issue 2423053002: Install the 'name' property in classes at runtime (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/ast/compile-time-value.h" 7 #include "src/ast/compile-time-value.h"
8 #include "src/ast/scopes.h" 8 #include "src/ast/scopes.h"
9 #include "src/compilation-info.h" 9 #include "src/compilation-info.h"
10 #include "src/compiler.h" 10 #include "src/compiler.h"
(...skipping 1641 matching lines...) Expand 10 before | Expand all | Expand 10 after
1652 NewNode(op, receiver, key, value, attr); 1652 NewNode(op, receiver, key, value, attr);
1653 break; 1653 break;
1654 } 1654 }
1655 case ClassLiteral::Property::FIELD: { 1655 case ClassLiteral::Property::FIELD: {
1656 UNREACHABLE(); 1656 UNREACHABLE();
1657 break; 1657 break;
1658 } 1658 }
1659 } 1659 }
1660 } 1660 }
1661 1661
1662 // ES6 section 14.5.16 class expression evaluation, step 5
1663 DCHECK(!expr->constructor()->name().is_null());
1664 // abort if 'name' is undefined
1665 if (expr->constructor()->name()->length() != 0) {
1666 // if "name" is already defined, exit
1667 environment()->Push(environment()->Peek(1)); // literal
1668 Node* receiver = environment()->Pop();
1669 Node* key = jsgraph()->Constant(isolate()->factory()->name_string());
1670 IfBuilder has_name(this);
1671 const Operator* has_name_op =
1672 javascript()->CallRuntime(Runtime::kObjectHasOwnProperty);
1673 Node* has_name_call = NewNode(has_name_op, receiver, key);
1674 PrepareFrameState(has_name_call, BailoutId::None());
1675 has_name.If(has_name_call, BranchHint::kFalse);
1676 has_name.Then();
1677 has_name.Else();
1678 {
1679 // define "name" property
1680 environment()->Push(environment()->Peek(1)); // literal
1681 Node* receiver = environment()->Pop();
1682 Node* key = jsgraph()->Constant(isolate()->factory()->name_string());
1683 Node* value = jsgraph()->Constant(expr->constructor()->name());
1684 Node* attr = jsgraph()->Constant(DONT_ENUM | READ_ONLY);
1685 Node* set_function_name = jsgraph()->Constant(0);
1686 const Operator* define_name_op =
1687 javascript()->CallRuntime(Runtime::kDefineDataPropertyInLiteral);
1688 Node* define_name_call = NewNode(define_name_op, receiver, key, value,
1689 attr, set_function_name);
1690 PrepareFrameState(define_name_call, BailoutId::None());
1691 }
1692 has_name.End();
1693 }
1694
1662 // Set the constructor to have fast properties. 1695 // Set the constructor to have fast properties.
1663 prototype = environment()->Pop(); 1696 prototype = environment()->Pop();
1664 literal = environment()->Pop(); 1697 literal = environment()->Pop();
1665 const Operator* op = javascript()->CallRuntime(Runtime::kToFastProperties); 1698 const Operator* op = javascript()->CallRuntime(Runtime::kToFastProperties);
1666 literal = NewNode(op, literal); 1699 literal = NewNode(op, literal);
1667 1700
1668 // Assign to class variable. 1701 // Assign to class variable.
1669 if (expr->class_variable_proxy() != nullptr) { 1702 if (expr->class_variable_proxy() != nullptr) {
1670 Variable* var = expr->class_variable_proxy()->var(); 1703 Variable* var = expr->class_variable_proxy()->var();
1671 VectorSlotPair feedback = CreateVectorSlotPair( 1704 VectorSlotPair feedback = CreateVectorSlotPair(
(...skipping 2652 matching lines...) Expand 10 before | Expand all | Expand 10 after
4324 // Phi does not exist yet, introduce one. 4357 // Phi does not exist yet, introduce one.
4325 value = NewPhi(inputs, value, control); 4358 value = NewPhi(inputs, value, control);
4326 value->ReplaceInput(inputs - 1, other); 4359 value->ReplaceInput(inputs - 1, other);
4327 } 4360 }
4328 return value; 4361 return value;
4329 } 4362 }
4330 4363
4331 } // namespace compiler 4364 } // namespace compiler
4332 } // namespace internal 4365 } // namespace internal
4333 } // namespace v8 4366 } // namespace v8
OLDNEW
« no previous file with comments | « src/code-stubs.cc ('k') | src/contexts.h » ('j') | src/interpreter/bytecode-generator.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698