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

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: All ports done 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
323 if (FLAG_vector_ics) {
324 __ Mov(VectorLoadICDescriptor::SlotRegister(),
325 SmiFromSlot(function()->HomeObjectFeedbackSlot()));
326 }
327 CallLoadIC(NOT_CONTEXTUAL);
328
329 SetVar(home_object_var, x0, x1, x2);
330 }
331
310 if (FLAG_trace) { 332 if (FLAG_trace) {
311 __ CallRuntime(Runtime::kTraceEnter, 0); 333 __ CallRuntime(Runtime::kTraceEnter, 0);
312 } 334 }
313 335
314
315 // Visit the declarations and body unless there is an illegal 336 // Visit the declarations and body unless there is an illegal
316 // redeclaration. 337 // redeclaration.
317 if (scope()->HasIllegalRedeclaration()) { 338 if (scope()->HasIllegalRedeclaration()) {
318 Comment cmnt(masm_, "[ Declarations"); 339 Comment cmnt(masm_, "[ Declarations");
319 scope()->VisitIllegalRedeclaration(this); 340 scope()->VisitIllegalRedeclaration(this);
320 341
321 } else { 342 } else {
322 PrepareForBailoutForId(BailoutId::FunctionEntry(), NO_REGISTERS); 343 PrepareForBailoutForId(BailoutId::FunctionEntry(), NO_REGISTERS);
323 { Comment cmnt(masm_, "[ Declarations"); 344 { Comment cmnt(masm_, "[ Declarations");
324 if (scope()->is_function_scope() && scope()->function() != NULL) { 345 if (scope()->is_function_scope() && scope()->function() != NULL) {
(...skipping 981 matching lines...) Expand 10 before | Expand all | Expand 10 after
1306 context()->Plug(x0); 1327 context()->Plug(x0);
1307 } 1328 }
1308 1329
1309 1330
1310 void FullCodeGenerator::VisitVariableProxy(VariableProxy* expr) { 1331 void FullCodeGenerator::VisitVariableProxy(VariableProxy* expr) {
1311 Comment cmnt(masm_, "[ VariableProxy"); 1332 Comment cmnt(masm_, "[ VariableProxy");
1312 EmitVariableLoad(expr); 1333 EmitVariableLoad(expr);
1313 } 1334 }
1314 1335
1315 1336
1316 void FullCodeGenerator::EmitLoadHomeObject(SuperReference* expr) {
1317 Comment cnmt(masm_, "[ SuperReference ");
1318
1319 __ ldr(LoadDescriptor::ReceiverRegister(),
1320 MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset));
1321
1322 Handle<Symbol> home_object_symbol(isolate()->heap()->home_object_symbol());
1323 __ Mov(LoadDescriptor::NameRegister(), Operand(home_object_symbol));
1324
1325 if (FLAG_vector_ics) {
1326 __ Mov(VectorLoadICDescriptor::SlotRegister(),
1327 SmiFromSlot(expr->HomeObjectFeedbackSlot()));
1328 CallLoadIC(NOT_CONTEXTUAL);
1329 } else {
1330 CallLoadIC(NOT_CONTEXTUAL, expr->HomeObjectFeedbackId());
1331 }
1332
1333 __ Mov(x10, Operand(isolate()->factory()->undefined_value()));
1334 __ cmp(x0, x10);
1335 Label done;
1336 __ b(&done, ne);
1337 __ CallRuntime(Runtime::kThrowNonMethodError, 0);
1338 __ bind(&done);
1339 }
1340
1341
1342 void FullCodeGenerator::EmitSetHomeObjectIfNeeded(Expression* initializer, 1337 void FullCodeGenerator::EmitSetHomeObjectIfNeeded(Expression* initializer,
1343 int offset) { 1338 int offset) {
1344 if (NeedsHomeObject(initializer)) { 1339 if (NeedsHomeObject(initializer)) {
1345 __ Peek(StoreDescriptor::ReceiverRegister(), 0); 1340 __ Peek(StoreDescriptor::ReceiverRegister(), 0);
1346 __ Mov(StoreDescriptor::NameRegister(), 1341 __ Mov(StoreDescriptor::NameRegister(),
1347 Operand(isolate()->factory()->home_object_symbol())); 1342 Operand(isolate()->factory()->home_object_symbol()));
1348 __ Peek(StoreDescriptor::ValueRegister(), offset * kPointerSize); 1343 __ Peek(StoreDescriptor::ValueRegister(), offset * kPointerSize);
1349 CallStoreIC(); 1344 CallStoreIC();
1350 } 1345 }
1351 } 1346 }
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after
1932 if (expr->is_compound()) { 1927 if (expr->is_compound()) {
1933 // We need the receiver both on the stack and in the register. 1928 // We need the receiver both on the stack and in the register.
1934 VisitForStackValue(property->obj()); 1929 VisitForStackValue(property->obj());
1935 __ Peek(LoadDescriptor::ReceiverRegister(), 0); 1930 __ Peek(LoadDescriptor::ReceiverRegister(), 0);
1936 } else { 1931 } else {
1937 VisitForStackValue(property->obj()); 1932 VisitForStackValue(property->obj());
1938 } 1933 }
1939 break; 1934 break;
1940 case NAMED_SUPER_PROPERTY: 1935 case NAMED_SUPER_PROPERTY:
1941 VisitForStackValue(property->obj()->AsSuperReference()->this_var()); 1936 VisitForStackValue(property->obj()->AsSuperReference()->this_var());
1942 EmitLoadHomeObject(property->obj()->AsSuperReference()); 1937 VisitForAccumulatorValue(
1938 property->obj()->AsSuperReference()->home_object_var());
1943 __ Push(result_register()); 1939 __ Push(result_register());
1944 if (expr->is_compound()) { 1940 if (expr->is_compound()) {
1945 const Register scratch = x10; 1941 const Register scratch = x10;
1946 __ Peek(scratch, kPointerSize); 1942 __ Peek(scratch, kPointerSize);
1947 __ Push(scratch, result_register()); 1943 __ Push(scratch, result_register());
1948 } 1944 }
1949 break; 1945 break;
1950 case KEYED_SUPER_PROPERTY: 1946 case KEYED_SUPER_PROPERTY:
1951 VisitForStackValue(property->obj()->AsSuperReference()->this_var()); 1947 VisitForStackValue(property->obj()->AsSuperReference()->this_var());
1952 EmitLoadHomeObject(property->obj()->AsSuperReference()); 1948 VisitForStackValue(
1953 __ Push(result_register()); 1949 property->obj()->AsSuperReference()->home_object_var());
1954 VisitForAccumulatorValue(property->key()); 1950 VisitForAccumulatorValue(property->key());
1955 __ Push(result_register()); 1951 __ Push(result_register());
1956 if (expr->is_compound()) { 1952 if (expr->is_compound()) {
1957 const Register scratch1 = x10; 1953 const Register scratch1 = x10;
1958 const Register scratch2 = x11; 1954 const Register scratch2 = x11;
1959 __ Peek(scratch1, 2 * kPointerSize); 1955 __ Peek(scratch1, 2 * kPointerSize);
1960 __ Peek(scratch2, kPointerSize); 1956 __ Peek(scratch2, kPointerSize);
1961 __ Push(scratch1, scratch2, result_register()); 1957 __ Push(scratch1, scratch2, result_register());
1962 } 1958 }
1963 break; 1959 break;
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
2307 __ Mov(StoreDescriptor::ReceiverRegister(), x0); 2303 __ Mov(StoreDescriptor::ReceiverRegister(), x0);
2308 __ Pop(StoreDescriptor::ValueRegister()); // Restore value. 2304 __ Pop(StoreDescriptor::ValueRegister()); // Restore value.
2309 __ Mov(StoreDescriptor::NameRegister(), 2305 __ Mov(StoreDescriptor::NameRegister(),
2310 Operand(prop->key()->AsLiteral()->value())); 2306 Operand(prop->key()->AsLiteral()->value()));
2311 CallStoreIC(); 2307 CallStoreIC();
2312 break; 2308 break;
2313 } 2309 }
2314 case NAMED_SUPER_PROPERTY: { 2310 case NAMED_SUPER_PROPERTY: {
2315 __ Push(x0); 2311 __ Push(x0);
2316 VisitForStackValue(prop->obj()->AsSuperReference()->this_var()); 2312 VisitForStackValue(prop->obj()->AsSuperReference()->this_var());
2317 EmitLoadHomeObject(prop->obj()->AsSuperReference()); 2313 VisitForAccumulatorValue(
2314 prop->obj()->AsSuperReference()->home_object_var());
2318 // stack: value, this; x0: home_object 2315 // stack: value, this; x0: home_object
2319 Register scratch = x10; 2316 Register scratch = x10;
2320 Register scratch2 = x11; 2317 Register scratch2 = x11;
2321 __ mov(scratch, result_register()); // home_object 2318 __ mov(scratch, result_register()); // home_object
2322 __ Peek(x0, kPointerSize); // value 2319 __ Peek(x0, kPointerSize); // value
2323 __ Peek(scratch2, 0); // this 2320 __ Peek(scratch2, 0); // this
2324 __ Poke(scratch2, kPointerSize); // this 2321 __ Poke(scratch2, kPointerSize); // this
2325 __ Poke(scratch, 0); // home_object 2322 __ Poke(scratch, 0); // home_object
2326 // stack: this, home_object; x0: value 2323 // stack: this, home_object; x0: value
2327 EmitNamedSuperPropertyStore(prop); 2324 EmitNamedSuperPropertyStore(prop);
2328 break; 2325 break;
2329 } 2326 }
2330 case KEYED_SUPER_PROPERTY: { 2327 case KEYED_SUPER_PROPERTY: {
2331 __ Push(x0); 2328 __ Push(x0);
2332 VisitForStackValue(prop->obj()->AsSuperReference()->this_var()); 2329 VisitForStackValue(prop->obj()->AsSuperReference()->this_var());
2333 EmitLoadHomeObject(prop->obj()->AsSuperReference()); 2330 VisitForStackValue(prop->obj()->AsSuperReference()->home_object_var());
2334 __ Push(result_register());
2335 VisitForAccumulatorValue(prop->key()); 2331 VisitForAccumulatorValue(prop->key());
2336 Register scratch = x10; 2332 Register scratch = x10;
2337 Register scratch2 = x11; 2333 Register scratch2 = x11;
2338 __ Peek(scratch2, 2 * kPointerSize); // value 2334 __ Peek(scratch2, 2 * kPointerSize); // value
2339 // stack: value, this, home_object; x0: key, x11: value 2335 // stack: value, this, home_object; x0: key, x11: value
2340 __ Peek(scratch, kPointerSize); // this 2336 __ Peek(scratch, kPointerSize); // this
2341 __ Poke(scratch, 2 * kPointerSize); 2337 __ Poke(scratch, 2 * kPointerSize);
2342 __ Peek(scratch, 0); // home_object 2338 __ Peek(scratch, 0); // home_object
2343 __ Poke(scratch, kPointerSize); 2339 __ Poke(scratch, kPointerSize);
2344 __ Poke(x0, 0); 2340 __ Poke(x0, 0);
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
2539 Comment cmnt(masm_, "[ Property"); 2535 Comment cmnt(masm_, "[ Property");
2540 Expression* key = expr->key(); 2536 Expression* key = expr->key();
2541 2537
2542 if (key->IsPropertyName()) { 2538 if (key->IsPropertyName()) {
2543 if (!expr->IsSuperAccess()) { 2539 if (!expr->IsSuperAccess()) {
2544 VisitForAccumulatorValue(expr->obj()); 2540 VisitForAccumulatorValue(expr->obj());
2545 __ Move(LoadDescriptor::ReceiverRegister(), x0); 2541 __ Move(LoadDescriptor::ReceiverRegister(), x0);
2546 EmitNamedPropertyLoad(expr); 2542 EmitNamedPropertyLoad(expr);
2547 } else { 2543 } else {
2548 VisitForStackValue(expr->obj()->AsSuperReference()->this_var()); 2544 VisitForStackValue(expr->obj()->AsSuperReference()->this_var());
2549 EmitLoadHomeObject(expr->obj()->AsSuperReference()); 2545 VisitForStackValue(expr->obj()->AsSuperReference()->home_object_var());
2550 __ Push(result_register());
2551 EmitNamedSuperPropertyLoad(expr); 2546 EmitNamedSuperPropertyLoad(expr);
2552 } 2547 }
2553 } else { 2548 } else {
2554 if (!expr->IsSuperAccess()) { 2549 if (!expr->IsSuperAccess()) {
2555 VisitForStackValue(expr->obj()); 2550 VisitForStackValue(expr->obj());
2556 VisitForAccumulatorValue(expr->key()); 2551 VisitForAccumulatorValue(expr->key());
2557 __ Move(LoadDescriptor::NameRegister(), x0); 2552 __ Move(LoadDescriptor::NameRegister(), x0);
2558 __ Pop(LoadDescriptor::ReceiverRegister()); 2553 __ Pop(LoadDescriptor::ReceiverRegister());
2559 EmitKeyedPropertyLoad(expr); 2554 EmitKeyedPropertyLoad(expr);
2560 } else { 2555 } else {
2561 VisitForStackValue(expr->obj()->AsSuperReference()->this_var()); 2556 VisitForStackValue(expr->obj()->AsSuperReference()->this_var());
2562 EmitLoadHomeObject(expr->obj()->AsSuperReference()); 2557 VisitForStackValue(expr->obj()->AsSuperReference()->home_object_var());
2563 __ Push(result_register());
2564 VisitForStackValue(expr->key()); 2558 VisitForStackValue(expr->key());
2565 EmitKeyedSuperPropertyLoad(expr); 2559 EmitKeyedSuperPropertyLoad(expr);
2566 } 2560 }
2567 } 2561 }
2568 PrepareForBailoutForId(expr->LoadId(), TOS_REG); 2562 PrepareForBailoutForId(expr->LoadId(), TOS_REG);
2569 context()->Plug(x0); 2563 context()->Plug(x0);
2570 } 2564 }
2571 2565
2572 2566
2573 void FullCodeGenerator::CallIC(Handle<Code> code, 2567 void FullCodeGenerator::CallIC(Handle<Code> code,
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
2622 Property* prop = callee->AsProperty(); 2616 Property* prop = callee->AsProperty();
2623 DCHECK(prop->IsSuperAccess()); 2617 DCHECK(prop->IsSuperAccess());
2624 2618
2625 SetSourcePosition(prop->position()); 2619 SetSourcePosition(prop->position());
2626 Literal* key = prop->key()->AsLiteral(); 2620 Literal* key = prop->key()->AsLiteral();
2627 DCHECK(!key->value()->IsSmi()); 2621 DCHECK(!key->value()->IsSmi());
2628 2622
2629 // Load the function from the receiver. 2623 // Load the function from the receiver.
2630 const Register scratch = x10; 2624 const Register scratch = x10;
2631 SuperReference* super_ref = callee->AsProperty()->obj()->AsSuperReference(); 2625 SuperReference* super_ref = callee->AsProperty()->obj()->AsSuperReference();
2632 EmitLoadHomeObject(super_ref); 2626 VisitForStackValue(super_ref->home_object_var());
2633 __ Push(x0);
2634 VisitForAccumulatorValue(super_ref->this_var()); 2627 VisitForAccumulatorValue(super_ref->this_var());
2635 __ Push(x0); 2628 __ Push(x0);
2636 __ Peek(scratch, kPointerSize); 2629 __ Peek(scratch, kPointerSize);
2637 __ Push(x0, scratch); 2630 __ Push(x0, scratch);
2638 __ Push(key->value()); 2631 __ Push(key->value());
2639 2632
2640 // Stack here: 2633 // Stack here:
2641 // - home_object 2634 // - home_object
2642 // - this (receiver) 2635 // - this (receiver)
2643 // - this (receiver) <-- LoadFromSuper will pop here and below. 2636 // - this (receiver) <-- LoadFromSuper will pop here and below.
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
2682 Expression* callee = expr->expression(); 2675 Expression* callee = expr->expression();
2683 DCHECK(callee->IsProperty()); 2676 DCHECK(callee->IsProperty());
2684 Property* prop = callee->AsProperty(); 2677 Property* prop = callee->AsProperty();
2685 DCHECK(prop->IsSuperAccess()); 2678 DCHECK(prop->IsSuperAccess());
2686 2679
2687 SetSourcePosition(prop->position()); 2680 SetSourcePosition(prop->position());
2688 2681
2689 // Load the function from the receiver. 2682 // Load the function from the receiver.
2690 const Register scratch = x10; 2683 const Register scratch = x10;
2691 SuperReference* super_ref = callee->AsProperty()->obj()->AsSuperReference(); 2684 SuperReference* super_ref = callee->AsProperty()->obj()->AsSuperReference();
2692 EmitLoadHomeObject(super_ref); 2685 VisitForStackValue(super_ref->home_object_var());
2693 __ Push(x0);
2694 VisitForAccumulatorValue(super_ref->this_var()); 2686 VisitForAccumulatorValue(super_ref->this_var());
2695 __ Push(x0); 2687 __ Push(x0);
2696 __ Peek(scratch, kPointerSize); 2688 __ Peek(scratch, kPointerSize);
2697 __ Push(x0, scratch); 2689 __ Push(x0, scratch);
2698 VisitForStackValue(prop->key()); 2690 VisitForStackValue(prop->key());
2699 2691
2700 // Stack here: 2692 // Stack here:
2701 // - home_object 2693 // - home_object
2702 // - this (receiver) 2694 // - this (receiver)
2703 // - this (receiver) <-- LoadKeyedFromSuper will pop here and below. 2695 // - this (receiver) <-- LoadKeyedFromSuper will pop here and below.
(...skipping 1819 matching lines...) Expand 10 before | Expand all | Expand 10 after
4523 case NAMED_PROPERTY: { 4515 case NAMED_PROPERTY: {
4524 // Put the object both on the stack and in the register. 4516 // Put the object both on the stack and in the register.
4525 VisitForStackValue(prop->obj()); 4517 VisitForStackValue(prop->obj());
4526 __ Peek(LoadDescriptor::ReceiverRegister(), 0); 4518 __ Peek(LoadDescriptor::ReceiverRegister(), 0);
4527 EmitNamedPropertyLoad(prop); 4519 EmitNamedPropertyLoad(prop);
4528 break; 4520 break;
4529 } 4521 }
4530 4522
4531 case NAMED_SUPER_PROPERTY: { 4523 case NAMED_SUPER_PROPERTY: {
4532 VisitForStackValue(prop->obj()->AsSuperReference()->this_var()); 4524 VisitForStackValue(prop->obj()->AsSuperReference()->this_var());
4533 EmitLoadHomeObject(prop->obj()->AsSuperReference()); 4525 VisitForAccumulatorValue(
4526 prop->obj()->AsSuperReference()->home_object_var());
4534 __ Push(result_register()); 4527 __ Push(result_register());
4535 const Register scratch = x10; 4528 const Register scratch = x10;
4536 __ Peek(scratch, kPointerSize); 4529 __ Peek(scratch, kPointerSize);
4537 __ Push(scratch, result_register()); 4530 __ Push(scratch, result_register());
4538 EmitNamedSuperPropertyLoad(prop); 4531 EmitNamedSuperPropertyLoad(prop);
4539 break; 4532 break;
4540 } 4533 }
4541 4534
4542 case KEYED_SUPER_PROPERTY: { 4535 case KEYED_SUPER_PROPERTY: {
4543 VisitForStackValue(prop->obj()->AsSuperReference()->this_var()); 4536 VisitForStackValue(prop->obj()->AsSuperReference()->this_var());
4544 EmitLoadHomeObject(prop->obj()->AsSuperReference()); 4537 VisitForStackValue(prop->obj()->AsSuperReference()->home_object_var());
4545 __ Push(result_register());
4546 VisitForAccumulatorValue(prop->key()); 4538 VisitForAccumulatorValue(prop->key());
4547 __ Push(result_register()); 4539 __ Push(result_register());
4548 const Register scratch1 = x10; 4540 const Register scratch1 = x10;
4549 const Register scratch2 = x11; 4541 const Register scratch2 = x11;
4550 __ Peek(scratch1, 2 * kPointerSize); 4542 __ Peek(scratch1, 2 * kPointerSize);
4551 __ Peek(scratch2, kPointerSize); 4543 __ Peek(scratch2, kPointerSize);
4552 __ Push(scratch1, scratch2, result_register()); 4544 __ Push(scratch1, scratch2, result_register());
4553 EmitKeyedSuperPropertyLoad(prop); 4545 EmitKeyedSuperPropertyLoad(prop);
4554 break; 4546 break;
4555 } 4547 }
(...skipping 927 matching lines...) Expand 10 before | Expand all | Expand 10 after
5483 } 5475 }
5484 } 5476 }
5485 5477
5486 return INTERRUPT; 5478 return INTERRUPT;
5487 } 5479 }
5488 5480
5489 5481
5490 } } // namespace v8::internal 5482 } } // namespace v8::internal
5491 5483
5492 #endif // V8_TARGET_ARCH_ARM64 5484 #endif // V8_TARGET_ARCH_ARM64
OLDNEW
« no previous file with comments | « src/arm/full-codegen-arm.cc ('k') | src/ast.h » ('j') | src/preparser.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698