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

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

Issue 593073002: Stores and compound assignments for named super properties. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: CR feedback Created 6 years, 2 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 | Annotate | Revision Log
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 1798 matching lines...) Expand 10 before | Expand all | Expand 10 after
1809 } 1809 }
1810 1810
1811 1811
1812 void FullCodeGenerator::VisitAssignment(Assignment* expr) { 1812 void FullCodeGenerator::VisitAssignment(Assignment* expr) {
1813 DCHECK(expr->target()->IsValidReferenceExpression()); 1813 DCHECK(expr->target()->IsValidReferenceExpression());
1814 1814
1815 Comment cmnt(masm_, "[ Assignment"); 1815 Comment cmnt(masm_, "[ Assignment");
1816 1816
1817 // Left-hand side can only be a property, a global or a (parameter or local) 1817 // Left-hand side can only be a property, a global or a (parameter or local)
1818 // slot. 1818 // slot.
1819 enum LhsKind { VARIABLE, NAMED_PROPERTY, KEYED_PROPERTY }; 1819 enum LhsKind {
1820 VARIABLE,
1821 NAMED_PROPERTY,
1822 KEYED_PROPERTY,
1823 NAMED_SUPER_PROPERTY
1824 };
1820 LhsKind assign_type = VARIABLE; 1825 LhsKind assign_type = VARIABLE;
1821 Property* property = expr->target()->AsProperty(); 1826 Property* property = expr->target()->AsProperty();
1822 if (property != NULL) { 1827 if (property != NULL) {
1823 assign_type = (property->key()->IsPropertyName()) 1828 assign_type = (property->key()->IsPropertyName())
1824 ? NAMED_PROPERTY 1829 ? (property->IsSuperAccess() ? NAMED_SUPER_PROPERTY
1825 : KEYED_PROPERTY; 1830 : NAMED_PROPERTY)
1831 : KEYED_PROPERTY;
1826 } 1832 }
1827 1833
1828 // Evaluate LHS expression. 1834 // Evaluate LHS expression.
1829 switch (assign_type) { 1835 switch (assign_type) {
1830 case VARIABLE: 1836 case VARIABLE:
1831 // Nothing to do here. 1837 // Nothing to do here.
1832 break; 1838 break;
1839 case NAMED_SUPER_PROPERTY:
1840 VisitForStackValue(property->obj()->AsSuperReference()->this_var());
1841 EmitLoadHomeObject(property->obj()->AsSuperReference());
1842 __ push(result_register());
1843 if (expr->is_compound()) {
1844 __ push(MemOperand(esp, kPointerSize));
1845 __ push(result_register());
1846 }
1847 break;
1833 case NAMED_PROPERTY: 1848 case NAMED_PROPERTY:
1834 if (expr->is_compound()) { 1849 if (expr->is_compound()) {
1835 // We need the receiver both on the stack and in the register. 1850 // We need the receiver both on the stack and in the register.
1836 VisitForStackValue(property->obj()); 1851 VisitForStackValue(property->obj());
1837 __ mov(LoadDescriptor::ReceiverRegister(), Operand(esp, 0)); 1852 __ mov(LoadDescriptor::ReceiverRegister(), Operand(esp, 0));
1838 } else { 1853 } else {
1839 VisitForStackValue(property->obj()); 1854 VisitForStackValue(property->obj());
1840 } 1855 }
1841 break; 1856 break;
1842 case KEYED_PROPERTY: { 1857 case KEYED_PROPERTY: {
(...skipping 13 matching lines...) Expand all
1856 // For compound assignments we need another deoptimization point after the 1871 // For compound assignments we need another deoptimization point after the
1857 // variable/property load. 1872 // variable/property load.
1858 if (expr->is_compound()) { 1873 if (expr->is_compound()) {
1859 AccumulatorValueContext result_context(this); 1874 AccumulatorValueContext result_context(this);
1860 { AccumulatorValueContext left_operand_context(this); 1875 { AccumulatorValueContext left_operand_context(this);
1861 switch (assign_type) { 1876 switch (assign_type) {
1862 case VARIABLE: 1877 case VARIABLE:
1863 EmitVariableLoad(expr->target()->AsVariableProxy()); 1878 EmitVariableLoad(expr->target()->AsVariableProxy());
1864 PrepareForBailout(expr->target(), TOS_REG); 1879 PrepareForBailout(expr->target(), TOS_REG);
1865 break; 1880 break;
1881 case NAMED_SUPER_PROPERTY:
1882 EmitNamedSuperPropertyLoad(property);
1883 PrepareForBailoutForId(property->LoadId(), TOS_REG);
1884 break;
1866 case NAMED_PROPERTY: 1885 case NAMED_PROPERTY:
1867 EmitNamedPropertyLoad(property); 1886 EmitNamedPropertyLoad(property);
1868 PrepareForBailoutForId(property->LoadId(), TOS_REG); 1887 PrepareForBailoutForId(property->LoadId(), TOS_REG);
1869 break; 1888 break;
1870 case KEYED_PROPERTY: 1889 case KEYED_PROPERTY:
1871 EmitKeyedPropertyLoad(property); 1890 EmitKeyedPropertyLoad(property);
1872 PrepareForBailoutForId(property->LoadId(), TOS_REG); 1891 PrepareForBailoutForId(property->LoadId(), TOS_REG);
1873 break; 1892 break;
1874 } 1893 }
1875 } 1894 }
(...skipping 29 matching lines...) Expand all
1905 switch (assign_type) { 1924 switch (assign_type) {
1906 case VARIABLE: 1925 case VARIABLE:
1907 EmitVariableAssignment(expr->target()->AsVariableProxy()->var(), 1926 EmitVariableAssignment(expr->target()->AsVariableProxy()->var(),
1908 expr->op()); 1927 expr->op());
1909 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); 1928 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG);
1910 context()->Plug(eax); 1929 context()->Plug(eax);
1911 break; 1930 break;
1912 case NAMED_PROPERTY: 1931 case NAMED_PROPERTY:
1913 EmitNamedPropertyAssignment(expr); 1932 EmitNamedPropertyAssignment(expr);
1914 break; 1933 break;
1934 case NAMED_SUPER_PROPERTY:
1935 EmitNamedSuperPropertyAssignment(expr);
1936 break;
1915 case KEYED_PROPERTY: 1937 case KEYED_PROPERTY:
1916 EmitKeyedPropertyAssignment(expr); 1938 EmitKeyedPropertyAssignment(expr);
1917 break; 1939 break;
1918 } 1940 }
1919 } 1941 }
1920 1942
1921 1943
1922 void FullCodeGenerator::VisitYield(Yield* expr) { 1944 void FullCodeGenerator::VisitYield(Yield* expr) {
1923 Comment cmnt(masm_, "[ Yield"); 1945 Comment cmnt(masm_, "[ Yield");
1924 // Evaluate yielded value first; the initial iterator definition depends on 1946 // Evaluate yielded value first; the initial iterator definition depends on
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
2244 __ mov(VectorLoadICDescriptor::SlotRegister(), 2266 __ mov(VectorLoadICDescriptor::SlotRegister(),
2245 Immediate(Smi::FromInt(prop->PropertyFeedbackSlot()))); 2267 Immediate(Smi::FromInt(prop->PropertyFeedbackSlot())));
2246 CallLoadIC(NOT_CONTEXTUAL); 2268 CallLoadIC(NOT_CONTEXTUAL);
2247 } else { 2269 } else {
2248 CallLoadIC(NOT_CONTEXTUAL, prop->PropertyFeedbackId()); 2270 CallLoadIC(NOT_CONTEXTUAL, prop->PropertyFeedbackId());
2249 } 2271 }
2250 } 2272 }
2251 2273
2252 2274
2253 void FullCodeGenerator::EmitNamedSuperPropertyLoad(Property* prop) { 2275 void FullCodeGenerator::EmitNamedSuperPropertyLoad(Property* prop) {
2276 // Stack: receiver, home_object.
2254 SetSourcePosition(prop->position()); 2277 SetSourcePosition(prop->position());
2255 Literal* key = prop->key()->AsLiteral(); 2278 Literal* key = prop->key()->AsLiteral();
2256 DCHECK(!key->value()->IsSmi()); 2279 DCHECK(!key->value()->IsSmi());
2257 DCHECK(prop->IsSuperAccess()); 2280 DCHECK(prop->IsSuperAccess());
2258 2281
2259 SuperReference* super_ref = prop->obj()->AsSuperReference();
2260 EmitLoadHomeObject(super_ref);
2261 __ push(eax);
2262 VisitForStackValue(super_ref->this_var());
2263 __ push(Immediate(key->value())); 2282 __ push(Immediate(key->value()));
2264 __ CallRuntime(Runtime::kLoadFromSuper, 3); 2283 __ CallRuntime(Runtime::kLoadFromSuper, 3);
2265 } 2284 }
2266 2285
2267 2286
2268 void FullCodeGenerator::EmitKeyedPropertyLoad(Property* prop) { 2287 void FullCodeGenerator::EmitKeyedPropertyLoad(Property* prop) {
2269 SetSourcePosition(prop->position()); 2288 SetSourcePosition(prop->position());
2270 Handle<Code> ic = CodeFactory::KeyedLoadIC(isolate()).code(); 2289 Handle<Code> ic = CodeFactory::KeyedLoadIC(isolate()).code();
2271 if (FLAG_vector_ics) { 2290 if (FLAG_vector_ics) {
2272 __ mov(VectorLoadICDescriptor::SlotRegister(), 2291 __ mov(VectorLoadICDescriptor::SlotRegister(),
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
2523 // Record source code position before IC call. 2542 // Record source code position before IC call.
2524 SetSourcePosition(expr->position()); 2543 SetSourcePosition(expr->position());
2525 __ mov(StoreDescriptor::NameRegister(), prop->key()->AsLiteral()->value()); 2544 __ mov(StoreDescriptor::NameRegister(), prop->key()->AsLiteral()->value());
2526 __ pop(StoreDescriptor::ReceiverRegister()); 2545 __ pop(StoreDescriptor::ReceiverRegister());
2527 CallStoreIC(expr->AssignmentFeedbackId()); 2546 CallStoreIC(expr->AssignmentFeedbackId());
2528 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); 2547 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG);
2529 context()->Plug(eax); 2548 context()->Plug(eax);
2530 } 2549 }
2531 2550
2532 2551
2552 void FullCodeGenerator::EmitNamedSuperPropertyAssignment(Assignment* expr) {
2553 // Assignment to named property of super.
2554 // eax : value
2555 // stack : receiver ('this'), home_object
2556 Property* prop = expr->target()->AsProperty();
2557 DCHECK(prop != NULL);
2558 Literal* key = prop->key()->AsLiteral();
2559 DCHECK(key != NULL);
2560
2561 __ push(eax);
2562 __ push(Immediate(key->value()));
2563 __ CallRuntime((strict_mode() == STRICT ? Runtime::kStoreToSuper_Strict
2564 : Runtime::kStoreToSuper_Sloppy),
2565 4);
2566 context()->Plug(eax);
2567 }
2568
2569
2533 void FullCodeGenerator::EmitKeyedPropertyAssignment(Assignment* expr) { 2570 void FullCodeGenerator::EmitKeyedPropertyAssignment(Assignment* expr) {
2534 // Assignment to a property, using a keyed store IC. 2571 // Assignment to a property, using a keyed store IC.
2535 // eax : value 2572 // eax : value
2536 // esp[0] : key 2573 // esp[0] : key
2537 // esp[kPointerSize] : receiver 2574 // esp[kPointerSize] : receiver
2538 2575
2539 __ pop(StoreDescriptor::NameRegister()); // Key. 2576 __ pop(StoreDescriptor::NameRegister()); // Key.
2540 __ pop(StoreDescriptor::ReceiverRegister()); 2577 __ pop(StoreDescriptor::ReceiverRegister());
2541 DCHECK(StoreDescriptor::ValueRegister().is(eax)); 2578 DCHECK(StoreDescriptor::ValueRegister().is(eax));
2542 // Record source code position before IC call. 2579 // Record source code position before IC call.
2543 SetSourcePosition(expr->position()); 2580 SetSourcePosition(expr->position());
2544 Handle<Code> ic = CodeFactory::KeyedStoreIC(isolate(), strict_mode()).code(); 2581 Handle<Code> ic = CodeFactory::KeyedStoreIC(isolate(), strict_mode()).code();
2545 CallIC(ic, expr->AssignmentFeedbackId()); 2582 CallIC(ic, expr->AssignmentFeedbackId());
2546 2583
2547 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); 2584 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG);
2548 context()->Plug(eax); 2585 context()->Plug(eax);
2549 } 2586 }
2550 2587
2551 2588
2552 void FullCodeGenerator::VisitProperty(Property* expr) { 2589 void FullCodeGenerator::VisitProperty(Property* expr) {
2553 Comment cmnt(masm_, "[ Property"); 2590 Comment cmnt(masm_, "[ Property");
2554 Expression* key = expr->key(); 2591 Expression* key = expr->key();
2555 2592
2556 if (key->IsPropertyName()) { 2593 if (key->IsPropertyName()) {
2557 if (!expr->IsSuperAccess()) { 2594 if (!expr->IsSuperAccess()) {
2558 VisitForAccumulatorValue(expr->obj()); 2595 VisitForAccumulatorValue(expr->obj());
2559 __ Move(LoadDescriptor::ReceiverRegister(), result_register()); 2596 __ Move(LoadDescriptor::ReceiverRegister(), result_register());
2560 EmitNamedPropertyLoad(expr); 2597 EmitNamedPropertyLoad(expr);
2561 } else { 2598 } else {
2599 VisitForStackValue(expr->obj()->AsSuperReference()->this_var());
2600 EmitLoadHomeObject(expr->obj()->AsSuperReference());
2601 __ push(result_register());
2562 EmitNamedSuperPropertyLoad(expr); 2602 EmitNamedSuperPropertyLoad(expr);
2563 } 2603 }
2564 PrepareForBailoutForId(expr->LoadId(), TOS_REG); 2604 PrepareForBailoutForId(expr->LoadId(), TOS_REG);
2565 context()->Plug(eax); 2605 context()->Plug(eax);
2566 } else { 2606 } else {
2567 VisitForStackValue(expr->obj()); 2607 VisitForStackValue(expr->obj());
2568 VisitForAccumulatorValue(expr->key()); 2608 VisitForAccumulatorValue(expr->key());
2569 __ pop(LoadDescriptor::ReceiverRegister()); // Object. 2609 __ pop(LoadDescriptor::ReceiverRegister()); // Object.
2570 __ Move(LoadDescriptor::NameRegister(), result_register()); // Key. 2610 __ Move(LoadDescriptor::NameRegister(), result_register()); // Key.
2571 EmitKeyedPropertyLoad(expr); 2611 EmitKeyedPropertyLoad(expr);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
2620 2660
2621 SetSourcePosition(prop->position()); 2661 SetSourcePosition(prop->position());
2622 Literal* key = prop->key()->AsLiteral(); 2662 Literal* key = prop->key()->AsLiteral();
2623 DCHECK(!key->value()->IsSmi()); 2663 DCHECK(!key->value()->IsSmi());
2624 // Load the function from the receiver. 2664 // Load the function from the receiver.
2625 SuperReference* super_ref = callee->AsProperty()->obj()->AsSuperReference(); 2665 SuperReference* super_ref = callee->AsProperty()->obj()->AsSuperReference();
2626 EmitLoadHomeObject(super_ref); 2666 EmitLoadHomeObject(super_ref);
2627 __ push(eax); 2667 __ push(eax);
2628 VisitForAccumulatorValue(super_ref->this_var()); 2668 VisitForAccumulatorValue(super_ref->this_var());
2629 __ push(eax); 2669 __ push(eax);
2630 __ push(Operand(esp, kPointerSize));
2631 __ push(eax); 2670 __ push(eax);
2671 __ push(Operand(esp, kPointerSize * 2));
2632 __ push(Immediate(key->value())); 2672 __ push(Immediate(key->value()));
2633 // Stack here: 2673 // Stack here:
2634 // - home_object 2674 // - home_object
2635 // - this (receiver) 2675 // - this (receiver)
2636 // - home_object <-- LoadFromSuper will pop here and below. 2676 // - this (receiver) <-- LoadFromSuper will pop here and below.
2637 // - this (receiver) 2677 // - home_object
2638 // - key 2678 // - key
2639 __ CallRuntime(Runtime::kLoadFromSuper, 3); 2679 __ CallRuntime(Runtime::kLoadFromSuper, 3);
2640 2680
2641 // Replace home_object with target function. 2681 // Replace home_object with target function.
2642 __ mov(Operand(esp, kPointerSize), eax); 2682 __ mov(Operand(esp, kPointerSize), eax);
2643 2683
2644 // Stack here: 2684 // Stack here:
2645 // - target function 2685 // - target function
2646 // - this (receiver) 2686 // - this (receiver)
2647 EmitCall(expr, CallICState::METHOD); 2687 EmitCall(expr, CallICState::METHOD);
(...skipping 2256 matching lines...) Expand 10 before | Expand all | Expand 10 after
4904 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), 4944 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(),
4905 Assembler::target_address_at(call_target_address, 4945 Assembler::target_address_at(call_target_address,
4906 unoptimized_code)); 4946 unoptimized_code));
4907 return OSR_AFTER_STACK_CHECK; 4947 return OSR_AFTER_STACK_CHECK;
4908 } 4948 }
4909 4949
4910 4950
4911 } } // namespace v8::internal 4951 } } // namespace v8::internal
4912 4952
4913 #endif // V8_TARGET_ARCH_IA32 4953 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/full-codegen.h ('k') | src/objects.h » ('j') | test/mjsunit/harmony/super.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698