OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/interpreter/bytecode-generator.h" | 5 #include "src/interpreter/bytecode-generator.h" |
6 | 6 |
7 #include "src/ast/scopes.h" | 7 #include "src/ast/scopes.h" |
8 #include "src/compiler.h" | 8 #include "src/compiler.h" |
9 #include "src/interpreter/bytecode-register-allocator.h" | 9 #include "src/interpreter/bytecode-register-allocator.h" |
10 #include "src/interpreter/control-flow-builders.h" | 10 #include "src/interpreter/control-flow-builders.h" |
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 } | 411 } |
412 | 412 |
413 void PrepareForConsecutiveAllocations(int count) { | 413 void PrepareForConsecutiveAllocations(int count) { |
414 allocator_.PrepareForConsecutiveAllocations(count); | 414 allocator_.PrepareForConsecutiveAllocations(count); |
415 } | 415 } |
416 | 416 |
417 Register NextConsecutiveRegister() { | 417 Register NextConsecutiveRegister() { |
418 return allocator_.NextConsecutiveRegister(); | 418 return allocator_.NextConsecutiveRegister(); |
419 } | 419 } |
420 | 420 |
| 421 template <size_t N> |
| 422 void PrepareAndInitializeConsecutiveAllocations(Register (®isters)[N]) { |
| 423 return allocator_.PrepareAndInitializeConsecutiveAllocations(registers, N); |
| 424 } |
| 425 |
421 bool RegisterIsAllocatedInThisScope(Register reg) const { | 426 bool RegisterIsAllocatedInThisScope(Register reg) const { |
422 return allocator_.RegisterIsAllocatedInThisScope(reg); | 427 return allocator_.RegisterIsAllocatedInThisScope(reg); |
423 } | 428 } |
424 | 429 |
425 RegisterAllocationScope* outer() const { return outer_; } | 430 RegisterAllocationScope* outer() const { return outer_; } |
426 | 431 |
427 private: | 432 private: |
428 BytecodeGenerator* generator() const { return generator_; } | 433 BytecodeGenerator* generator() const { return generator_; } |
429 BytecodeArrayBuilder* builder() const { return generator_->builder(); } | 434 BytecodeArrayBuilder* builder() const { return generator_->builder(); } |
430 | 435 |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
536 result_register_ = reg; | 541 result_register_ = reg; |
537 set_result_identified(); | 542 set_result_identified(); |
538 } | 543 } |
539 | 544 |
540 Register ResultRegister() const { return result_register_; } | 545 Register ResultRegister() const { return result_register_; } |
541 | 546 |
542 private: | 547 private: |
543 Register result_register_; | 548 Register result_register_; |
544 }; | 549 }; |
545 | 550 |
| 551 class BytecodeGenerator::SuperPropertyArguments final { |
| 552 public: |
| 553 SuperPropertyArguments() {} |
| 554 |
| 555 Register (®isters())[4] { return args_; } |
| 556 Register receiver() const { return args_[0]; } |
| 557 Register home_object() const { return args_[1]; } |
| 558 Register name_or_key() const { return args_[2]; } |
| 559 Register store_value() const { return args_[3]; } |
| 560 Register language_mode() const { return args_[3]; } |
| 561 size_t size() const { return arraysize(args_); } |
| 562 |
| 563 private: |
| 564 Register args_[4]; |
| 565 |
| 566 DISALLOW_COPY_AND_ASSIGN(SuperPropertyArguments); |
| 567 }; |
| 568 |
546 BytecodeGenerator::BytecodeGenerator(Isolate* isolate, Zone* zone) | 569 BytecodeGenerator::BytecodeGenerator(Isolate* isolate, Zone* zone) |
547 : isolate_(isolate), | 570 : isolate_(isolate), |
548 zone_(zone), | 571 zone_(zone), |
549 builder_(nullptr), | 572 builder_(nullptr), |
550 info_(nullptr), | 573 info_(nullptr), |
551 scope_(nullptr), | 574 scope_(nullptr), |
552 globals_(0, zone), | 575 globals_(0, zone), |
553 execution_control_(nullptr), | 576 execution_control_(nullptr), |
554 execution_context_(nullptr), | 577 execution_context_(nullptr), |
555 execution_result_(nullptr), | 578 execution_result_(nullptr), |
556 register_allocator_(nullptr), | 579 register_allocator_(nullptr), |
557 try_catch_nesting_level_(0), | 580 try_catch_nesting_level_(0), |
558 try_finally_nesting_level_(0) { | 581 try_finally_nesting_level_(0) { |
559 InitializeAstVisitor(isolate); | 582 InitializeAstVisitor(isolate); |
560 } | 583 } |
561 | 584 |
562 | |
563 Handle<BytecodeArray> BytecodeGenerator::MakeBytecode(CompilationInfo* info) { | 585 Handle<BytecodeArray> BytecodeGenerator::MakeBytecode(CompilationInfo* info) { |
564 set_info(info); | 586 set_info(info); |
565 set_scope(info->scope()); | 587 set_scope(info->scope()); |
566 | 588 |
567 // Initialize bytecode array builder. | 589 // Initialize bytecode array builder. |
568 set_builder(new (zone()) BytecodeArrayBuilder( | 590 set_builder(new (zone()) BytecodeArrayBuilder( |
569 isolate(), zone(), info->num_parameters_including_this(), | 591 isolate(), zone(), info->num_parameters_including_this(), |
570 scope()->MaxNestedContextChainLength(), scope()->num_stack_slots())); | 592 scope()->MaxNestedContextChainLength(), scope()->num_stack_slots())); |
571 | 593 |
572 // Initialize the incoming context. | 594 // Initialize the incoming context. |
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1043 RegisterAllocationScope register_scope(this); | 1065 RegisterAllocationScope register_scope(this); |
1044 Register value = register_allocator()->NewRegister(); | 1066 Register value = register_allocator()->NewRegister(); |
1045 builder()->StoreAccumulatorInRegister(value); | 1067 builder()->StoreAccumulatorInRegister(value); |
1046 Register object = VisitForRegisterValue(property->obj()); | 1068 Register object = VisitForRegisterValue(property->obj()); |
1047 Register key = VisitForRegisterValue(property->key()); | 1069 Register key = VisitForRegisterValue(property->key()); |
1048 builder()->LoadAccumulatorWithRegister(value); | 1070 builder()->LoadAccumulatorWithRegister(value); |
1049 builder()->StoreKeyedProperty(object, key, feedback_index(slot), | 1071 builder()->StoreKeyedProperty(object, key, feedback_index(slot), |
1050 language_mode()); | 1072 language_mode()); |
1051 break; | 1073 break; |
1052 } | 1074 } |
1053 case NAMED_SUPER_PROPERTY: | 1075 case NAMED_SUPER_PROPERTY: { |
1054 case KEYED_SUPER_PROPERTY: | 1076 RegisterAllocationScope register_scope(this); |
1055 UNIMPLEMENTED(); | 1077 SuperPropertyArguments super_args; |
| 1078 Register value = register_allocator()->NewRegister(); |
| 1079 builder()->StoreAccumulatorInRegister(value); |
| 1080 PrepareNamedSuperPropertyArguments( |
| 1081 property->obj()->AsSuperPropertyReference(), |
| 1082 property->key()->AsLiteral()->AsPropertyName(), &super_args); |
| 1083 builder()->LoadAccumulatorWithRegister(value); |
| 1084 BuildNamedSuperPropertyStore(&super_args); |
| 1085 break; |
| 1086 } |
| 1087 case KEYED_SUPER_PROPERTY: { |
| 1088 RegisterAllocationScope register_scope(this); |
| 1089 SuperPropertyArguments super_args; |
| 1090 Register value = register_allocator()->NewRegister(); |
| 1091 builder()->StoreAccumulatorInRegister(value); |
| 1092 PrepareKeyedSuperPropertyArguments( |
| 1093 property->obj()->AsSuperPropertyReference(), property->key(), |
| 1094 &super_args); |
| 1095 builder()->LoadAccumulatorWithRegister(value); |
| 1096 BuildKeyedSuperPropertyStore(&super_args); |
| 1097 break; |
| 1098 } |
1056 } | 1099 } |
1057 } | 1100 } |
1058 | 1101 |
1059 | 1102 |
1060 void BytecodeGenerator::VisitForInStatement(ForInStatement* stmt) { | 1103 void BytecodeGenerator::VisitForInStatement(ForInStatement* stmt) { |
1061 if (stmt->subject()->IsNullLiteral() || | 1104 if (stmt->subject()->IsNullLiteral() || |
1062 stmt->subject()->IsUndefinedLiteral(isolate())) { | 1105 stmt->subject()->IsUndefinedLiteral(isolate())) { |
1063 // ForIn generates lots of code, skip if it wouldn't produce any effects. | 1106 // ForIn generates lots of code, skip if it wouldn't produce any effects. |
1064 return; | 1107 return; |
1065 } | 1108 } |
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1488 UNREACHABLE(); | 1531 UNREACHABLE(); |
1489 case ObjectLiteral::Property::MATERIALIZED_LITERAL: | 1532 case ObjectLiteral::Property::MATERIALIZED_LITERAL: |
1490 DCHECK(!CompileTimeValue::IsCompileTimeValue(property->value())); | 1533 DCHECK(!CompileTimeValue::IsCompileTimeValue(property->value())); |
1491 // Fall through. | 1534 // Fall through. |
1492 case ObjectLiteral::Property::COMPUTED: { | 1535 case ObjectLiteral::Property::COMPUTED: { |
1493 // It is safe to use [[Put]] here because the boilerplate already | 1536 // It is safe to use [[Put]] here because the boilerplate already |
1494 // contains computed properties with an uninitialized value. | 1537 // contains computed properties with an uninitialized value. |
1495 if (literal_key->value()->IsInternalizedString()) { | 1538 if (literal_key->value()->IsInternalizedString()) { |
1496 if (property->emit_store()) { | 1539 if (property->emit_store()) { |
1497 VisitForAccumulatorValue(property->value()); | 1540 VisitForAccumulatorValue(property->value()); |
1498 builder()->StoreNamedProperty( | 1541 if (FunctionLiteral::NeedsHomeObject(property->value())) { |
1499 literal, literal_key->AsPropertyName(), | 1542 RegisterAllocationScope register_scope(this); |
1500 feedback_index(property->GetSlot(0)), language_mode()); | 1543 Register value = register_allocator()->NewRegister(); |
| 1544 builder()->StoreAccumulatorInRegister(value); |
| 1545 builder()->StoreNamedProperty( |
| 1546 literal, literal_key->AsPropertyName(), |
| 1547 feedback_index(property->GetSlot(0)), language_mode()); |
| 1548 VisitSetHomeObject(value, literal, property, 1); |
| 1549 } else { |
| 1550 builder()->StoreNamedProperty( |
| 1551 literal, literal_key->AsPropertyName(), |
| 1552 feedback_index(property->GetSlot(0)), language_mode()); |
| 1553 } |
1501 } else { | 1554 } else { |
1502 VisitForEffect(property->value()); | 1555 VisitForEffect(property->value()); |
1503 } | 1556 } |
1504 } else { | 1557 } else { |
1505 register_allocator()->PrepareForConsecutiveAllocations(4); | 1558 register_allocator()->PrepareForConsecutiveAllocations(4); |
1506 Register literal_argument = | 1559 Register literal_argument = |
1507 register_allocator()->NextConsecutiveRegister(); | 1560 register_allocator()->NextConsecutiveRegister(); |
1508 Register key = register_allocator()->NextConsecutiveRegister(); | 1561 Register key = register_allocator()->NextConsecutiveRegister(); |
1509 Register value = register_allocator()->NextConsecutiveRegister(); | 1562 Register value = register_allocator()->NextConsecutiveRegister(); |
1510 Register language = register_allocator()->NextConsecutiveRegister(); | 1563 Register language = register_allocator()->NextConsecutiveRegister(); |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1774 VisitVariableLoad(variable, slot, typeof_mode); | 1827 VisitVariableLoad(variable, slot, typeof_mode); |
1775 } | 1828 } |
1776 | 1829 |
1777 Register BytecodeGenerator::VisitVariableLoadForRegisterValue( | 1830 Register BytecodeGenerator::VisitVariableLoadForRegisterValue( |
1778 Variable* variable, FeedbackVectorSlot slot, TypeofMode typeof_mode) { | 1831 Variable* variable, FeedbackVectorSlot slot, TypeofMode typeof_mode) { |
1779 RegisterResultScope register_scope(this); | 1832 RegisterResultScope register_scope(this); |
1780 VisitVariableLoad(variable, slot, typeof_mode); | 1833 VisitVariableLoad(variable, slot, typeof_mode); |
1781 return register_scope.ResultRegister(); | 1834 return register_scope.ResultRegister(); |
1782 } | 1835 } |
1783 | 1836 |
| 1837 void BytecodeGenerator::PrepareNamedSuperPropertyArguments( |
| 1838 SuperPropertyReference* super_property, Handle<Name> name, |
| 1839 SuperPropertyArguments* super_args) { |
| 1840 register_allocator()->PrepareAndInitializeConsecutiveAllocations( |
| 1841 super_args->registers()); |
| 1842 |
| 1843 VisitForAccumulatorValue(super_property->this_var()); |
| 1844 builder()->StoreAccumulatorInRegister(super_args->receiver()); |
| 1845 VisitForAccumulatorValue(super_property->home_object()); |
| 1846 builder()->StoreAccumulatorInRegister(super_args->home_object()); |
| 1847 builder()->LoadLiteral(name).StoreAccumulatorInRegister( |
| 1848 super_args->name_or_key()); |
| 1849 } |
| 1850 |
| 1851 void BytecodeGenerator::PrepareKeyedSuperPropertyArguments( |
| 1852 SuperPropertyReference* super_property, Expression* key, |
| 1853 SuperPropertyArguments* super_args) { |
| 1854 register_allocator()->PrepareAndInitializeConsecutiveAllocations( |
| 1855 super_args->registers()); |
| 1856 |
| 1857 VisitForAccumulatorValue(super_property->this_var()); |
| 1858 builder()->StoreAccumulatorInRegister(super_args->receiver()); |
| 1859 VisitForAccumulatorValue(super_property->home_object()); |
| 1860 builder()->StoreAccumulatorInRegister(super_args->home_object()); |
| 1861 VisitForAccumulatorValue(key); |
| 1862 builder()->StoreAccumulatorInRegister(super_args->name_or_key()); |
| 1863 } |
| 1864 |
| 1865 void BytecodeGenerator::BuildNamedSuperPropertyLoad( |
| 1866 SuperPropertyArguments* super_args) { |
| 1867 builder() |
| 1868 ->LoadLiteral(Smi::FromInt(static_cast<int>(language_mode()))) |
| 1869 .StoreAccumulatorInRegister(super_args->language_mode()); |
| 1870 builder()->CallRuntime(Runtime::kLoadFromSuper, super_args->receiver(), |
| 1871 super_args->size()); |
| 1872 } |
| 1873 |
| 1874 void BytecodeGenerator::BuildKeyedSuperPropertyLoad( |
| 1875 SuperPropertyArguments* super_args) { |
| 1876 builder() |
| 1877 ->LoadLiteral(Smi::FromInt(static_cast<int>(language_mode()))) |
| 1878 .StoreAccumulatorInRegister(super_args->language_mode()); |
| 1879 builder()->CallRuntime(Runtime::kLoadKeyedFromSuper, super_args->receiver(), |
| 1880 super_args->size()); |
| 1881 } |
| 1882 |
| 1883 void BytecodeGenerator::BuildNamedSuperPropertyStore( |
| 1884 SuperPropertyArguments* super_args) { |
| 1885 builder()->StoreAccumulatorInRegister(super_args->store_value()); |
| 1886 Runtime::FunctionId function_id = is_strict(language_mode()) |
| 1887 ? Runtime::kStoreToSuper_Strict |
| 1888 : Runtime::kStoreToSuper_Sloppy; |
| 1889 builder()->CallRuntime(function_id, super_args->receiver(), |
| 1890 super_args->size()); |
| 1891 } |
| 1892 |
| 1893 void BytecodeGenerator::BuildKeyedSuperPropertyStore( |
| 1894 SuperPropertyArguments* super_args) { |
| 1895 builder()->StoreAccumulatorInRegister(super_args->store_value()); |
| 1896 Runtime::FunctionId function_id = is_strict(language_mode()) |
| 1897 ? Runtime::kStoreKeyedToSuper_Strict |
| 1898 : Runtime::kStoreKeyedToSuper_Sloppy; |
| 1899 builder()->CallRuntime(function_id, super_args->receiver(), |
| 1900 super_args->size()); |
| 1901 } |
| 1902 |
1784 void BytecodeGenerator::BuildThrowReferenceError(Handle<String> name) { | 1903 void BytecodeGenerator::BuildThrowReferenceError(Handle<String> name) { |
1785 RegisterAllocationScope register_scope(this); | 1904 RegisterAllocationScope register_scope(this); |
1786 Register name_reg = register_allocator()->NewRegister(); | 1905 Register name_reg = register_allocator()->NewRegister(); |
1787 builder()->LoadLiteral(name).StoreAccumulatorInRegister(name_reg).CallRuntime( | 1906 builder()->LoadLiteral(name).StoreAccumulatorInRegister(name_reg).CallRuntime( |
1788 Runtime::kThrowReferenceError, name_reg, 1); | 1907 Runtime::kThrowReferenceError, name_reg, 1); |
1789 } | 1908 } |
1790 | 1909 |
1791 void BytecodeGenerator::BuildThrowIfHole(Handle<String> name) { | 1910 void BytecodeGenerator::BuildThrowIfHole(Handle<String> name) { |
1792 // TODO(interpreter): Can the parser reduce the number of checks | 1911 // TODO(interpreter): Can the parser reduce the number of checks |
1793 // performed? Or should there be a ThrowIfHole bytecode. | 1912 // performed? Or should there be a ThrowIfHole bytecode. |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1981 } else { | 2100 } else { |
1982 builder()->StoreLookupSlot(variable->name(), language_mode()); | 2101 builder()->StoreLookupSlot(variable->name(), language_mode()); |
1983 } | 2102 } |
1984 break; | 2103 break; |
1985 } | 2104 } |
1986 } | 2105 } |
1987 } | 2106 } |
1988 | 2107 |
1989 | 2108 |
1990 void BytecodeGenerator::VisitAssignment(Assignment* expr) { | 2109 void BytecodeGenerator::VisitAssignment(Assignment* expr) { |
1991 DCHECK(expr->target()->IsValidReferenceExpression()); | 2110 DCHECK(expr->target()->IsValidReferenceExpressionOrThis()); |
1992 Register object, key; | 2111 Register object, key; |
| 2112 SuperPropertyArguments super_args; |
1993 Handle<String> name; | 2113 Handle<String> name; |
1994 | 2114 |
1995 // Left-hand side can only be a property, a global or a variable slot. | 2115 // Left-hand side can only be a property, a global or a variable slot. |
1996 Property* property = expr->target()->AsProperty(); | 2116 Property* property = expr->target()->AsProperty(); |
1997 LhsKind assign_type = Property::GetAssignType(property); | 2117 LhsKind assign_type = Property::GetAssignType(property); |
1998 | 2118 |
1999 // Evaluate LHS expression. | 2119 // Evaluate LHS expression. |
2000 switch (assign_type) { | 2120 switch (assign_type) { |
2001 case VARIABLE: | 2121 case VARIABLE: |
2002 // Nothing to do to evaluate variable assignment LHS. | 2122 // Nothing to do to evaluate variable assignment LHS. |
2003 break; | 2123 break; |
2004 case NAMED_PROPERTY: { | 2124 case NAMED_PROPERTY: { |
2005 object = VisitForRegisterValue(property->obj()); | 2125 object = VisitForRegisterValue(property->obj()); |
2006 name = property->key()->AsLiteral()->AsPropertyName(); | 2126 name = property->key()->AsLiteral()->AsPropertyName(); |
2007 break; | 2127 break; |
2008 } | 2128 } |
2009 case KEYED_PROPERTY: { | 2129 case KEYED_PROPERTY: { |
2010 object = VisitForRegisterValue(property->obj()); | 2130 object = VisitForRegisterValue(property->obj()); |
2011 if (expr->is_compound()) { | 2131 if (expr->is_compound()) { |
2012 // Use VisitForAccumulator and store to register so that the key is | 2132 // Use VisitForAccumulator and store to register so that the key is |
2013 // still in the accumulator for loading the old value below. | 2133 // still in the accumulator for loading the old value below. |
2014 key = register_allocator()->NewRegister(); | 2134 key = register_allocator()->NewRegister(); |
2015 VisitForAccumulatorValue(property->key()); | 2135 VisitForAccumulatorValue(property->key()); |
2016 builder()->StoreAccumulatorInRegister(key); | 2136 builder()->StoreAccumulatorInRegister(key); |
2017 } else { | 2137 } else { |
2018 key = VisitForRegisterValue(property->key()); | 2138 key = VisitForRegisterValue(property->key()); |
2019 } | 2139 } |
2020 break; | 2140 break; |
2021 } | 2141 } |
2022 case NAMED_SUPER_PROPERTY: | 2142 case NAMED_SUPER_PROPERTY: { |
2023 case KEYED_SUPER_PROPERTY: | 2143 PrepareNamedSuperPropertyArguments( |
2024 UNIMPLEMENTED(); | 2144 property->obj()->AsSuperPropertyReference(), |
| 2145 property->key()->AsLiteral()->AsPropertyName(), &super_args); |
| 2146 break; |
| 2147 } |
| 2148 case KEYED_SUPER_PROPERTY: { |
| 2149 PrepareKeyedSuperPropertyArguments( |
| 2150 property->obj()->AsSuperPropertyReference(), property->key(), |
| 2151 &super_args); |
| 2152 break; |
| 2153 } |
2025 } | 2154 } |
2026 | 2155 |
2027 // Evaluate the value and potentially handle compound assignments by loading | 2156 // Evaluate the value and potentially handle compound assignments by loading |
2028 // the left-hand side value and performing a binary operation. | 2157 // the left-hand side value and performing a binary operation. |
2029 if (expr->is_compound()) { | 2158 if (expr->is_compound()) { |
2030 Register old_value; | 2159 Register old_value; |
2031 switch (assign_type) { | 2160 switch (assign_type) { |
2032 case VARIABLE: { | 2161 case VARIABLE: { |
2033 VariableProxy* proxy = expr->target()->AsVariableProxy(); | 2162 VariableProxy* proxy = expr->target()->AsVariableProxy(); |
2034 old_value = VisitVariableLoadForRegisterValue( | 2163 old_value = VisitVariableLoadForRegisterValue( |
(...skipping 12 matching lines...) Expand all Loading... |
2047 case KEYED_PROPERTY: { | 2176 case KEYED_PROPERTY: { |
2048 // Key is already in accumulator at this point due to evaluating the | 2177 // Key is already in accumulator at this point due to evaluating the |
2049 // LHS above. | 2178 // LHS above. |
2050 FeedbackVectorSlot slot = property->PropertyFeedbackSlot(); | 2179 FeedbackVectorSlot slot = property->PropertyFeedbackSlot(); |
2051 old_value = register_allocator()->NewRegister(); | 2180 old_value = register_allocator()->NewRegister(); |
2052 builder() | 2181 builder() |
2053 ->LoadKeyedProperty(object, feedback_index(slot), language_mode()) | 2182 ->LoadKeyedProperty(object, feedback_index(slot), language_mode()) |
2054 .StoreAccumulatorInRegister(old_value); | 2183 .StoreAccumulatorInRegister(old_value); |
2055 break; | 2184 break; |
2056 } | 2185 } |
2057 case NAMED_SUPER_PROPERTY: | 2186 case NAMED_SUPER_PROPERTY: { |
2058 case KEYED_SUPER_PROPERTY: | 2187 old_value = register_allocator()->NewRegister(); |
2059 UNIMPLEMENTED(); | 2188 BuildNamedSuperPropertyLoad(&super_args); |
| 2189 builder()->StoreAccumulatorInRegister(old_value); |
2060 break; | 2190 break; |
| 2191 } |
| 2192 case KEYED_SUPER_PROPERTY: { |
| 2193 old_value = register_allocator()->NewRegister(); |
| 2194 BuildKeyedSuperPropertyLoad(&super_args); |
| 2195 builder()->StoreAccumulatorInRegister(old_value); |
| 2196 break; |
| 2197 } |
2061 } | 2198 } |
2062 VisitForAccumulatorValue(expr->value()); | 2199 VisitForAccumulatorValue(expr->value()); |
2063 builder()->BinaryOperation(expr->binary_op(), old_value, | 2200 builder()->BinaryOperation(expr->binary_op(), old_value, |
2064 language_mode_strength()); | 2201 language_mode_strength()); |
2065 } else { | 2202 } else { |
2066 VisitForAccumulatorValue(expr->value()); | 2203 VisitForAccumulatorValue(expr->value()); |
2067 } | 2204 } |
2068 | 2205 |
2069 // Store the value. | 2206 // Store the value. |
2070 FeedbackVectorSlot slot = expr->AssignmentSlot(); | 2207 FeedbackVectorSlot slot = expr->AssignmentSlot(); |
2071 switch (assign_type) { | 2208 switch (assign_type) { |
2072 case VARIABLE: { | 2209 case VARIABLE: { |
2073 // TODO(oth): The VisitVariableAssignment() call is hard to reason about. | 2210 // TODO(oth): The VisitVariableAssignment() call is hard to reason about. |
2074 // Is the value in the accumulator safe? Yes, but scary. | 2211 // Is the value in the accumulator safe? Yes, but scary. |
2075 Variable* variable = expr->target()->AsVariableProxy()->var(); | 2212 Variable* variable = expr->target()->AsVariableProxy()->var(); |
2076 VisitVariableAssignment(variable, expr->op(), slot); | 2213 VisitVariableAssignment(variable, expr->op(), slot); |
2077 break; | 2214 break; |
2078 } | 2215 } |
2079 case NAMED_PROPERTY: | 2216 case NAMED_PROPERTY: |
2080 builder()->StoreNamedProperty(object, name, feedback_index(slot), | 2217 builder()->StoreNamedProperty(object, name, feedback_index(slot), |
2081 language_mode()); | 2218 language_mode()); |
2082 break; | 2219 break; |
2083 case KEYED_PROPERTY: | 2220 case KEYED_PROPERTY: |
2084 builder()->StoreKeyedProperty(object, key, feedback_index(slot), | 2221 builder()->StoreKeyedProperty(object, key, feedback_index(slot), |
2085 language_mode()); | 2222 language_mode()); |
2086 break; | 2223 break; |
2087 case NAMED_SUPER_PROPERTY: | 2224 case NAMED_SUPER_PROPERTY: { |
2088 case KEYED_SUPER_PROPERTY: | 2225 BuildNamedSuperPropertyStore(&super_args); |
2089 UNIMPLEMENTED(); | 2226 break; |
| 2227 } |
| 2228 case KEYED_SUPER_PROPERTY: { |
| 2229 BuildKeyedSuperPropertyStore(&super_args); |
| 2230 break; |
| 2231 } |
2090 } | 2232 } |
2091 execution_result()->SetResultInAccumulator(); | 2233 execution_result()->SetResultInAccumulator(); |
2092 } | 2234 } |
2093 | 2235 |
2094 | 2236 |
2095 void BytecodeGenerator::VisitYield(Yield* expr) { UNIMPLEMENTED(); } | 2237 void BytecodeGenerator::VisitYield(Yield* expr) { UNIMPLEMENTED(); } |
2096 | 2238 |
2097 | 2239 |
2098 void BytecodeGenerator::VisitThrow(Throw* expr) { | 2240 void BytecodeGenerator::VisitThrow(Throw* expr) { |
2099 VisitForAccumulatorValue(expr->exception()); | 2241 VisitForAccumulatorValue(expr->exception()); |
(...skipping 17 matching lines...) Expand all Loading... |
2117 expr->key()->AsLiteral()->AsPropertyName(), | 2259 expr->key()->AsLiteral()->AsPropertyName(), |
2118 feedback_index(slot), language_mode()); | 2260 feedback_index(slot), language_mode()); |
2119 break; | 2261 break; |
2120 } | 2262 } |
2121 case KEYED_PROPERTY: { | 2263 case KEYED_PROPERTY: { |
2122 VisitForAccumulatorValue(expr->key()); | 2264 VisitForAccumulatorValue(expr->key()); |
2123 builder()->LoadKeyedProperty(obj, feedback_index(slot), language_mode()); | 2265 builder()->LoadKeyedProperty(obj, feedback_index(slot), language_mode()); |
2124 break; | 2266 break; |
2125 } | 2267 } |
2126 case NAMED_SUPER_PROPERTY: | 2268 case NAMED_SUPER_PROPERTY: |
| 2269 VisitNamedSuperPropertyLoad(expr, Register::invalid_value()); |
| 2270 break; |
2127 case KEYED_SUPER_PROPERTY: | 2271 case KEYED_SUPER_PROPERTY: |
2128 UNIMPLEMENTED(); | 2272 VisitKeyedSuperPropertyLoad(expr, Register::invalid_value()); |
| 2273 break; |
2129 } | 2274 } |
2130 execution_result()->SetResultInAccumulator(); | 2275 execution_result()->SetResultInAccumulator(); |
2131 } | 2276 } |
2132 | 2277 |
2133 | |
2134 void BytecodeGenerator::VisitPropertyLoadForAccumulator(Register obj, | 2278 void BytecodeGenerator::VisitPropertyLoadForAccumulator(Register obj, |
2135 Property* expr) { | 2279 Property* expr) { |
2136 AccumulatorResultScope result_scope(this); | 2280 AccumulatorResultScope result_scope(this); |
2137 VisitPropertyLoad(obj, expr); | 2281 VisitPropertyLoad(obj, expr); |
2138 } | 2282 } |
2139 | 2283 |
| 2284 void BytecodeGenerator::VisitNamedSuperPropertyLoad(Property* property, |
| 2285 Register opt_receiver_out) { |
| 2286 RegisterAllocationScope register_scope(this); |
| 2287 SuperPropertyArguments super_args; |
| 2288 PrepareNamedSuperPropertyArguments( |
| 2289 property->obj()->AsSuperPropertyReference(), |
| 2290 property->key()->AsLiteral()->AsPropertyName(), &super_args); |
| 2291 if (opt_receiver_out.is_valid()) { |
| 2292 builder()->MoveRegister(super_args.receiver(), opt_receiver_out); |
| 2293 } |
| 2294 BuildNamedSuperPropertyLoad(&super_args); |
| 2295 } |
| 2296 |
| 2297 void BytecodeGenerator::VisitKeyedSuperPropertyLoad(Property* property, |
| 2298 Register opt_receiver_out) { |
| 2299 RegisterAllocationScope register_scope(this); |
| 2300 SuperPropertyArguments super_args; |
| 2301 PrepareKeyedSuperPropertyArguments( |
| 2302 property->obj()->AsSuperPropertyReference(), property->key(), |
| 2303 &super_args); |
| 2304 if (opt_receiver_out.is_valid()) { |
| 2305 builder()->MoveRegister(super_args.receiver(), opt_receiver_out); |
| 2306 } |
| 2307 BuildKeyedSuperPropertyLoad(&super_args); |
| 2308 } |
2140 | 2309 |
2141 void BytecodeGenerator::VisitProperty(Property* expr) { | 2310 void BytecodeGenerator::VisitProperty(Property* expr) { |
2142 Register obj = VisitForRegisterValue(expr->obj()); | 2311 LhsKind property_kind = Property::GetAssignType(expr); |
2143 VisitPropertyLoad(obj, expr); | 2312 if (property_kind != NAMED_SUPER_PROPERTY && |
| 2313 property_kind != KEYED_SUPER_PROPERTY) { |
| 2314 Register obj = VisitForRegisterValue(expr->obj()); |
| 2315 VisitPropertyLoad(obj, expr); |
| 2316 } else { |
| 2317 VisitPropertyLoad(Register::invalid_value(), expr); |
| 2318 } |
2144 } | 2319 } |
2145 | 2320 |
2146 | |
2147 Register BytecodeGenerator::VisitArguments(ZoneList<Expression*>* args) { | 2321 Register BytecodeGenerator::VisitArguments(ZoneList<Expression*>* args) { |
2148 if (args->length() == 0) { | 2322 if (args->length() == 0) { |
2149 return Register(); | 2323 return Register(); |
2150 } | 2324 } |
2151 | 2325 |
2152 // Visit arguments and place in a contiguous block of temporary | 2326 // Visit arguments and place in a contiguous block of temporary |
2153 // registers. Return the first temporary register corresponding to | 2327 // registers. Return the first temporary register corresponding to |
2154 // the first argument. | 2328 // the first argument. |
2155 // | 2329 // |
2156 // NB the caller may have already called | 2330 // NB the caller may have already called |
(...skipping 12 matching lines...) Expand all Loading... |
2169 // Visit remaining arguments | 2343 // Visit remaining arguments |
2170 for (int i = 1; i < static_cast<int>(args->length()); i++) { | 2344 for (int i = 1; i < static_cast<int>(args->length()); i++) { |
2171 Register ith_arg = register_allocator()->NextConsecutiveRegister(); | 2345 Register ith_arg = register_allocator()->NextConsecutiveRegister(); |
2172 VisitForAccumulatorValue(args->at(i)); | 2346 VisitForAccumulatorValue(args->at(i)); |
2173 builder()->StoreAccumulatorInRegister(ith_arg); | 2347 builder()->StoreAccumulatorInRegister(ith_arg); |
2174 DCHECK(ith_arg.index() - i == first_arg.index()); | 2348 DCHECK(ith_arg.index() - i == first_arg.index()); |
2175 } | 2349 } |
2176 return first_arg; | 2350 return first_arg; |
2177 } | 2351 } |
2178 | 2352 |
2179 | |
2180 void BytecodeGenerator::VisitCall(Call* expr) { | 2353 void BytecodeGenerator::VisitCall(Call* expr) { |
2181 Expression* callee_expr = expr->expression(); | 2354 Expression* callee_expr = expr->expression(); |
2182 Call::CallType call_type = expr->GetCallType(isolate()); | 2355 Call::CallType call_type = expr->GetCallType(isolate()); |
2183 | 2356 |
| 2357 if (call_type == Call::SUPER_CALL) { |
| 2358 return VisitCallSuper(expr); |
| 2359 } |
| 2360 |
2184 // Prepare the callee and the receiver to the function call. This depends on | 2361 // Prepare the callee and the receiver to the function call. This depends on |
2185 // the semantics of the underlying call type. | 2362 // the semantics of the underlying call type. |
2186 | 2363 |
2187 // The receiver and arguments need to be allocated consecutively for | 2364 // The receiver and arguments need to be allocated consecutively for |
2188 // Call(). We allocate the callee and receiver consecutively for calls to | 2365 // Call(). We allocate the callee and receiver consecutively for calls to |
2189 // %LoadLookupSlotForCall. Future optimizations could avoid this there are | 2366 // %LoadLookupSlotForCall. Future optimizations could avoid this there are |
2190 // no arguments or the receiver and arguments are already consecutive. | 2367 // no arguments or the receiver and arguments are already consecutive. |
2191 ZoneList<Expression*>* args = expr->arguments(); | 2368 ZoneList<Expression*>* args = expr->arguments(); |
2192 register_allocator()->PrepareForConsecutiveAllocations(args->length() + 2); | 2369 register_allocator()->PrepareForConsecutiveAllocations(args->length() + 2); |
2193 Register callee = register_allocator()->NextConsecutiveRegister(); | 2370 Register callee = register_allocator()->NextConsecutiveRegister(); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2231 } | 2408 } |
2232 // Fall through. | 2409 // Fall through. |
2233 DCHECK_EQ(call_type, Call::POSSIBLY_EVAL_CALL); | 2410 DCHECK_EQ(call_type, Call::POSSIBLY_EVAL_CALL); |
2234 } | 2411 } |
2235 case Call::OTHER_CALL: { | 2412 case Call::OTHER_CALL: { |
2236 builder()->LoadUndefined().StoreAccumulatorInRegister(receiver); | 2413 builder()->LoadUndefined().StoreAccumulatorInRegister(receiver); |
2237 VisitForAccumulatorValue(callee_expr); | 2414 VisitForAccumulatorValue(callee_expr); |
2238 builder()->StoreAccumulatorInRegister(callee); | 2415 builder()->StoreAccumulatorInRegister(callee); |
2239 break; | 2416 break; |
2240 } | 2417 } |
2241 case Call::NAMED_SUPER_PROPERTY_CALL: | 2418 case Call::NAMED_SUPER_PROPERTY_CALL: { |
2242 case Call::KEYED_SUPER_PROPERTY_CALL: | 2419 Property* property = callee_expr->AsProperty(); |
| 2420 VisitNamedSuperPropertyLoad(property, receiver); |
| 2421 builder()->StoreAccumulatorInRegister(callee); |
| 2422 break; |
| 2423 } |
| 2424 case Call::KEYED_SUPER_PROPERTY_CALL: { |
| 2425 Property* property = callee_expr->AsProperty(); |
| 2426 VisitKeyedSuperPropertyLoad(property, receiver); |
| 2427 builder()->StoreAccumulatorInRegister(callee); |
| 2428 break; |
| 2429 } |
2243 case Call::SUPER_CALL: | 2430 case Call::SUPER_CALL: |
2244 UNIMPLEMENTED(); | 2431 UNREACHABLE(); |
| 2432 break; |
2245 } | 2433 } |
2246 | 2434 |
2247 // Evaluate all arguments to the function call and store in sequential | 2435 // Evaluate all arguments to the function call and store in sequential |
2248 // registers. | 2436 // registers. |
2249 Register arg = VisitArguments(args); | 2437 Register arg = VisitArguments(args); |
2250 CHECK(args->length() == 0 || arg.index() == receiver.index() + 1); | 2438 CHECK(args->length() == 0 || arg.index() == receiver.index() + 1); |
2251 | 2439 |
2252 // Resolve callee for a potential direct eval call. This block will mutate the | 2440 // Resolve callee for a potential direct eval call. This block will mutate the |
2253 // callee value. | 2441 // callee value. |
2254 if (call_type == Call::POSSIBLY_EVAL_CALL && args->length() > 0) { | 2442 if (call_type == Call::POSSIBLY_EVAL_CALL && args->length() > 0) { |
(...skipping 23 matching lines...) Expand all Loading... |
2278 ->CallRuntime(Runtime::kResolvePossiblyDirectEval, callee_for_eval, 5) | 2466 ->CallRuntime(Runtime::kResolvePossiblyDirectEval, callee_for_eval, 5) |
2279 .StoreAccumulatorInRegister(callee); | 2467 .StoreAccumulatorInRegister(callee); |
2280 } | 2468 } |
2281 | 2469 |
2282 builder()->SetExpressionPosition(expr); | 2470 builder()->SetExpressionPosition(expr); |
2283 builder()->Call(callee, receiver, 1 + args->length(), | 2471 builder()->Call(callee, receiver, 1 + args->length(), |
2284 feedback_index(expr->CallFeedbackICSlot())); | 2472 feedback_index(expr->CallFeedbackICSlot())); |
2285 execution_result()->SetResultInAccumulator(); | 2473 execution_result()->SetResultInAccumulator(); |
2286 } | 2474 } |
2287 | 2475 |
| 2476 void BytecodeGenerator::VisitCallSuper(Call* expr) { |
| 2477 RegisterAllocationScope register_scope(this); |
| 2478 SuperCallReference* super = expr->expression()->AsSuperCallReference(); |
| 2479 |
| 2480 // Prepare the constructor to the super call. |
| 2481 Register this_function = register_allocator()->NewRegister(); |
| 2482 VisitForAccumulatorValue(super->this_function_var()); |
| 2483 builder() |
| 2484 ->StoreAccumulatorInRegister(this_function) |
| 2485 .CallRuntime(Runtime::kInlineGetSuperConstructor, this_function, 1); |
| 2486 |
| 2487 Register constructor = this_function; // Re-use dead this_function register. |
| 2488 builder()->StoreAccumulatorInRegister(constructor); |
| 2489 |
| 2490 ZoneList<Expression*>* args = expr->arguments(); |
| 2491 Register first_arg = VisitArguments(args); |
| 2492 |
| 2493 // The new target is loaded into the accumulator from the |
| 2494 // {new.target} variable. |
| 2495 VisitForAccumulatorValue(super->new_target_var()); |
| 2496 |
| 2497 // Call construct. |
| 2498 builder()->SetExpressionPosition(expr); |
| 2499 builder()->New(constructor, first_arg, args->length()); |
| 2500 execution_result()->SetResultInAccumulator(); |
| 2501 } |
2288 | 2502 |
2289 void BytecodeGenerator::VisitCallNew(CallNew* expr) { | 2503 void BytecodeGenerator::VisitCallNew(CallNew* expr) { |
2290 Register constructor = register_allocator()->NewRegister(); | 2504 Register constructor = register_allocator()->NewRegister(); |
2291 VisitForAccumulatorValue(expr->expression()); | 2505 VisitForAccumulatorValue(expr->expression()); |
2292 builder()->StoreAccumulatorInRegister(constructor); | 2506 builder()->StoreAccumulatorInRegister(constructor); |
2293 | 2507 |
2294 ZoneList<Expression*>* args = expr->arguments(); | 2508 ZoneList<Expression*>* args = expr->arguments(); |
2295 Register first_arg = VisitArguments(args); | 2509 Register first_arg = VisitArguments(args); |
| 2510 |
2296 builder()->SetExpressionPosition(expr); | 2511 builder()->SetExpressionPosition(expr); |
2297 builder()->New(constructor, first_arg, args->length()); | 2512 // The accumulator holds new target which is the same as the |
| 2513 // constructor for CallNew. |
| 2514 builder() |
| 2515 ->LoadAccumulatorWithRegister(constructor) |
| 2516 .New(constructor, first_arg, args->length()); |
2298 execution_result()->SetResultInAccumulator(); | 2517 execution_result()->SetResultInAccumulator(); |
2299 } | 2518 } |
2300 | 2519 |
2301 | 2520 |
2302 void BytecodeGenerator::VisitCallRuntime(CallRuntime* expr) { | 2521 void BytecodeGenerator::VisitCallRuntime(CallRuntime* expr) { |
2303 ZoneList<Expression*>* args = expr->arguments(); | 2522 ZoneList<Expression*>* args = expr->arguments(); |
2304 if (expr->is_jsruntime()) { | 2523 if (expr->is_jsruntime()) { |
2305 // Allocate a register for the receiver and load it with undefined. | 2524 // Allocate a register for the receiver and load it with undefined. |
2306 register_allocator()->PrepareForConsecutiveAllocations(1 + args->length()); | 2525 register_allocator()->PrepareForConsecutiveAllocations(1 + args->length()); |
2307 Register receiver = register_allocator()->NextConsecutiveRegister(); | 2526 Register receiver = register_allocator()->NextConsecutiveRegister(); |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2441 DCHECK(expr->expression()->IsValidReferenceExpressionOrThis()); | 2660 DCHECK(expr->expression()->IsValidReferenceExpressionOrThis()); |
2442 | 2661 |
2443 // Left-hand side can only be a property, a global or a variable slot. | 2662 // Left-hand side can only be a property, a global or a variable slot. |
2444 Property* property = expr->expression()->AsProperty(); | 2663 Property* property = expr->expression()->AsProperty(); |
2445 LhsKind assign_type = Property::GetAssignType(property); | 2664 LhsKind assign_type = Property::GetAssignType(property); |
2446 | 2665 |
2447 // TODO(rmcilroy): Set is_postfix to false if visiting for effect. | 2666 // TODO(rmcilroy): Set is_postfix to false if visiting for effect. |
2448 bool is_postfix = expr->is_postfix(); | 2667 bool is_postfix = expr->is_postfix(); |
2449 | 2668 |
2450 // Evaluate LHS expression and get old value. | 2669 // Evaluate LHS expression and get old value. |
2451 Register obj, key, old_value; | 2670 Register object, key, old_value; |
| 2671 SuperPropertyArguments super_args; |
2452 Handle<String> name; | 2672 Handle<String> name; |
2453 switch (assign_type) { | 2673 switch (assign_type) { |
2454 case VARIABLE: { | 2674 case VARIABLE: { |
2455 VariableProxy* proxy = expr->expression()->AsVariableProxy(); | 2675 VariableProxy* proxy = expr->expression()->AsVariableProxy(); |
2456 VisitVariableLoadForAccumulatorValue(proxy->var(), | 2676 VisitVariableLoadForAccumulatorValue(proxy->var(), |
2457 proxy->VariableFeedbackSlot()); | 2677 proxy->VariableFeedbackSlot()); |
2458 break; | 2678 break; |
2459 } | 2679 } |
2460 case NAMED_PROPERTY: { | 2680 case NAMED_PROPERTY: { |
2461 FeedbackVectorSlot slot = property->PropertyFeedbackSlot(); | 2681 FeedbackVectorSlot slot = property->PropertyFeedbackSlot(); |
2462 obj = VisitForRegisterValue(property->obj()); | 2682 object = VisitForRegisterValue(property->obj()); |
2463 name = property->key()->AsLiteral()->AsPropertyName(); | 2683 name = property->key()->AsLiteral()->AsPropertyName(); |
2464 builder()->LoadNamedProperty(obj, name, feedback_index(slot), | 2684 builder()->LoadNamedProperty(object, name, feedback_index(slot), |
2465 language_mode()); | 2685 language_mode()); |
2466 break; | 2686 break; |
2467 } | 2687 } |
2468 case KEYED_PROPERTY: { | 2688 case KEYED_PROPERTY: { |
2469 FeedbackVectorSlot slot = property->PropertyFeedbackSlot(); | 2689 FeedbackVectorSlot slot = property->PropertyFeedbackSlot(); |
2470 obj = VisitForRegisterValue(property->obj()); | 2690 object = VisitForRegisterValue(property->obj()); |
2471 // Use visit for accumulator here since we need the key in the accumulator | 2691 // Use visit for accumulator here since we need the key in the accumulator |
2472 // for the LoadKeyedProperty. | 2692 // for the LoadKeyedProperty. |
2473 key = register_allocator()->NewRegister(); | 2693 key = register_allocator()->NewRegister(); |
2474 VisitForAccumulatorValue(property->key()); | 2694 VisitForAccumulatorValue(property->key()); |
2475 builder()->StoreAccumulatorInRegister(key).LoadKeyedProperty( | 2695 builder()->StoreAccumulatorInRegister(key).LoadKeyedProperty( |
2476 obj, feedback_index(slot), language_mode()); | 2696 object, feedback_index(slot), language_mode()); |
2477 break; | 2697 break; |
2478 } | 2698 } |
2479 case NAMED_SUPER_PROPERTY: | 2699 case NAMED_SUPER_PROPERTY: { |
2480 case KEYED_SUPER_PROPERTY: | 2700 PrepareNamedSuperPropertyArguments( |
2481 UNIMPLEMENTED(); | 2701 property->obj()->AsSuperPropertyReference(), |
| 2702 property->key()->AsLiteral()->AsPropertyName(), &super_args); |
| 2703 BuildNamedSuperPropertyLoad(&super_args); |
| 2704 break; |
| 2705 } |
| 2706 case KEYED_SUPER_PROPERTY: { |
| 2707 PrepareKeyedSuperPropertyArguments( |
| 2708 property->obj()->AsSuperPropertyReference(), property->key(), |
| 2709 &super_args); |
| 2710 BuildKeyedSuperPropertyLoad(&super_args); |
| 2711 break; |
| 2712 } |
2482 } | 2713 } |
2483 | 2714 |
2484 // Convert old value into a number. | 2715 // Convert old value into a number. |
2485 if (!is_strong(language_mode())) { | 2716 if (!is_strong(language_mode())) { |
2486 builder()->CastAccumulatorToNumber(); | 2717 builder()->CastAccumulatorToNumber(); |
2487 } | 2718 } |
2488 | 2719 |
2489 // Save result for postfix expressions. | 2720 // Save result for postfix expressions. |
2490 if (is_postfix) { | 2721 if (is_postfix) { |
2491 old_value = register_allocator()->outer()->NewRegister(); | 2722 old_value = register_allocator()->outer()->NewRegister(); |
2492 builder()->StoreAccumulatorInRegister(old_value); | 2723 builder()->StoreAccumulatorInRegister(old_value); |
2493 } | 2724 } |
2494 | 2725 |
2495 // Perform +1/-1 operation. | 2726 // Perform +1/-1 operation. |
2496 builder()->CountOperation(expr->binary_op(), language_mode_strength()); | 2727 builder()->CountOperation(expr->binary_op(), language_mode_strength()); |
2497 | 2728 |
2498 // Store the value. | 2729 // Store the value. |
2499 FeedbackVectorSlot feedback_slot = expr->CountSlot(); | 2730 FeedbackVectorSlot feedback_slot = expr->CountSlot(); |
2500 switch (assign_type) { | 2731 switch (assign_type) { |
2501 case VARIABLE: { | 2732 case VARIABLE: { |
2502 Variable* variable = expr->expression()->AsVariableProxy()->var(); | 2733 Variable* variable = expr->expression()->AsVariableProxy()->var(); |
2503 VisitVariableAssignment(variable, expr->op(), feedback_slot); | 2734 VisitVariableAssignment(variable, expr->op(), feedback_slot); |
2504 break; | 2735 break; |
2505 } | 2736 } |
2506 case NAMED_PROPERTY: { | 2737 case NAMED_PROPERTY: { |
2507 builder()->StoreNamedProperty(obj, name, feedback_index(feedback_slot), | 2738 builder()->StoreNamedProperty(object, name, feedback_index(feedback_slot), |
2508 language_mode()); | 2739 language_mode()); |
2509 break; | 2740 break; |
2510 } | 2741 } |
2511 case KEYED_PROPERTY: { | 2742 case KEYED_PROPERTY: { |
2512 builder()->StoreKeyedProperty(obj, key, feedback_index(feedback_slot), | 2743 builder()->StoreKeyedProperty(object, key, feedback_index(feedback_slot), |
2513 language_mode()); | 2744 language_mode()); |
2514 break; | 2745 break; |
2515 } | 2746 } |
2516 case NAMED_SUPER_PROPERTY: | 2747 case NAMED_SUPER_PROPERTY: { |
2517 case KEYED_SUPER_PROPERTY: | 2748 BuildNamedSuperPropertyStore(&super_args); |
2518 UNIMPLEMENTED(); | 2749 break; |
| 2750 } |
| 2751 case KEYED_SUPER_PROPERTY: { |
| 2752 BuildKeyedSuperPropertyStore(&super_args); |
| 2753 break; |
| 2754 } |
2519 } | 2755 } |
2520 | 2756 |
2521 // Restore old value for postfix expressions. | 2757 // Restore old value for postfix expressions. |
2522 if (is_postfix) { | 2758 if (is_postfix) { |
2523 execution_result()->SetResultInRegister(old_value); | 2759 execution_result()->SetResultInRegister(old_value); |
2524 } else { | 2760 } else { |
2525 execution_result()->SetResultInAccumulator(); | 2761 execution_result()->SetResultInAccumulator(); |
2526 } | 2762 } |
2527 } | 2763 } |
2528 | 2764 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2568 UNREACHABLE(); | 2804 UNREACHABLE(); |
2569 } | 2805 } |
2570 | 2806 |
2571 | 2807 |
2572 void BytecodeGenerator::VisitThisFunction(ThisFunction* expr) { | 2808 void BytecodeGenerator::VisitThisFunction(ThisFunction* expr) { |
2573 execution_result()->SetResultInRegister(Register::function_closure()); | 2809 execution_result()->SetResultInRegister(Register::function_closure()); |
2574 } | 2810 } |
2575 | 2811 |
2576 | 2812 |
2577 void BytecodeGenerator::VisitSuperCallReference(SuperCallReference* expr) { | 2813 void BytecodeGenerator::VisitSuperCallReference(SuperCallReference* expr) { |
2578 UNIMPLEMENTED(); | 2814 // Handled by VisitCall(). |
| 2815 UNREACHABLE(); |
2579 } | 2816 } |
2580 | 2817 |
2581 | 2818 |
2582 void BytecodeGenerator::VisitSuperPropertyReference( | 2819 void BytecodeGenerator::VisitSuperPropertyReference( |
2583 SuperPropertyReference* expr) { | 2820 SuperPropertyReference* expr) { |
2584 UNIMPLEMENTED(); | 2821 builder()->CallRuntime(Runtime::kThrowUnsupportedSuperError, Register(0), 0); |
| 2822 execution_result()->SetResultInAccumulator(); |
2585 } | 2823 } |
2586 | 2824 |
2587 | 2825 |
2588 void BytecodeGenerator::VisitCommaExpression(BinaryOperation* binop) { | 2826 void BytecodeGenerator::VisitCommaExpression(BinaryOperation* binop) { |
2589 VisitForEffect(binop->left()); | 2827 VisitForEffect(binop->left()); |
2590 Visit(binop->right()); | 2828 Visit(binop->right()); |
2591 } | 2829 } |
2592 | 2830 |
2593 | 2831 |
2594 void BytecodeGenerator::VisitLogicalOrExpression(BinaryOperation* binop) { | 2832 void BytecodeGenerator::VisitLogicalOrExpression(BinaryOperation* binop) { |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2747 // TODO(rmcilroy): Replace value_out with VisitForRegister(); | 2985 // TODO(rmcilroy): Replace value_out with VisitForRegister(); |
2748 if (property == nullptr) { | 2986 if (property == nullptr) { |
2749 builder()->LoadNull().StoreAccumulatorInRegister(value_out); | 2987 builder()->LoadNull().StoreAccumulatorInRegister(value_out); |
2750 } else { | 2988 } else { |
2751 VisitForAccumulatorValue(property->value()); | 2989 VisitForAccumulatorValue(property->value()); |
2752 builder()->StoreAccumulatorInRegister(value_out); | 2990 builder()->StoreAccumulatorInRegister(value_out); |
2753 VisitSetHomeObject(value_out, home_object, property); | 2991 VisitSetHomeObject(value_out, home_object, property); |
2754 } | 2992 } |
2755 } | 2993 } |
2756 | 2994 |
2757 | |
2758 void BytecodeGenerator::VisitSetHomeObject(Register value, Register home_object, | 2995 void BytecodeGenerator::VisitSetHomeObject(Register value, Register home_object, |
2759 ObjectLiteralProperty* property, | 2996 ObjectLiteralProperty* property, |
2760 int slot_number) { | 2997 int slot_number) { |
2761 Expression* expr = property->value(); | 2998 Expression* expr = property->value(); |
2762 if (!FunctionLiteral::NeedsHomeObject(expr)) return; | 2999 if (FunctionLiteral::NeedsHomeObject(expr)) { |
2763 | 3000 Handle<Name> name = isolate()->factory()->home_object_symbol(); |
2764 UNIMPLEMENTED(); | 3001 FeedbackVectorSlot slot = property->GetSlot(slot_number); |
| 3002 builder() |
| 3003 ->LoadAccumulatorWithRegister(home_object) |
| 3004 .StoreNamedProperty(value, name, feedback_index(slot), language_mode()); |
| 3005 } |
2765 } | 3006 } |
2766 | 3007 |
2767 | 3008 |
2768 void BytecodeGenerator::VisitArgumentsObject(Variable* variable) { | 3009 void BytecodeGenerator::VisitArgumentsObject(Variable* variable) { |
2769 if (variable == nullptr) return; | 3010 if (variable == nullptr) return; |
2770 | 3011 |
2771 DCHECK(variable->IsContextSlot() || variable->IsStackAllocated()); | 3012 DCHECK(variable->IsContextSlot() || variable->IsStackAllocated()); |
2772 | 3013 |
2773 // Allocate and initialize a new arguments object and assign to the | 3014 // Allocate and initialize a new arguments object and assign to the |
2774 // {arguments} variable. | 3015 // {arguments} variable. |
(...skipping 12 matching lines...) Expand all Loading... |
2787 // Allocate and initialize a new rest parameter and assign to the {rest} | 3028 // Allocate and initialize a new rest parameter and assign to the {rest} |
2788 // variable. | 3029 // variable. |
2789 builder()->CreateArguments(CreateArgumentsType::kRestParameter); | 3030 builder()->CreateArguments(CreateArgumentsType::kRestParameter); |
2790 DCHECK(rest->IsContextSlot() || rest->IsStackAllocated()); | 3031 DCHECK(rest->IsContextSlot() || rest->IsStackAllocated()); |
2791 VisitVariableAssignment(rest, Token::ASSIGN, FeedbackVectorSlot::Invalid()); | 3032 VisitVariableAssignment(rest, Token::ASSIGN, FeedbackVectorSlot::Invalid()); |
2792 } | 3033 } |
2793 | 3034 |
2794 void BytecodeGenerator::VisitThisFunctionVariable(Variable* variable) { | 3035 void BytecodeGenerator::VisitThisFunctionVariable(Variable* variable) { |
2795 if (variable == nullptr) return; | 3036 if (variable == nullptr) return; |
2796 | 3037 |
2797 // TODO(rmcilroy): Remove once we have tests which exercise this code path. | |
2798 UNIMPLEMENTED(); | |
2799 | |
2800 // Store the closure we were called with in the given variable. | 3038 // Store the closure we were called with in the given variable. |
2801 builder()->LoadAccumulatorWithRegister(Register::function_closure()); | 3039 builder()->LoadAccumulatorWithRegister(Register::function_closure()); |
2802 VisitVariableAssignment(variable, Token::INIT, FeedbackVectorSlot::Invalid()); | 3040 VisitVariableAssignment(variable, Token::INIT, FeedbackVectorSlot::Invalid()); |
2803 } | 3041 } |
2804 | 3042 |
2805 | 3043 |
2806 void BytecodeGenerator::VisitNewTargetVariable(Variable* variable) { | 3044 void BytecodeGenerator::VisitNewTargetVariable(Variable* variable) { |
2807 if (variable == nullptr) return; | 3045 if (variable == nullptr) return; |
2808 | 3046 |
2809 // Store the new target we were called with in the given variable. | 3047 // Store the new target we were called with in the given variable. |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2886 } | 3124 } |
2887 | 3125 |
2888 | 3126 |
2889 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { | 3127 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { |
2890 return info()->feedback_vector()->GetIndex(slot); | 3128 return info()->feedback_vector()->GetIndex(slot); |
2891 } | 3129 } |
2892 | 3130 |
2893 } // namespace interpreter | 3131 } // namespace interpreter |
2894 } // namespace internal | 3132 } // namespace internal |
2895 } // namespace v8 | 3133 } // namespace v8 |
OLD | NEW |