| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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/crankshaft/typing.h" | 5 #include "src/crankshaft/typing.h" |
| 6 | 6 |
| 7 #include "src/frames.h" | 7 #include "src/frames.h" |
| 8 #include "src/frames-inl.h" | 8 #include "src/frames-inl.h" |
| 9 #include "src/ostreams.h" | 9 #include "src/ostreams.h" |
| 10 #include "src/parser.h" // for CompileTimeValue; TODO(rossberg): should move | 10 #include "src/parser.h" // for CompileTimeValue; TODO(rossberg): should move |
| (...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 ObjectLiteral::Property* prop = properties->at(i); | 403 ObjectLiteral::Property* prop = properties->at(i); |
| 404 | 404 |
| 405 // Collect type feedback. | 405 // Collect type feedback. |
| 406 if ((prop->kind() == ObjectLiteral::Property::MATERIALIZED_LITERAL && | 406 if ((prop->kind() == ObjectLiteral::Property::MATERIALIZED_LITERAL && |
| 407 !CompileTimeValue::IsCompileTimeValue(prop->value())) || | 407 !CompileTimeValue::IsCompileTimeValue(prop->value())) || |
| 408 prop->kind() == ObjectLiteral::Property::COMPUTED) { | 408 prop->kind() == ObjectLiteral::Property::COMPUTED) { |
| 409 if (!prop->is_computed_name() && | 409 if (!prop->is_computed_name() && |
| 410 prop->key()->AsLiteral()->value()->IsInternalizedString() && | 410 prop->key()->AsLiteral()->value()->IsInternalizedString() && |
| 411 prop->emit_store()) { | 411 prop->emit_store()) { |
| 412 // Record type feed back for the property. | 412 // Record type feed back for the property. |
| 413 TypeFeedbackId id = prop->key()->AsLiteral()->LiteralFeedbackId(); | |
| 414 FeedbackVectorSlot slot = prop->GetSlot(); | 413 FeedbackVectorSlot slot = prop->GetSlot(); |
| 415 SmallMapList maps; | 414 SmallMapList maps; |
| 416 if (FLAG_vector_stores) { | 415 oracle()->CollectReceiverTypes(slot, &maps); |
| 417 oracle()->CollectReceiverTypes(slot, &maps); | |
| 418 } else { | |
| 419 oracle()->CollectReceiverTypes(id, &maps); | |
| 420 } | |
| 421 prop->set_receiver_type(maps.length() == 1 ? maps.at(0) | 416 prop->set_receiver_type(maps.length() == 1 ? maps.at(0) |
| 422 : Handle<Map>::null()); | 417 : Handle<Map>::null()); |
| 423 } | 418 } |
| 424 } | 419 } |
| 425 | 420 |
| 426 RECURSE(Visit(prop->value())); | 421 RECURSE(Visit(prop->value())); |
| 427 } | 422 } |
| 428 | 423 |
| 429 NarrowType(expr, Bounds(Type::Object(zone()))); | 424 NarrowType(expr, Bounds(Type::Object(zone()))); |
| 430 } | 425 } |
| 431 | 426 |
| 432 | 427 |
| 433 void AstTyper::VisitArrayLiteral(ArrayLiteral* expr) { | 428 void AstTyper::VisitArrayLiteral(ArrayLiteral* expr) { |
| 434 ZoneList<Expression*>* values = expr->values(); | 429 ZoneList<Expression*>* values = expr->values(); |
| 435 for (int i = 0; i < values->length(); ++i) { | 430 for (int i = 0; i < values->length(); ++i) { |
| 436 Expression* value = values->at(i); | 431 Expression* value = values->at(i); |
| 437 RECURSE(Visit(value)); | 432 RECURSE(Visit(value)); |
| 438 } | 433 } |
| 439 | 434 |
| 440 NarrowType(expr, Bounds(Type::Object(zone()))); | 435 NarrowType(expr, Bounds(Type::Object(zone()))); |
| 441 } | 436 } |
| 442 | 437 |
| 443 | 438 |
| 444 void AstTyper::VisitAssignment(Assignment* expr) { | 439 void AstTyper::VisitAssignment(Assignment* expr) { |
| 445 // Collect type feedback. | 440 // Collect type feedback. |
| 446 Property* prop = expr->target()->AsProperty(); | 441 Property* prop = expr->target()->AsProperty(); |
| 447 if (prop != NULL) { | 442 if (prop != NULL) { |
| 448 TypeFeedbackId id = expr->AssignmentFeedbackId(); | |
| 449 FeedbackVectorSlot slot = expr->AssignmentSlot(); | 443 FeedbackVectorSlot slot = expr->AssignmentSlot(); |
| 450 expr->set_is_uninitialized(FLAG_vector_stores | 444 expr->set_is_uninitialized(oracle()->StoreIsUninitialized(slot)); |
| 451 ? oracle()->StoreIsUninitialized(slot) | |
| 452 : oracle()->StoreIsUninitialized(id)); | |
| 453 if (!expr->IsUninitialized()) { | 445 if (!expr->IsUninitialized()) { |
| 454 SmallMapList* receiver_types = expr->GetReceiverTypes(); | 446 SmallMapList* receiver_types = expr->GetReceiverTypes(); |
| 455 if (prop->key()->IsPropertyName()) { | 447 if (prop->key()->IsPropertyName()) { |
| 456 Literal* lit_key = prop->key()->AsLiteral(); | 448 Literal* lit_key = prop->key()->AsLiteral(); |
| 457 DCHECK(lit_key != NULL && lit_key->value()->IsString()); | 449 DCHECK(lit_key != NULL && lit_key->value()->IsString()); |
| 458 Handle<String> name = Handle<String>::cast(lit_key->value()); | 450 Handle<String> name = Handle<String>::cast(lit_key->value()); |
| 459 if (FLAG_vector_stores) { | 451 oracle()->AssignmentReceiverTypes(slot, name, receiver_types); |
| 460 oracle()->AssignmentReceiverTypes(slot, name, receiver_types); | |
| 461 } else { | |
| 462 oracle()->AssignmentReceiverTypes(id, name, receiver_types); | |
| 463 } | |
| 464 } else { | 452 } else { |
| 465 KeyedAccessStoreMode store_mode; | 453 KeyedAccessStoreMode store_mode; |
| 466 IcCheckType key_type; | 454 IcCheckType key_type; |
| 467 if (FLAG_vector_stores) { | 455 oracle()->KeyedAssignmentReceiverTypes(slot, receiver_types, |
| 468 oracle()->KeyedAssignmentReceiverTypes(slot, receiver_types, | 456 &store_mode, &key_type); |
| 469 &store_mode, &key_type); | |
| 470 } else { | |
| 471 oracle()->KeyedAssignmentReceiverTypes(id, receiver_types, | |
| 472 &store_mode, &key_type); | |
| 473 } | |
| 474 expr->set_store_mode(store_mode); | 457 expr->set_store_mode(store_mode); |
| 475 expr->set_key_type(key_type); | 458 expr->set_key_type(key_type); |
| 476 } | 459 } |
| 477 } | 460 } |
| 478 } | 461 } |
| 479 | 462 |
| 480 Expression* rhs = | 463 Expression* rhs = |
| 481 expr->is_compound() ? expr->binary_operation() : expr->value(); | 464 expr->is_compound() ? expr->binary_operation() : expr->value(); |
| 482 RECURSE(Visit(expr->target())); | 465 RECURSE(Visit(expr->target())); |
| 483 RECURSE(Visit(rhs)); | 466 RECURSE(Visit(rhs)); |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 622 NarrowType(expr, Bounds(Type::InternalizedString(zone()))); | 605 NarrowType(expr, Bounds(Type::InternalizedString(zone()))); |
| 623 break; | 606 break; |
| 624 default: | 607 default: |
| 625 UNREACHABLE(); | 608 UNREACHABLE(); |
| 626 } | 609 } |
| 627 } | 610 } |
| 628 | 611 |
| 629 | 612 |
| 630 void AstTyper::VisitCountOperation(CountOperation* expr) { | 613 void AstTyper::VisitCountOperation(CountOperation* expr) { |
| 631 // Collect type feedback. | 614 // Collect type feedback. |
| 632 TypeFeedbackId store_id = expr->CountStoreFeedbackId(); | |
| 633 FeedbackVectorSlot slot = expr->CountSlot(); | 615 FeedbackVectorSlot slot = expr->CountSlot(); |
| 634 KeyedAccessStoreMode store_mode; | 616 KeyedAccessStoreMode store_mode; |
| 635 IcCheckType key_type; | 617 IcCheckType key_type; |
| 636 if (FLAG_vector_stores) { | 618 oracle()->GetStoreModeAndKeyType(slot, &store_mode, &key_type); |
| 637 oracle()->GetStoreModeAndKeyType(slot, &store_mode, &key_type); | 619 oracle()->CountReceiverTypes(slot, expr->GetReceiverTypes()); |
| 638 oracle()->CountReceiverTypes(slot, expr->GetReceiverTypes()); | |
| 639 } else { | |
| 640 oracle()->GetStoreModeAndKeyType(store_id, &store_mode, &key_type); | |
| 641 oracle()->CountReceiverTypes(store_id, expr->GetReceiverTypes()); | |
| 642 } | |
| 643 expr->set_store_mode(store_mode); | 620 expr->set_store_mode(store_mode); |
| 644 expr->set_key_type(key_type); | 621 expr->set_key_type(key_type); |
| 645 expr->set_type(oracle()->CountType(expr->CountBinOpFeedbackId())); | 622 expr->set_type(oracle()->CountType(expr->CountBinOpFeedbackId())); |
| 646 // TODO(rossberg): merge the count type with the generic expression type. | 623 // TODO(rossberg): merge the count type with the generic expression type. |
| 647 | 624 |
| 648 RECURSE(Visit(expr->expression())); | 625 RECURSE(Visit(expr->expression())); |
| 649 | 626 |
| 650 NarrowType(expr, Bounds(Type::SignedSmall(zone()), Type::Number(zone()))); | 627 NarrowType(expr, Bounds(Type::SignedSmall(zone()), Type::Number(zone()))); |
| 651 | 628 |
| 652 VariableProxy* proxy = expr->expression()->AsVariableProxy(); | 629 VariableProxy* proxy = expr->expression()->AsVariableProxy(); |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 813 void AstTyper::VisitImportDeclaration(ImportDeclaration* declaration) { | 790 void AstTyper::VisitImportDeclaration(ImportDeclaration* declaration) { |
| 814 } | 791 } |
| 815 | 792 |
| 816 | 793 |
| 817 void AstTyper::VisitExportDeclaration(ExportDeclaration* declaration) { | 794 void AstTyper::VisitExportDeclaration(ExportDeclaration* declaration) { |
| 818 } | 795 } |
| 819 | 796 |
| 820 | 797 |
| 821 } // namespace internal | 798 } // namespace internal |
| 822 } // namespace v8 | 799 } // namespace v8 |
| OLD | NEW |