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

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: 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 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
333 if (FLAG_vector_ics) {
334 __ li(VectorLoadICDescriptor::SlotRegister(),
335 Operand(SmiFromSlot(function()->HomeObjectFeedbackSlot())));
336 }
337 CallLoadIC(NOT_CONTEXTUAL);
338
339 SetVar(home_object_var, v0, a1, a2);
340 }
341
320 if (FLAG_trace) { 342 if (FLAG_trace) {
321 __ CallRuntime(Runtime::kTraceEnter, 0); 343 __ CallRuntime(Runtime::kTraceEnter, 0);
322 } 344 }
323 345
324 // Visit the declarations and body unless there is an illegal 346 // Visit the declarations and body unless there is an illegal
325 // redeclaration. 347 // redeclaration.
326 if (scope()->HasIllegalRedeclaration()) { 348 if (scope()->HasIllegalRedeclaration()) {
327 Comment cmnt(masm_, "[ Declarations"); 349 Comment cmnt(masm_, "[ Declarations");
328 scope()->VisitIllegalRedeclaration(this); 350 scope()->VisitIllegalRedeclaration(this);
329 351
(...skipping 976 matching lines...) Expand 10 before | Expand all | Expand 10 after
1306 context()->Plug(v0); 1328 context()->Plug(v0);
1307 } 1329 }
1308 1330
1309 1331
1310 void FullCodeGenerator::VisitVariableProxy(VariableProxy* expr) { 1332 void FullCodeGenerator::VisitVariableProxy(VariableProxy* expr) {
1311 Comment cmnt(masm_, "[ VariableProxy"); 1333 Comment cmnt(masm_, "[ VariableProxy");
1312 EmitVariableLoad(expr); 1334 EmitVariableLoad(expr);
1313 } 1335 }
1314 1336
1315 1337
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 if (FLAG_vector_ics) {
1326 __ li(VectorLoadICDescriptor::SlotRegister(),
1327 Operand(SmiFromSlot(expr->HomeObjectFeedbackSlot())));
1328 CallLoadIC(NOT_CONTEXTUAL);
1329 } else {
1330 CallLoadIC(NOT_CONTEXTUAL, expr->HomeObjectFeedbackId());
1331 }
1332
1333 Label done;
1334 __ Branch(&done, ne, v0, Operand(isolate()->factory()->undefined_value()));
1335 __ CallRuntime(Runtime::kThrowNonMethodError, 0);
1336 __ bind(&done);
1337 }
1338
1339
1340 void FullCodeGenerator::EmitSetHomeObjectIfNeeded(Expression* initializer, 1338 void FullCodeGenerator::EmitSetHomeObjectIfNeeded(Expression* initializer,
1341 int offset) { 1339 int offset) {
1342 if (NeedsHomeObject(initializer)) { 1340 if (NeedsHomeObject(initializer)) {
1343 __ lw(StoreDescriptor::ReceiverRegister(), MemOperand(sp)); 1341 __ lw(StoreDescriptor::ReceiverRegister(), MemOperand(sp));
1344 __ li(StoreDescriptor::NameRegister(), 1342 __ li(StoreDescriptor::NameRegister(),
1345 Operand(isolate()->factory()->home_object_symbol())); 1343 Operand(isolate()->factory()->home_object_symbol()));
1346 __ lw(StoreDescriptor::ValueRegister(), 1344 __ lw(StoreDescriptor::ValueRegister(),
1347 MemOperand(sp, offset * kPointerSize)); 1345 MemOperand(sp, offset * kPointerSize));
1348 CallStoreIC(); 1346 CallStoreIC();
1349 } 1347 }
(...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after
1943 if (expr->is_compound()) { 1941 if (expr->is_compound()) {
1944 // We need the receiver both on the stack and in the register. 1942 // We need the receiver both on the stack and in the register.
1945 VisitForStackValue(property->obj()); 1943 VisitForStackValue(property->obj());
1946 __ lw(LoadDescriptor::ReceiverRegister(), MemOperand(sp, 0)); 1944 __ lw(LoadDescriptor::ReceiverRegister(), MemOperand(sp, 0));
1947 } else { 1945 } else {
1948 VisitForStackValue(property->obj()); 1946 VisitForStackValue(property->obj());
1949 } 1947 }
1950 break; 1948 break;
1951 case NAMED_SUPER_PROPERTY: 1949 case NAMED_SUPER_PROPERTY:
1952 VisitForStackValue(property->obj()->AsSuperReference()->this_var()); 1950 VisitForStackValue(property->obj()->AsSuperReference()->this_var());
1953 EmitLoadHomeObject(property->obj()->AsSuperReference()); 1951 VisitForAccumulatorValue(
1952 property->obj()->AsSuperReference()->home_object_var());
1954 __ Push(result_register()); 1953 __ Push(result_register());
1955 if (expr->is_compound()) { 1954 if (expr->is_compound()) {
1956 const Register scratch = a1; 1955 const Register scratch = a1;
1957 __ lw(scratch, MemOperand(sp, kPointerSize)); 1956 __ lw(scratch, MemOperand(sp, kPointerSize));
1958 __ Push(scratch, result_register()); 1957 __ Push(scratch, result_register());
1959 } 1958 }
1960 break; 1959 break;
1961 case KEYED_SUPER_PROPERTY: { 1960 case KEYED_SUPER_PROPERTY: {
1962 const Register scratch = a1; 1961 const Register scratch = a1;
1963 VisitForStackValue(property->obj()->AsSuperReference()->this_var()); 1962 VisitForStackValue(property->obj()->AsSuperReference()->this_var());
1964 EmitLoadHomeObject(property->obj()->AsSuperReference()); 1963 VisitForAccumulatorValue(
1964 property->obj()->AsSuperReference()->home_object_var());
1965 __ Move(scratch, result_register()); 1965 __ Move(scratch, result_register());
1966 VisitForAccumulatorValue(property->key()); 1966 VisitForAccumulatorValue(property->key());
1967 __ Push(scratch, result_register()); 1967 __ Push(scratch, result_register());
1968 if (expr->is_compound()) { 1968 if (expr->is_compound()) {
1969 const Register scratch1 = t0; 1969 const Register scratch1 = t0;
1970 __ lw(scratch1, MemOperand(sp, 2 * kPointerSize)); 1970 __ lw(scratch1, MemOperand(sp, 2 * kPointerSize));
1971 __ Push(scratch1, scratch, result_register()); 1971 __ Push(scratch1, scratch, result_register());
1972 } 1972 }
1973 break; 1973 break;
1974 } 1974 }
(...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after
2601 __ mov(StoreDescriptor::ReceiverRegister(), result_register()); 2601 __ mov(StoreDescriptor::ReceiverRegister(), result_register());
2602 __ pop(StoreDescriptor::ValueRegister()); // Restore value. 2602 __ pop(StoreDescriptor::ValueRegister()); // Restore value.
2603 __ li(StoreDescriptor::NameRegister(), 2603 __ li(StoreDescriptor::NameRegister(),
2604 Operand(prop->key()->AsLiteral()->value())); 2604 Operand(prop->key()->AsLiteral()->value()));
2605 CallStoreIC(); 2605 CallStoreIC();
2606 break; 2606 break;
2607 } 2607 }
2608 case NAMED_SUPER_PROPERTY: { 2608 case NAMED_SUPER_PROPERTY: {
2609 __ Push(v0); 2609 __ Push(v0);
2610 VisitForStackValue(prop->obj()->AsSuperReference()->this_var()); 2610 VisitForStackValue(prop->obj()->AsSuperReference()->this_var());
2611 EmitLoadHomeObject(prop->obj()->AsSuperReference()); 2611 VisitForAccumulatorValue(
2612 prop->obj()->AsSuperReference()->home_object_var());
2612 // stack: value, this; v0: home_object 2613 // stack: value, this; v0: home_object
2613 Register scratch = a2; 2614 Register scratch = a2;
2614 Register scratch2 = a3; 2615 Register scratch2 = a3;
2615 __ mov(scratch, result_register()); // home_object 2616 __ mov(scratch, result_register()); // home_object
2616 __ lw(v0, MemOperand(sp, kPointerSize)); // value 2617 __ lw(v0, MemOperand(sp, kPointerSize)); // value
2617 __ lw(scratch2, MemOperand(sp, 0)); // this 2618 __ lw(scratch2, MemOperand(sp, 0)); // this
2618 __ sw(scratch2, MemOperand(sp, kPointerSize)); // this 2619 __ sw(scratch2, MemOperand(sp, kPointerSize)); // this
2619 __ sw(scratch, MemOperand(sp, 0)); // home_object 2620 __ sw(scratch, MemOperand(sp, 0)); // home_object
2620 // stack: this, home_object; v0: value 2621 // stack: this, home_object; v0: value
2621 EmitNamedSuperPropertyStore(prop); 2622 EmitNamedSuperPropertyStore(prop);
2622 break; 2623 break;
2623 } 2624 }
2624 case KEYED_SUPER_PROPERTY: { 2625 case KEYED_SUPER_PROPERTY: {
2625 __ Push(v0); 2626 __ Push(v0);
2626 VisitForStackValue(prop->obj()->AsSuperReference()->this_var()); 2627 VisitForStackValue(prop->obj()->AsSuperReference()->this_var());
2627 EmitLoadHomeObject(prop->obj()->AsSuperReference()); 2628 VisitForStackValue(prop->obj()->AsSuperReference()->home_object_var());
2628 __ Push(result_register());
2629 VisitForAccumulatorValue(prop->key()); 2629 VisitForAccumulatorValue(prop->key());
2630 Register scratch = a2; 2630 Register scratch = a2;
2631 Register scratch2 = a3; 2631 Register scratch2 = a3;
2632 __ lw(scratch2, MemOperand(sp, 2 * kPointerSize)); // value 2632 __ lw(scratch2, MemOperand(sp, 2 * kPointerSize)); // value
2633 // stack: value, this, home_object; v0: key, a3: value 2633 // stack: value, this, home_object; v0: key, a3: value
2634 __ lw(scratch, MemOperand(sp, kPointerSize)); // this 2634 __ lw(scratch, MemOperand(sp, kPointerSize)); // this
2635 __ sw(scratch, MemOperand(sp, 2 * kPointerSize)); 2635 __ sw(scratch, MemOperand(sp, 2 * kPointerSize));
2636 __ lw(scratch, MemOperand(sp, 0)); // home_object 2636 __ lw(scratch, MemOperand(sp, 0)); // home_object
2637 __ sw(scratch, MemOperand(sp, kPointerSize)); 2637 __ sw(scratch, MemOperand(sp, kPointerSize));
2638 __ sw(v0, MemOperand(sp, 0)); 2638 __ sw(v0, MemOperand(sp, 0));
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
2835 Comment cmnt(masm_, "[ Property"); 2835 Comment cmnt(masm_, "[ Property");
2836 Expression* key = expr->key(); 2836 Expression* key = expr->key();
2837 2837
2838 if (key->IsPropertyName()) { 2838 if (key->IsPropertyName()) {
2839 if (!expr->IsSuperAccess()) { 2839 if (!expr->IsSuperAccess()) {
2840 VisitForAccumulatorValue(expr->obj()); 2840 VisitForAccumulatorValue(expr->obj());
2841 __ Move(LoadDescriptor::ReceiverRegister(), v0); 2841 __ Move(LoadDescriptor::ReceiverRegister(), v0);
2842 EmitNamedPropertyLoad(expr); 2842 EmitNamedPropertyLoad(expr);
2843 } else { 2843 } else {
2844 VisitForStackValue(expr->obj()->AsSuperReference()->this_var()); 2844 VisitForStackValue(expr->obj()->AsSuperReference()->this_var());
2845 EmitLoadHomeObject(expr->obj()->AsSuperReference()); 2845 VisitForStackValue(expr->obj()->AsSuperReference()->home_object_var());
2846 __ Push(result_register());
2847 EmitNamedSuperPropertyLoad(expr); 2846 EmitNamedSuperPropertyLoad(expr);
2848 } 2847 }
2849 } else { 2848 } else {
2850 if (!expr->IsSuperAccess()) { 2849 if (!expr->IsSuperAccess()) {
2851 VisitForStackValue(expr->obj()); 2850 VisitForStackValue(expr->obj());
2852 VisitForAccumulatorValue(expr->key()); 2851 VisitForAccumulatorValue(expr->key());
2853 __ Move(LoadDescriptor::NameRegister(), v0); 2852 __ Move(LoadDescriptor::NameRegister(), v0);
2854 __ pop(LoadDescriptor::ReceiverRegister()); 2853 __ pop(LoadDescriptor::ReceiverRegister());
2855 EmitKeyedPropertyLoad(expr); 2854 EmitKeyedPropertyLoad(expr);
2856 } else { 2855 } else {
2857 VisitForStackValue(expr->obj()->AsSuperReference()->this_var()); 2856 VisitForStackValue(expr->obj()->AsSuperReference()->this_var());
2858 EmitLoadHomeObject(expr->obj()->AsSuperReference()); 2857 VisitForStackValue(expr->obj()->AsSuperReference()->home_object_var());
2859 __ Push(result_register());
2860 VisitForStackValue(expr->key()); 2858 VisitForStackValue(expr->key());
2861 EmitKeyedSuperPropertyLoad(expr); 2859 EmitKeyedSuperPropertyLoad(expr);
2862 } 2860 }
2863 } 2861 }
2864 PrepareForBailoutForId(expr->LoadId(), TOS_REG); 2862 PrepareForBailoutForId(expr->LoadId(), TOS_REG);
2865 context()->Plug(v0); 2863 context()->Plug(v0);
2866 } 2864 }
2867 2865
2868 2866
2869 void FullCodeGenerator::CallIC(Handle<Code> code, 2867 void FullCodeGenerator::CallIC(Handle<Code> code,
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
2912 DCHECK(callee->IsProperty()); 2910 DCHECK(callee->IsProperty());
2913 Property* prop = callee->AsProperty(); 2911 Property* prop = callee->AsProperty();
2914 DCHECK(prop->IsSuperAccess()); 2912 DCHECK(prop->IsSuperAccess());
2915 2913
2916 SetSourcePosition(prop->position()); 2914 SetSourcePosition(prop->position());
2917 Literal* key = prop->key()->AsLiteral(); 2915 Literal* key = prop->key()->AsLiteral();
2918 DCHECK(!key->value()->IsSmi()); 2916 DCHECK(!key->value()->IsSmi());
2919 // Load the function from the receiver. 2917 // Load the function from the receiver.
2920 const Register scratch = a1; 2918 const Register scratch = a1;
2921 SuperReference* super_ref = prop->obj()->AsSuperReference(); 2919 SuperReference* super_ref = prop->obj()->AsSuperReference();
2922 EmitLoadHomeObject(super_ref); 2920 VisitForAccumulatorValue(super_ref->home_object_var());
2923 __ mov(scratch, v0); 2921 __ mov(scratch, v0);
2924 VisitForAccumulatorValue(super_ref->this_var()); 2922 VisitForAccumulatorValue(super_ref->this_var());
2925 __ Push(scratch, v0, v0, scratch); 2923 __ Push(scratch, v0, v0, scratch);
2926 __ Push(key->value()); 2924 __ Push(key->value());
2927 2925
2928 // Stack here: 2926 // Stack here:
2929 // - home_object 2927 // - home_object
2930 // - this (receiver) 2928 // - this (receiver)
2931 // - this (receiver) <-- LoadFromSuper will pop here and below. 2929 // - this (receiver) <-- LoadFromSuper will pop here and below.
2932 // - home_object 2930 // - home_object
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
2970 void FullCodeGenerator::EmitKeyedSuperCallWithLoadIC(Call* expr) { 2968 void FullCodeGenerator::EmitKeyedSuperCallWithLoadIC(Call* expr) {
2971 Expression* callee = expr->expression(); 2969 Expression* callee = expr->expression();
2972 DCHECK(callee->IsProperty()); 2970 DCHECK(callee->IsProperty());
2973 Property* prop = callee->AsProperty(); 2971 Property* prop = callee->AsProperty();
2974 DCHECK(prop->IsSuperAccess()); 2972 DCHECK(prop->IsSuperAccess());
2975 2973
2976 SetSourcePosition(prop->position()); 2974 SetSourcePosition(prop->position());
2977 // Load the function from the receiver. 2975 // Load the function from the receiver.
2978 const Register scratch = a1; 2976 const Register scratch = a1;
2979 SuperReference* super_ref = prop->obj()->AsSuperReference(); 2977 SuperReference* super_ref = prop->obj()->AsSuperReference();
2980 EmitLoadHomeObject(super_ref); 2978 VisitForAccumulatorValue(super_ref->home_object_var());
2981 __ Move(scratch, v0); 2979 __ Move(scratch, v0);
2982 VisitForAccumulatorValue(super_ref->this_var()); 2980 VisitForAccumulatorValue(super_ref->this_var());
2983 __ Push(scratch, v0, v0, scratch); 2981 __ Push(scratch, v0, v0, scratch);
2984 VisitForStackValue(prop->key()); 2982 VisitForStackValue(prop->key());
2985 2983
2986 // Stack here: 2984 // Stack here:
2987 // - home_object 2985 // - home_object
2988 // - this (receiver) 2986 // - this (receiver)
2989 // - this (receiver) <-- LoadKeyedFromSuper will pop here and below. 2987 // - this (receiver) <-- LoadKeyedFromSuper will pop here and below.
2990 // - home_object 2988 // - home_object
(...skipping 1855 matching lines...) Expand 10 before | Expand all | Expand 10 after
4846 case NAMED_PROPERTY: { 4844 case NAMED_PROPERTY: {
4847 // Put the object both on the stack and in the register. 4845 // Put the object both on the stack and in the register.
4848 VisitForStackValue(prop->obj()); 4846 VisitForStackValue(prop->obj());
4849 __ lw(LoadDescriptor::ReceiverRegister(), MemOperand(sp, 0)); 4847 __ lw(LoadDescriptor::ReceiverRegister(), MemOperand(sp, 0));
4850 EmitNamedPropertyLoad(prop); 4848 EmitNamedPropertyLoad(prop);
4851 break; 4849 break;
4852 } 4850 }
4853 4851
4854 case NAMED_SUPER_PROPERTY: { 4852 case NAMED_SUPER_PROPERTY: {
4855 VisitForStackValue(prop->obj()->AsSuperReference()->this_var()); 4853 VisitForStackValue(prop->obj()->AsSuperReference()->this_var());
4856 EmitLoadHomeObject(prop->obj()->AsSuperReference()); 4854 VisitForAccumulatorValue(
4855 prop->obj()->AsSuperReference()->home_object_var());
4857 __ Push(result_register()); 4856 __ Push(result_register());
4858 const Register scratch = a1; 4857 const Register scratch = a1;
4859 __ lw(scratch, MemOperand(sp, kPointerSize)); 4858 __ lw(scratch, MemOperand(sp, kPointerSize));
4860 __ Push(scratch, result_register()); 4859 __ Push(scratch, result_register());
4861 EmitNamedSuperPropertyLoad(prop); 4860 EmitNamedSuperPropertyLoad(prop);
4862 break; 4861 break;
4863 } 4862 }
4864 4863
4865 case KEYED_SUPER_PROPERTY: { 4864 case KEYED_SUPER_PROPERTY: {
4866 VisitForStackValue(prop->obj()->AsSuperReference()->this_var()); 4865 VisitForStackValue(prop->obj()->AsSuperReference()->this_var());
4867 EmitLoadHomeObject(prop->obj()->AsSuperReference()); 4866 VisitForAccumulatorValue(
4867 prop->obj()->AsSuperReference()->home_object_var());
4868 const Register scratch = a1; 4868 const Register scratch = a1;
4869 const Register scratch1 = t0; 4869 const Register scratch1 = t0;
4870 __ Move(scratch, result_register()); 4870 __ Move(scratch, result_register());
4871 VisitForAccumulatorValue(prop->key()); 4871 VisitForAccumulatorValue(prop->key());
4872 __ Push(scratch, result_register()); 4872 __ Push(scratch, result_register());
4873 __ lw(scratch1, MemOperand(sp, 2 * kPointerSize)); 4873 __ lw(scratch1, MemOperand(sp, 2 * kPointerSize));
4874 __ Push(scratch1, scratch, result_register()); 4874 __ Push(scratch1, scratch, result_register());
4875 EmitKeyedSuperPropertyLoad(prop); 4875 EmitKeyedSuperPropertyLoad(prop);
4876 break; 4876 break;
4877 } 4877 }
(...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after
5450 Assembler::target_address_at(pc_immediate_load_address)) == 5450 Assembler::target_address_at(pc_immediate_load_address)) ==
5451 reinterpret_cast<uint32_t>( 5451 reinterpret_cast<uint32_t>(
5452 isolate->builtins()->OsrAfterStackCheck()->entry())); 5452 isolate->builtins()->OsrAfterStackCheck()->entry()));
5453 return OSR_AFTER_STACK_CHECK; 5453 return OSR_AFTER_STACK_CHECK;
5454 } 5454 }
5455 5455
5456 5456
5457 } } // namespace v8::internal 5457 } } // namespace v8::internal
5458 5458
5459 #endif // V8_TARGET_ARCH_MIPS 5459 #endif // V8_TARGET_ARCH_MIPS
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698