OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 #if V8_TARGET_ARCH_ARM64 | 5 #if V8_TARGET_ARCH_ARM64 |
6 | 6 |
7 #include "src/full-codegen/full-codegen.h" | 7 #include "src/full-codegen/full-codegen.h" |
8 #include "src/ast/compile-time-value.h" | 8 #include "src/ast/compile-time-value.h" |
9 #include "src/ast/scopes.h" | 9 #include "src/ast/scopes.h" |
10 #include "src/code-factory.h" | 10 #include "src/code-factory.h" |
(...skipping 1869 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1880 } | 1880 } |
1881 context()->Plug(x0); | 1881 context()->Plug(x0); |
1882 } | 1882 } |
1883 | 1883 |
1884 | 1884 |
1885 void FullCodeGenerator::EmitClassDefineProperties(ClassLiteral* lit) { | 1885 void FullCodeGenerator::EmitClassDefineProperties(ClassLiteral* lit) { |
1886 for (int i = 0; i < lit->properties()->length(); i++) { | 1886 for (int i = 0; i < lit->properties()->length(); i++) { |
1887 ClassLiteral::Property* property = lit->properties()->at(i); | 1887 ClassLiteral::Property* property = lit->properties()->at(i); |
1888 Expression* value = property->value(); | 1888 Expression* value = property->value(); |
1889 | 1889 |
| 1890 if (property->kind() == ClassLiteral::Property::FIELD && |
| 1891 !property->is_static()) { |
| 1892 // Non-static properties produced by the parser have as their 'key' an |
| 1893 // expression producing their name and as their 'value' a variable which |
| 1894 // is refered to by the synthetic initializer function in order to |
| 1895 // determine the name during class instantiation. This is necessary |
| 1896 // because computed names must only be evaluated once, at class definition |
| 1897 // time. |
| 1898 // That is, code which looks like `class C { [f()] = 1; }` is desugared |
| 1899 // into something like |
| 1900 // class C { constructor(){ this.[.class-field-0-name] = 1; } }; |
| 1901 // let .class-field-0-name = f(); |
| 1902 // except that the assignment to .class-field-name-0 occurs interleaved |
| 1903 // with the rest of the class body; it is performed by the block in which |
| 1904 // this comment appears. |
| 1905 DCHECK(property->value()->IsVariableProxy()); |
| 1906 Variable* variable = property->value()->AsVariableProxy()->var(); |
| 1907 VisitForStackValue(property->key()); |
| 1908 EmitVariableAssignment(variable, Token::INIT, |
| 1909 FeedbackVectorSlot::Invalid()); |
| 1910 DropOperands(1); |
| 1911 continue; |
| 1912 } |
| 1913 |
1890 Register scratch = x1; | 1914 Register scratch = x1; |
1891 if (property->is_static()) { | 1915 if (property->is_static()) { |
1892 __ Peek(scratch, kPointerSize); // constructor | 1916 __ Peek(scratch, kPointerSize); // constructor |
1893 } else { | 1917 } else { |
1894 __ Peek(scratch, 0); // prototype | 1918 __ Peek(scratch, 0); // prototype |
1895 } | 1919 } |
1896 PushOperand(scratch); | 1920 PushOperand(scratch); |
1897 EmitPropertyKey(property, lit->GetIdForProperty(i)); | 1921 EmitPropertyKey(property, lit->GetIdForProperty(i)); |
1898 | 1922 |
1899 // The static prototype property is read only. We handle the non computed | 1923 // The static prototype property is read only. We handle the non computed |
(...skipping 21 matching lines...) Expand all Loading... |
1921 PushOperand(Smi::FromInt(DONT_ENUM)); | 1945 PushOperand(Smi::FromInt(DONT_ENUM)); |
1922 CallRuntimeWithOperands(Runtime::kDefineGetterPropertyUnchecked); | 1946 CallRuntimeWithOperands(Runtime::kDefineGetterPropertyUnchecked); |
1923 break; | 1947 break; |
1924 | 1948 |
1925 case ClassLiteral::Property::SETTER: | 1949 case ClassLiteral::Property::SETTER: |
1926 PushOperand(Smi::FromInt(DONT_ENUM)); | 1950 PushOperand(Smi::FromInt(DONT_ENUM)); |
1927 CallRuntimeWithOperands(Runtime::kDefineSetterPropertyUnchecked); | 1951 CallRuntimeWithOperands(Runtime::kDefineSetterPropertyUnchecked); |
1928 break; | 1952 break; |
1929 | 1953 |
1930 case ClassLiteral::Property::FIELD: | 1954 case ClassLiteral::Property::FIELD: |
1931 default: | 1955 DCHECK(property->is_static()); |
1932 UNREACHABLE(); | 1956 PushOperand(Smi::FromInt(DONT_ENUM)); |
| 1957 PushOperand(Smi::FromInt(property->NeedsSetFunctionName())); |
| 1958 CallRuntimeWithOperands(Runtime::kDefineDataPropertyInLiteral); |
| 1959 break; |
1933 } | 1960 } |
1934 } | 1961 } |
1935 } | 1962 } |
1936 | 1963 |
1937 | 1964 |
1938 void FullCodeGenerator::EmitAssignment(Expression* expr, | 1965 void FullCodeGenerator::EmitAssignment(Expression* expr, |
1939 FeedbackVectorSlot slot) { | 1966 FeedbackVectorSlot slot) { |
1940 DCHECK(expr->IsValidReferenceExpressionOrThis()); | 1967 DCHECK(expr->IsValidReferenceExpressionOrThis()); |
1941 | 1968 |
1942 Property* prop = expr->AsProperty(); | 1969 Property* prop = expr->AsProperty(); |
(...skipping 1865 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3808 } | 3835 } |
3809 | 3836 |
3810 return INTERRUPT; | 3837 return INTERRUPT; |
3811 } | 3838 } |
3812 | 3839 |
3813 | 3840 |
3814 } // namespace internal | 3841 } // namespace internal |
3815 } // namespace v8 | 3842 } // namespace v8 |
3816 | 3843 |
3817 #endif // V8_TARGET_ARCH_ARM64 | 3844 #endif // V8_TARGET_ARCH_ARM64 |
OLD | NEW |