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

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: 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
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 // ctor is in x0.
2182 DCHECK(lit != NULL);
2183 __ push(x0);
2184
2185 Register scratch = x1;
2186 __ Ldr(scratch,
2187 FieldMemOperand(x0, JSFunction::kPrototypeOrInitialMapOffset));
2188 __ Push(scratch);
Dmitry Lomov (no reviews) 2014/10/27 21:37:13 Comment on why access check is not needed.
arv (Not doing code reviews) 2014/10/28 09:42:00 Done.
Dmitry Lomov (no reviews) 2014/10/28 10:34:08 Acknowledged.
2189
2190 for (int i = 0; i < lit->properties()->length(); i++) {
2191 ObjectLiteral::Property* property = lit->properties()->at(i);
2192 Literal* key = property->key()->AsLiteral();
2193 Expression* value = property->value();
2194 DCHECK(key != NULL);
2195
2196 if (property->is_static()) {
2197 __ Peek(x1, kPointerSize); // constructor
Dmitry Lomov (no reviews) 2014/10/27 21:37:13 Nit: Use scratch register here.
arv (Not doing code reviews) 2014/10/28 09:42:00 Done.
Dmitry Lomov (no reviews) 2014/10/28 10:34:08 Acknowledged.
2198 } else {
2199 __ Peek(x1, 0); // prototype
2200 }
2201 __ Push(x1);
2202 VisitForStackValue(key);
2203
2204 switch (property->kind()) {
2205 case ObjectLiteral::Property::CONSTANT:
2206 case ObjectLiteral::Property::MATERIALIZED_LITERAL:
2207 case ObjectLiteral::Property::COMPUTED:
2208 case ObjectLiteral::Property::PROTOTYPE:
2209 VisitForStackValue(value);
2210 __ Mov(x0, Smi::FromInt(NONE));
2211 __ Push(x0);
2212 __ CallRuntime(Runtime::kDefineDataPropertyUnchecked, 4);
2213 break;
2214
2215 case ObjectLiteral::Property::GETTER:
2216 VisitForStackValue(value);
2217 __ LoadRoot(x0, Heap::kNullValueRootIndex);
2218 __ push(x0);
2219 __ Mov(x0, Smi::FromInt(NONE));
2220 __ Push(x0);
2221 __ CallRuntime(Runtime::kDefineAccessorPropertyUnchecked, 5);
2222 break;
2223
2224 case ObjectLiteral::Property::SETTER:
2225 __ LoadRoot(x0, Heap::kNullValueRootIndex);
2226 __ push(x0);
2227 VisitForStackValue(value);
2228 __ Mov(x0, Smi::FromInt(NONE));
2229 __ Push(x0);
2230 __ CallRuntime(Runtime::kDefineAccessorPropertyUnchecked, 5);
2231 break;
2232
2233 default:
2234 UNREACHABLE();
2235 }
2236 }
2237
2238 // prototype
2239 __ CallRuntime(Runtime::kToFastProperties, 1);
2240
2241 // constructor
2242 __ CallRuntime(Runtime::kToFastProperties, 1);
2243
2244 context()->Plug(x0);
Dmitry Lomov (no reviews) 2014/10/27 21:37:13 The caller plugs context, no need to do this here.
arv (Not doing code reviews) 2014/10/28 09:42:00 Done.
Dmitry Lomov (no reviews) 2014/10/28 10:34:08 Acknowledged.
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 2663 matching lines...) Expand 10 before | Expand all | Expand 10 after
4851 JSGeneratorObject::ResumeMode resume_mode) { 4921 JSGeneratorObject::ResumeMode resume_mode) {
4852 ASM_LOCATION("FullCodeGenerator::EmitGeneratorResume"); 4922 ASM_LOCATION("FullCodeGenerator::EmitGeneratorResume");
4853 Register value_reg = x0; 4923 Register value_reg = x0;
4854 Register generator_object = x1; 4924 Register generator_object = x1;
4855 Register the_hole = x2; 4925 Register the_hole = x2;
4856 Register operand_stack_size = w3; 4926 Register operand_stack_size = w3;
4857 Register function = x4; 4927 Register function = x4;
4858 4928
4859 // The value stays in x0, and is ultimately read by the resumed generator, as 4929 // The value stays in x0, and is ultimately read by the resumed generator, as
4860 // if CallRuntime(Runtime::kSuspendJSGeneratorObject) returned it. Or it 4930 // if CallRuntime(Runtime::kSuspendJSGeneratorObject) returned it. Or it
4861 // is read to throw the value when the resumed generator is already closed. r1 4931 // is read to throw the value when the resumed generator is already closed. x1
4862 // will hold the generator object until the activation has been resumed. 4932 // will hold the generator object until the activation has been resumed.
4863 VisitForStackValue(generator); 4933 VisitForStackValue(generator);
4864 VisitForAccumulatorValue(value); 4934 VisitForAccumulatorValue(value);
4865 __ Pop(generator_object); 4935 __ Pop(generator_object);
4866 4936
4867 // Check generator state. 4937 // Check generator state.
4868 Label wrong_state, closed_state, done; 4938 Label wrong_state, closed_state, done;
4869 __ Ldr(x10, FieldMemOperand(generator_object, 4939 __ Ldr(x10, FieldMemOperand(generator_object,
4870 JSGeneratorObject::kContinuationOffset)); 4940 JSGeneratorObject::kContinuationOffset));
4871 STATIC_ASSERT(JSGeneratorObject::kGeneratorExecuting < 0); 4941 STATIC_ASSERT(JSGeneratorObject::kGeneratorExecuting < 0);
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
5260 return previous_; 5330 return previous_;
5261 } 5331 }
5262 5332
5263 5333
5264 #undef __ 5334 #undef __
5265 5335
5266 5336
5267 } } // namespace v8::internal 5337 } } // namespace v8::internal
5268 5338
5269 #endif // V8_TARGET_ARCH_ARM64 5339 #endif // V8_TARGET_ARCH_ARM64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698