OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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_X87 | 5 #if V8_TARGET_ARCH_X87 |
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 1871 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1882 __ bind(&done); | 1882 __ bind(&done); |
1883 context()->Plug(eax); | 1883 context()->Plug(eax); |
1884 } | 1884 } |
1885 | 1885 |
1886 | 1886 |
1887 void FullCodeGenerator::EmitClassDefineProperties(ClassLiteral* lit) { | 1887 void FullCodeGenerator::EmitClassDefineProperties(ClassLiteral* lit) { |
1888 for (int i = 0; i < lit->properties()->length(); i++) { | 1888 for (int i = 0; i < lit->properties()->length(); i++) { |
1889 ClassLiteral::Property* property = lit->properties()->at(i); | 1889 ClassLiteral::Property* property = lit->properties()->at(i); |
1890 Expression* value = property->value(); | 1890 Expression* value = property->value(); |
1891 | 1891 |
| 1892 if (property->kind() == ClassLiteral::Property::FIELD && |
| 1893 !property->is_static()) { |
| 1894 // Non-static properties produced by the parser have as their 'key' an |
| 1895 // expression producing their name and as their 'value' a variable which |
| 1896 // is refered to by the synthetic initializer function in order to |
| 1897 // determine the name during class instantiation. This is necessary |
| 1898 // because computed names must only be evaluated once, at class definition |
| 1899 // time. |
| 1900 // That is, code which looks like `class C { [f()] = 1; }` is desugared |
| 1901 // into something like |
| 1902 // class C { constructor(){ this.[.class-field-0-name] = 1; } }; |
| 1903 // let .class-field-0-name = f(); |
| 1904 // except that the assignment to .class-field-name-0 occurs interleaved |
| 1905 // with the rest of the class body; it is performed by the block in which |
| 1906 // this comment appears. |
| 1907 DCHECK(property->value()->IsVariableProxy()); |
| 1908 Variable* variable = property->value()->AsVariableProxy()->var(); |
| 1909 VisitForStackValue(property->key()); |
| 1910 EmitVariableAssignment(variable, Token::INIT, |
| 1911 FeedbackVectorSlot::Invalid()); |
| 1912 DropOperands(1); |
| 1913 continue; |
| 1914 } |
| 1915 |
1892 if (property->is_static()) { | 1916 if (property->is_static()) { |
1893 PushOperand(Operand(esp, kPointerSize)); // constructor | 1917 PushOperand(Operand(esp, kPointerSize)); // constructor |
1894 } else { | 1918 } else { |
1895 PushOperand(Operand(esp, 0)); // prototype | 1919 PushOperand(Operand(esp, 0)); // prototype |
1896 } | 1920 } |
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 |
1900 // property name case in the parser. Since this is the only case where we | 1924 // property name case in the parser. Since this is the only case where we |
1901 // need to check for an own read only property we special case this so we do | 1925 // need to check for an own read only property we special case this so we do |
(...skipping 19 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 UNREACHABLE(); | 1955 DCHECK(property->is_static()); |
| 1956 PushOperand(Smi::FromInt(DONT_ENUM)); |
| 1957 PushOperand(Smi::FromInt(property->NeedsSetFunctionName())); |
| 1958 CallRuntimeWithOperands(Runtime::kDefineDataPropertyInLiteral); |
1932 break; | 1959 break; |
1933 } | 1960 } |
1934 } | 1961 } |
1935 } | 1962 } |
1936 | 1963 |
1937 | 1964 |
1938 void FullCodeGenerator::EmitBinaryOp(BinaryOperation* expr, Token::Value op) { | 1965 void FullCodeGenerator::EmitBinaryOp(BinaryOperation* expr, Token::Value op) { |
1939 PopOperand(edx); | 1966 PopOperand(edx); |
1940 Handle<Code> code = CodeFactory::BinaryOpIC(isolate(), op).code(); | 1967 Handle<Code> code = CodeFactory::BinaryOpIC(isolate(), op).code(); |
1941 JumpPatchSite patch_site(masm_); // unbound, signals no inlined smi code. | 1968 JumpPatchSite patch_site(masm_); // unbound, signals no inlined smi code. |
(...skipping 1681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3623 isolate->builtins()->OnStackReplacement()->entry(), | 3650 isolate->builtins()->OnStackReplacement()->entry(), |
3624 Assembler::target_address_at(call_target_address, unoptimized_code)); | 3651 Assembler::target_address_at(call_target_address, unoptimized_code)); |
3625 return ON_STACK_REPLACEMENT; | 3652 return ON_STACK_REPLACEMENT; |
3626 } | 3653 } |
3627 | 3654 |
3628 | 3655 |
3629 } // namespace internal | 3656 } // namespace internal |
3630 } // namespace v8 | 3657 } // namespace v8 |
3631 | 3658 |
3632 #endif // V8_TARGET_ARCH_X87 | 3659 #endif // V8_TARGET_ARCH_X87 |
OLD | NEW |