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

Side by Side Diff: src/full-codegen/arm/full-codegen-arm.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/compiler/ast-graph-builder.cc ('k') | src/full-codegen/arm64/full-codegen-arm64.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_ARM 5 #if V8_TARGET_ARCH_ARM
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 1968 matching lines...) Expand 10 before | Expand all | Expand 10 after
1979 __ bind(&done); 1979 __ bind(&done);
1980 context()->Plug(r0); 1980 context()->Plug(r0);
1981 } 1981 }
1982 1982
1983 1983
1984 void FullCodeGenerator::EmitClassDefineProperties(ClassLiteral* lit) { 1984 void FullCodeGenerator::EmitClassDefineProperties(ClassLiteral* lit) {
1985 for (int i = 0; i < lit->properties()->length(); i++) { 1985 for (int i = 0; i < lit->properties()->length(); i++) {
1986 ClassLiteral::Property* property = lit->properties()->at(i); 1986 ClassLiteral::Property* property = lit->properties()->at(i);
1987 Expression* value = property->value(); 1987 Expression* value = property->value();
1988 1988
1989 if (property->kind() == ClassLiteral::Property::FIELD &&
1990 !property->is_static()) {
1991 // Non-static properties produced by the parser have as their 'key' an
1992 // expression producing their name and as their 'value' a variable which
1993 // is refered to by the synthetic initializer function in order to
1994 // determine the name during class instantiation. This is necessary
1995 // because computed names must only be evaluated once, at class definition
1996 // time.
1997 // That is, code which looks like `class C { [f()] = 1; }` is desugared
1998 // into something like
1999 // class C { constructor(){ this.[.class-field-0-name] = 1; } };
2000 // let .class-field-0-name = f();
2001 // except that the assignment to .class-field-name-0 occurs interleaved
2002 // with the rest of the class body; it is performed by the block in which
2003 // this comment appears.
2004 DCHECK(property->value()->IsVariableProxy());
2005 Variable* variable = property->value()->AsVariableProxy()->var();
2006 VisitForStackValue(property->key());
2007 EmitVariableAssignment(variable, Token::INIT,
2008 FeedbackVectorSlot::Invalid());
2009 DropOperands(1);
2010 continue;
2011 }
2012
1989 Register scratch = r1; 2013 Register scratch = r1;
1990 if (property->is_static()) { 2014 if (property->is_static()) {
1991 __ ldr(scratch, MemOperand(sp, kPointerSize)); // constructor 2015 __ ldr(scratch, MemOperand(sp, kPointerSize)); // constructor
1992 } else { 2016 } else {
1993 __ ldr(scratch, MemOperand(sp, 0)); // prototype 2017 __ ldr(scratch, MemOperand(sp, 0)); // prototype
1994 } 2018 }
1995 PushOperand(scratch); 2019 PushOperand(scratch);
1996 EmitPropertyKey(property, lit->GetIdForProperty(i)); 2020 EmitPropertyKey(property, lit->GetIdForProperty(i));
1997 2021
1998 // The static prototype property is read only. We handle the non computed 2022 // The static prototype property is read only. We handle the non computed
(...skipping 21 matching lines...) Expand all
2020 PushOperand(Smi::FromInt(DONT_ENUM)); 2044 PushOperand(Smi::FromInt(DONT_ENUM));
2021 CallRuntimeWithOperands(Runtime::kDefineGetterPropertyUnchecked); 2045 CallRuntimeWithOperands(Runtime::kDefineGetterPropertyUnchecked);
2022 break; 2046 break;
2023 2047
2024 case ClassLiteral::Property::SETTER: 2048 case ClassLiteral::Property::SETTER:
2025 PushOperand(Smi::FromInt(DONT_ENUM)); 2049 PushOperand(Smi::FromInt(DONT_ENUM));
2026 CallRuntimeWithOperands(Runtime::kDefineSetterPropertyUnchecked); 2050 CallRuntimeWithOperands(Runtime::kDefineSetterPropertyUnchecked);
2027 break; 2051 break;
2028 2052
2029 case ClassLiteral::Property::FIELD: 2053 case ClassLiteral::Property::FIELD:
2030 default: 2054 DCHECK(property->is_static());
2031 UNREACHABLE(); 2055 PushOperand(Smi::FromInt(DONT_ENUM));
2056 PushOperand(Smi::FromInt(property->NeedsSetFunctionName()));
2057 CallRuntimeWithOperands(Runtime::kDefineDataPropertyInLiteral);
2058 break;
2032 } 2059 }
2033 } 2060 }
2034 } 2061 }
2035 2062
2036 2063
2037 void FullCodeGenerator::EmitBinaryOp(BinaryOperation* expr, Token::Value op) { 2064 void FullCodeGenerator::EmitBinaryOp(BinaryOperation* expr, Token::Value op) {
2038 PopOperand(r1); 2065 PopOperand(r1);
2039 Handle<Code> code = CodeFactory::BinaryOpIC(isolate(), op).code(); 2066 Handle<Code> code = CodeFactory::BinaryOpIC(isolate(), op).code();
2040 JumpPatchSite patch_site(masm_); // unbound, signals no inlined smi code. 2067 JumpPatchSite patch_site(masm_); // unbound, signals no inlined smi code.
2041 CallIC(code, expr->BinaryOperationFeedbackId()); 2068 CallIC(code, expr->BinaryOperationFeedbackId());
(...skipping 1756 matching lines...) Expand 10 before | Expand all | Expand 10 after
3798 DCHECK(interrupt_address == 3825 DCHECK(interrupt_address ==
3799 isolate->builtins()->OnStackReplacement()->entry()); 3826 isolate->builtins()->OnStackReplacement()->entry());
3800 return ON_STACK_REPLACEMENT; 3827 return ON_STACK_REPLACEMENT;
3801 } 3828 }
3802 3829
3803 3830
3804 } // namespace internal 3831 } // namespace internal
3805 } // namespace v8 3832 } // namespace v8
3806 3833
3807 #endif // V8_TARGET_ARCH_ARM 3834 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « src/compiler/ast-graph-builder.cc ('k') | src/full-codegen/arm64/full-codegen-arm64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698