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

Side by Side Diff: src/full-codegen/x64/full-codegen-x64.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/s390/full-codegen-s390.cc ('k') | src/full-codegen/x87/full-codegen-x87.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_X64 5 #if V8_TARGET_ARCH_X64
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 1870 matching lines...) Expand 10 before | Expand all | Expand 10 after
1881 __ bind(&done); 1881 __ bind(&done);
1882 context()->Plug(rax); 1882 context()->Plug(rax);
1883 } 1883 }
1884 1884
1885 1885
1886 void FullCodeGenerator::EmitClassDefineProperties(ClassLiteral* lit) { 1886 void FullCodeGenerator::EmitClassDefineProperties(ClassLiteral* lit) {
1887 for (int i = 0; i < lit->properties()->length(); i++) { 1887 for (int i = 0; i < lit->properties()->length(); i++) {
1888 ClassLiteral::Property* property = lit->properties()->at(i); 1888 ClassLiteral::Property* property = lit->properties()->at(i);
1889 Expression* value = property->value(); 1889 Expression* value = property->value();
1890 1890
1891 if (property->kind() == ClassLiteral::Property::FIELD &&
1892 !property->is_static()) {
1893 // Non-static properties produced by the parser have as their 'key' an
1894 // expression producing their name and as their 'value' a variable which
1895 // is refered to by the synthetic initializer function in order to
1896 // determine the name during class instantiation. This is necessary
1897 // because computed names must only be evaluated once, at class definition
1898 // time.
1899 // That is, code which looks like `class C { [f()] = 1; }` is desugared
1900 // into something like
1901 // class C { constructor(){ this.[.class-field-0-name] = 1; } };
1902 // let .class-field-0-name = f();
1903 // except that the assignment to .class-field-name-0 occurs interleaved
1904 // with the rest of the class body; it is performed by the block in which
1905 // this comment appears.
1906 DCHECK(property->value()->IsVariableProxy());
1907 Variable* variable = property->value()->AsVariableProxy()->var();
1908 VisitForStackValue(property->key());
1909 EmitVariableAssignment(variable, Token::INIT,
1910 FeedbackVectorSlot::Invalid());
1911 DropOperands(1);
1912 continue;
1913 }
1914
1891 if (property->is_static()) { 1915 if (property->is_static()) {
1892 PushOperand(Operand(rsp, kPointerSize)); // constructor 1916 PushOperand(Operand(rsp, kPointerSize)); // constructor
1893 } else { 1917 } else {
1894 PushOperand(Operand(rsp, 0)); // prototype 1918 PushOperand(Operand(rsp, 0)); // prototype
1895 } 1919 }
1896 EmitPropertyKey(property, lit->GetIdForProperty(i)); 1920 EmitPropertyKey(property, lit->GetIdForProperty(i));
1897 1921
1898 // The static prototype property is read only. We handle the non computed 1922 // The static prototype property is read only. We handle the non computed
1899 // property name case in the parser. Since this is the only case where we 1923 // property name case in the parser. Since this is the only case where we
1900 // need to check for an own read only property we special case this so we do 1924 // need to check for an own read only property we special case this so we do
(...skipping 19 matching lines...) Expand all
1920 PushOperand(Smi::FromInt(DONT_ENUM)); 1944 PushOperand(Smi::FromInt(DONT_ENUM));
1921 CallRuntimeWithOperands(Runtime::kDefineGetterPropertyUnchecked); 1945 CallRuntimeWithOperands(Runtime::kDefineGetterPropertyUnchecked);
1922 break; 1946 break;
1923 1947
1924 case ClassLiteral::Property::SETTER: 1948 case ClassLiteral::Property::SETTER:
1925 PushOperand(Smi::FromInt(DONT_ENUM)); 1949 PushOperand(Smi::FromInt(DONT_ENUM));
1926 CallRuntimeWithOperands(Runtime::kDefineSetterPropertyUnchecked); 1950 CallRuntimeWithOperands(Runtime::kDefineSetterPropertyUnchecked);
1927 break; 1951 break;
1928 1952
1929 case ClassLiteral::Property::FIELD: 1953 case ClassLiteral::Property::FIELD:
1930 default: 1954 DCHECK(property->is_static());
1931 UNREACHABLE(); 1955 PushOperand(Smi::FromInt(DONT_ENUM));
1956 PushOperand(Smi::FromInt(property->NeedsSetFunctionName()));
1957 CallRuntimeWithOperands(Runtime::kDefineDataPropertyInLiteral);
1958 break;
1932 } 1959 }
1933 } 1960 }
1934 } 1961 }
1935 1962
1936 1963
1937 void FullCodeGenerator::EmitBinaryOp(BinaryOperation* expr, Token::Value op) { 1964 void FullCodeGenerator::EmitBinaryOp(BinaryOperation* expr, Token::Value op) {
1938 PopOperand(rdx); 1965 PopOperand(rdx);
1939 Handle<Code> code = CodeFactory::BinaryOpIC(isolate(), op).code(); 1966 Handle<Code> code = CodeFactory::BinaryOpIC(isolate(), op).code();
1940 JumpPatchSite patch_site(masm_); // unbound, signals no inlined smi code. 1967 JumpPatchSite patch_site(masm_); // unbound, signals no inlined smi code.
1941 CallIC(code, expr->BinaryOperationFeedbackId()); 1968 CallIC(code, expr->BinaryOperationFeedbackId());
(...skipping 1676 matching lines...) Expand 10 before | Expand all | Expand 10 after
3618 DCHECK_EQ( 3645 DCHECK_EQ(
3619 isolate->builtins()->OnStackReplacement()->entry(), 3646 isolate->builtins()->OnStackReplacement()->entry(),
3620 Assembler::target_address_at(call_target_address, unoptimized_code)); 3647 Assembler::target_address_at(call_target_address, unoptimized_code));
3621 return ON_STACK_REPLACEMENT; 3648 return ON_STACK_REPLACEMENT;
3622 } 3649 }
3623 3650
3624 } // namespace internal 3651 } // namespace internal
3625 } // namespace v8 3652 } // namespace v8
3626 3653
3627 #endif // V8_TARGET_ARCH_X64 3654 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/full-codegen/s390/full-codegen-s390.cc ('k') | src/full-codegen/x87/full-codegen-x87.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698