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

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

Issue 1135243004: [es6] Support super.property in eval and arrow functions (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebase Created 5 years, 7 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
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 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 type = ArgumentsAccessStub::NEW_SLOPPY_SLOW; 300 type = ArgumentsAccessStub::NEW_SLOPPY_SLOW;
301 } else { 301 } else {
302 type = ArgumentsAccessStub::NEW_SLOPPY_FAST; 302 type = ArgumentsAccessStub::NEW_SLOPPY_FAST;
303 } 303 }
304 ArgumentsAccessStub stub(isolate(), type, has_new_target); 304 ArgumentsAccessStub stub(isolate(), type, has_new_target);
305 __ CallStub(&stub); 305 __ CallStub(&stub);
306 306
307 SetVar(arguments, x0, x1, x2); 307 SetVar(arguments, x0, x1, x2);
308 } 308 }
309 309
310 // Possibly set up a local binding to the [[HomeObject]].
311 Variable* home_object_var = scope()->home_object_var();
312 if (home_object_var != nullptr) {
313 Comment cmnt(masm_, "[ Home object");
314 if (function_in_register_x1) {
315 __ Mov(LoadDescriptor::ReceiverRegister(), x1);
316 } else {
317 __ ldr(LoadDescriptor::ReceiverRegister(),
318 MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset));
319 }
320 Handle<Symbol> home_object_symbol(isolate()->heap()->home_object_symbol());
321 __ Mov(LoadDescriptor::NameRegister(), home_object_symbol);
322 if (FLAG_vector_ics) {
323 __ Mov(LoadDescriptor::SlotRegister(),
324 SmiFromSlot(function()->HomeObjectFeedbackSlot()));
325 }
326 CallLoadIC(NOT_CONTEXTUAL);
327
328 SetVar(home_object_var, x0, x1, x2);
329 }
330
310 if (FLAG_trace) { 331 if (FLAG_trace) {
311 __ CallRuntime(Runtime::kTraceEnter, 0); 332 __ CallRuntime(Runtime::kTraceEnter, 0);
312 } 333 }
313 334
314
315 // Visit the declarations and body unless there is an illegal 335 // Visit the declarations and body unless there is an illegal
316 // redeclaration. 336 // redeclaration.
317 if (scope()->HasIllegalRedeclaration()) { 337 if (scope()->HasIllegalRedeclaration()) {
318 Comment cmnt(masm_, "[ Declarations"); 338 Comment cmnt(masm_, "[ Declarations");
319 scope()->VisitIllegalRedeclaration(this); 339 scope()->VisitIllegalRedeclaration(this);
320 340
321 } else { 341 } else {
322 PrepareForBailoutForId(BailoutId::FunctionEntry(), NO_REGISTERS); 342 PrepareForBailoutForId(BailoutId::FunctionEntry(), NO_REGISTERS);
323 { Comment cmnt(masm_, "[ Declarations"); 343 { Comment cmnt(masm_, "[ Declarations");
324 if (scope()->is_function_scope() && scope()->function() != NULL) { 344 if (scope()->is_function_scope() && scope()->function() != NULL) {
(...skipping 978 matching lines...) Expand 10 before | Expand all | Expand 10 after
1303 context()->Plug(x0); 1323 context()->Plug(x0);
1304 } 1324 }
1305 1325
1306 1326
1307 void FullCodeGenerator::VisitVariableProxy(VariableProxy* expr) { 1327 void FullCodeGenerator::VisitVariableProxy(VariableProxy* expr) {
1308 Comment cmnt(masm_, "[ VariableProxy"); 1328 Comment cmnt(masm_, "[ VariableProxy");
1309 EmitVariableLoad(expr); 1329 EmitVariableLoad(expr);
1310 } 1330 }
1311 1331
1312 1332
1313 void FullCodeGenerator::EmitLoadHomeObject(SuperReference* expr) {
1314 Comment cnmt(masm_, "[ SuperReference ");
1315
1316 __ ldr(LoadDescriptor::ReceiverRegister(),
1317 MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset));
1318
1319 Handle<Symbol> home_object_symbol(isolate()->heap()->home_object_symbol());
1320 __ Mov(LoadDescriptor::NameRegister(), Operand(home_object_symbol));
1321
1322 __ Mov(LoadDescriptor::SlotRegister(),
1323 SmiFromSlot(expr->HomeObjectFeedbackSlot()));
1324 CallLoadIC(NOT_CONTEXTUAL);
1325
1326 __ Mov(x10, Operand(isolate()->factory()->undefined_value()));
1327 __ cmp(x0, x10);
1328 Label done;
1329 __ b(&done, ne);
1330 __ CallRuntime(Runtime::kThrowNonMethodError, 0);
1331 __ bind(&done);
1332 }
1333
1334
1335 void FullCodeGenerator::EmitSetHomeObjectIfNeeded(Expression* initializer, 1333 void FullCodeGenerator::EmitSetHomeObjectIfNeeded(Expression* initializer,
1336 int offset) { 1334 int offset) {
1337 if (NeedsHomeObject(initializer)) { 1335 if (NeedsHomeObject(initializer)) {
1338 __ Peek(StoreDescriptor::ReceiverRegister(), 0); 1336 __ Peek(StoreDescriptor::ReceiverRegister(), 0);
1339 __ Mov(StoreDescriptor::NameRegister(), 1337 __ Mov(StoreDescriptor::NameRegister(),
1340 Operand(isolate()->factory()->home_object_symbol())); 1338 Operand(isolate()->factory()->home_object_symbol()));
1341 __ Peek(StoreDescriptor::ValueRegister(), offset * kPointerSize); 1339 __ Peek(StoreDescriptor::ValueRegister(), offset * kPointerSize);
1342 CallStoreIC(); 1340 CallStoreIC();
1343 } 1341 }
1344 } 1342 }
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after
1921 if (expr->is_compound()) { 1919 if (expr->is_compound()) {
1922 // We need the receiver both on the stack and in the register. 1920 // We need the receiver both on the stack and in the register.
1923 VisitForStackValue(property->obj()); 1921 VisitForStackValue(property->obj());
1924 __ Peek(LoadDescriptor::ReceiverRegister(), 0); 1922 __ Peek(LoadDescriptor::ReceiverRegister(), 0);
1925 } else { 1923 } else {
1926 VisitForStackValue(property->obj()); 1924 VisitForStackValue(property->obj());
1927 } 1925 }
1928 break; 1926 break;
1929 case NAMED_SUPER_PROPERTY: 1927 case NAMED_SUPER_PROPERTY:
1930 VisitForStackValue(property->obj()->AsSuperReference()->this_var()); 1928 VisitForStackValue(property->obj()->AsSuperReference()->this_var());
1931 EmitLoadHomeObject(property->obj()->AsSuperReference()); 1929 VisitForAccumulatorValue(
1930 property->obj()->AsSuperReference()->home_object_var());
1932 __ Push(result_register()); 1931 __ Push(result_register());
1933 if (expr->is_compound()) { 1932 if (expr->is_compound()) {
1934 const Register scratch = x10; 1933 const Register scratch = x10;
1935 __ Peek(scratch, kPointerSize); 1934 __ Peek(scratch, kPointerSize);
1936 __ Push(scratch, result_register()); 1935 __ Push(scratch, result_register());
1937 } 1936 }
1938 break; 1937 break;
1939 case KEYED_SUPER_PROPERTY: 1938 case KEYED_SUPER_PROPERTY:
1940 VisitForStackValue(property->obj()->AsSuperReference()->this_var()); 1939 VisitForStackValue(property->obj()->AsSuperReference()->this_var());
1941 EmitLoadHomeObject(property->obj()->AsSuperReference()); 1940 VisitForStackValue(
1942 __ Push(result_register()); 1941 property->obj()->AsSuperReference()->home_object_var());
1943 VisitForAccumulatorValue(property->key()); 1942 VisitForAccumulatorValue(property->key());
1944 __ Push(result_register()); 1943 __ Push(result_register());
1945 if (expr->is_compound()) { 1944 if (expr->is_compound()) {
1946 const Register scratch1 = x10; 1945 const Register scratch1 = x10;
1947 const Register scratch2 = x11; 1946 const Register scratch2 = x11;
1948 __ Peek(scratch1, 2 * kPointerSize); 1947 __ Peek(scratch1, 2 * kPointerSize);
1949 __ Peek(scratch2, kPointerSize); 1948 __ Peek(scratch2, kPointerSize);
1950 __ Push(scratch1, scratch2, result_register()); 1949 __ Push(scratch1, scratch2, result_register());
1951 } 1950 }
1952 break; 1951 break;
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
2288 __ Mov(StoreDescriptor::ReceiverRegister(), x0); 2287 __ Mov(StoreDescriptor::ReceiverRegister(), x0);
2289 __ Pop(StoreDescriptor::ValueRegister()); // Restore value. 2288 __ Pop(StoreDescriptor::ValueRegister()); // Restore value.
2290 __ Mov(StoreDescriptor::NameRegister(), 2289 __ Mov(StoreDescriptor::NameRegister(),
2291 Operand(prop->key()->AsLiteral()->value())); 2290 Operand(prop->key()->AsLiteral()->value()));
2292 CallStoreIC(); 2291 CallStoreIC();
2293 break; 2292 break;
2294 } 2293 }
2295 case NAMED_SUPER_PROPERTY: { 2294 case NAMED_SUPER_PROPERTY: {
2296 __ Push(x0); 2295 __ Push(x0);
2297 VisitForStackValue(prop->obj()->AsSuperReference()->this_var()); 2296 VisitForStackValue(prop->obj()->AsSuperReference()->this_var());
2298 EmitLoadHomeObject(prop->obj()->AsSuperReference()); 2297 VisitForAccumulatorValue(
2298 prop->obj()->AsSuperReference()->home_object_var());
2299 // stack: value, this; x0: home_object 2299 // stack: value, this; x0: home_object
2300 Register scratch = x10; 2300 Register scratch = x10;
2301 Register scratch2 = x11; 2301 Register scratch2 = x11;
2302 __ mov(scratch, result_register()); // home_object 2302 __ mov(scratch, result_register()); // home_object
2303 __ Peek(x0, kPointerSize); // value 2303 __ Peek(x0, kPointerSize); // value
2304 __ Peek(scratch2, 0); // this 2304 __ Peek(scratch2, 0); // this
2305 __ Poke(scratch2, kPointerSize); // this 2305 __ Poke(scratch2, kPointerSize); // this
2306 __ Poke(scratch, 0); // home_object 2306 __ Poke(scratch, 0); // home_object
2307 // stack: this, home_object; x0: value 2307 // stack: this, home_object; x0: value
2308 EmitNamedSuperPropertyStore(prop); 2308 EmitNamedSuperPropertyStore(prop);
2309 break; 2309 break;
2310 } 2310 }
2311 case KEYED_SUPER_PROPERTY: { 2311 case KEYED_SUPER_PROPERTY: {
2312 __ Push(x0); 2312 __ Push(x0);
2313 VisitForStackValue(prop->obj()->AsSuperReference()->this_var()); 2313 VisitForStackValue(prop->obj()->AsSuperReference()->this_var());
2314 EmitLoadHomeObject(prop->obj()->AsSuperReference()); 2314 VisitForStackValue(prop->obj()->AsSuperReference()->home_object_var());
2315 __ Push(result_register());
2316 VisitForAccumulatorValue(prop->key()); 2315 VisitForAccumulatorValue(prop->key());
2317 Register scratch = x10; 2316 Register scratch = x10;
2318 Register scratch2 = x11; 2317 Register scratch2 = x11;
2319 __ Peek(scratch2, 2 * kPointerSize); // value 2318 __ Peek(scratch2, 2 * kPointerSize); // value
2320 // stack: value, this, home_object; x0: key, x11: value 2319 // stack: value, this, home_object; x0: key, x11: value
2321 __ Peek(scratch, kPointerSize); // this 2320 __ Peek(scratch, kPointerSize); // this
2322 __ Poke(scratch, 2 * kPointerSize); 2321 __ Poke(scratch, 2 * kPointerSize);
2323 __ Peek(scratch, 0); // home_object 2322 __ Peek(scratch, 0); // home_object
2324 __ Poke(scratch, kPointerSize); 2323 __ Poke(scratch, kPointerSize);
2325 __ Poke(x0, 0); 2324 __ Poke(x0, 0);
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
2520 Comment cmnt(masm_, "[ Property"); 2519 Comment cmnt(masm_, "[ Property");
2521 Expression* key = expr->key(); 2520 Expression* key = expr->key();
2522 2521
2523 if (key->IsPropertyName()) { 2522 if (key->IsPropertyName()) {
2524 if (!expr->IsSuperAccess()) { 2523 if (!expr->IsSuperAccess()) {
2525 VisitForAccumulatorValue(expr->obj()); 2524 VisitForAccumulatorValue(expr->obj());
2526 __ Move(LoadDescriptor::ReceiverRegister(), x0); 2525 __ Move(LoadDescriptor::ReceiverRegister(), x0);
2527 EmitNamedPropertyLoad(expr); 2526 EmitNamedPropertyLoad(expr);
2528 } else { 2527 } else {
2529 VisitForStackValue(expr->obj()->AsSuperReference()->this_var()); 2528 VisitForStackValue(expr->obj()->AsSuperReference()->this_var());
2530 EmitLoadHomeObject(expr->obj()->AsSuperReference()); 2529 VisitForStackValue(expr->obj()->AsSuperReference()->home_object_var());
2531 __ Push(result_register());
2532 EmitNamedSuperPropertyLoad(expr); 2530 EmitNamedSuperPropertyLoad(expr);
2533 } 2531 }
2534 } else { 2532 } else {
2535 if (!expr->IsSuperAccess()) { 2533 if (!expr->IsSuperAccess()) {
2536 VisitForStackValue(expr->obj()); 2534 VisitForStackValue(expr->obj());
2537 VisitForAccumulatorValue(expr->key()); 2535 VisitForAccumulatorValue(expr->key());
2538 __ Move(LoadDescriptor::NameRegister(), x0); 2536 __ Move(LoadDescriptor::NameRegister(), x0);
2539 __ Pop(LoadDescriptor::ReceiverRegister()); 2537 __ Pop(LoadDescriptor::ReceiverRegister());
2540 EmitKeyedPropertyLoad(expr); 2538 EmitKeyedPropertyLoad(expr);
2541 } else { 2539 } else {
2542 VisitForStackValue(expr->obj()->AsSuperReference()->this_var()); 2540 VisitForStackValue(expr->obj()->AsSuperReference()->this_var());
2543 EmitLoadHomeObject(expr->obj()->AsSuperReference()); 2541 VisitForStackValue(expr->obj()->AsSuperReference()->home_object_var());
2544 __ Push(result_register());
2545 VisitForStackValue(expr->key()); 2542 VisitForStackValue(expr->key());
2546 EmitKeyedSuperPropertyLoad(expr); 2543 EmitKeyedSuperPropertyLoad(expr);
2547 } 2544 }
2548 } 2545 }
2549 PrepareForBailoutForId(expr->LoadId(), TOS_REG); 2546 PrepareForBailoutForId(expr->LoadId(), TOS_REG);
2550 context()->Plug(x0); 2547 context()->Plug(x0);
2551 } 2548 }
2552 2549
2553 2550
2554 void FullCodeGenerator::CallIC(Handle<Code> code, 2551 void FullCodeGenerator::CallIC(Handle<Code> code,
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
2603 Property* prop = callee->AsProperty(); 2600 Property* prop = callee->AsProperty();
2604 DCHECK(prop->IsSuperAccess()); 2601 DCHECK(prop->IsSuperAccess());
2605 2602
2606 SetSourcePosition(prop->position()); 2603 SetSourcePosition(prop->position());
2607 Literal* key = prop->key()->AsLiteral(); 2604 Literal* key = prop->key()->AsLiteral();
2608 DCHECK(!key->value()->IsSmi()); 2605 DCHECK(!key->value()->IsSmi());
2609 2606
2610 // Load the function from the receiver. 2607 // Load the function from the receiver.
2611 const Register scratch = x10; 2608 const Register scratch = x10;
2612 SuperReference* super_ref = callee->AsProperty()->obj()->AsSuperReference(); 2609 SuperReference* super_ref = callee->AsProperty()->obj()->AsSuperReference();
2613 EmitLoadHomeObject(super_ref); 2610 VisitForStackValue(super_ref->home_object_var());
2614 __ Push(x0);
2615 VisitForAccumulatorValue(super_ref->this_var()); 2611 VisitForAccumulatorValue(super_ref->this_var());
2616 __ Push(x0); 2612 __ Push(x0);
2617 __ Peek(scratch, kPointerSize); 2613 __ Peek(scratch, kPointerSize);
2618 __ Push(x0, scratch); 2614 __ Push(x0, scratch);
2619 __ Push(key->value()); 2615 __ Push(key->value());
2620 2616
2621 // Stack here: 2617 // Stack here:
2622 // - home_object 2618 // - home_object
2623 // - this (receiver) 2619 // - this (receiver)
2624 // - this (receiver) <-- LoadFromSuper will pop here and below. 2620 // - this (receiver) <-- LoadFromSuper will pop here and below.
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
2663 Expression* callee = expr->expression(); 2659 Expression* callee = expr->expression();
2664 DCHECK(callee->IsProperty()); 2660 DCHECK(callee->IsProperty());
2665 Property* prop = callee->AsProperty(); 2661 Property* prop = callee->AsProperty();
2666 DCHECK(prop->IsSuperAccess()); 2662 DCHECK(prop->IsSuperAccess());
2667 2663
2668 SetSourcePosition(prop->position()); 2664 SetSourcePosition(prop->position());
2669 2665
2670 // Load the function from the receiver. 2666 // Load the function from the receiver.
2671 const Register scratch = x10; 2667 const Register scratch = x10;
2672 SuperReference* super_ref = callee->AsProperty()->obj()->AsSuperReference(); 2668 SuperReference* super_ref = callee->AsProperty()->obj()->AsSuperReference();
2673 EmitLoadHomeObject(super_ref); 2669 VisitForStackValue(super_ref->home_object_var());
2674 __ Push(x0);
2675 VisitForAccumulatorValue(super_ref->this_var()); 2670 VisitForAccumulatorValue(super_ref->this_var());
2676 __ Push(x0); 2671 __ Push(x0);
2677 __ Peek(scratch, kPointerSize); 2672 __ Peek(scratch, kPointerSize);
2678 __ Push(x0, scratch); 2673 __ Push(x0, scratch);
2679 VisitForStackValue(prop->key()); 2674 VisitForStackValue(prop->key());
2680 2675
2681 // Stack here: 2676 // Stack here:
2682 // - home_object 2677 // - home_object
2683 // - this (receiver) 2678 // - this (receiver)
2684 // - this (receiver) <-- LoadKeyedFromSuper will pop here and below. 2679 // - this (receiver) <-- LoadKeyedFromSuper will pop here and below.
(...skipping 1815 matching lines...) Expand 10 before | Expand all | Expand 10 after
4500 case NAMED_PROPERTY: { 4495 case NAMED_PROPERTY: {
4501 // Put the object both on the stack and in the register. 4496 // Put the object both on the stack and in the register.
4502 VisitForStackValue(prop->obj()); 4497 VisitForStackValue(prop->obj());
4503 __ Peek(LoadDescriptor::ReceiverRegister(), 0); 4498 __ Peek(LoadDescriptor::ReceiverRegister(), 0);
4504 EmitNamedPropertyLoad(prop); 4499 EmitNamedPropertyLoad(prop);
4505 break; 4500 break;
4506 } 4501 }
4507 4502
4508 case NAMED_SUPER_PROPERTY: { 4503 case NAMED_SUPER_PROPERTY: {
4509 VisitForStackValue(prop->obj()->AsSuperReference()->this_var()); 4504 VisitForStackValue(prop->obj()->AsSuperReference()->this_var());
4510 EmitLoadHomeObject(prop->obj()->AsSuperReference()); 4505 VisitForAccumulatorValue(
4506 prop->obj()->AsSuperReference()->home_object_var());
4511 __ Push(result_register()); 4507 __ Push(result_register());
4512 const Register scratch = x10; 4508 const Register scratch = x10;
4513 __ Peek(scratch, kPointerSize); 4509 __ Peek(scratch, kPointerSize);
4514 __ Push(scratch, result_register()); 4510 __ Push(scratch, result_register());
4515 EmitNamedSuperPropertyLoad(prop); 4511 EmitNamedSuperPropertyLoad(prop);
4516 break; 4512 break;
4517 } 4513 }
4518 4514
4519 case KEYED_SUPER_PROPERTY: { 4515 case KEYED_SUPER_PROPERTY: {
4520 VisitForStackValue(prop->obj()->AsSuperReference()->this_var()); 4516 VisitForStackValue(prop->obj()->AsSuperReference()->this_var());
4521 EmitLoadHomeObject(prop->obj()->AsSuperReference()); 4517 VisitForStackValue(prop->obj()->AsSuperReference()->home_object_var());
4522 __ Push(result_register());
4523 VisitForAccumulatorValue(prop->key()); 4518 VisitForAccumulatorValue(prop->key());
4524 __ Push(result_register()); 4519 __ Push(result_register());
4525 const Register scratch1 = x10; 4520 const Register scratch1 = x10;
4526 const Register scratch2 = x11; 4521 const Register scratch2 = x11;
4527 __ Peek(scratch1, 2 * kPointerSize); 4522 __ Peek(scratch1, 2 * kPointerSize);
4528 __ Peek(scratch2, kPointerSize); 4523 __ Peek(scratch2, kPointerSize);
4529 __ Push(scratch1, scratch2, result_register()); 4524 __ Push(scratch1, scratch2, result_register());
4530 EmitKeyedSuperPropertyLoad(prop); 4525 EmitKeyedSuperPropertyLoad(prop);
4531 break; 4526 break;
4532 } 4527 }
(...skipping 920 matching lines...) Expand 10 before | Expand all | Expand 10 after
5453 } 5448 }
5454 } 5449 }
5455 5450
5456 return INTERRUPT; 5451 return INTERRUPT;
5457 } 5452 }
5458 5453
5459 5454
5460 } } // namespace v8::internal 5455 } } // namespace v8::internal
5461 5456
5462 #endif // V8_TARGET_ARCH_ARM64 5457 #endif // V8_TARGET_ARCH_ARM64
OLDNEW
« no previous file with comments | « src/arm/full-codegen-arm.cc ('k') | src/ast.h » ('j') | src/x64/full-codegen-x64.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698