Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(72)

Side by Side Diff: src/interpreter/bytecode-generator.cc

Issue 2707873002: Collect type profile for DevTools. (Closed)
Patch Set: Use constructor name if available. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 903 matching lines...) Expand 10 before | Expand all | Expand 10 after
914 case VariableLocation::LOOKUP: { 914 case VariableLocation::LOOKUP: {
915 DCHECK_EQ(VAR, variable->mode()); 915 DCHECK_EQ(VAR, variable->mode());
916 DCHECK(!variable->binding_needs_init()); 916 DCHECK(!variable->binding_needs_init());
917 917
918 Register name = register_allocator()->NewRegister(); 918 Register name = register_allocator()->NewRegister();
919 919
920 builder() 920 builder()
921 ->LoadLiteral(variable->raw_name()) 921 ->LoadLiteral(variable->raw_name())
922 .StoreAccumulatorInRegister(name) 922 .StoreAccumulatorInRegister(name)
923 .CallRuntime(Runtime::kDeclareEvalVar, name); 923 .CallRuntime(Runtime::kDeclareEvalVar, name);
924
924 break; 925 break;
925 } 926 }
926 case VariableLocation::MODULE: 927 case VariableLocation::MODULE:
927 if (variable->IsExport() && variable->binding_needs_init()) { 928 if (variable->IsExport() && variable->binding_needs_init()) {
928 builder()->LoadTheHole(); 929 builder()->LoadTheHole();
929 BuildVariableAssignment(variable, Token::INIT, FeedbackSlot::Invalid(), 930 BuildVariableAssignment(variable, Token::INIT, FeedbackSlot::Invalid(),
930 HoleCheckMode::kElided); 931 HoleCheckMode::kElided);
931 } 932 }
932 // Nothing to do for imports. 933 // Nothing to do for imports.
933 break; 934 break;
(...skipping 1273 matching lines...) Expand 10 before | Expand all | Expand 10 after
2207 DCHECK(expr->target()->IsValidReferenceExpressionOrThis()); 2208 DCHECK(expr->target()->IsValidReferenceExpressionOrThis());
2208 Register object, key; 2209 Register object, key;
2209 RegisterList super_property_args; 2210 RegisterList super_property_args;
2210 const AstRawString* name; 2211 const AstRawString* name;
2211 2212
2212 // Left-hand side can only be a property, a global or a variable slot. 2213 // Left-hand side can only be a property, a global or a variable slot.
2213 Property* property = expr->target()->AsProperty(); 2214 Property* property = expr->target()->AsProperty();
2214 LhsKind assign_type = Property::GetAssignType(property); 2215 LhsKind assign_type = Property::GetAssignType(property);
2215 2216
2216 // Evaluate LHS expression. 2217 // Evaluate LHS expression.
2218 Register lhs_name = register_allocator()->NewRegister();
2219
2217 switch (assign_type) { 2220 switch (assign_type) {
2218 case VARIABLE: 2221 case VARIABLE:
2222 if (FLAG_type_profile) {
Yang 2017/02/22 10:39:28 The issue with this flag and snapshot is: if the f
2223 builder()
2224 ->LoadLiteral(expr->target()->AsVariableProxy()->var()->raw_name())
2225 .StoreAccumulatorInRegister(lhs_name);
2226 }
2219 // Nothing to do to evaluate variable assignment LHS. 2227 // Nothing to do to evaluate variable assignment LHS.
2220 break; 2228 break;
2221 case NAMED_PROPERTY: { 2229 case NAMED_PROPERTY: {
2222 object = VisitForRegisterValue(property->obj()); 2230 object = VisitForRegisterValue(property->obj());
2223 name = property->key()->AsLiteral()->AsRawPropertyName(); 2231 name = property->key()->AsLiteral()->AsRawPropertyName();
2232 if (FLAG_type_profile) {
2233 builder()->LoadLiteral(name).StoreAccumulatorInRegister(lhs_name);
2234 }
2224 break; 2235 break;
2225 } 2236 }
2226 case KEYED_PROPERTY: { 2237 case KEYED_PROPERTY: {
2227 object = VisitForRegisterValue(property->obj()); 2238 object = VisitForRegisterValue(property->obj());
2228 key = VisitForRegisterValue(property->key()); 2239 key = VisitForRegisterValue(property->key());
2240 if (FLAG_type_profile) {
2241 builder()->StoreAccumulatorInRegister(lhs_name);
2242 }
2229 break; 2243 break;
2230 } 2244 }
2231 case NAMED_SUPER_PROPERTY: { 2245 case NAMED_SUPER_PROPERTY: {
2232 super_property_args = register_allocator()->NewRegisterList(4); 2246 super_property_args = register_allocator()->NewRegisterList(4);
2233 SuperPropertyReference* super_property = 2247 SuperPropertyReference* super_property =
2234 property->obj()->AsSuperPropertyReference(); 2248 property->obj()->AsSuperPropertyReference();
2235 VisitForRegisterValue(super_property->this_var(), super_property_args[0]); 2249 VisitForRegisterValue(super_property->this_var(), super_property_args[0]);
2236 VisitForRegisterValue(super_property->home_object(), 2250 VisitForRegisterValue(super_property->home_object(),
2237 super_property_args[1]); 2251 super_property_args[1]);
2238 builder() 2252 builder()
2239 ->LoadLiteral(property->key()->AsLiteral()->AsRawPropertyName()) 2253 ->LoadLiteral(property->key()->AsLiteral()->AsRawPropertyName())
2240 .StoreAccumulatorInRegister(super_property_args[2]); 2254 .StoreAccumulatorInRegister(super_property_args[2]);
2255 if (FLAG_type_profile) {
2256 builder()->StoreAccumulatorInRegister(lhs_name);
2257 }
2241 break; 2258 break;
2242 } 2259 }
2243 case KEYED_SUPER_PROPERTY: { 2260 case KEYED_SUPER_PROPERTY: {
2244 super_property_args = register_allocator()->NewRegisterList(4); 2261 super_property_args = register_allocator()->NewRegisterList(4);
2245 SuperPropertyReference* super_property = 2262 SuperPropertyReference* super_property =
2246 property->obj()->AsSuperPropertyReference(); 2263 property->obj()->AsSuperPropertyReference();
2247 VisitForRegisterValue(super_property->this_var(), super_property_args[0]); 2264 VisitForRegisterValue(super_property->this_var(), super_property_args[0]);
2248 VisitForRegisterValue(super_property->home_object(), 2265 VisitForRegisterValue(super_property->home_object(),
2249 super_property_args[1]); 2266 super_property_args[1]);
2250 VisitForRegisterValue(property->key(), super_property_args[2]); 2267 VisitForRegisterValue(property->key(), super_property_args[2]);
2268 if (FLAG_type_profile) {
2269 builder()->StoreAccumulatorInRegister(lhs_name);
2270 }
2271
2251 break; 2272 break;
2252 } 2273 }
2253 } 2274 }
2254 2275
2255 // Evaluate the value and potentially handle compound assignments by loading 2276 // Evaluate the value and potentially handle compound assignments by loading
2256 // the left-hand side value and performing a binary operation. 2277 // the left-hand side value and performing a binary operation.
2257 if (expr->is_compound()) { 2278 if (expr->is_compound()) {
2258 Register old_value = register_allocator()->NewRegister(); 2279 Register old_value = register_allocator()->NewRegister();
2259 switch (assign_type) { 2280 switch (assign_type) {
2260 case VARIABLE: { 2281 case VARIABLE: {
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
2329 .CallRuntime(StoreToSuperRuntimeId(), super_property_args); 2350 .CallRuntime(StoreToSuperRuntimeId(), super_property_args);
2330 break; 2351 break;
2331 } 2352 }
2332 case KEYED_SUPER_PROPERTY: { 2353 case KEYED_SUPER_PROPERTY: {
2333 builder() 2354 builder()
2334 ->StoreAccumulatorInRegister(super_property_args[3]) 2355 ->StoreAccumulatorInRegister(super_property_args[3])
2335 .CallRuntime(StoreKeyedToSuperRuntimeId(), super_property_args); 2356 .CallRuntime(StoreKeyedToSuperRuntimeId(), super_property_args);
2336 break; 2357 break;
2337 } 2358 }
2338 } 2359 }
2360
2361 // Value is in accumulator.
2362 if (FLAG_type_profile) {
2363 Register value = register_allocator()->NewRegister();
2364 builder()->StoreAccumulatorInRegister(value);
2365
2366 FeedbackSlot collect_type_feedback_slot = expr->CollectTypeProfileSlot();
2367
2368 builder()->CollectTypeProfile(lhs_name, value,
Yang 2017/02/22 10:39:28 We would at some point need a mapping from feedbac
2369 feedback_index(collect_type_feedback_slot));
2370 }
2339 } 2371 }
2340 2372
2341 void BytecodeGenerator::VisitYield(Yield* expr) { 2373 void BytecodeGenerator::VisitYield(Yield* expr) {
2342 builder()->SetExpressionPosition(expr); 2374 builder()->SetExpressionPosition(expr);
2343 Register value = VisitForRegisterValue(expr->expression()); 2375 Register value = VisitForRegisterValue(expr->expression());
2344 2376
2345 Register generator = VisitForRegisterValue(expr->generator_object()); 2377 Register generator = VisitForRegisterValue(expr->generator_object());
2346 2378
2347 // Save context, registers, and state. Then return. 2379 // Save context, registers, and state. Then return.
2348 builder() 2380 builder()
(...skipping 1122 matching lines...) Expand 10 before | Expand all | Expand 10 after
3471 } 3503 }
3472 3504
3473 Runtime::FunctionId BytecodeGenerator::StoreKeyedToSuperRuntimeId() { 3505 Runtime::FunctionId BytecodeGenerator::StoreKeyedToSuperRuntimeId() {
3474 return is_strict(language_mode()) ? Runtime::kStoreKeyedToSuper_Strict 3506 return is_strict(language_mode()) ? Runtime::kStoreKeyedToSuper_Strict
3475 : Runtime::kStoreKeyedToSuper_Sloppy; 3507 : Runtime::kStoreKeyedToSuper_Sloppy;
3476 } 3508 }
3477 3509
3478 } // namespace interpreter 3510 } // namespace interpreter
3479 } // namespace internal 3511 } // namespace internal
3480 } // namespace v8 3512 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698