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

Side by Side Diff: src/full-codegen/ia32/full-codegen-ia32.cc

Issue 2330473002: Class fields, part 3 (backends)
Patch Set: bytecode test Created 4 years, 3 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
« no previous file with comments | « src/full-codegen/full-codegen.cc ('k') | src/full-codegen/mips/full-codegen-mips.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_IA32 5 #if V8_TARGET_ARCH_IA32
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 1879 matching lines...) Expand 10 before | Expand all | Expand 10 after
1890 __ bind(&done); 1890 __ bind(&done);
1891 context()->Plug(eax); 1891 context()->Plug(eax);
1892 } 1892 }
1893 1893
1894 1894
1895 void FullCodeGenerator::EmitClassDefineProperties(ClassLiteral* lit) { 1895 void FullCodeGenerator::EmitClassDefineProperties(ClassLiteral* lit) {
1896 for (int i = 0; i < lit->properties()->length(); i++) { 1896 for (int i = 0; i < lit->properties()->length(); i++) {
1897 ClassLiteral::Property* property = lit->properties()->at(i); 1897 ClassLiteral::Property* property = lit->properties()->at(i);
1898 Expression* value = property->value(); 1898 Expression* value = property->value();
1899 1899
1900 if (property->kind() == ClassLiteral::Property::FIELD &&
1901 !property->is_static()) {
1902 // Non-static properties produced by the parser have as their 'key' an
1903 // expression producing their name and as their 'value' a variable which
1904 // is refered to by the synthetic initializer function in order to
1905 // determine the name during class instantiation. This is necessary
1906 // because computed names must only be evaluated once, at class definition
1907 // time.
1908 // That is, code which looks like `class C { [f()] = 1; }` is desugared
1909 // into something like
1910 // class C { constructor(){ this.[.class-field-0-name] = 1; } };
1911 // let .class-field-0-name = f();
1912 // except that the assignment to .class-field-name-0 occurs interleaved
1913 // with the rest of the class body; it is performed by the block in which
1914 // this comment appears.
1915 DCHECK(property->value()->IsVariableProxy());
1916 Variable* variable = property->value()->AsVariableProxy()->var();
1917 VisitForStackValue(property->key());
1918 EmitVariableAssignment(variable, Token::INIT,
1919 FeedbackVectorSlot::Invalid());
1920 DropOperands(1);
1921 continue;
1922 }
1923
1900 if (property->is_static()) { 1924 if (property->is_static()) {
1901 PushOperand(Operand(esp, kPointerSize)); // constructor 1925 PushOperand(Operand(esp, kPointerSize)); // constructor
1902 } else { 1926 } else {
1903 PushOperand(Operand(esp, 0)); // prototype 1927 PushOperand(Operand(esp, 0)); // prototype
1904 } 1928 }
1905 EmitPropertyKey(property, lit->GetIdForProperty(i)); 1929 EmitPropertyKey(property, lit->GetIdForProperty(i));
1906 1930
1907 // The static prototype property is read only. We handle the non computed 1931 // The static prototype property is read only. We handle the non computed
1908 // property name case in the parser. Since this is the only case where we 1932 // property name case in the parser. Since this is the only case where we
1909 // need to check for an own read only property we special case this so we do 1933 // need to check for an own read only property we special case this so we do
(...skipping 19 matching lines...) Expand all
1929 PushOperand(Smi::FromInt(DONT_ENUM)); 1953 PushOperand(Smi::FromInt(DONT_ENUM));
1930 CallRuntimeWithOperands(Runtime::kDefineGetterPropertyUnchecked); 1954 CallRuntimeWithOperands(Runtime::kDefineGetterPropertyUnchecked);
1931 break; 1955 break;
1932 1956
1933 case ClassLiteral::Property::SETTER: 1957 case ClassLiteral::Property::SETTER:
1934 PushOperand(Smi::FromInt(DONT_ENUM)); 1958 PushOperand(Smi::FromInt(DONT_ENUM));
1935 CallRuntimeWithOperands(Runtime::kDefineSetterPropertyUnchecked); 1959 CallRuntimeWithOperands(Runtime::kDefineSetterPropertyUnchecked);
1936 break; 1960 break;
1937 1961
1938 case ClassLiteral::Property::FIELD: 1962 case ClassLiteral::Property::FIELD:
1939 UNREACHABLE(); 1963 DCHECK(property->is_static());
1964 PushOperand(Smi::FromInt(DONT_ENUM));
1965 PushOperand(Smi::FromInt(property->NeedsSetFunctionName()));
1966 CallRuntimeWithOperands(Runtime::kDefineDataPropertyInLiteral);
1940 break; 1967 break;
1941 } 1968 }
1942 } 1969 }
1943 } 1970 }
1944 1971
1945 1972
1946 void FullCodeGenerator::EmitBinaryOp(BinaryOperation* expr, Token::Value op) { 1973 void FullCodeGenerator::EmitBinaryOp(BinaryOperation* expr, Token::Value op) {
1947 PopOperand(edx); 1974 PopOperand(edx);
1948 Handle<Code> code = CodeFactory::BinaryOpIC(isolate(), op).code(); 1975 Handle<Code> code = CodeFactory::BinaryOpIC(isolate(), op).code();
1949 JumpPatchSite patch_site(masm_); // unbound, signals no inlined smi code. 1976 JumpPatchSite patch_site(masm_); // unbound, signals no inlined smi code.
(...skipping 1681 matching lines...) Expand 10 before | Expand all | Expand 10 after
3631 isolate->builtins()->OnStackReplacement()->entry(), 3658 isolate->builtins()->OnStackReplacement()->entry(),
3632 Assembler::target_address_at(call_target_address, unoptimized_code)); 3659 Assembler::target_address_at(call_target_address, unoptimized_code));
3633 return ON_STACK_REPLACEMENT; 3660 return ON_STACK_REPLACEMENT;
3634 } 3661 }
3635 3662
3636 3663
3637 } // namespace internal 3664 } // namespace internal
3638 } // namespace v8 3665 } // namespace v8
3639 3666
3640 #endif // V8_TARGET_ARCH_IA32 3667 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/full-codegen/full-codegen.cc ('k') | src/full-codegen/mips/full-codegen-mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698