| 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/compile-time-value.h" | 7 #include "src/ast/compile-time-value.h" |
| 8 #include "src/ast/scopes.h" | 8 #include "src/ast/scopes.h" |
| 9 #include "src/builtins/builtins-constructor.h" | 9 #include "src/builtins/builtins-constructor.h" |
| 10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
| (...skipping 2193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2204 DCHECK(expr->target()->IsValidReferenceExpressionOrThis()); | 2204 DCHECK(expr->target()->IsValidReferenceExpressionOrThis()); |
| 2205 Register object, key; | 2205 Register object, key; |
| 2206 RegisterList super_property_args; | 2206 RegisterList super_property_args; |
| 2207 const AstRawString* name; | 2207 const AstRawString* name; |
| 2208 | 2208 |
| 2209 // Left-hand side can only be a property, a global or a variable slot. | 2209 // Left-hand side can only be a property, a global or a variable slot. |
| 2210 Property* property = expr->target()->AsProperty(); | 2210 Property* property = expr->target()->AsProperty(); |
| 2211 LhsKind assign_type = Property::GetAssignType(property); | 2211 LhsKind assign_type = Property::GetAssignType(property); |
| 2212 | 2212 |
| 2213 // Evaluate LHS expression. | 2213 // Evaluate LHS expression. |
| 2214 Register lhs_name; |
| 2215 if (expr->HasTypeProfileSlot()) { |
| 2216 lhs_name = register_allocator()->NewRegister(); |
| 2217 } |
| 2218 |
| 2214 switch (assign_type) { | 2219 switch (assign_type) { |
| 2215 case VARIABLE: | 2220 case VARIABLE: |
| 2221 if (expr->HasTypeProfileSlot()) { |
| 2222 builder() |
| 2223 ->LoadLiteral(expr->target()->AsVariableProxy()->var()->raw_name()) |
| 2224 .StoreAccumulatorInRegister(lhs_name); |
| 2225 } |
| 2216 // Nothing to do to evaluate variable assignment LHS. | 2226 // Nothing to do to evaluate variable assignment LHS. |
| 2217 break; | 2227 break; |
| 2218 case NAMED_PROPERTY: { | 2228 case NAMED_PROPERTY: { |
| 2219 object = VisitForRegisterValue(property->obj()); | 2229 object = VisitForRegisterValue(property->obj()); |
| 2220 name = property->key()->AsLiteral()->AsRawPropertyName(); | 2230 name = property->key()->AsLiteral()->AsRawPropertyName(); |
| 2231 if (expr->HasTypeProfileSlot()) { |
| 2232 builder()->LoadLiteral(name).StoreAccumulatorInRegister(lhs_name); |
| 2233 } |
| 2221 break; | 2234 break; |
| 2222 } | 2235 } |
| 2223 case KEYED_PROPERTY: { | 2236 case KEYED_PROPERTY: { |
| 2224 object = VisitForRegisterValue(property->obj()); | 2237 object = VisitForRegisterValue(property->obj()); |
| 2225 key = VisitForRegisterValue(property->key()); | 2238 key = VisitForRegisterValue(property->key()); |
| 2239 if (expr->HasTypeProfileSlot()) { |
| 2240 builder()->StoreAccumulatorInRegister(lhs_name); |
| 2241 } |
| 2226 break; | 2242 break; |
| 2227 } | 2243 } |
| 2228 case NAMED_SUPER_PROPERTY: { | 2244 case NAMED_SUPER_PROPERTY: { |
| 2229 super_property_args = register_allocator()->NewRegisterList(4); | 2245 super_property_args = register_allocator()->NewRegisterList(4); |
| 2230 SuperPropertyReference* super_property = | 2246 SuperPropertyReference* super_property = |
| 2231 property->obj()->AsSuperPropertyReference(); | 2247 property->obj()->AsSuperPropertyReference(); |
| 2232 VisitForRegisterValue(super_property->this_var(), super_property_args[0]); | 2248 VisitForRegisterValue(super_property->this_var(), super_property_args[0]); |
| 2233 VisitForRegisterValue(super_property->home_object(), | 2249 VisitForRegisterValue(super_property->home_object(), |
| 2234 super_property_args[1]); | 2250 super_property_args[1]); |
| 2235 builder() | 2251 builder() |
| 2236 ->LoadLiteral(property->key()->AsLiteral()->AsRawPropertyName()) | 2252 ->LoadLiteral(property->key()->AsLiteral()->AsRawPropertyName()) |
| 2237 .StoreAccumulatorInRegister(super_property_args[2]); | 2253 .StoreAccumulatorInRegister(super_property_args[2]); |
| 2254 if (expr->HasTypeProfileSlot()) { |
| 2255 builder()->StoreAccumulatorInRegister(lhs_name); |
| 2256 } |
| 2238 break; | 2257 break; |
| 2239 } | 2258 } |
| 2240 case KEYED_SUPER_PROPERTY: { | 2259 case KEYED_SUPER_PROPERTY: { |
| 2241 super_property_args = register_allocator()->NewRegisterList(4); | 2260 super_property_args = register_allocator()->NewRegisterList(4); |
| 2242 SuperPropertyReference* super_property = | 2261 SuperPropertyReference* super_property = |
| 2243 property->obj()->AsSuperPropertyReference(); | 2262 property->obj()->AsSuperPropertyReference(); |
| 2244 VisitForRegisterValue(super_property->this_var(), super_property_args[0]); | 2263 VisitForRegisterValue(super_property->this_var(), super_property_args[0]); |
| 2245 VisitForRegisterValue(super_property->home_object(), | 2264 VisitForRegisterValue(super_property->home_object(), |
| 2246 super_property_args[1]); | 2265 super_property_args[1]); |
| 2247 VisitForRegisterValue(property->key(), super_property_args[2]); | 2266 VisitForRegisterValue(property->key(), super_property_args[2]); |
| 2267 if (expr->HasTypeProfileSlot()) { |
| 2268 builder()->StoreAccumulatorInRegister(lhs_name); |
| 2269 } |
| 2270 |
| 2248 break; | 2271 break; |
| 2249 } | 2272 } |
| 2250 } | 2273 } |
| 2251 | 2274 |
| 2252 // Evaluate the value and potentially handle compound assignments by loading | 2275 // Evaluate the value and potentially handle compound assignments by loading |
| 2253 // the left-hand side value and performing a binary operation. | 2276 // the left-hand side value and performing a binary operation. |
| 2254 if (expr->is_compound()) { | 2277 if (expr->is_compound()) { |
| 2255 Register old_value = register_allocator()->NewRegister(); | 2278 Register old_value = register_allocator()->NewRegister(); |
| 2256 switch (assign_type) { | 2279 switch (assign_type) { |
| 2257 case VARIABLE: { | 2280 case VARIABLE: { |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2326 .CallRuntime(StoreToSuperRuntimeId(), super_property_args); | 2349 .CallRuntime(StoreToSuperRuntimeId(), super_property_args); |
| 2327 break; | 2350 break; |
| 2328 } | 2351 } |
| 2329 case KEYED_SUPER_PROPERTY: { | 2352 case KEYED_SUPER_PROPERTY: { |
| 2330 builder() | 2353 builder() |
| 2331 ->StoreAccumulatorInRegister(super_property_args[3]) | 2354 ->StoreAccumulatorInRegister(super_property_args[3]) |
| 2332 .CallRuntime(StoreKeyedToSuperRuntimeId(), super_property_args); | 2355 .CallRuntime(StoreKeyedToSuperRuntimeId(), super_property_args); |
| 2333 break; | 2356 break; |
| 2334 } | 2357 } |
| 2335 } | 2358 } |
| 2359 |
| 2360 // Value is in accumulator. |
| 2361 if (expr->HasTypeProfileSlot()) { |
| 2362 FeedbackSlot collect_type_feedback_slot = expr->TypeProfileSlot(); |
| 2363 |
| 2364 builder()->CollectTypeProfile(lhs_name, |
| 2365 feedback_index(collect_type_feedback_slot)); |
| 2366 } |
| 2336 } | 2367 } |
| 2337 | 2368 |
| 2338 void BytecodeGenerator::VisitYield(Yield* expr) { | 2369 void BytecodeGenerator::VisitYield(Yield* expr) { |
| 2339 builder()->SetExpressionPosition(expr); | 2370 builder()->SetExpressionPosition(expr); |
| 2340 Register value = VisitForRegisterValue(expr->expression()); | 2371 Register value = VisitForRegisterValue(expr->expression()); |
| 2341 | 2372 |
| 2342 Register generator = VisitForRegisterValue(expr->generator_object()); | 2373 Register generator = VisitForRegisterValue(expr->generator_object()); |
| 2343 | 2374 |
| 2344 // Save context, registers, and state. Then return. | 2375 // Save context, registers, and state. Then return. |
| 2345 builder() | 2376 builder() |
| (...skipping 1142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3488 } | 3519 } |
| 3489 | 3520 |
| 3490 Runtime::FunctionId BytecodeGenerator::StoreKeyedToSuperRuntimeId() { | 3521 Runtime::FunctionId BytecodeGenerator::StoreKeyedToSuperRuntimeId() { |
| 3491 return is_strict(language_mode()) ? Runtime::kStoreKeyedToSuper_Strict | 3522 return is_strict(language_mode()) ? Runtime::kStoreKeyedToSuper_Strict |
| 3492 : Runtime::kStoreKeyedToSuper_Sloppy; | 3523 : Runtime::kStoreKeyedToSuper_Sloppy; |
| 3493 } | 3524 } |
| 3494 | 3525 |
| 3495 } // namespace interpreter | 3526 } // namespace interpreter |
| 3496 } // namespace internal | 3527 } // namespace internal |
| 3497 } // namespace v8 | 3528 } // namespace v8 |
| OLD | NEW |