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 880 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
891 case VariableLocation::LOOKUP: { | 891 case VariableLocation::LOOKUP: { |
892 DCHECK_EQ(VAR, variable->mode()); | 892 DCHECK_EQ(VAR, variable->mode()); |
893 DCHECK(!variable->binding_needs_init()); | 893 DCHECK(!variable->binding_needs_init()); |
894 | 894 |
895 Register name = register_allocator()->NewRegister(); | 895 Register name = register_allocator()->NewRegister(); |
896 | 896 |
897 builder() | 897 builder() |
898 ->LoadLiteral(variable->raw_name()) | 898 ->LoadLiteral(variable->raw_name()) |
899 .StoreAccumulatorInRegister(name) | 899 .StoreAccumulatorInRegister(name) |
900 .CallRuntime(Runtime::kDeclareEvalVar, name); | 900 .CallRuntime(Runtime::kDeclareEvalVar, name); |
| 901 |
901 break; | 902 break; |
902 } | 903 } |
903 case VariableLocation::MODULE: | 904 case VariableLocation::MODULE: |
904 if (variable->IsExport() && variable->binding_needs_init()) { | 905 if (variable->IsExport() && variable->binding_needs_init()) { |
905 builder()->LoadTheHole(); | 906 builder()->LoadTheHole(); |
906 BuildVariableAssignment(variable, Token::INIT, FeedbackSlot::Invalid(), | 907 BuildVariableAssignment(variable, Token::INIT, FeedbackSlot::Invalid(), |
907 HoleCheckMode::kElided); | 908 HoleCheckMode::kElided); |
908 } | 909 } |
909 // Nothing to do for imports. | 910 // Nothing to do for imports. |
910 break; | 911 break; |
(...skipping 1272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2183 DCHECK(expr->target()->IsValidReferenceExpressionOrThis()); | 2184 DCHECK(expr->target()->IsValidReferenceExpressionOrThis()); |
2184 Register object, key; | 2185 Register object, key; |
2185 RegisterList super_property_args; | 2186 RegisterList super_property_args; |
2186 const AstRawString* name; | 2187 const AstRawString* name; |
2187 | 2188 |
2188 // Left-hand side can only be a property, a global or a variable slot. | 2189 // Left-hand side can only be a property, a global or a variable slot. |
2189 Property* property = expr->target()->AsProperty(); | 2190 Property* property = expr->target()->AsProperty(); |
2190 LhsKind assign_type = Property::GetAssignType(property); | 2191 LhsKind assign_type = Property::GetAssignType(property); |
2191 | 2192 |
2192 // Evaluate LHS expression. | 2193 // Evaluate LHS expression. |
| 2194 Register lhs_name = register_allocator()->NewRegister(); |
| 2195 |
2193 switch (assign_type) { | 2196 switch (assign_type) { |
2194 case VARIABLE: | 2197 case VARIABLE: |
| 2198 if (true || FLAG_type_profile) { |
| 2199 builder() |
| 2200 ->LoadLiteral(expr->target()->AsVariableProxy()->var()->raw_name()) |
| 2201 .StoreAccumulatorInRegister(lhs_name); |
| 2202 } |
2195 // Nothing to do to evaluate variable assignment LHS. | 2203 // Nothing to do to evaluate variable assignment LHS. |
2196 break; | 2204 break; |
2197 case NAMED_PROPERTY: { | 2205 case NAMED_PROPERTY: { |
2198 object = VisitForRegisterValue(property->obj()); | 2206 object = VisitForRegisterValue(property->obj()); |
2199 name = property->key()->AsLiteral()->AsRawPropertyName(); | 2207 name = property->key()->AsLiteral()->AsRawPropertyName(); |
| 2208 if (true || FLAG_type_profile) { |
| 2209 builder()->LoadLiteral(name).StoreAccumulatorInRegister(lhs_name); |
| 2210 } |
2200 break; | 2211 break; |
2201 } | 2212 } |
2202 case KEYED_PROPERTY: { | 2213 case KEYED_PROPERTY: { |
2203 object = VisitForRegisterValue(property->obj()); | 2214 object = VisitForRegisterValue(property->obj()); |
2204 key = VisitForRegisterValue(property->key()); | 2215 key = VisitForRegisterValue(property->key()); |
| 2216 if (true || FLAG_type_profile) { |
| 2217 builder()->StoreAccumulatorInRegister(lhs_name); |
| 2218 } |
2205 break; | 2219 break; |
2206 } | 2220 } |
2207 case NAMED_SUPER_PROPERTY: { | 2221 case NAMED_SUPER_PROPERTY: { |
2208 super_property_args = register_allocator()->NewRegisterList(4); | 2222 super_property_args = register_allocator()->NewRegisterList(4); |
2209 SuperPropertyReference* super_property = | 2223 SuperPropertyReference* super_property = |
2210 property->obj()->AsSuperPropertyReference(); | 2224 property->obj()->AsSuperPropertyReference(); |
2211 VisitForRegisterValue(super_property->this_var(), super_property_args[0]); | 2225 VisitForRegisterValue(super_property->this_var(), super_property_args[0]); |
2212 VisitForRegisterValue(super_property->home_object(), | 2226 VisitForRegisterValue(super_property->home_object(), |
2213 super_property_args[1]); | 2227 super_property_args[1]); |
2214 builder() | 2228 builder() |
2215 ->LoadLiteral(property->key()->AsLiteral()->AsRawPropertyName()) | 2229 ->LoadLiteral(property->key()->AsLiteral()->AsRawPropertyName()) |
2216 .StoreAccumulatorInRegister(super_property_args[2]); | 2230 .StoreAccumulatorInRegister(super_property_args[2]); |
| 2231 if (true || FLAG_type_profile) { |
| 2232 builder()->StoreAccumulatorInRegister(lhs_name); |
| 2233 } |
2217 break; | 2234 break; |
2218 } | 2235 } |
2219 case KEYED_SUPER_PROPERTY: { | 2236 case KEYED_SUPER_PROPERTY: { |
2220 super_property_args = register_allocator()->NewRegisterList(4); | 2237 super_property_args = register_allocator()->NewRegisterList(4); |
2221 SuperPropertyReference* super_property = | 2238 SuperPropertyReference* super_property = |
2222 property->obj()->AsSuperPropertyReference(); | 2239 property->obj()->AsSuperPropertyReference(); |
2223 VisitForRegisterValue(super_property->this_var(), super_property_args[0]); | 2240 VisitForRegisterValue(super_property->this_var(), super_property_args[0]); |
2224 VisitForRegisterValue(super_property->home_object(), | 2241 VisitForRegisterValue(super_property->home_object(), |
2225 super_property_args[1]); | 2242 super_property_args[1]); |
2226 VisitForRegisterValue(property->key(), super_property_args[2]); | 2243 VisitForRegisterValue(property->key(), super_property_args[2]); |
| 2244 if (true || FLAG_type_profile) { |
| 2245 builder()->StoreAccumulatorInRegister(lhs_name); |
| 2246 } |
| 2247 |
2227 break; | 2248 break; |
2228 } | 2249 } |
2229 } | 2250 } |
2230 | 2251 |
2231 // Evaluate the value and potentially handle compound assignments by loading | 2252 // Evaluate the value and potentially handle compound assignments by loading |
2232 // the left-hand side value and performing a binary operation. | 2253 // the left-hand side value and performing a binary operation. |
2233 if (expr->is_compound()) { | 2254 if (expr->is_compound()) { |
2234 Register old_value = register_allocator()->NewRegister(); | 2255 Register old_value = register_allocator()->NewRegister(); |
2235 switch (assign_type) { | 2256 switch (assign_type) { |
2236 case VARIABLE: { | 2257 case VARIABLE: { |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2305 .CallRuntime(StoreToSuperRuntimeId(), super_property_args); | 2326 .CallRuntime(StoreToSuperRuntimeId(), super_property_args); |
2306 break; | 2327 break; |
2307 } | 2328 } |
2308 case KEYED_SUPER_PROPERTY: { | 2329 case KEYED_SUPER_PROPERTY: { |
2309 builder() | 2330 builder() |
2310 ->StoreAccumulatorInRegister(super_property_args[3]) | 2331 ->StoreAccumulatorInRegister(super_property_args[3]) |
2311 .CallRuntime(StoreKeyedToSuperRuntimeId(), super_property_args); | 2332 .CallRuntime(StoreKeyedToSuperRuntimeId(), super_property_args); |
2312 break; | 2333 break; |
2313 } | 2334 } |
2314 } | 2335 } |
| 2336 |
| 2337 // Value is in accumulator. |
| 2338 if (FLAG_type_profile) { |
| 2339 Register value = register_allocator()->NewRegister(); |
| 2340 builder()->StoreAccumulatorInRegister(value); |
| 2341 |
| 2342 FeedbackSlot collect_type_feedback_slot = expr->CollectTypeProfileSlot(); |
| 2343 |
| 2344 builder()->CollectTypeProfile(lhs_name, value, |
| 2345 feedback_index(collect_type_feedback_slot)); |
| 2346 } |
2315 } | 2347 } |
2316 | 2348 |
2317 void BytecodeGenerator::VisitYield(Yield* expr) { | 2349 void BytecodeGenerator::VisitYield(Yield* expr) { |
2318 builder()->SetExpressionPosition(expr); | 2350 builder()->SetExpressionPosition(expr); |
2319 Register value = VisitForRegisterValue(expr->expression()); | 2351 Register value = VisitForRegisterValue(expr->expression()); |
2320 | 2352 |
2321 Register generator = VisitForRegisterValue(expr->generator_object()); | 2353 Register generator = VisitForRegisterValue(expr->generator_object()); |
2322 | 2354 |
2323 // Save context, registers, and state. Then return. | 2355 // Save context, registers, and state. Then return. |
2324 builder() | 2356 builder() |
(...skipping 1124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3449 } | 3481 } |
3450 | 3482 |
3451 Runtime::FunctionId BytecodeGenerator::StoreKeyedToSuperRuntimeId() { | 3483 Runtime::FunctionId BytecodeGenerator::StoreKeyedToSuperRuntimeId() { |
3452 return is_strict(language_mode()) ? Runtime::kStoreKeyedToSuper_Strict | 3484 return is_strict(language_mode()) ? Runtime::kStoreKeyedToSuper_Strict |
3453 : Runtime::kStoreKeyedToSuper_Sloppy; | 3485 : Runtime::kStoreKeyedToSuper_Sloppy; |
3454 } | 3486 } |
3455 | 3487 |
3456 } // namespace interpreter | 3488 } // namespace interpreter |
3457 } // namespace internal | 3489 } // namespace internal |
3458 } // namespace v8 | 3490 } // namespace v8 |
OLD | NEW |