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

Side by Side Diff: src/mips/full-codegen-mips.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 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 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #if V8_TARGET_ARCH_MIPS 7 #if V8_TARGET_ARCH_MIPS
8 8
9 // Note on Mips implementation: 9 // Note on Mips implementation:
10 // 10 //
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 type = ArgumentsAccessStub::NEW_SLOPPY_SLOW; 310 type = ArgumentsAccessStub::NEW_SLOPPY_SLOW;
311 } else { 311 } else {
312 type = ArgumentsAccessStub::NEW_SLOPPY_FAST; 312 type = ArgumentsAccessStub::NEW_SLOPPY_FAST;
313 } 313 }
314 ArgumentsAccessStub stub(isolate(), type, has_new_target); 314 ArgumentsAccessStub stub(isolate(), type, has_new_target);
315 __ CallStub(&stub); 315 __ CallStub(&stub);
316 316
317 SetVar(arguments, v0, a1, a2); 317 SetVar(arguments, v0, a1, a2);
318 } 318 }
319 319
320 // Possibly set up a local binding to the [[HomeObject]].
321 Variable* home_object_var = scope()->home_object_var();
322 if (home_object_var != nullptr) {
323 Comment cmnt(masm_, "[ Home object");
324 if (function_in_register) {
325 __ Move(LoadDescriptor::ReceiverRegister(), a1);
326 } else {
327 __ lw(LoadDescriptor::ReceiverRegister(),
328 MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset));
329 }
330 Handle<Symbol> home_object_symbol(isolate()->heap()->home_object_symbol());
331 __ li(LoadDescriptor::NameRegister(), Operand(home_object_symbol));
332 __ li(LoadDescriptor::SlotRegister(),
333 Operand(SmiFromSlot(function()->HomeObjectFeedbackSlot())));
334 CallLoadIC(NOT_CONTEXTUAL);
335
336 SetVar(home_object_var, v0, a1, a2);
337 }
338
320 if (FLAG_trace) { 339 if (FLAG_trace) {
321 __ CallRuntime(Runtime::kTraceEnter, 0); 340 __ CallRuntime(Runtime::kTraceEnter, 0);
322 } 341 }
323 342
324 // Visit the declarations and body unless there is an illegal 343 // Visit the declarations and body unless there is an illegal
325 // redeclaration. 344 // redeclaration.
326 if (scope()->HasIllegalRedeclaration()) { 345 if (scope()->HasIllegalRedeclaration()) {
327 Comment cmnt(masm_, "[ Declarations"); 346 Comment cmnt(masm_, "[ Declarations");
328 scope()->VisitIllegalRedeclaration(this); 347 scope()->VisitIllegalRedeclaration(this);
329 348
(...skipping 976 matching lines...) Expand 10 before | Expand all | Expand 10 after
1306 context()->Plug(v0); 1325 context()->Plug(v0);
1307 } 1326 }
1308 1327
1309 1328
1310 void FullCodeGenerator::VisitVariableProxy(VariableProxy* expr) { 1329 void FullCodeGenerator::VisitVariableProxy(VariableProxy* expr) {
1311 Comment cmnt(masm_, "[ VariableProxy"); 1330 Comment cmnt(masm_, "[ VariableProxy");
1312 EmitVariableLoad(expr); 1331 EmitVariableLoad(expr);
1313 } 1332 }
1314 1333
1315 1334
1316 void FullCodeGenerator::EmitLoadHomeObject(SuperReference* expr) {
1317 Comment cnmt(masm_, "[ SuperReference ");
1318
1319 __ lw(LoadDescriptor::ReceiverRegister(),
1320 MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset));
1321
1322 Handle<Symbol> home_object_symbol(isolate()->heap()->home_object_symbol());
1323 __ li(LoadDescriptor::NameRegister(), home_object_symbol);
1324
1325 __ li(LoadDescriptor::SlotRegister(),
1326 Operand(SmiFromSlot(expr->HomeObjectFeedbackSlot())));
1327 CallLoadIC(NOT_CONTEXTUAL);
1328
1329 Label done;
1330 __ Branch(&done, ne, v0, Operand(isolate()->factory()->undefined_value()));
1331 __ CallRuntime(Runtime::kThrowNonMethodError, 0);
1332 __ bind(&done);
1333 }
1334
1335
1336 void FullCodeGenerator::EmitSetHomeObjectIfNeeded(Expression* initializer, 1335 void FullCodeGenerator::EmitSetHomeObjectIfNeeded(Expression* initializer,
1337 int offset) { 1336 int offset) {
1338 if (NeedsHomeObject(initializer)) { 1337 if (NeedsHomeObject(initializer)) {
1339 __ lw(StoreDescriptor::ReceiverRegister(), MemOperand(sp)); 1338 __ lw(StoreDescriptor::ReceiverRegister(), MemOperand(sp));
1340 __ li(StoreDescriptor::NameRegister(), 1339 __ li(StoreDescriptor::NameRegister(),
1341 Operand(isolate()->factory()->home_object_symbol())); 1340 Operand(isolate()->factory()->home_object_symbol()));
1342 __ lw(StoreDescriptor::ValueRegister(), 1341 __ lw(StoreDescriptor::ValueRegister(),
1343 MemOperand(sp, offset * kPointerSize)); 1342 MemOperand(sp, offset * kPointerSize));
1344 CallStoreIC(); 1343 CallStoreIC();
1345 } 1344 }
(...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after
1935 if (expr->is_compound()) { 1934 if (expr->is_compound()) {
1936 // We need the receiver both on the stack and in the register. 1935 // We need the receiver both on the stack and in the register.
1937 VisitForStackValue(property->obj()); 1936 VisitForStackValue(property->obj());
1938 __ lw(LoadDescriptor::ReceiverRegister(), MemOperand(sp, 0)); 1937 __ lw(LoadDescriptor::ReceiverRegister(), MemOperand(sp, 0));
1939 } else { 1938 } else {
1940 VisitForStackValue(property->obj()); 1939 VisitForStackValue(property->obj());
1941 } 1940 }
1942 break; 1941 break;
1943 case NAMED_SUPER_PROPERTY: 1942 case NAMED_SUPER_PROPERTY:
1944 VisitForStackValue(property->obj()->AsSuperReference()->this_var()); 1943 VisitForStackValue(property->obj()->AsSuperReference()->this_var());
1945 EmitLoadHomeObject(property->obj()->AsSuperReference()); 1944 VisitForAccumulatorValue(
1945 property->obj()->AsSuperReference()->home_object_var());
1946 __ Push(result_register()); 1946 __ Push(result_register());
1947 if (expr->is_compound()) { 1947 if (expr->is_compound()) {
1948 const Register scratch = a1; 1948 const Register scratch = a1;
1949 __ lw(scratch, MemOperand(sp, kPointerSize)); 1949 __ lw(scratch, MemOperand(sp, kPointerSize));
1950 __ Push(scratch, result_register()); 1950 __ Push(scratch, result_register());
1951 } 1951 }
1952 break; 1952 break;
1953 case KEYED_SUPER_PROPERTY: { 1953 case KEYED_SUPER_PROPERTY: {
1954 const Register scratch = a1; 1954 const Register scratch = a1;
1955 VisitForStackValue(property->obj()->AsSuperReference()->this_var()); 1955 VisitForStackValue(property->obj()->AsSuperReference()->this_var());
1956 EmitLoadHomeObject(property->obj()->AsSuperReference()); 1956 VisitForAccumulatorValue(
1957 property->obj()->AsSuperReference()->home_object_var());
1957 __ Move(scratch, result_register()); 1958 __ Move(scratch, result_register());
1958 VisitForAccumulatorValue(property->key()); 1959 VisitForAccumulatorValue(property->key());
1959 __ Push(scratch, result_register()); 1960 __ Push(scratch, result_register());
1960 if (expr->is_compound()) { 1961 if (expr->is_compound()) {
1961 const Register scratch1 = t0; 1962 const Register scratch1 = t0;
1962 __ lw(scratch1, MemOperand(sp, 2 * kPointerSize)); 1963 __ lw(scratch1, MemOperand(sp, 2 * kPointerSize));
1963 __ Push(scratch1, scratch, result_register()); 1964 __ Push(scratch1, scratch, result_register());
1964 } 1965 }
1965 break; 1966 break;
1966 } 1967 }
(...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after
2579 __ mov(StoreDescriptor::ReceiverRegister(), result_register()); 2580 __ mov(StoreDescriptor::ReceiverRegister(), result_register());
2580 __ pop(StoreDescriptor::ValueRegister()); // Restore value. 2581 __ pop(StoreDescriptor::ValueRegister()); // Restore value.
2581 __ li(StoreDescriptor::NameRegister(), 2582 __ li(StoreDescriptor::NameRegister(),
2582 Operand(prop->key()->AsLiteral()->value())); 2583 Operand(prop->key()->AsLiteral()->value()));
2583 CallStoreIC(); 2584 CallStoreIC();
2584 break; 2585 break;
2585 } 2586 }
2586 case NAMED_SUPER_PROPERTY: { 2587 case NAMED_SUPER_PROPERTY: {
2587 __ Push(v0); 2588 __ Push(v0);
2588 VisitForStackValue(prop->obj()->AsSuperReference()->this_var()); 2589 VisitForStackValue(prop->obj()->AsSuperReference()->this_var());
2589 EmitLoadHomeObject(prop->obj()->AsSuperReference()); 2590 VisitForAccumulatorValue(
2591 prop->obj()->AsSuperReference()->home_object_var());
2590 // stack: value, this; v0: home_object 2592 // stack: value, this; v0: home_object
2591 Register scratch = a2; 2593 Register scratch = a2;
2592 Register scratch2 = a3; 2594 Register scratch2 = a3;
2593 __ mov(scratch, result_register()); // home_object 2595 __ mov(scratch, result_register()); // home_object
2594 __ lw(v0, MemOperand(sp, kPointerSize)); // value 2596 __ lw(v0, MemOperand(sp, kPointerSize)); // value
2595 __ lw(scratch2, MemOperand(sp, 0)); // this 2597 __ lw(scratch2, MemOperand(sp, 0)); // this
2596 __ sw(scratch2, MemOperand(sp, kPointerSize)); // this 2598 __ sw(scratch2, MemOperand(sp, kPointerSize)); // this
2597 __ sw(scratch, MemOperand(sp, 0)); // home_object 2599 __ sw(scratch, MemOperand(sp, 0)); // home_object
2598 // stack: this, home_object; v0: value 2600 // stack: this, home_object; v0: value
2599 EmitNamedSuperPropertyStore(prop); 2601 EmitNamedSuperPropertyStore(prop);
2600 break; 2602 break;
2601 } 2603 }
2602 case KEYED_SUPER_PROPERTY: { 2604 case KEYED_SUPER_PROPERTY: {
2603 __ Push(v0); 2605 __ Push(v0);
2604 VisitForStackValue(prop->obj()->AsSuperReference()->this_var()); 2606 VisitForStackValue(prop->obj()->AsSuperReference()->this_var());
2605 EmitLoadHomeObject(prop->obj()->AsSuperReference()); 2607 VisitForStackValue(prop->obj()->AsSuperReference()->home_object_var());
2606 __ Push(result_register());
2607 VisitForAccumulatorValue(prop->key()); 2608 VisitForAccumulatorValue(prop->key());
2608 Register scratch = a2; 2609 Register scratch = a2;
2609 Register scratch2 = a3; 2610 Register scratch2 = a3;
2610 __ lw(scratch2, MemOperand(sp, 2 * kPointerSize)); // value 2611 __ lw(scratch2, MemOperand(sp, 2 * kPointerSize)); // value
2611 // stack: value, this, home_object; v0: key, a3: value 2612 // stack: value, this, home_object; v0: key, a3: value
2612 __ lw(scratch, MemOperand(sp, kPointerSize)); // this 2613 __ lw(scratch, MemOperand(sp, kPointerSize)); // this
2613 __ sw(scratch, MemOperand(sp, 2 * kPointerSize)); 2614 __ sw(scratch, MemOperand(sp, 2 * kPointerSize));
2614 __ lw(scratch, MemOperand(sp, 0)); // home_object 2615 __ lw(scratch, MemOperand(sp, 0)); // home_object
2615 __ sw(scratch, MemOperand(sp, kPointerSize)); 2616 __ sw(scratch, MemOperand(sp, kPointerSize));
2616 __ sw(v0, MemOperand(sp, 0)); 2617 __ sw(v0, MemOperand(sp, 0));
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
2813 Comment cmnt(masm_, "[ Property"); 2814 Comment cmnt(masm_, "[ Property");
2814 Expression* key = expr->key(); 2815 Expression* key = expr->key();
2815 2816
2816 if (key->IsPropertyName()) { 2817 if (key->IsPropertyName()) {
2817 if (!expr->IsSuperAccess()) { 2818 if (!expr->IsSuperAccess()) {
2818 VisitForAccumulatorValue(expr->obj()); 2819 VisitForAccumulatorValue(expr->obj());
2819 __ Move(LoadDescriptor::ReceiverRegister(), v0); 2820 __ Move(LoadDescriptor::ReceiverRegister(), v0);
2820 EmitNamedPropertyLoad(expr); 2821 EmitNamedPropertyLoad(expr);
2821 } else { 2822 } else {
2822 VisitForStackValue(expr->obj()->AsSuperReference()->this_var()); 2823 VisitForStackValue(expr->obj()->AsSuperReference()->this_var());
2823 EmitLoadHomeObject(expr->obj()->AsSuperReference()); 2824 VisitForStackValue(expr->obj()->AsSuperReference()->home_object_var());
2824 __ Push(result_register());
2825 EmitNamedSuperPropertyLoad(expr); 2825 EmitNamedSuperPropertyLoad(expr);
2826 } 2826 }
2827 } else { 2827 } else {
2828 if (!expr->IsSuperAccess()) { 2828 if (!expr->IsSuperAccess()) {
2829 VisitForStackValue(expr->obj()); 2829 VisitForStackValue(expr->obj());
2830 VisitForAccumulatorValue(expr->key()); 2830 VisitForAccumulatorValue(expr->key());
2831 __ Move(LoadDescriptor::NameRegister(), v0); 2831 __ Move(LoadDescriptor::NameRegister(), v0);
2832 __ pop(LoadDescriptor::ReceiverRegister()); 2832 __ pop(LoadDescriptor::ReceiverRegister());
2833 EmitKeyedPropertyLoad(expr); 2833 EmitKeyedPropertyLoad(expr);
2834 } else { 2834 } else {
2835 VisitForStackValue(expr->obj()->AsSuperReference()->this_var()); 2835 VisitForStackValue(expr->obj()->AsSuperReference()->this_var());
2836 EmitLoadHomeObject(expr->obj()->AsSuperReference()); 2836 VisitForStackValue(expr->obj()->AsSuperReference()->home_object_var());
2837 __ Push(result_register());
2838 VisitForStackValue(expr->key()); 2837 VisitForStackValue(expr->key());
2839 EmitKeyedSuperPropertyLoad(expr); 2838 EmitKeyedSuperPropertyLoad(expr);
2840 } 2839 }
2841 } 2840 }
2842 PrepareForBailoutForId(expr->LoadId(), TOS_REG); 2841 PrepareForBailoutForId(expr->LoadId(), TOS_REG);
2843 context()->Plug(v0); 2842 context()->Plug(v0);
2844 } 2843 }
2845 2844
2846 2845
2847 void FullCodeGenerator::CallIC(Handle<Code> code, 2846 void FullCodeGenerator::CallIC(Handle<Code> code,
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
2890 DCHECK(callee->IsProperty()); 2889 DCHECK(callee->IsProperty());
2891 Property* prop = callee->AsProperty(); 2890 Property* prop = callee->AsProperty();
2892 DCHECK(prop->IsSuperAccess()); 2891 DCHECK(prop->IsSuperAccess());
2893 2892
2894 SetSourcePosition(prop->position()); 2893 SetSourcePosition(prop->position());
2895 Literal* key = prop->key()->AsLiteral(); 2894 Literal* key = prop->key()->AsLiteral();
2896 DCHECK(!key->value()->IsSmi()); 2895 DCHECK(!key->value()->IsSmi());
2897 // Load the function from the receiver. 2896 // Load the function from the receiver.
2898 const Register scratch = a1; 2897 const Register scratch = a1;
2899 SuperReference* super_ref = prop->obj()->AsSuperReference(); 2898 SuperReference* super_ref = prop->obj()->AsSuperReference();
2900 EmitLoadHomeObject(super_ref); 2899 VisitForAccumulatorValue(super_ref->home_object_var());
2901 __ mov(scratch, v0); 2900 __ mov(scratch, v0);
2902 VisitForAccumulatorValue(super_ref->this_var()); 2901 VisitForAccumulatorValue(super_ref->this_var());
2903 __ Push(scratch, v0, v0, scratch); 2902 __ Push(scratch, v0, v0, scratch);
2904 __ Push(key->value()); 2903 __ Push(key->value());
2905 2904
2906 // Stack here: 2905 // Stack here:
2907 // - home_object 2906 // - home_object
2908 // - this (receiver) 2907 // - this (receiver)
2909 // - this (receiver) <-- LoadFromSuper will pop here and below. 2908 // - this (receiver) <-- LoadFromSuper will pop here and below.
2910 // - home_object 2909 // - home_object
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
2948 void FullCodeGenerator::EmitKeyedSuperCallWithLoadIC(Call* expr) { 2947 void FullCodeGenerator::EmitKeyedSuperCallWithLoadIC(Call* expr) {
2949 Expression* callee = expr->expression(); 2948 Expression* callee = expr->expression();
2950 DCHECK(callee->IsProperty()); 2949 DCHECK(callee->IsProperty());
2951 Property* prop = callee->AsProperty(); 2950 Property* prop = callee->AsProperty();
2952 DCHECK(prop->IsSuperAccess()); 2951 DCHECK(prop->IsSuperAccess());
2953 2952
2954 SetSourcePosition(prop->position()); 2953 SetSourcePosition(prop->position());
2955 // Load the function from the receiver. 2954 // Load the function from the receiver.
2956 const Register scratch = a1; 2955 const Register scratch = a1;
2957 SuperReference* super_ref = prop->obj()->AsSuperReference(); 2956 SuperReference* super_ref = prop->obj()->AsSuperReference();
2958 EmitLoadHomeObject(super_ref); 2957 VisitForAccumulatorValue(super_ref->home_object_var());
2959 __ Move(scratch, v0); 2958 __ Move(scratch, v0);
2960 VisitForAccumulatorValue(super_ref->this_var()); 2959 VisitForAccumulatorValue(super_ref->this_var());
2961 __ Push(scratch, v0, v0, scratch); 2960 __ Push(scratch, v0, v0, scratch);
2962 VisitForStackValue(prop->key()); 2961 VisitForStackValue(prop->key());
2963 2962
2964 // Stack here: 2963 // Stack here:
2965 // - home_object 2964 // - home_object
2966 // - this (receiver) 2965 // - this (receiver)
2967 // - this (receiver) <-- LoadKeyedFromSuper will pop here and below. 2966 // - this (receiver) <-- LoadKeyedFromSuper will pop here and below.
2968 // - home_object 2967 // - home_object
(...skipping 1851 matching lines...) Expand 10 before | Expand all | Expand 10 after
4820 case NAMED_PROPERTY: { 4819 case NAMED_PROPERTY: {
4821 // Put the object both on the stack and in the register. 4820 // Put the object both on the stack and in the register.
4822 VisitForStackValue(prop->obj()); 4821 VisitForStackValue(prop->obj());
4823 __ lw(LoadDescriptor::ReceiverRegister(), MemOperand(sp, 0)); 4822 __ lw(LoadDescriptor::ReceiverRegister(), MemOperand(sp, 0));
4824 EmitNamedPropertyLoad(prop); 4823 EmitNamedPropertyLoad(prop);
4825 break; 4824 break;
4826 } 4825 }
4827 4826
4828 case NAMED_SUPER_PROPERTY: { 4827 case NAMED_SUPER_PROPERTY: {
4829 VisitForStackValue(prop->obj()->AsSuperReference()->this_var()); 4828 VisitForStackValue(prop->obj()->AsSuperReference()->this_var());
4830 EmitLoadHomeObject(prop->obj()->AsSuperReference()); 4829 VisitForAccumulatorValue(
4830 prop->obj()->AsSuperReference()->home_object_var());
4831 __ Push(result_register()); 4831 __ Push(result_register());
4832 const Register scratch = a1; 4832 const Register scratch = a1;
4833 __ lw(scratch, MemOperand(sp, kPointerSize)); 4833 __ lw(scratch, MemOperand(sp, kPointerSize));
4834 __ Push(scratch, result_register()); 4834 __ Push(scratch, result_register());
4835 EmitNamedSuperPropertyLoad(prop); 4835 EmitNamedSuperPropertyLoad(prop);
4836 break; 4836 break;
4837 } 4837 }
4838 4838
4839 case KEYED_SUPER_PROPERTY: { 4839 case KEYED_SUPER_PROPERTY: {
4840 VisitForStackValue(prop->obj()->AsSuperReference()->this_var()); 4840 VisitForStackValue(prop->obj()->AsSuperReference()->this_var());
4841 EmitLoadHomeObject(prop->obj()->AsSuperReference()); 4841 VisitForAccumulatorValue(
4842 prop->obj()->AsSuperReference()->home_object_var());
4842 const Register scratch = a1; 4843 const Register scratch = a1;
4843 const Register scratch1 = t0; 4844 const Register scratch1 = t0;
4844 __ Move(scratch, result_register()); 4845 __ Move(scratch, result_register());
4845 VisitForAccumulatorValue(prop->key()); 4846 VisitForAccumulatorValue(prop->key());
4846 __ Push(scratch, result_register()); 4847 __ Push(scratch, result_register());
4847 __ lw(scratch1, MemOperand(sp, 2 * kPointerSize)); 4848 __ lw(scratch1, MemOperand(sp, 2 * kPointerSize));
4848 __ Push(scratch1, scratch, result_register()); 4849 __ Push(scratch1, scratch, result_register());
4849 EmitKeyedSuperPropertyLoad(prop); 4850 EmitKeyedSuperPropertyLoad(prop);
4850 break; 4851 break;
4851 } 4852 }
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after
5423 Assembler::target_address_at(pc_immediate_load_address)) == 5424 Assembler::target_address_at(pc_immediate_load_address)) ==
5424 reinterpret_cast<uint32_t>( 5425 reinterpret_cast<uint32_t>(
5425 isolate->builtins()->OsrAfterStackCheck()->entry())); 5426 isolate->builtins()->OsrAfterStackCheck()->entry()));
5426 return OSR_AFTER_STACK_CHECK; 5427 return OSR_AFTER_STACK_CHECK;
5427 } 5428 }
5428 5429
5429 5430
5430 } } // namespace v8::internal 5431 } } // namespace v8::internal
5431 5432
5432 #endif // V8_TARGET_ARCH_MIPS 5433 #endif // V8_TARGET_ARCH_MIPS
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698