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 2196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2207 DCHECK(expr->target()->IsValidReferenceExpressionOrThis()); | 2207 DCHECK(expr->target()->IsValidReferenceExpressionOrThis()); |
2208 Register object, key; | 2208 Register object, key; |
2209 RegisterList super_property_args; | 2209 RegisterList super_property_args; |
2210 const AstRawString* name; | 2210 const AstRawString* name; |
2211 | 2211 |
2212 // Left-hand side can only be a property, a global or a variable slot. | 2212 // Left-hand side can only be a property, a global or a variable slot. |
2213 Property* property = expr->target()->AsProperty(); | 2213 Property* property = expr->target()->AsProperty(); |
2214 LhsKind assign_type = Property::GetAssignType(property); | 2214 LhsKind assign_type = Property::GetAssignType(property); |
2215 | 2215 |
2216 // Evaluate LHS expression. | 2216 // Evaluate LHS expression. |
2217 Register lhs_name; | |
Yang
2017/03/09 10:28:27
Do we have a plan to use a better way to identify
Franzi
2017/03/10 12:14:29
I'm only passing the name so that I can understand
| |
2218 if (expr->HasCollectTypeProfileSlot()) { | |
2219 lhs_name = register_allocator()->NewRegister(); | |
2220 } | |
2221 | |
2217 switch (assign_type) { | 2222 switch (assign_type) { |
2218 case VARIABLE: | 2223 case VARIABLE: |
2224 if (expr->HasCollectTypeProfileSlot()) { | |
2225 builder() | |
2226 ->LoadLiteral(expr->target()->AsVariableProxy()->var()->raw_name()) | |
2227 .StoreAccumulatorInRegister(lhs_name); | |
2228 } | |
2219 // Nothing to do to evaluate variable assignment LHS. | 2229 // Nothing to do to evaluate variable assignment LHS. |
2220 break; | 2230 break; |
2221 case NAMED_PROPERTY: { | 2231 case NAMED_PROPERTY: { |
2222 object = VisitForRegisterValue(property->obj()); | 2232 object = VisitForRegisterValue(property->obj()); |
2223 name = property->key()->AsLiteral()->AsRawPropertyName(); | 2233 name = property->key()->AsLiteral()->AsRawPropertyName(); |
2234 if (expr->HasCollectTypeProfileSlot()) { | |
2235 builder()->LoadLiteral(name).StoreAccumulatorInRegister(lhs_name); | |
2236 } | |
2224 break; | 2237 break; |
2225 } | 2238 } |
2226 case KEYED_PROPERTY: { | 2239 case KEYED_PROPERTY: { |
2227 object = VisitForRegisterValue(property->obj()); | 2240 object = VisitForRegisterValue(property->obj()); |
2228 key = VisitForRegisterValue(property->key()); | 2241 key = VisitForRegisterValue(property->key()); |
2242 if (expr->HasCollectTypeProfileSlot()) { | |
2243 builder()->StoreAccumulatorInRegister(lhs_name); | |
2244 } | |
2229 break; | 2245 break; |
2230 } | 2246 } |
2231 case NAMED_SUPER_PROPERTY: { | 2247 case NAMED_SUPER_PROPERTY: { |
2232 super_property_args = register_allocator()->NewRegisterList(4); | 2248 super_property_args = register_allocator()->NewRegisterList(4); |
2233 SuperPropertyReference* super_property = | 2249 SuperPropertyReference* super_property = |
2234 property->obj()->AsSuperPropertyReference(); | 2250 property->obj()->AsSuperPropertyReference(); |
2235 VisitForRegisterValue(super_property->this_var(), super_property_args[0]); | 2251 VisitForRegisterValue(super_property->this_var(), super_property_args[0]); |
2236 VisitForRegisterValue(super_property->home_object(), | 2252 VisitForRegisterValue(super_property->home_object(), |
2237 super_property_args[1]); | 2253 super_property_args[1]); |
2238 builder() | 2254 builder() |
2239 ->LoadLiteral(property->key()->AsLiteral()->AsRawPropertyName()) | 2255 ->LoadLiteral(property->key()->AsLiteral()->AsRawPropertyName()) |
2240 .StoreAccumulatorInRegister(super_property_args[2]); | 2256 .StoreAccumulatorInRegister(super_property_args[2]); |
2257 if (expr->HasCollectTypeProfileSlot()) { | |
2258 builder()->StoreAccumulatorInRegister(lhs_name); | |
2259 } | |
2241 break; | 2260 break; |
2242 } | 2261 } |
2243 case KEYED_SUPER_PROPERTY: { | 2262 case KEYED_SUPER_PROPERTY: { |
2244 super_property_args = register_allocator()->NewRegisterList(4); | 2263 super_property_args = register_allocator()->NewRegisterList(4); |
2245 SuperPropertyReference* super_property = | 2264 SuperPropertyReference* super_property = |
2246 property->obj()->AsSuperPropertyReference(); | 2265 property->obj()->AsSuperPropertyReference(); |
2247 VisitForRegisterValue(super_property->this_var(), super_property_args[0]); | 2266 VisitForRegisterValue(super_property->this_var(), super_property_args[0]); |
2248 VisitForRegisterValue(super_property->home_object(), | 2267 VisitForRegisterValue(super_property->home_object(), |
2249 super_property_args[1]); | 2268 super_property_args[1]); |
2250 VisitForRegisterValue(property->key(), super_property_args[2]); | 2269 VisitForRegisterValue(property->key(), super_property_args[2]); |
2270 if (expr->HasCollectTypeProfileSlot()) { | |
2271 builder()->StoreAccumulatorInRegister(lhs_name); | |
2272 } | |
2273 | |
2251 break; | 2274 break; |
2252 } | 2275 } |
2253 } | 2276 } |
2254 | 2277 |
2255 // Evaluate the value and potentially handle compound assignments by loading | 2278 // Evaluate the value and potentially handle compound assignments by loading |
2256 // the left-hand side value and performing a binary operation. | 2279 // the left-hand side value and performing a binary operation. |
2257 if (expr->is_compound()) { | 2280 if (expr->is_compound()) { |
2258 Register old_value = register_allocator()->NewRegister(); | 2281 Register old_value = register_allocator()->NewRegister(); |
2259 switch (assign_type) { | 2282 switch (assign_type) { |
2260 case VARIABLE: { | 2283 case VARIABLE: { |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2329 .CallRuntime(StoreToSuperRuntimeId(), super_property_args); | 2352 .CallRuntime(StoreToSuperRuntimeId(), super_property_args); |
2330 break; | 2353 break; |
2331 } | 2354 } |
2332 case KEYED_SUPER_PROPERTY: { | 2355 case KEYED_SUPER_PROPERTY: { |
2333 builder() | 2356 builder() |
2334 ->StoreAccumulatorInRegister(super_property_args[3]) | 2357 ->StoreAccumulatorInRegister(super_property_args[3]) |
2335 .CallRuntime(StoreKeyedToSuperRuntimeId(), super_property_args); | 2358 .CallRuntime(StoreKeyedToSuperRuntimeId(), super_property_args); |
2336 break; | 2359 break; |
2337 } | 2360 } |
2338 } | 2361 } |
2362 | |
2363 // Value is in accumulator. | |
2364 if (expr->HasCollectTypeProfileSlot()) { | |
2365 FeedbackSlot collect_type_feedback_slot = expr->CollectTypeProfileSlot(); | |
2366 | |
2367 builder()->CollectTypeProfile(lhs_name, | |
2368 feedback_index(collect_type_feedback_slot)); | |
2369 } | |
2339 } | 2370 } |
2340 | 2371 |
2341 void BytecodeGenerator::VisitYield(Yield* expr) { | 2372 void BytecodeGenerator::VisitYield(Yield* expr) { |
2342 builder()->SetExpressionPosition(expr); | 2373 builder()->SetExpressionPosition(expr); |
2343 Register value = VisitForRegisterValue(expr->expression()); | 2374 Register value = VisitForRegisterValue(expr->expression()); |
2344 | 2375 |
2345 Register generator = VisitForRegisterValue(expr->generator_object()); | 2376 Register generator = VisitForRegisterValue(expr->generator_object()); |
2346 | 2377 |
2347 // Save context, registers, and state. Then return. | 2378 // Save context, registers, and state. Then return. |
2348 builder() | 2379 builder() |
(...skipping 1122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3471 } | 3502 } |
3472 | 3503 |
3473 Runtime::FunctionId BytecodeGenerator::StoreKeyedToSuperRuntimeId() { | 3504 Runtime::FunctionId BytecodeGenerator::StoreKeyedToSuperRuntimeId() { |
3474 return is_strict(language_mode()) ? Runtime::kStoreKeyedToSuper_Strict | 3505 return is_strict(language_mode()) ? Runtime::kStoreKeyedToSuper_Strict |
3475 : Runtime::kStoreKeyedToSuper_Sloppy; | 3506 : Runtime::kStoreKeyedToSuper_Sloppy; |
3476 } | 3507 } |
3477 | 3508 |
3478 } // namespace interpreter | 3509 } // namespace interpreter |
3479 } // namespace internal | 3510 } // namespace internal |
3480 } // namespace v8 | 3511 } // namespace v8 |
OLD | NEW |