OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 2121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2132 | 2132 |
2133 void FullCodeGenerator::EmitNamedPropertyAssignment(Assignment* expr) { | 2133 void FullCodeGenerator::EmitNamedPropertyAssignment(Assignment* expr) { |
2134 // Assignment to a property, using a named store IC. | 2134 // Assignment to a property, using a named store IC. |
2135 // eax : value | 2135 // eax : value |
2136 // esp[0] : receiver | 2136 // esp[0] : receiver |
2137 | 2137 |
2138 Property* prop = expr->target()->AsProperty(); | 2138 Property* prop = expr->target()->AsProperty(); |
2139 ASSERT(prop != NULL); | 2139 ASSERT(prop != NULL); |
2140 ASSERT(prop->key()->AsLiteral() != NULL); | 2140 ASSERT(prop->key()->AsLiteral() != NULL); |
2141 | 2141 |
| 2142 // If the assignment starts a block of assignments to the same object, |
| 2143 // change to slow case to avoid the quadratic behavior of repeatedly |
| 2144 // adding fast properties. |
| 2145 if (expr->starts_initialization_block()) { |
| 2146 __ push(result_register()); |
| 2147 __ push(Operand(esp, kPointerSize)); // Receiver is now under value. |
| 2148 __ CallRuntime(Runtime::kToSlowProperties, 1); |
| 2149 __ pop(result_register()); |
| 2150 } |
| 2151 |
2142 // Record source code position before IC call. | 2152 // Record source code position before IC call. |
2143 SetSourcePosition(expr->position()); | 2153 SetSourcePosition(expr->position()); |
2144 __ mov(ecx, prop->key()->AsLiteral()->handle()); | 2154 __ mov(ecx, prop->key()->AsLiteral()->handle()); |
2145 __ pop(edx); | 2155 if (expr->ends_initialization_block()) { |
| 2156 __ mov(edx, Operand(esp, 0)); |
| 2157 } else { |
| 2158 __ pop(edx); |
| 2159 } |
2146 Handle<Code> ic = is_classic_mode() | 2160 Handle<Code> ic = is_classic_mode() |
2147 ? isolate()->builtins()->StoreIC_Initialize() | 2161 ? isolate()->builtins()->StoreIC_Initialize() |
2148 : isolate()->builtins()->StoreIC_Initialize_Strict(); | 2162 : isolate()->builtins()->StoreIC_Initialize_Strict(); |
2149 CallIC(ic, RelocInfo::CODE_TARGET, expr->AssignmentFeedbackId()); | 2163 CallIC(ic, RelocInfo::CODE_TARGET, expr->AssignmentFeedbackId()); |
2150 | 2164 |
| 2165 // If the assignment ends an initialization block, revert to fast case. |
| 2166 if (expr->ends_initialization_block()) { |
| 2167 __ push(eax); // Result of assignment, saved even if not needed. |
| 2168 __ push(Operand(esp, kPointerSize)); // Receiver is under value. |
| 2169 __ CallRuntime(Runtime::kToFastProperties, 1); |
| 2170 __ pop(eax); |
| 2171 __ Drop(1); |
| 2172 } |
2151 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); | 2173 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); |
2152 context()->Plug(eax); | 2174 context()->Plug(eax); |
2153 } | 2175 } |
2154 | 2176 |
2155 | 2177 |
2156 void FullCodeGenerator::EmitKeyedPropertyAssignment(Assignment* expr) { | 2178 void FullCodeGenerator::EmitKeyedPropertyAssignment(Assignment* expr) { |
2157 // Assignment to a property, using a keyed store IC. | 2179 // Assignment to a property, using a keyed store IC. |
2158 // eax : value | 2180 // eax : value |
2159 // esp[0] : key | 2181 // esp[0] : key |
2160 // esp[kPointerSize] : receiver | 2182 // esp[kPointerSize] : receiver |
2161 | 2183 |
| 2184 // If the assignment starts a block of assignments to the same object, |
| 2185 // change to slow case to avoid the quadratic behavior of repeatedly |
| 2186 // adding fast properties. |
| 2187 if (expr->starts_initialization_block()) { |
| 2188 __ push(result_register()); |
| 2189 // Receiver is now under the key and value. |
| 2190 __ push(Operand(esp, 2 * kPointerSize)); |
| 2191 __ CallRuntime(Runtime::kToSlowProperties, 1); |
| 2192 __ pop(result_register()); |
| 2193 } |
| 2194 |
2162 __ pop(ecx); // Key. | 2195 __ pop(ecx); // Key. |
2163 __ pop(edx); | 2196 if (expr->ends_initialization_block()) { |
| 2197 __ mov(edx, Operand(esp, 0)); // Leave receiver on the stack for later. |
| 2198 } else { |
| 2199 __ pop(edx); |
| 2200 } |
2164 // Record source code position before IC call. | 2201 // Record source code position before IC call. |
2165 SetSourcePosition(expr->position()); | 2202 SetSourcePosition(expr->position()); |
2166 Handle<Code> ic = is_classic_mode() | 2203 Handle<Code> ic = is_classic_mode() |
2167 ? isolate()->builtins()->KeyedStoreIC_Initialize() | 2204 ? isolate()->builtins()->KeyedStoreIC_Initialize() |
2168 : isolate()->builtins()->KeyedStoreIC_Initialize_Strict(); | 2205 : isolate()->builtins()->KeyedStoreIC_Initialize_Strict(); |
2169 CallIC(ic, RelocInfo::CODE_TARGET, expr->AssignmentFeedbackId()); | 2206 CallIC(ic, RelocInfo::CODE_TARGET, expr->AssignmentFeedbackId()); |
2170 | 2207 |
| 2208 // If the assignment ends an initialization block, revert to fast case. |
| 2209 if (expr->ends_initialization_block()) { |
| 2210 __ pop(edx); |
| 2211 __ push(eax); // Result of assignment, saved even if not needed. |
| 2212 __ push(edx); |
| 2213 __ CallRuntime(Runtime::kToFastProperties, 1); |
| 2214 __ pop(eax); |
| 2215 } |
| 2216 |
2171 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); | 2217 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); |
2172 context()->Plug(eax); | 2218 context()->Plug(eax); |
2173 } | 2219 } |
2174 | 2220 |
2175 | 2221 |
2176 void FullCodeGenerator::VisitProperty(Property* expr) { | 2222 void FullCodeGenerator::VisitProperty(Property* expr) { |
2177 Comment cmnt(masm_, "[ Property"); | 2223 Comment cmnt(masm_, "[ Property"); |
2178 Expression* key = expr->key(); | 2224 Expression* key = expr->key(); |
2179 | 2225 |
2180 if (key->IsPropertyName()) { | 2226 if (key->IsPropertyName()) { |
(...skipping 2336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4517 *stack_depth = 0; | 4563 *stack_depth = 0; |
4518 *context_length = 0; | 4564 *context_length = 0; |
4519 return previous_; | 4565 return previous_; |
4520 } | 4566 } |
4521 | 4567 |
4522 #undef __ | 4568 #undef __ |
4523 | 4569 |
4524 } } // namespace v8::internal | 4570 } } // namespace v8::internal |
4525 | 4571 |
4526 #endif // V8_TARGET_ARCH_IA32 | 4572 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |