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

Side by Side Diff: src/x87/full-codegen-x87.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/x64/full-codegen-x64.cc ('k') | test/cctest/test-compiler.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_X87 7 #if V8_TARGET_ARCH_X87
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 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 } else if (FLAG_debug_code) { 228 } else if (FLAG_debug_code) {
229 Label done; 229 Label done;
230 __ JumpIfInNewSpace(esi, eax, &done, Label::kNear); 230 __ JumpIfInNewSpace(esi, eax, &done, Label::kNear);
231 __ Abort(kExpectedNewSpaceObject); 231 __ Abort(kExpectedNewSpaceObject);
232 __ bind(&done); 232 __ bind(&done);
233 } 233 }
234 } 234 }
235 } 235 }
236 } 236 }
237 237
238 Variable* home_object_var = scope()->home_object_var();
239 if (home_object_var != nullptr) {
240 __ push(edi);
241 }
242
243 ArgumentsAccessStub::HasNewTarget has_new_target = 238 ArgumentsAccessStub::HasNewTarget has_new_target =
244 IsSubclassConstructor(info->function()->kind()) 239 IsSubclassConstructor(info->function()->kind())
245 ? ArgumentsAccessStub::HAS_NEW_TARGET 240 ? ArgumentsAccessStub::HAS_NEW_TARGET
246 : ArgumentsAccessStub::NO_NEW_TARGET; 241 : ArgumentsAccessStub::NO_NEW_TARGET;
247 242
248 // Possibly allocate RestParameters 243 // Possibly allocate RestParameters
249 int rest_index; 244 int rest_index;
250 Variable* rest_param = scope()->rest_parameter(&rest_index); 245 Variable* rest_param = scope()->rest_parameter(&rest_index);
251 if (rest_param) { 246 if (rest_param) {
252 Comment cmnt(masm_, "[ Allocate rest parameter array"); 247 Comment cmnt(masm_, "[ Allocate rest parameter array");
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 } else { 294 } else {
300 type = ArgumentsAccessStub::NEW_SLOPPY_FAST; 295 type = ArgumentsAccessStub::NEW_SLOPPY_FAST;
301 } 296 }
302 297
303 ArgumentsAccessStub stub(isolate(), type, has_new_target); 298 ArgumentsAccessStub stub(isolate(), type, has_new_target);
304 __ CallStub(&stub); 299 __ CallStub(&stub);
305 300
306 SetVar(arguments, eax, ebx, edx); 301 SetVar(arguments, eax, ebx, edx);
307 } 302 }
308 303
309 // Possibly set up a local binding to the [[HomeObject]].
310 if (home_object_var != nullptr) {
311 Comment cmnt(masm_, "[ Home object");
312 __ pop(LoadDescriptor::ReceiverRegister());
313 Handle<Symbol> home_object_symbol(isolate()->heap()->home_object_symbol());
314 __ mov(LoadDescriptor::NameRegister(), Immediate(home_object_symbol));
315 __ mov(LoadDescriptor::SlotRegister(),
316 Immediate(SmiFromSlot(function()->HomeObjectFeedbackSlot())));
317 CallLoadIC(NOT_CONTEXTUAL);
318
319 SetVar(home_object_var, eax, ebx, edx);
320 }
321
322 if (FLAG_trace) { 304 if (FLAG_trace) {
323 __ CallRuntime(Runtime::kTraceEnter, 0); 305 __ CallRuntime(Runtime::kTraceEnter, 0);
324 } 306 }
325 307
326 // Visit the declarations and body unless there is an illegal 308 // Visit the declarations and body unless there is an illegal
327 // redeclaration. 309 // redeclaration.
328 if (scope()->HasIllegalRedeclaration()) { 310 if (scope()->HasIllegalRedeclaration()) {
329 Comment cmnt(masm_, "[ Declarations"); 311 Comment cmnt(masm_, "[ Declarations");
330 scope()->VisitIllegalRedeclaration(this); 312 scope()->VisitIllegalRedeclaration(this);
331 313
(...skipping 1575 matching lines...) Expand 10 before | Expand all | Expand 10 after
1907 LhsKind assign_type = Property::GetAssignType(property); 1889 LhsKind assign_type = Property::GetAssignType(property);
1908 1890
1909 // Evaluate LHS expression. 1891 // Evaluate LHS expression.
1910 switch (assign_type) { 1892 switch (assign_type) {
1911 case VARIABLE: 1893 case VARIABLE:
1912 // Nothing to do here. 1894 // Nothing to do here.
1913 break; 1895 break;
1914 case NAMED_SUPER_PROPERTY: 1896 case NAMED_SUPER_PROPERTY:
1915 VisitForStackValue(property->obj()->AsSuperReference()->this_var()); 1897 VisitForStackValue(property->obj()->AsSuperReference()->this_var());
1916 VisitForAccumulatorValue( 1898 VisitForAccumulatorValue(
1917 property->obj()->AsSuperReference()->home_object_var()); 1899 property->obj()->AsSuperReference()->home_object());
1918 __ push(result_register()); 1900 __ push(result_register());
1919 if (expr->is_compound()) { 1901 if (expr->is_compound()) {
1920 __ push(MemOperand(esp, kPointerSize)); 1902 __ push(MemOperand(esp, kPointerSize));
1921 __ push(result_register()); 1903 __ push(result_register());
1922 } 1904 }
1923 break; 1905 break;
1924 case NAMED_PROPERTY: 1906 case NAMED_PROPERTY:
1925 if (expr->is_compound()) { 1907 if (expr->is_compound()) {
1926 // We need the receiver both on the stack and in the register. 1908 // We need the receiver both on the stack and in the register.
1927 VisitForStackValue(property->obj()); 1909 VisitForStackValue(property->obj());
1928 __ mov(LoadDescriptor::ReceiverRegister(), Operand(esp, 0)); 1910 __ mov(LoadDescriptor::ReceiverRegister(), Operand(esp, 0));
1929 } else { 1911 } else {
1930 VisitForStackValue(property->obj()); 1912 VisitForStackValue(property->obj());
1931 } 1913 }
1932 break; 1914 break;
1933 case KEYED_SUPER_PROPERTY: 1915 case KEYED_SUPER_PROPERTY:
1934 VisitForStackValue(property->obj()->AsSuperReference()->this_var()); 1916 VisitForStackValue(property->obj()->AsSuperReference()->this_var());
1935 VisitForStackValue( 1917 VisitForStackValue(property->obj()->AsSuperReference()->home_object());
1936 property->obj()->AsSuperReference()->home_object_var());
1937 VisitForAccumulatorValue(property->key()); 1918 VisitForAccumulatorValue(property->key());
1938 __ Push(result_register()); 1919 __ Push(result_register());
1939 if (expr->is_compound()) { 1920 if (expr->is_compound()) {
1940 __ push(MemOperand(esp, 2 * kPointerSize)); 1921 __ push(MemOperand(esp, 2 * kPointerSize));
1941 __ push(MemOperand(esp, 2 * kPointerSize)); 1922 __ push(MemOperand(esp, 2 * kPointerSize));
1942 __ push(result_register()); 1923 __ push(result_register());
1943 } 1924 }
1944 break; 1925 break;
1945 case KEYED_PROPERTY: { 1926 case KEYED_PROPERTY: {
1946 if (expr->is_compound()) { 1927 if (expr->is_compound()) {
(...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after
2551 __ pop(StoreDescriptor::ValueRegister()); // Restore value. 2532 __ pop(StoreDescriptor::ValueRegister()); // Restore value.
2552 __ mov(StoreDescriptor::NameRegister(), 2533 __ mov(StoreDescriptor::NameRegister(),
2553 prop->key()->AsLiteral()->value()); 2534 prop->key()->AsLiteral()->value());
2554 if (FLAG_vector_stores) EmitLoadStoreICSlot(slot); 2535 if (FLAG_vector_stores) EmitLoadStoreICSlot(slot);
2555 CallStoreIC(); 2536 CallStoreIC();
2556 break; 2537 break;
2557 } 2538 }
2558 case NAMED_SUPER_PROPERTY: { 2539 case NAMED_SUPER_PROPERTY: {
2559 __ push(eax); 2540 __ push(eax);
2560 VisitForStackValue(prop->obj()->AsSuperReference()->this_var()); 2541 VisitForStackValue(prop->obj()->AsSuperReference()->this_var());
2561 VisitForAccumulatorValue( 2542 VisitForAccumulatorValue(prop->obj()->AsSuperReference()->home_object());
2562 prop->obj()->AsSuperReference()->home_object_var());
2563 // stack: value, this; eax: home_object 2543 // stack: value, this; eax: home_object
2564 Register scratch = ecx; 2544 Register scratch = ecx;
2565 Register scratch2 = edx; 2545 Register scratch2 = edx;
2566 __ mov(scratch, result_register()); // home_object 2546 __ mov(scratch, result_register()); // home_object
2567 __ mov(eax, MemOperand(esp, kPointerSize)); // value 2547 __ mov(eax, MemOperand(esp, kPointerSize)); // value
2568 __ mov(scratch2, MemOperand(esp, 0)); // this 2548 __ mov(scratch2, MemOperand(esp, 0)); // this
2569 __ mov(MemOperand(esp, kPointerSize), scratch2); // this 2549 __ mov(MemOperand(esp, kPointerSize), scratch2); // this
2570 __ mov(MemOperand(esp, 0), scratch); // home_object 2550 __ mov(MemOperand(esp, 0), scratch); // home_object
2571 // stack: this, home_object. eax: value 2551 // stack: this, home_object. eax: value
2572 EmitNamedSuperPropertyStore(prop); 2552 EmitNamedSuperPropertyStore(prop);
2573 break; 2553 break;
2574 } 2554 }
2575 case KEYED_SUPER_PROPERTY: { 2555 case KEYED_SUPER_PROPERTY: {
2576 __ push(eax); 2556 __ push(eax);
2577 VisitForStackValue(prop->obj()->AsSuperReference()->this_var()); 2557 VisitForStackValue(prop->obj()->AsSuperReference()->this_var());
2578 VisitForStackValue(prop->obj()->AsSuperReference()->home_object_var()); 2558 VisitForStackValue(prop->obj()->AsSuperReference()->home_object());
2579 VisitForAccumulatorValue(prop->key()); 2559 VisitForAccumulatorValue(prop->key());
2580 Register scratch = ecx; 2560 Register scratch = ecx;
2581 Register scratch2 = edx; 2561 Register scratch2 = edx;
2582 __ mov(scratch2, MemOperand(esp, 2 * kPointerSize)); // value 2562 __ mov(scratch2, MemOperand(esp, 2 * kPointerSize)); // value
2583 // stack: value, this, home_object; eax: key, edx: value 2563 // stack: value, this, home_object; eax: key, edx: value
2584 __ mov(scratch, MemOperand(esp, kPointerSize)); // this 2564 __ mov(scratch, MemOperand(esp, kPointerSize)); // this
2585 __ mov(MemOperand(esp, 2 * kPointerSize), scratch); 2565 __ mov(MemOperand(esp, 2 * kPointerSize), scratch);
2586 __ mov(scratch, MemOperand(esp, 0)); // home_object 2566 __ mov(scratch, MemOperand(esp, 0)); // home_object
2587 __ mov(MemOperand(esp, kPointerSize), scratch); 2567 __ mov(MemOperand(esp, kPointerSize), scratch);
2588 __ mov(MemOperand(esp, 0), eax); 2568 __ mov(MemOperand(esp, 0), eax);
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
2791 Comment cmnt(masm_, "[ Property"); 2771 Comment cmnt(masm_, "[ Property");
2792 Expression* key = expr->key(); 2772 Expression* key = expr->key();
2793 2773
2794 if (key->IsPropertyName()) { 2774 if (key->IsPropertyName()) {
2795 if (!expr->IsSuperAccess()) { 2775 if (!expr->IsSuperAccess()) {
2796 VisitForAccumulatorValue(expr->obj()); 2776 VisitForAccumulatorValue(expr->obj());
2797 __ Move(LoadDescriptor::ReceiverRegister(), result_register()); 2777 __ Move(LoadDescriptor::ReceiverRegister(), result_register());
2798 EmitNamedPropertyLoad(expr); 2778 EmitNamedPropertyLoad(expr);
2799 } else { 2779 } else {
2800 VisitForStackValue(expr->obj()->AsSuperReference()->this_var()); 2780 VisitForStackValue(expr->obj()->AsSuperReference()->this_var());
2801 VisitForStackValue(expr->obj()->AsSuperReference()->home_object_var()); 2781 VisitForStackValue(expr->obj()->AsSuperReference()->home_object());
2802 EmitNamedSuperPropertyLoad(expr); 2782 EmitNamedSuperPropertyLoad(expr);
2803 } 2783 }
2804 } else { 2784 } else {
2805 if (!expr->IsSuperAccess()) { 2785 if (!expr->IsSuperAccess()) {
2806 VisitForStackValue(expr->obj()); 2786 VisitForStackValue(expr->obj());
2807 VisitForAccumulatorValue(expr->key()); 2787 VisitForAccumulatorValue(expr->key());
2808 __ pop(LoadDescriptor::ReceiverRegister()); // Object. 2788 __ pop(LoadDescriptor::ReceiverRegister()); // Object.
2809 __ Move(LoadDescriptor::NameRegister(), result_register()); // Key. 2789 __ Move(LoadDescriptor::NameRegister(), result_register()); // Key.
2810 EmitKeyedPropertyLoad(expr); 2790 EmitKeyedPropertyLoad(expr);
2811 } else { 2791 } else {
2812 VisitForStackValue(expr->obj()->AsSuperReference()->this_var()); 2792 VisitForStackValue(expr->obj()->AsSuperReference()->this_var());
2813 VisitForStackValue(expr->obj()->AsSuperReference()->home_object_var()); 2793 VisitForStackValue(expr->obj()->AsSuperReference()->home_object());
2814 VisitForStackValue(expr->key()); 2794 VisitForStackValue(expr->key());
2815 EmitKeyedSuperPropertyLoad(expr); 2795 EmitKeyedSuperPropertyLoad(expr);
2816 } 2796 }
2817 } 2797 }
2818 PrepareForBailoutForId(expr->LoadId(), TOS_REG); 2798 PrepareForBailoutForId(expr->LoadId(), TOS_REG);
2819 context()->Plug(eax); 2799 context()->Plug(eax);
2820 } 2800 }
2821 2801
2822 2802
2823 void FullCodeGenerator::CallIC(Handle<Code> code, 2803 void FullCodeGenerator::CallIC(Handle<Code> code,
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
2862 Expression* callee = expr->expression(); 2842 Expression* callee = expr->expression();
2863 DCHECK(callee->IsProperty()); 2843 DCHECK(callee->IsProperty());
2864 Property* prop = callee->AsProperty(); 2844 Property* prop = callee->AsProperty();
2865 DCHECK(prop->IsSuperAccess()); 2845 DCHECK(prop->IsSuperAccess());
2866 2846
2867 SetSourcePosition(prop->position()); 2847 SetSourcePosition(prop->position());
2868 Literal* key = prop->key()->AsLiteral(); 2848 Literal* key = prop->key()->AsLiteral();
2869 DCHECK(!key->value()->IsSmi()); 2849 DCHECK(!key->value()->IsSmi());
2870 // Load the function from the receiver. 2850 // Load the function from the receiver.
2871 SuperReference* super_ref = callee->AsProperty()->obj()->AsSuperReference(); 2851 SuperReference* super_ref = callee->AsProperty()->obj()->AsSuperReference();
2872 VisitForStackValue(super_ref->home_object_var()); 2852 VisitForStackValue(super_ref->home_object());
2873 VisitForAccumulatorValue(super_ref->this_var()); 2853 VisitForAccumulatorValue(super_ref->this_var());
2874 __ push(eax); 2854 __ push(eax);
2875 __ push(eax); 2855 __ push(eax);
2876 __ push(Operand(esp, kPointerSize * 2)); 2856 __ push(Operand(esp, kPointerSize * 2));
2877 __ push(Immediate(key->value())); 2857 __ push(Immediate(key->value()));
2878 // Stack here: 2858 // Stack here:
2879 // - home_object 2859 // - home_object
2880 // - this (receiver) 2860 // - this (receiver)
2881 // - this (receiver) <-- LoadFromSuper will pop here and below. 2861 // - this (receiver) <-- LoadFromSuper will pop here and below.
2882 // - home_object 2862 // - home_object
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
2918 2898
2919 void FullCodeGenerator::EmitKeyedSuperCallWithLoadIC(Call* expr) { 2899 void FullCodeGenerator::EmitKeyedSuperCallWithLoadIC(Call* expr) {
2920 Expression* callee = expr->expression(); 2900 Expression* callee = expr->expression();
2921 DCHECK(callee->IsProperty()); 2901 DCHECK(callee->IsProperty());
2922 Property* prop = callee->AsProperty(); 2902 Property* prop = callee->AsProperty();
2923 DCHECK(prop->IsSuperAccess()); 2903 DCHECK(prop->IsSuperAccess());
2924 2904
2925 SetSourcePosition(prop->position()); 2905 SetSourcePosition(prop->position());
2926 // Load the function from the receiver. 2906 // Load the function from the receiver.
2927 SuperReference* super_ref = callee->AsProperty()->obj()->AsSuperReference(); 2907 SuperReference* super_ref = callee->AsProperty()->obj()->AsSuperReference();
2928 VisitForStackValue(super_ref->home_object_var()); 2908 VisitForStackValue(super_ref->home_object());
2929 VisitForAccumulatorValue(super_ref->this_var()); 2909 VisitForAccumulatorValue(super_ref->this_var());
2930 __ push(eax); 2910 __ push(eax);
2931 __ push(eax); 2911 __ push(eax);
2932 __ push(Operand(esp, kPointerSize * 2)); 2912 __ push(Operand(esp, kPointerSize * 2));
2933 VisitForStackValue(prop->key()); 2913 VisitForStackValue(prop->key());
2934 // Stack here: 2914 // Stack here:
2935 // - home_object 2915 // - home_object
2936 // - this (receiver) 2916 // - this (receiver)
2937 // - this (receiver) <-- LoadKeyedFromSuper will pop here and below. 2917 // - this (receiver) <-- LoadKeyedFromSuper will pop here and below.
2938 // - home_object 2918 // - home_object
(...skipping 1853 matching lines...) Expand 10 before | Expand all | Expand 10 after
4792 // Put the object both on the stack and in the register. 4772 // Put the object both on the stack and in the register.
4793 VisitForStackValue(prop->obj()); 4773 VisitForStackValue(prop->obj());
4794 __ mov(LoadDescriptor::ReceiverRegister(), Operand(esp, 0)); 4774 __ mov(LoadDescriptor::ReceiverRegister(), Operand(esp, 0));
4795 EmitNamedPropertyLoad(prop); 4775 EmitNamedPropertyLoad(prop);
4796 break; 4776 break;
4797 } 4777 }
4798 4778
4799 case NAMED_SUPER_PROPERTY: { 4779 case NAMED_SUPER_PROPERTY: {
4800 VisitForStackValue(prop->obj()->AsSuperReference()->this_var()); 4780 VisitForStackValue(prop->obj()->AsSuperReference()->this_var());
4801 VisitForAccumulatorValue( 4781 VisitForAccumulatorValue(
4802 prop->obj()->AsSuperReference()->home_object_var()); 4782 prop->obj()->AsSuperReference()->home_object());
4803 __ push(result_register()); 4783 __ push(result_register());
4804 __ push(MemOperand(esp, kPointerSize)); 4784 __ push(MemOperand(esp, kPointerSize));
4805 __ push(result_register()); 4785 __ push(result_register());
4806 EmitNamedSuperPropertyLoad(prop); 4786 EmitNamedSuperPropertyLoad(prop);
4807 break; 4787 break;
4808 } 4788 }
4809 4789
4810 case KEYED_SUPER_PROPERTY: { 4790 case KEYED_SUPER_PROPERTY: {
4811 VisitForStackValue(prop->obj()->AsSuperReference()->this_var()); 4791 VisitForStackValue(prop->obj()->AsSuperReference()->this_var());
4812 VisitForStackValue(prop->obj()->AsSuperReference()->home_object_var()); 4792 VisitForStackValue(prop->obj()->AsSuperReference()->home_object());
4813 VisitForAccumulatorValue(prop->key()); 4793 VisitForAccumulatorValue(prop->key());
4814 __ push(result_register()); 4794 __ push(result_register());
4815 __ push(MemOperand(esp, 2 * kPointerSize)); 4795 __ push(MemOperand(esp, 2 * kPointerSize));
4816 __ push(MemOperand(esp, 2 * kPointerSize)); 4796 __ push(MemOperand(esp, 2 * kPointerSize));
4817 __ push(result_register()); 4797 __ push(result_register());
4818 EmitKeyedSuperPropertyLoad(prop); 4798 EmitKeyedSuperPropertyLoad(prop);
4819 break; 4799 break;
4820 } 4800 }
4821 4801
4822 case KEYED_PROPERTY: { 4802 case KEYED_PROPERTY: {
(...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after
5428 Assembler::target_address_at(call_target_address, 5408 Assembler::target_address_at(call_target_address,
5429 unoptimized_code)); 5409 unoptimized_code));
5430 return OSR_AFTER_STACK_CHECK; 5410 return OSR_AFTER_STACK_CHECK;
5431 } 5411 }
5432 5412
5433 5413
5434 } // namespace internal 5414 } // namespace internal
5435 } // namespace v8 5415 } // namespace v8
5436 5416
5437 #endif // V8_TARGET_ARCH_X87 5417 #endif // V8_TARGET_ARCH_X87
OLDNEW
« no previous file with comments | « src/x64/full-codegen-x64.cc ('k') | test/cctest/test-compiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698