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

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

Issue 680993003: Classes: Add basic support for properties (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: git rebase Created 6 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « src/arm/full-codegen-arm.cc ('k') | src/ast.h » ('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 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 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #if V8_TARGET_ARCH_ARM64 7 #if V8_TARGET_ARCH_ARM64
8 8
9 #include "src/code-factory.h" 9 #include "src/code-factory.h"
10 #include "src/code-stubs.h" 10 #include "src/code-stubs.h"
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 if (scope()->is_function_scope() && scope()->function() != NULL) { 293 if (scope()->is_function_scope() && scope()->function() != NULL) {
294 VariableDeclaration* function = scope()->function(); 294 VariableDeclaration* function = scope()->function();
295 DCHECK(function->proxy()->var()->mode() == CONST || 295 DCHECK(function->proxy()->var()->mode() == CONST ||
296 function->proxy()->var()->mode() == CONST_LEGACY); 296 function->proxy()->var()->mode() == CONST_LEGACY);
297 DCHECK(function->proxy()->var()->location() != Variable::UNALLOCATED); 297 DCHECK(function->proxy()->var()->location() != Variable::UNALLOCATED);
298 VisitVariableDeclaration(function); 298 VisitVariableDeclaration(function);
299 } 299 }
300 VisitDeclarations(scope()->declarations()); 300 VisitDeclarations(scope()->declarations());
301 } 301 }
302 302
303 { Comment cmnt(masm_, "[ Stack check"); 303 {
304 Comment cmnt(masm_, "[ Stack check");
304 PrepareForBailoutForId(BailoutId::Declarations(), NO_REGISTERS); 305 PrepareForBailoutForId(BailoutId::Declarations(), NO_REGISTERS);
305 Label ok; 306 Label ok;
306 DCHECK(jssp.Is(__ StackPointer())); 307 DCHECK(jssp.Is(__ StackPointer()));
307 __ CompareRoot(jssp, Heap::kStackLimitRootIndex); 308 __ CompareRoot(jssp, Heap::kStackLimitRootIndex);
308 __ B(hs, &ok); 309 __ B(hs, &ok);
309 PredictableCodeSizeScope predictable(masm_, 310 PredictableCodeSizeScope predictable(masm_,
310 Assembler::kCallSizeWithRelocation); 311 Assembler::kCallSizeWithRelocation);
311 __ Call(isolate()->builtins()->StackCheck(), RelocInfo::CODE_TARGET); 312 __ Call(isolate()->builtins()->StackCheck(), RelocInfo::CODE_TARGET);
312 __ Bind(&ok); 313 __ Bind(&ok);
313 } 314 }
314 315
315 { Comment cmnt(masm_, "[ Body"); 316 {
317 Comment cmnt(masm_, "[ Body");
316 DCHECK(loop_depth() == 0); 318 DCHECK(loop_depth() == 0);
317 VisitStatements(function()->body()); 319 VisitStatements(function()->body());
318 DCHECK(loop_depth() == 0); 320 DCHECK(loop_depth() == 0);
319 } 321 }
320 } 322 }
321 323
322 // Always emit a 'return undefined' in case control fell off the end of 324 // Always emit a 'return undefined' in case control fell off the end of
323 // the body. 325 // the body.
324 { Comment cmnt(masm_, "[ return <undefined>;"); 326 { Comment cmnt(masm_, "[ return <undefined>;");
325 __ LoadRoot(x0, Heap::kUndefinedValueRootIndex); 327 __ LoadRoot(x0, Heap::kUndefinedValueRootIndex);
(...skipping 1707 matching lines...) Expand 10 before | Expand all | Expand 10 after
2033 DCHECK(!key->value()->IsSmi()); 2035 DCHECK(!key->value()->IsSmi());
2034 DCHECK(prop->IsSuperAccess()); 2036 DCHECK(prop->IsSuperAccess());
2035 2037
2036 __ Push(key->value()); 2038 __ Push(key->value());
2037 __ CallRuntime(Runtime::kLoadFromSuper, 3); 2039 __ CallRuntime(Runtime::kLoadFromSuper, 3);
2038 } 2040 }
2039 2041
2040 2042
2041 void FullCodeGenerator::EmitKeyedPropertyLoad(Property* prop) { 2043 void FullCodeGenerator::EmitKeyedPropertyLoad(Property* prop) {
2042 SetSourcePosition(prop->position()); 2044 SetSourcePosition(prop->position());
2043 // Call keyed load IC. It has arguments key and receiver in r0 and r1. 2045 // Call keyed load IC. It has arguments key and receiver in x0 and x1.
2044 Handle<Code> ic = CodeFactory::KeyedLoadIC(isolate()).code(); 2046 Handle<Code> ic = CodeFactory::KeyedLoadIC(isolate()).code();
2045 if (FLAG_vector_ics) { 2047 if (FLAG_vector_ics) {
2046 __ Mov(VectorLoadICDescriptor::SlotRegister(), 2048 __ Mov(VectorLoadICDescriptor::SlotRegister(),
2047 SmiFromSlot(prop->PropertyFeedbackSlot())); 2049 SmiFromSlot(prop->PropertyFeedbackSlot()));
2048 CallIC(ic); 2050 CallIC(ic);
2049 } else { 2051 } else {
2050 CallIC(ic, prop->PropertyFeedbackId()); 2052 CallIC(ic, prop->PropertyFeedbackId());
2051 } 2053 }
2052 } 2054 }
2053 2055
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
2168 JumpPatchSite patch_site(masm_); // Unbound, signals no inlined smi code. 2170 JumpPatchSite patch_site(masm_); // Unbound, signals no inlined smi code.
2169 { 2171 {
2170 Assembler::BlockPoolsScope scope(masm_); 2172 Assembler::BlockPoolsScope scope(masm_);
2171 CallIC(code, expr->BinaryOperationFeedbackId()); 2173 CallIC(code, expr->BinaryOperationFeedbackId());
2172 patch_site.EmitPatchInfo(); 2174 patch_site.EmitPatchInfo();
2173 } 2175 }
2174 context()->Plug(x0); 2176 context()->Plug(x0);
2175 } 2177 }
2176 2178
2177 2179
2180 void FullCodeGenerator::EmitClassDefineProperties(ClassLiteral* lit) {
2181 // Constructor is in x0.
2182 DCHECK(lit != NULL);
2183 __ push(x0);
2184
2185 // No access check is needed here since the constructor is created by the
2186 // class literal.
2187 Register scratch = x1;
2188 __ Ldr(scratch,
2189 FieldMemOperand(x0, JSFunction::kPrototypeOrInitialMapOffset));
2190 __ Push(scratch);
2191
2192 for (int i = 0; i < lit->properties()->length(); i++) {
2193 ObjectLiteral::Property* property = lit->properties()->at(i);
2194 Literal* key = property->key()->AsLiteral();
2195 Expression* value = property->value();
2196 DCHECK(key != NULL);
2197
2198 if (property->is_static()) {
2199 __ Peek(scratch, kPointerSize); // constructor
2200 } else {
2201 __ Peek(scratch, 0); // prototype
2202 }
2203 __ Push(scratch);
2204 VisitForStackValue(key);
2205
2206 switch (property->kind()) {
2207 case ObjectLiteral::Property::CONSTANT:
2208 case ObjectLiteral::Property::MATERIALIZED_LITERAL:
2209 case ObjectLiteral::Property::COMPUTED:
2210 case ObjectLiteral::Property::PROTOTYPE:
2211 VisitForStackValue(value);
2212 __ Mov(scratch, Smi::FromInt(NONE));
2213 __ Push(scratch);
2214 __ CallRuntime(Runtime::kDefineDataPropertyUnchecked, 4);
2215 break;
2216
2217 case ObjectLiteral::Property::GETTER:
2218 VisitForStackValue(value);
2219 __ LoadRoot(scratch, Heap::kNullValueRootIndex);
2220 __ push(scratch);
2221 __ Mov(scratch, Smi::FromInt(NONE));
2222 __ Push(scratch);
2223 __ CallRuntime(Runtime::kDefineAccessorPropertyUnchecked, 5);
2224 break;
2225
2226 case ObjectLiteral::Property::SETTER:
2227 __ LoadRoot(scratch, Heap::kNullValueRootIndex);
2228 __ push(scratch);
2229 VisitForStackValue(value);
2230 __ Mov(scratch, Smi::FromInt(NONE));
2231 __ Push(scratch);
2232 __ CallRuntime(Runtime::kDefineAccessorPropertyUnchecked, 5);
2233 break;
2234
2235 default:
2236 UNREACHABLE();
2237 }
2238 }
2239
2240 // prototype
2241 __ CallRuntime(Runtime::kToFastProperties, 1);
2242
2243 // constructor
2244 __ CallRuntime(Runtime::kToFastProperties, 1);
2245 }
2246
2247
2178 void FullCodeGenerator::EmitAssignment(Expression* expr) { 2248 void FullCodeGenerator::EmitAssignment(Expression* expr) {
2179 DCHECK(expr->IsValidReferenceExpression()); 2249 DCHECK(expr->IsValidReferenceExpression());
2180 2250
2181 Property* prop = expr->AsProperty(); 2251 Property* prop = expr->AsProperty();
2182 LhsKind assign_type = GetAssignType(prop); 2252 LhsKind assign_type = GetAssignType(prop);
2183 2253
2184 switch (assign_type) { 2254 switch (assign_type) {
2185 case VARIABLE: { 2255 case VARIABLE: {
2186 Variable* var = expr->AsVariableProxy()->var(); 2256 Variable* var = expr->AsVariableProxy()->var();
2187 EffectContext context(this); 2257 EffectContext context(this);
(...skipping 2664 matching lines...) Expand 10 before | Expand all | Expand 10 after
4852 JSGeneratorObject::ResumeMode resume_mode) { 4922 JSGeneratorObject::ResumeMode resume_mode) {
4853 ASM_LOCATION("FullCodeGenerator::EmitGeneratorResume"); 4923 ASM_LOCATION("FullCodeGenerator::EmitGeneratorResume");
4854 Register value_reg = x0; 4924 Register value_reg = x0;
4855 Register generator_object = x1; 4925 Register generator_object = x1;
4856 Register the_hole = x2; 4926 Register the_hole = x2;
4857 Register operand_stack_size = w3; 4927 Register operand_stack_size = w3;
4858 Register function = x4; 4928 Register function = x4;
4859 4929
4860 // The value stays in x0, and is ultimately read by the resumed generator, as 4930 // The value stays in x0, and is ultimately read by the resumed generator, as
4861 // if CallRuntime(Runtime::kSuspendJSGeneratorObject) returned it. Or it 4931 // if CallRuntime(Runtime::kSuspendJSGeneratorObject) returned it. Or it
4862 // is read to throw the value when the resumed generator is already closed. r1 4932 // is read to throw the value when the resumed generator is already closed. x1
4863 // will hold the generator object until the activation has been resumed. 4933 // will hold the generator object until the activation has been resumed.
4864 VisitForStackValue(generator); 4934 VisitForStackValue(generator);
4865 VisitForAccumulatorValue(value); 4935 VisitForAccumulatorValue(value);
4866 __ Pop(generator_object); 4936 __ Pop(generator_object);
4867 4937
4868 // Check generator state. 4938 // Check generator state.
4869 Label wrong_state, closed_state, done; 4939 Label wrong_state, closed_state, done;
4870 __ Ldr(x10, FieldMemOperand(generator_object, 4940 __ Ldr(x10, FieldMemOperand(generator_object,
4871 JSGeneratorObject::kContinuationOffset)); 4941 JSGeneratorObject::kContinuationOffset));
4872 STATIC_ASSERT(JSGeneratorObject::kGeneratorExecuting < 0); 4942 STATIC_ASSERT(JSGeneratorObject::kGeneratorExecuting < 0);
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
5261 return previous_; 5331 return previous_;
5262 } 5332 }
5263 5333
5264 5334
5265 #undef __ 5335 #undef __
5266 5336
5267 5337
5268 } } // namespace v8::internal 5338 } } // namespace v8::internal
5269 5339
5270 #endif // V8_TARGET_ARCH_ARM64 5340 #endif // V8_TARGET_ARCH_ARM64
OLDNEW
« no previous file with comments | « src/arm/full-codegen-arm.cc ('k') | src/ast.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698