 Chromium Code Reviews
 Chromium Code Reviews Issue 2755973002:
  [type profile] Collect return types.  (Closed)
    
  
    Issue 2755973002:
  [type profile] Collect return types.  (Closed) 
  | 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 1073 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1084 execution_control()->Continue(stmt->target()); | 1084 execution_control()->Continue(stmt->target()); | 
| 1085 } | 1085 } | 
| 1086 | 1086 | 
| 1087 void BytecodeGenerator::VisitBreakStatement(BreakStatement* stmt) { | 1087 void BytecodeGenerator::VisitBreakStatement(BreakStatement* stmt) { | 
| 1088 builder()->SetStatementPosition(stmt); | 1088 builder()->SetStatementPosition(stmt); | 
| 1089 execution_control()->Break(stmt->target()); | 1089 execution_control()->Break(stmt->target()); | 
| 1090 } | 1090 } | 
| 1091 | 1091 | 
| 1092 void BytecodeGenerator::VisitReturnStatement(ReturnStatement* stmt) { | 1092 void BytecodeGenerator::VisitReturnStatement(ReturnStatement* stmt) { | 
| 1093 builder()->SetStatementPosition(stmt); | 1093 builder()->SetStatementPosition(stmt); | 
| 1094 | |
| 1095 Register position; | |
| 1096 Register name; | |
| 1097 if (stmt->HasTypeProfileSlot()) { | |
| 1098 position = register_allocator()->NewRegister(); | |
| 1099 | |
| 1100 builder() | |
| 1101 ->LoadLiteral(Smi::FromInt(stmt->position())) | |
| 1102 .StoreAccumulatorInRegister(position); | |
| 
rmcilroy
2017/03/20 10:02:46
Any reason you need to store position as a registe
 
Franzi
2017/03/20 15:38:39
Done. Using kImm because for the global(?) return
 | |
| 1103 | |
| 1104 name = register_allocator()->NewRegister(); | |
| 1105 | |
| 1106 if (stmt->expression()->IsVariableProxy()) { | |
| 1107 builder() | |
| 1108 ->LoadLiteral( | |
| 1109 stmt->expression()->AsVariableProxy()->var()->raw_name()) | |
| 1110 .StoreAccumulatorInRegister(name); | |
| 1111 } else { | |
| 1112 // Use a dummy string for now. | |
| 1113 builder() | |
| 1114 ->LoadLiteral(ast_string_constants()->return_string()) | |
| 1115 .StoreAccumulatorInRegister(name); | |
| 1116 } | |
| 
rmcilroy
2017/03/20 10:02:46
As I remember, the plan was to remove the need for
 
Franzi
2017/03/20 15:38:39
Done.
 | |
| 1117 } | |
| 1118 | |
| 1094 VisitForAccumulatorValue(stmt->expression()); | 1119 VisitForAccumulatorValue(stmt->expression()); | 
| 1095 | 1120 | 
| 1121 if (stmt->HasTypeProfileSlot()) { | |
| 1122 FeedbackSlot collect_type_feedback_slot = stmt->TypeProfileSlot(); | |
| 1123 builder()->CollectTypeProfile(position, name, | |
| 1124 feedback_index(collect_type_feedback_slot)); | |
| 1125 } | |
| 1126 | |
| 1096 if (stmt->is_async_return()) { | 1127 if (stmt->is_async_return()) { | 
| 1097 execution_control()->AsyncReturnAccumulator(); | 1128 execution_control()->AsyncReturnAccumulator(); | 
| 1098 } else { | 1129 } else { | 
| 1099 execution_control()->ReturnAccumulator(); | 1130 execution_control()->ReturnAccumulator(); | 
| 1100 } | 1131 } | 
| 1101 } | 1132 } | 
| 1102 | 1133 | 
| 1103 void BytecodeGenerator::VisitWithStatement(WithStatement* stmt) { | 1134 void BytecodeGenerator::VisitWithStatement(WithStatement* stmt) { | 
| 1104 builder()->SetStatementPosition(stmt); | 1135 builder()->SetStatementPosition(stmt); | 
| 1105 VisitForAccumulatorValue(stmt->expression()); | 1136 VisitForAccumulatorValue(stmt->expression()); | 
| (...skipping 1099 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2205 Register object, key; | 2236 Register object, key; | 
| 2206 RegisterList super_property_args; | 2237 RegisterList super_property_args; | 
| 2207 const AstRawString* name; | 2238 const AstRawString* name; | 
| 2208 | 2239 | 
| 2209 // Left-hand side can only be a property, a global or a variable slot. | 2240 // Left-hand side can only be a property, a global or a variable slot. | 
| 2210 Property* property = expr->target()->AsProperty(); | 2241 Property* property = expr->target()->AsProperty(); | 
| 2211 LhsKind assign_type = Property::GetAssignType(property); | 2242 LhsKind assign_type = Property::GetAssignType(property); | 
| 2212 | 2243 | 
| 2213 // Evaluate LHS expression. | 2244 // Evaluate LHS expression. | 
| 2214 Register lhs_name; | 2245 Register lhs_name; | 
| 2246 Register position; | |
| 2247 | |
| 2215 if (expr->HasTypeProfileSlot()) { | 2248 if (expr->HasTypeProfileSlot()) { | 
| 2216 lhs_name = register_allocator()->NewRegister(); | 2249 lhs_name = register_allocator()->NewRegister(); | 
| 2250 position = register_allocator()->NewRegister(); | |
| 2251 | |
| 2252 builder() | |
| 2253 ->LoadLiteral(Smi::FromInt(expr->position())) | |
| 2254 .StoreAccumulatorInRegister(position); | |
| 2217 } | 2255 } | 
| 2218 | 2256 | 
| 2219 switch (assign_type) { | 2257 switch (assign_type) { | 
| 2220 case VARIABLE: | 2258 case VARIABLE: | 
| 2221 if (expr->HasTypeProfileSlot()) { | 2259 if (expr->HasTypeProfileSlot()) { | 
| 2222 builder() | 2260 builder() | 
| 2223 ->LoadLiteral(expr->target()->AsVariableProxy()->var()->raw_name()) | 2261 ->LoadLiteral(expr->target()->AsVariableProxy()->var()->raw_name()) | 
| 2224 .StoreAccumulatorInRegister(lhs_name); | 2262 .StoreAccumulatorInRegister(lhs_name); | 
| 2225 } | 2263 } | 
| 2226 // Nothing to do to evaluate variable assignment LHS. | 2264 // Nothing to do to evaluate variable assignment LHS. | 
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2351 } | 2389 } | 
| 2352 case KEYED_SUPER_PROPERTY: { | 2390 case KEYED_SUPER_PROPERTY: { | 
| 2353 builder() | 2391 builder() | 
| 2354 ->StoreAccumulatorInRegister(super_property_args[3]) | 2392 ->StoreAccumulatorInRegister(super_property_args[3]) | 
| 2355 .CallRuntime(StoreKeyedToSuperRuntimeId(), super_property_args); | 2393 .CallRuntime(StoreKeyedToSuperRuntimeId(), super_property_args); | 
| 2356 break; | 2394 break; | 
| 2357 } | 2395 } | 
| 2358 } | 2396 } | 
| 2359 | 2397 | 
| 2360 // Value is in accumulator. | 2398 // Value is in accumulator. | 
| 2361 if (expr->HasTypeProfileSlot()) { | 2399 if (false && expr->HasTypeProfileSlot()) { | 
| 
Michael Starzinger
2017/03/20 09:29:26
nit: Looks like a left-over. If it is intentional
 
Franzi
2017/03/20 15:38:39
Done.
 | |
| 2362 FeedbackSlot collect_type_feedback_slot = expr->TypeProfileSlot(); | 2400 FeedbackSlot collect_type_feedback_slot = expr->TypeProfileSlot(); | 
| 2363 | 2401 | 
| 2364 builder()->CollectTypeProfile(lhs_name, | 2402 builder()->CollectTypeProfile(position, lhs_name, | 
| 2365 feedback_index(collect_type_feedback_slot)); | 2403 feedback_index(collect_type_feedback_slot)); | 
| 2366 } | 2404 } | 
| 2367 } | 2405 } | 
| 2368 | 2406 | 
| 2369 void BytecodeGenerator::VisitYield(Yield* expr) { | 2407 void BytecodeGenerator::VisitYield(Yield* expr) { | 
| 2370 builder()->SetExpressionPosition(expr); | 2408 builder()->SetExpressionPosition(expr); | 
| 2371 Register value = VisitForRegisterValue(expr->expression()); | 2409 Register value = VisitForRegisterValue(expr->expression()); | 
| 2372 | 2410 | 
| 2373 Register generator = VisitForRegisterValue(expr->generator_object()); | 2411 Register generator = VisitForRegisterValue(expr->generator_object()); | 
| 2374 | 2412 | 
| (...skipping 1144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3519 } | 3557 } | 
| 3520 | 3558 | 
| 3521 Runtime::FunctionId BytecodeGenerator::StoreKeyedToSuperRuntimeId() { | 3559 Runtime::FunctionId BytecodeGenerator::StoreKeyedToSuperRuntimeId() { | 
| 3522 return is_strict(language_mode()) ? Runtime::kStoreKeyedToSuper_Strict | 3560 return is_strict(language_mode()) ? Runtime::kStoreKeyedToSuper_Strict | 
| 3523 : Runtime::kStoreKeyedToSuper_Sloppy; | 3561 : Runtime::kStoreKeyedToSuper_Sloppy; | 
| 3524 } | 3562 } | 
| 3525 | 3563 | 
| 3526 } // namespace interpreter | 3564 } // namespace interpreter | 
| 3527 } // namespace internal | 3565 } // namespace internal | 
| 3528 } // namespace v8 | 3566 } // namespace v8 | 
| OLD | NEW |