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 2190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2201 // Non-initializing assignments to consts are ignored. | 2201 // Non-initializing assignments to consts are ignored. |
2202 } | 2202 } |
2203 | 2203 |
2204 | 2204 |
2205 void FullCodeGenerator::EmitNamedPropertyAssignment(Assignment* expr) { | 2205 void FullCodeGenerator::EmitNamedPropertyAssignment(Assignment* expr) { |
2206 // Assignment to a property, using a named store IC. | 2206 // Assignment to a property, using a named store IC. |
2207 Property* prop = expr->target()->AsProperty(); | 2207 Property* prop = expr->target()->AsProperty(); |
2208 ASSERT(prop != NULL); | 2208 ASSERT(prop != NULL); |
2209 ASSERT(prop->key()->AsLiteral() != NULL); | 2209 ASSERT(prop->key()->AsLiteral() != NULL); |
2210 | 2210 |
2211 // If the assignment starts a block of assignments to the same object, | |
2212 // change to slow case to avoid the quadratic behavior of repeatedly | |
2213 // adding fast properties. | |
2214 if (expr->starts_initialization_block()) { | |
2215 __ push(result_register()); | |
2216 __ lw(t0, MemOperand(sp, kPointerSize)); // Receiver is now under value. | |
2217 __ push(t0); | |
2218 __ CallRuntime(Runtime::kToSlowProperties, 1); | |
2219 __ pop(result_register()); | |
2220 } | |
2221 | |
2222 // Record source code position before IC call. | 2211 // Record source code position before IC call. |
2223 SetSourcePosition(expr->position()); | 2212 SetSourcePosition(expr->position()); |
2224 __ mov(a0, result_register()); // Load the value. | 2213 __ mov(a0, result_register()); // Load the value. |
2225 __ li(a2, Operand(prop->key()->AsLiteral()->handle())); | 2214 __ li(a2, Operand(prop->key()->AsLiteral()->handle())); |
2226 // Load receiver to a1. Leave a copy in the stack if needed for turning the | 2215 __ pop(a1); |
2227 // receiver into fast case. | |
2228 if (expr->ends_initialization_block()) { | |
2229 __ lw(a1, MemOperand(sp)); | |
2230 } else { | |
2231 __ pop(a1); | |
2232 } | |
2233 | 2216 |
2234 Handle<Code> ic = is_classic_mode() | 2217 Handle<Code> ic = is_classic_mode() |
2235 ? isolate()->builtins()->StoreIC_Initialize() | 2218 ? isolate()->builtins()->StoreIC_Initialize() |
2236 : isolate()->builtins()->StoreIC_Initialize_Strict(); | 2219 : isolate()->builtins()->StoreIC_Initialize_Strict(); |
2237 CallIC(ic, RelocInfo::CODE_TARGET, expr->AssignmentFeedbackId()); | 2220 CallIC(ic, RelocInfo::CODE_TARGET, expr->AssignmentFeedbackId()); |
2238 | 2221 |
2239 // If the assignment ends an initialization block, revert to fast case. | |
2240 if (expr->ends_initialization_block()) { | |
2241 __ push(v0); // Result of assignment, saved even if not needed. | |
2242 // Receiver is under the result value. | |
2243 __ lw(t0, MemOperand(sp, kPointerSize)); | |
2244 __ push(t0); | |
2245 __ CallRuntime(Runtime::kToFastProperties, 1); | |
2246 __ pop(v0); | |
2247 __ Drop(1); | |
2248 } | |
2249 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); | 2222 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); |
2250 context()->Plug(v0); | 2223 context()->Plug(v0); |
2251 } | 2224 } |
2252 | 2225 |
2253 | 2226 |
2254 void FullCodeGenerator::EmitKeyedPropertyAssignment(Assignment* expr) { | 2227 void FullCodeGenerator::EmitKeyedPropertyAssignment(Assignment* expr) { |
2255 // Assignment to a property, using a keyed store IC. | 2228 // Assignment to a property, using a keyed store IC. |
2256 | 2229 |
2257 // If the assignment starts a block of assignments to the same object, | |
2258 // change to slow case to avoid the quadratic behavior of repeatedly | |
2259 // adding fast properties. | |
2260 if (expr->starts_initialization_block()) { | |
2261 __ push(result_register()); | |
2262 // Receiver is now under the key and value. | |
2263 __ lw(t0, MemOperand(sp, 2 * kPointerSize)); | |
2264 __ push(t0); | |
2265 __ CallRuntime(Runtime::kToSlowProperties, 1); | |
2266 __ pop(result_register()); | |
2267 } | |
2268 | |
2269 // Record source code position before IC call. | 2230 // Record source code position before IC call. |
2270 SetSourcePosition(expr->position()); | 2231 SetSourcePosition(expr->position()); |
2271 // Call keyed store IC. | 2232 // Call keyed store IC. |
2272 // The arguments are: | 2233 // The arguments are: |
2273 // - a0 is the value, | 2234 // - a0 is the value, |
2274 // - a1 is the key, | 2235 // - a1 is the key, |
2275 // - a2 is the receiver. | 2236 // - a2 is the receiver. |
2276 __ mov(a0, result_register()); | 2237 __ mov(a0, result_register()); |
2277 __ pop(a1); // Key. | 2238 __ pop(a1); // Key. |
2278 // Load receiver to a2. Leave a copy in the stack if needed for turning the | 2239 __ pop(a2); |
2279 // receiver into fast case. | |
2280 if (expr->ends_initialization_block()) { | |
2281 __ lw(a2, MemOperand(sp)); | |
2282 } else { | |
2283 __ pop(a2); | |
2284 } | |
2285 | 2240 |
2286 Handle<Code> ic = is_classic_mode() | 2241 Handle<Code> ic = is_classic_mode() |
2287 ? isolate()->builtins()->KeyedStoreIC_Initialize() | 2242 ? isolate()->builtins()->KeyedStoreIC_Initialize() |
2288 : isolate()->builtins()->KeyedStoreIC_Initialize_Strict(); | 2243 : isolate()->builtins()->KeyedStoreIC_Initialize_Strict(); |
2289 CallIC(ic, RelocInfo::CODE_TARGET, expr->AssignmentFeedbackId()); | 2244 CallIC(ic, RelocInfo::CODE_TARGET, expr->AssignmentFeedbackId()); |
2290 | 2245 |
2291 // If the assignment ends an initialization block, revert to fast case. | |
2292 if (expr->ends_initialization_block()) { | |
2293 __ push(v0); // Result of assignment, saved even if not needed. | |
2294 // Receiver is under the result value. | |
2295 __ lw(t0, MemOperand(sp, kPointerSize)); | |
2296 __ push(t0); | |
2297 __ CallRuntime(Runtime::kToFastProperties, 1); | |
2298 __ pop(v0); | |
2299 __ Drop(1); | |
2300 } | |
2301 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); | 2246 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); |
2302 context()->Plug(v0); | 2247 context()->Plug(v0); |
2303 } | 2248 } |
2304 | 2249 |
2305 | 2250 |
2306 void FullCodeGenerator::VisitProperty(Property* expr) { | 2251 void FullCodeGenerator::VisitProperty(Property* expr) { |
2307 Comment cmnt(masm_, "[ Property"); | 2252 Comment cmnt(masm_, "[ Property"); |
2308 Expression* key = expr->key(); | 2253 Expression* key = expr->key(); |
2309 | 2254 |
2310 if (key->IsPropertyName()) { | 2255 if (key->IsPropertyName()) { |
(...skipping 2307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4618 *context_length = 0; | 4563 *context_length = 0; |
4619 return previous_; | 4564 return previous_; |
4620 } | 4565 } |
4621 | 4566 |
4622 | 4567 |
4623 #undef __ | 4568 #undef __ |
4624 | 4569 |
4625 } } // namespace v8::internal | 4570 } } // namespace v8::internal |
4626 | 4571 |
4627 #endif // V8_TARGET_ARCH_MIPS | 4572 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |