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

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

Issue 1154103005: Refactor lexical home object binding (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: git rebase Created 5 years, 6 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
« no previous file with comments | « src/ast-value-factory.cc ('k') | src/mips/full-codegen-mips.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_IA32 7 #if V8_TARGET_ARCH_IA32
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 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 } else if (FLAG_debug_code) { 231 } else if (FLAG_debug_code) {
232 Label done; 232 Label done;
233 __ JumpIfInNewSpace(esi, eax, &done, Label::kNear); 233 __ JumpIfInNewSpace(esi, eax, &done, Label::kNear);
234 __ Abort(kExpectedNewSpaceObject); 234 __ Abort(kExpectedNewSpaceObject);
235 __ bind(&done); 235 __ bind(&done);
236 } 236 }
237 } 237 }
238 } 238 }
239 } 239 }
240 240
241 Variable* home_object_var = scope()->home_object_var();
242 if (home_object_var != nullptr) {
243 __ push(edi);
244 }
245
246 // Possibly set up a local binding to the this function which is used in 241 // Possibly set up a local binding to the this function which is used in
247 // derived constructors with super calls. 242 // derived constructors with super calls.
248 Variable* this_function_var = scope()->this_function_var(); 243 Variable* this_function_var = scope()->this_function_var();
249 if (this_function_var != nullptr) { 244 if (this_function_var != nullptr) {
250 Comment cmnt(masm_, "[ This function"); 245 Comment cmnt(masm_, "[ This function");
251 SetVar(this_function_var, edi, ebx, edx); 246 SetVar(this_function_var, edi, ebx, edx);
252 } 247 }
253 248
254 Variable* new_target_var = scope()->new_target_var(); 249 Variable* new_target_var = scope()->new_target_var();
255 if (new_target_var != nullptr) { 250 if (new_target_var != nullptr) {
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 } else { 315 } else {
321 type = ArgumentsAccessStub::NEW_SLOPPY_FAST; 316 type = ArgumentsAccessStub::NEW_SLOPPY_FAST;
322 } 317 }
323 318
324 ArgumentsAccessStub stub(isolate(), type, has_new_target); 319 ArgumentsAccessStub stub(isolate(), type, has_new_target);
325 __ CallStub(&stub); 320 __ CallStub(&stub);
326 321
327 SetVar(arguments, eax, ebx, edx); 322 SetVar(arguments, eax, ebx, edx);
328 } 323 }
329 324
330 // Possibly set up a local binding to the [[HomeObject]].
331 if (home_object_var != nullptr) {
332 Comment cmnt(masm_, "[ Home object");
333 __ pop(LoadDescriptor::ReceiverRegister());
334 Handle<Symbol> home_object_symbol(isolate()->heap()->home_object_symbol());
335 __ mov(LoadDescriptor::NameRegister(), Immediate(home_object_symbol));
336 __ mov(LoadDescriptor::SlotRegister(),
337 Immediate(SmiFromSlot(function()->HomeObjectFeedbackSlot())));
338 CallLoadIC(NOT_CONTEXTUAL);
339
340 SetVar(home_object_var, eax, ebx, edx);
341 }
342
343 if (FLAG_trace) { 325 if (FLAG_trace) {
344 __ CallRuntime(Runtime::kTraceEnter, 0); 326 __ CallRuntime(Runtime::kTraceEnter, 0);
345 } 327 }
346 328
347 // Visit the declarations and body unless there is an illegal 329 // Visit the declarations and body unless there is an illegal
348 // redeclaration. 330 // redeclaration.
349 if (scope()->HasIllegalRedeclaration()) { 331 if (scope()->HasIllegalRedeclaration()) {
350 Comment cmnt(masm_, "[ Declarations"); 332 Comment cmnt(masm_, "[ Declarations");
351 scope()->VisitIllegalRedeclaration(this); 333 scope()->VisitIllegalRedeclaration(this);
352 334
(...skipping 1581 matching lines...) Expand 10 before | Expand all | Expand 10 after
1934 1916
1935 // Evaluate LHS expression. 1917 // Evaluate LHS expression.
1936 switch (assign_type) { 1918 switch (assign_type) {
1937 case VARIABLE: 1919 case VARIABLE:
1938 // Nothing to do here. 1920 // Nothing to do here.
1939 break; 1921 break;
1940 case NAMED_SUPER_PROPERTY: 1922 case NAMED_SUPER_PROPERTY:
1941 VisitForStackValue( 1923 VisitForStackValue(
1942 property->obj()->AsSuperPropertyReference()->this_var()); 1924 property->obj()->AsSuperPropertyReference()->this_var());
1943 VisitForAccumulatorValue( 1925 VisitForAccumulatorValue(
1944 property->obj()->AsSuperPropertyReference()->home_object_var()); 1926 property->obj()->AsSuperPropertyReference()->home_object());
1945 __ push(result_register()); 1927 __ push(result_register());
1946 if (expr->is_compound()) { 1928 if (expr->is_compound()) {
1947 __ push(MemOperand(esp, kPointerSize)); 1929 __ push(MemOperand(esp, kPointerSize));
1948 __ push(result_register()); 1930 __ push(result_register());
1949 } 1931 }
1950 break; 1932 break;
1951 case NAMED_PROPERTY: 1933 case NAMED_PROPERTY:
1952 if (expr->is_compound()) { 1934 if (expr->is_compound()) {
1953 // 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.
1954 VisitForStackValue(property->obj()); 1936 VisitForStackValue(property->obj());
1955 __ mov(LoadDescriptor::ReceiverRegister(), Operand(esp, 0)); 1937 __ mov(LoadDescriptor::ReceiverRegister(), Operand(esp, 0));
1956 } else { 1938 } else {
1957 VisitForStackValue(property->obj()); 1939 VisitForStackValue(property->obj());
1958 } 1940 }
1959 break; 1941 break;
1960 case KEYED_SUPER_PROPERTY: 1942 case KEYED_SUPER_PROPERTY:
1961 VisitForStackValue( 1943 VisitForStackValue(
1962 property->obj()->AsSuperPropertyReference()->this_var()); 1944 property->obj()->AsSuperPropertyReference()->this_var());
1963 VisitForStackValue( 1945 VisitForStackValue(
1964 property->obj()->AsSuperPropertyReference()->home_object_var()); 1946 property->obj()->AsSuperPropertyReference()->home_object());
1965 VisitForAccumulatorValue(property->key()); 1947 VisitForAccumulatorValue(property->key());
1966 __ Push(result_register()); 1948 __ Push(result_register());
1967 if (expr->is_compound()) { 1949 if (expr->is_compound()) {
1968 __ push(MemOperand(esp, 2 * kPointerSize)); 1950 __ push(MemOperand(esp, 2 * kPointerSize));
1969 __ push(MemOperand(esp, 2 * kPointerSize)); 1951 __ push(MemOperand(esp, 2 * kPointerSize));
1970 __ push(result_register()); 1952 __ push(result_register());
1971 } 1953 }
1972 break; 1954 break;
1973 case KEYED_PROPERTY: { 1955 case KEYED_PROPERTY: {
1974 if (expr->is_compound()) { 1956 if (expr->is_compound()) {
(...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after
2580 __ mov(StoreDescriptor::NameRegister(), 2562 __ mov(StoreDescriptor::NameRegister(),
2581 prop->key()->AsLiteral()->value()); 2563 prop->key()->AsLiteral()->value());
2582 if (FLAG_vector_stores) EmitLoadStoreICSlot(slot); 2564 if (FLAG_vector_stores) EmitLoadStoreICSlot(slot);
2583 CallStoreIC(); 2565 CallStoreIC();
2584 break; 2566 break;
2585 } 2567 }
2586 case NAMED_SUPER_PROPERTY: { 2568 case NAMED_SUPER_PROPERTY: {
2587 __ push(eax); 2569 __ push(eax);
2588 VisitForStackValue(prop->obj()->AsSuperPropertyReference()->this_var()); 2570 VisitForStackValue(prop->obj()->AsSuperPropertyReference()->this_var());
2589 VisitForAccumulatorValue( 2571 VisitForAccumulatorValue(
2590 prop->obj()->AsSuperPropertyReference()->home_object_var()); 2572 prop->obj()->AsSuperPropertyReference()->home_object());
2591 // stack: value, this; eax: home_object 2573 // stack: value, this; eax: home_object
2592 Register scratch = ecx; 2574 Register scratch = ecx;
2593 Register scratch2 = edx; 2575 Register scratch2 = edx;
2594 __ mov(scratch, result_register()); // home_object 2576 __ mov(scratch, result_register()); // home_object
2595 __ mov(eax, MemOperand(esp, kPointerSize)); // value 2577 __ mov(eax, MemOperand(esp, kPointerSize)); // value
2596 __ mov(scratch2, MemOperand(esp, 0)); // this 2578 __ mov(scratch2, MemOperand(esp, 0)); // this
2597 __ mov(MemOperand(esp, kPointerSize), scratch2); // this 2579 __ mov(MemOperand(esp, kPointerSize), scratch2); // this
2598 __ mov(MemOperand(esp, 0), scratch); // home_object 2580 __ mov(MemOperand(esp, 0), scratch); // home_object
2599 // stack: this, home_object. eax: value 2581 // stack: this, home_object. eax: value
2600 EmitNamedSuperPropertyStore(prop); 2582 EmitNamedSuperPropertyStore(prop);
2601 break; 2583 break;
2602 } 2584 }
2603 case KEYED_SUPER_PROPERTY: { 2585 case KEYED_SUPER_PROPERTY: {
2604 __ push(eax); 2586 __ push(eax);
2605 VisitForStackValue(prop->obj()->AsSuperPropertyReference()->this_var()); 2587 VisitForStackValue(prop->obj()->AsSuperPropertyReference()->this_var());
2606 VisitForStackValue( 2588 VisitForStackValue(
2607 prop->obj()->AsSuperPropertyReference()->home_object_var()); 2589 prop->obj()->AsSuperPropertyReference()->home_object());
2608 VisitForAccumulatorValue(prop->key()); 2590 VisitForAccumulatorValue(prop->key());
2609 Register scratch = ecx; 2591 Register scratch = ecx;
2610 Register scratch2 = edx; 2592 Register scratch2 = edx;
2611 __ mov(scratch2, MemOperand(esp, 2 * kPointerSize)); // value 2593 __ mov(scratch2, MemOperand(esp, 2 * kPointerSize)); // value
2612 // stack: value, this, home_object; eax: key, edx: value 2594 // stack: value, this, home_object; eax: key, edx: value
2613 __ mov(scratch, MemOperand(esp, kPointerSize)); // this 2595 __ mov(scratch, MemOperand(esp, kPointerSize)); // this
2614 __ mov(MemOperand(esp, 2 * kPointerSize), scratch); 2596 __ mov(MemOperand(esp, 2 * kPointerSize), scratch);
2615 __ mov(scratch, MemOperand(esp, 0)); // home_object 2597 __ mov(scratch, MemOperand(esp, 0)); // home_object
2616 __ mov(MemOperand(esp, kPointerSize), scratch); 2598 __ mov(MemOperand(esp, kPointerSize), scratch);
2617 __ mov(MemOperand(esp, 0), eax); 2599 __ mov(MemOperand(esp, 0), eax);
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
2821 Expression* key = expr->key(); 2803 Expression* key = expr->key();
2822 2804
2823 if (key->IsPropertyName()) { 2805 if (key->IsPropertyName()) {
2824 if (!expr->IsSuperAccess()) { 2806 if (!expr->IsSuperAccess()) {
2825 VisitForAccumulatorValue(expr->obj()); 2807 VisitForAccumulatorValue(expr->obj());
2826 __ Move(LoadDescriptor::ReceiverRegister(), result_register()); 2808 __ Move(LoadDescriptor::ReceiverRegister(), result_register());
2827 EmitNamedPropertyLoad(expr); 2809 EmitNamedPropertyLoad(expr);
2828 } else { 2810 } else {
2829 VisitForStackValue(expr->obj()->AsSuperPropertyReference()->this_var()); 2811 VisitForStackValue(expr->obj()->AsSuperPropertyReference()->this_var());
2830 VisitForStackValue( 2812 VisitForStackValue(
2831 expr->obj()->AsSuperPropertyReference()->home_object_var()); 2813 expr->obj()->AsSuperPropertyReference()->home_object());
2832 EmitNamedSuperPropertyLoad(expr); 2814 EmitNamedSuperPropertyLoad(expr);
2833 } 2815 }
2834 } else { 2816 } else {
2835 if (!expr->IsSuperAccess()) { 2817 if (!expr->IsSuperAccess()) {
2836 VisitForStackValue(expr->obj()); 2818 VisitForStackValue(expr->obj());
2837 VisitForAccumulatorValue(expr->key()); 2819 VisitForAccumulatorValue(expr->key());
2838 __ pop(LoadDescriptor::ReceiverRegister()); // Object. 2820 __ pop(LoadDescriptor::ReceiverRegister()); // Object.
2839 __ Move(LoadDescriptor::NameRegister(), result_register()); // Key. 2821 __ Move(LoadDescriptor::NameRegister(), result_register()); // Key.
2840 EmitKeyedPropertyLoad(expr); 2822 EmitKeyedPropertyLoad(expr);
2841 } else { 2823 } else {
2842 VisitForStackValue(expr->obj()->AsSuperPropertyReference()->this_var()); 2824 VisitForStackValue(expr->obj()->AsSuperPropertyReference()->this_var());
2843 VisitForStackValue( 2825 VisitForStackValue(
2844 expr->obj()->AsSuperPropertyReference()->home_object_var()); 2826 expr->obj()->AsSuperPropertyReference()->home_object());
2845 VisitForStackValue(expr->key()); 2827 VisitForStackValue(expr->key());
2846 EmitKeyedSuperPropertyLoad(expr); 2828 EmitKeyedSuperPropertyLoad(expr);
2847 } 2829 }
2848 } 2830 }
2849 PrepareForBailoutForId(expr->LoadId(), TOS_REG); 2831 PrepareForBailoutForId(expr->LoadId(), TOS_REG);
2850 context()->Plug(eax); 2832 context()->Plug(eax);
2851 } 2833 }
2852 2834
2853 2835
2854 void FullCodeGenerator::CallIC(Handle<Code> code, 2836 void FullCodeGenerator::CallIC(Handle<Code> code,
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
2893 Expression* callee = expr->expression(); 2875 Expression* callee = expr->expression();
2894 DCHECK(callee->IsProperty()); 2876 DCHECK(callee->IsProperty());
2895 Property* prop = callee->AsProperty(); 2877 Property* prop = callee->AsProperty();
2896 DCHECK(prop->IsSuperAccess()); 2878 DCHECK(prop->IsSuperAccess());
2897 2879
2898 SetSourcePosition(prop->position()); 2880 SetSourcePosition(prop->position());
2899 Literal* key = prop->key()->AsLiteral(); 2881 Literal* key = prop->key()->AsLiteral();
2900 DCHECK(!key->value()->IsSmi()); 2882 DCHECK(!key->value()->IsSmi());
2901 // Load the function from the receiver. 2883 // Load the function from the receiver.
2902 SuperPropertyReference* super_ref = prop->obj()->AsSuperPropertyReference(); 2884 SuperPropertyReference* super_ref = prop->obj()->AsSuperPropertyReference();
2903 VisitForStackValue(super_ref->home_object_var()); 2885 VisitForStackValue(super_ref->home_object());
2904 VisitForAccumulatorValue(super_ref->this_var()); 2886 VisitForAccumulatorValue(super_ref->this_var());
2905 __ push(eax); 2887 __ push(eax);
2906 __ push(eax); 2888 __ push(eax);
2907 __ push(Operand(esp, kPointerSize * 2)); 2889 __ push(Operand(esp, kPointerSize * 2));
2908 __ push(Immediate(key->value())); 2890 __ push(Immediate(key->value()));
2909 // Stack here: 2891 // Stack here:
2910 // - home_object 2892 // - home_object
2911 // - this (receiver) 2893 // - this (receiver)
2912 // - this (receiver) <-- LoadFromSuper will pop here and below. 2894 // - this (receiver) <-- LoadFromSuper will pop here and below.
2913 // - home_object 2895 // - home_object
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
2949 2931
2950 void FullCodeGenerator::EmitKeyedSuperCallWithLoadIC(Call* expr) { 2932 void FullCodeGenerator::EmitKeyedSuperCallWithLoadIC(Call* expr) {
2951 Expression* callee = expr->expression(); 2933 Expression* callee = expr->expression();
2952 DCHECK(callee->IsProperty()); 2934 DCHECK(callee->IsProperty());
2953 Property* prop = callee->AsProperty(); 2935 Property* prop = callee->AsProperty();
2954 DCHECK(prop->IsSuperAccess()); 2936 DCHECK(prop->IsSuperAccess());
2955 2937
2956 SetSourcePosition(prop->position()); 2938 SetSourcePosition(prop->position());
2957 // Load the function from the receiver. 2939 // Load the function from the receiver.
2958 SuperPropertyReference* super_ref = prop->obj()->AsSuperPropertyReference(); 2940 SuperPropertyReference* super_ref = prop->obj()->AsSuperPropertyReference();
2959 VisitForStackValue(super_ref->home_object_var()); 2941 VisitForStackValue(super_ref->home_object());
2960 VisitForAccumulatorValue(super_ref->this_var()); 2942 VisitForAccumulatorValue(super_ref->this_var());
2961 __ push(eax); 2943 __ push(eax);
2962 __ push(eax); 2944 __ push(eax);
2963 __ push(Operand(esp, kPointerSize * 2)); 2945 __ push(Operand(esp, kPointerSize * 2));
2964 VisitForStackValue(prop->key()); 2946 VisitForStackValue(prop->key());
2965 // Stack here: 2947 // Stack here:
2966 // - home_object 2948 // - home_object
2967 // - this (receiver) 2949 // - this (receiver)
2968 // - this (receiver) <-- LoadKeyedFromSuper will pop here and below. 2950 // - this (receiver) <-- LoadKeyedFromSuper will pop here and below.
2969 // - home_object 2951 // - home_object
(...skipping 1871 matching lines...) Expand 10 before | Expand all | Expand 10 after
4841 // Put the object both on the stack and in the register. 4823 // Put the object both on the stack and in the register.
4842 VisitForStackValue(prop->obj()); 4824 VisitForStackValue(prop->obj());
4843 __ mov(LoadDescriptor::ReceiverRegister(), Operand(esp, 0)); 4825 __ mov(LoadDescriptor::ReceiverRegister(), Operand(esp, 0));
4844 EmitNamedPropertyLoad(prop); 4826 EmitNamedPropertyLoad(prop);
4845 break; 4827 break;
4846 } 4828 }
4847 4829
4848 case NAMED_SUPER_PROPERTY: { 4830 case NAMED_SUPER_PROPERTY: {
4849 VisitForStackValue(prop->obj()->AsSuperPropertyReference()->this_var()); 4831 VisitForStackValue(prop->obj()->AsSuperPropertyReference()->this_var());
4850 VisitForAccumulatorValue( 4832 VisitForAccumulatorValue(
4851 prop->obj()->AsSuperPropertyReference()->home_object_var()); 4833 prop->obj()->AsSuperPropertyReference()->home_object());
4852 __ push(result_register()); 4834 __ push(result_register());
4853 __ push(MemOperand(esp, kPointerSize)); 4835 __ push(MemOperand(esp, kPointerSize));
4854 __ push(result_register()); 4836 __ push(result_register());
4855 EmitNamedSuperPropertyLoad(prop); 4837 EmitNamedSuperPropertyLoad(prop);
4856 break; 4838 break;
4857 } 4839 }
4858 4840
4859 case KEYED_SUPER_PROPERTY: { 4841 case KEYED_SUPER_PROPERTY: {
4860 VisitForStackValue(prop->obj()->AsSuperPropertyReference()->this_var()); 4842 VisitForStackValue(prop->obj()->AsSuperPropertyReference()->this_var());
4861 VisitForStackValue( 4843 VisitForStackValue(
4862 prop->obj()->AsSuperPropertyReference()->home_object_var()); 4844 prop->obj()->AsSuperPropertyReference()->home_object());
4863 VisitForAccumulatorValue(prop->key()); 4845 VisitForAccumulatorValue(prop->key());
4864 __ push(result_register()); 4846 __ push(result_register());
4865 __ push(MemOperand(esp, 2 * kPointerSize)); 4847 __ push(MemOperand(esp, 2 * kPointerSize));
4866 __ push(MemOperand(esp, 2 * kPointerSize)); 4848 __ push(MemOperand(esp, 2 * kPointerSize));
4867 __ push(result_register()); 4849 __ push(result_register());
4868 EmitKeyedSuperPropertyLoad(prop); 4850 EmitKeyedSuperPropertyLoad(prop);
4869 break; 4851 break;
4870 } 4852 }
4871 4853
4872 case KEYED_PROPERTY: { 4854 case KEYED_PROPERTY: {
(...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after
5478 Assembler::target_address_at(call_target_address, 5460 Assembler::target_address_at(call_target_address,
5479 unoptimized_code)); 5461 unoptimized_code));
5480 return OSR_AFTER_STACK_CHECK; 5462 return OSR_AFTER_STACK_CHECK;
5481 } 5463 }
5482 5464
5483 5465
5484 } // namespace internal 5466 } // namespace internal
5485 } // namespace v8 5467 } // namespace v8
5486 5468
5487 #endif // V8_TARGET_ARCH_IA32 5469 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ast-value-factory.cc ('k') | src/mips/full-codegen-mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698