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/typing.h" | 5 #include "src/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 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 | 395 |
396 // Collect type feedback. | 396 // Collect type feedback. |
397 if ((prop->kind() == ObjectLiteral::Property::MATERIALIZED_LITERAL && | 397 if ((prop->kind() == ObjectLiteral::Property::MATERIALIZED_LITERAL && |
398 !CompileTimeValue::IsCompileTimeValue(prop->value())) || | 398 !CompileTimeValue::IsCompileTimeValue(prop->value())) || |
399 prop->kind() == ObjectLiteral::Property::COMPUTED) { | 399 prop->kind() == ObjectLiteral::Property::COMPUTED) { |
400 if (!prop->is_computed_name() && | 400 if (!prop->is_computed_name() && |
401 prop->key()->AsLiteral()->value()->IsInternalizedString() && | 401 prop->key()->AsLiteral()->value()->IsInternalizedString() && |
402 prop->emit_store()) { | 402 prop->emit_store()) { |
403 // Record type feed back for the property. | 403 // Record type feed back for the property. |
404 TypeFeedbackId id = prop->key()->AsLiteral()->LiteralFeedbackId(); | 404 TypeFeedbackId id = prop->key()->AsLiteral()->LiteralFeedbackId(); |
405 FeedbackVectorICSlot slot = prop->GetSlot(); | 405 FeedbackVectorSlot slot = prop->GetSlot(); |
406 SmallMapList maps; | 406 SmallMapList maps; |
407 if (FLAG_vector_stores) { | 407 if (FLAG_vector_stores) { |
408 oracle()->CollectReceiverTypes(slot, &maps); | 408 oracle()->CollectReceiverTypes(slot, &maps); |
409 } else { | 409 } else { |
410 oracle()->CollectReceiverTypes(id, &maps); | 410 oracle()->CollectReceiverTypes(id, &maps); |
411 } | 411 } |
412 prop->set_receiver_type(maps.length() == 1 ? maps.at(0) | 412 prop->set_receiver_type(maps.length() == 1 ? maps.at(0) |
413 : Handle<Map>::null()); | 413 : Handle<Map>::null()); |
414 } | 414 } |
415 } | 415 } |
(...skipping 14 matching lines...) Expand all Loading... |
430 | 430 |
431 NarrowType(expr, Bounds(Type::Object(zone()))); | 431 NarrowType(expr, Bounds(Type::Object(zone()))); |
432 } | 432 } |
433 | 433 |
434 | 434 |
435 void AstTyper::VisitAssignment(Assignment* expr) { | 435 void AstTyper::VisitAssignment(Assignment* expr) { |
436 // Collect type feedback. | 436 // Collect type feedback. |
437 Property* prop = expr->target()->AsProperty(); | 437 Property* prop = expr->target()->AsProperty(); |
438 if (prop != NULL) { | 438 if (prop != NULL) { |
439 TypeFeedbackId id = expr->AssignmentFeedbackId(); | 439 TypeFeedbackId id = expr->AssignmentFeedbackId(); |
440 FeedbackVectorICSlot slot = expr->AssignmentSlot(); | 440 FeedbackVectorSlot slot = expr->AssignmentSlot(); |
441 expr->set_is_uninitialized(FLAG_vector_stores | 441 expr->set_is_uninitialized(FLAG_vector_stores |
442 ? oracle()->StoreIsUninitialized(slot) | 442 ? oracle()->StoreIsUninitialized(slot) |
443 : oracle()->StoreIsUninitialized(id)); | 443 : oracle()->StoreIsUninitialized(id)); |
444 if (!expr->IsUninitialized()) { | 444 if (!expr->IsUninitialized()) { |
445 SmallMapList* receiver_types = expr->GetReceiverTypes(); | 445 SmallMapList* receiver_types = expr->GetReceiverTypes(); |
446 if (prop->key()->IsPropertyName()) { | 446 if (prop->key()->IsPropertyName()) { |
447 Literal* lit_key = prop->key()->AsLiteral(); | 447 Literal* lit_key = prop->key()->AsLiteral(); |
448 DCHECK(lit_key != NULL && lit_key->value()->IsString()); | 448 DCHECK(lit_key != NULL && lit_key->value()->IsString()); |
449 Handle<String> name = Handle<String>::cast(lit_key->value()); | 449 Handle<String> name = Handle<String>::cast(lit_key->value()); |
450 if (FLAG_vector_stores) { | 450 if (FLAG_vector_stores) { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
492 void AstTyper::VisitThrow(Throw* expr) { | 492 void AstTyper::VisitThrow(Throw* expr) { |
493 RECURSE(Visit(expr->exception())); | 493 RECURSE(Visit(expr->exception())); |
494 // TODO(rossberg): is it worth having a non-termination effect? | 494 // TODO(rossberg): is it worth having a non-termination effect? |
495 | 495 |
496 NarrowType(expr, Bounds(Type::None(zone()))); | 496 NarrowType(expr, Bounds(Type::None(zone()))); |
497 } | 497 } |
498 | 498 |
499 | 499 |
500 void AstTyper::VisitProperty(Property* expr) { | 500 void AstTyper::VisitProperty(Property* expr) { |
501 // Collect type feedback. | 501 // Collect type feedback. |
502 FeedbackVectorICSlot slot(FeedbackVectorICSlot::Invalid()); | 502 FeedbackVectorSlot slot = expr->PropertyFeedbackSlot(); |
503 slot = expr->PropertyFeedbackSlot(); | |
504 expr->set_inline_cache_state(oracle()->LoadInlineCacheState(slot)); | 503 expr->set_inline_cache_state(oracle()->LoadInlineCacheState(slot)); |
505 | 504 |
506 if (!expr->IsUninitialized()) { | 505 if (!expr->IsUninitialized()) { |
507 if (expr->key()->IsPropertyName()) { | 506 if (expr->key()->IsPropertyName()) { |
508 Literal* lit_key = expr->key()->AsLiteral(); | 507 Literal* lit_key = expr->key()->AsLiteral(); |
509 DCHECK(lit_key != NULL && lit_key->value()->IsString()); | 508 DCHECK(lit_key != NULL && lit_key->value()->IsString()); |
510 Handle<String> name = Handle<String>::cast(lit_key->value()); | 509 Handle<String> name = Handle<String>::cast(lit_key->value()); |
511 oracle()->PropertyReceiverTypes(slot, name, expr->GetReceiverTypes()); | 510 oracle()->PropertyReceiverTypes(slot, name, expr->GetReceiverTypes()); |
512 } else { | 511 } else { |
513 bool is_string; | 512 bool is_string; |
(...skipping 10 matching lines...) Expand all Loading... |
524 | 523 |
525 // We don't know anything about the result type. | 524 // We don't know anything about the result type. |
526 } | 525 } |
527 | 526 |
528 | 527 |
529 void AstTyper::VisitCall(Call* expr) { | 528 void AstTyper::VisitCall(Call* expr) { |
530 // Collect type feedback. | 529 // Collect type feedback. |
531 RECURSE(Visit(expr->expression())); | 530 RECURSE(Visit(expr->expression())); |
532 bool is_uninitialized = true; | 531 bool is_uninitialized = true; |
533 if (expr->IsUsingCallFeedbackICSlot(isolate())) { | 532 if (expr->IsUsingCallFeedbackICSlot(isolate())) { |
534 FeedbackVectorICSlot slot = expr->CallFeedbackICSlot(); | 533 FeedbackVectorSlot slot = expr->CallFeedbackICSlot(); |
535 is_uninitialized = oracle()->CallIsUninitialized(slot); | 534 is_uninitialized = oracle()->CallIsUninitialized(slot); |
536 if (!expr->expression()->IsProperty() && | 535 if (!expr->expression()->IsProperty() && |
537 oracle()->CallIsMonomorphic(slot)) { | 536 oracle()->CallIsMonomorphic(slot)) { |
538 expr->set_target(oracle()->GetCallTarget(slot)); | 537 expr->set_target(oracle()->GetCallTarget(slot)); |
539 Handle<AllocationSite> site = oracle()->GetCallAllocationSite(slot); | 538 Handle<AllocationSite> site = oracle()->GetCallAllocationSite(slot); |
540 expr->set_allocation_site(site); | 539 expr->set_allocation_site(site); |
541 } | 540 } |
542 } | 541 } |
543 | 542 |
544 expr->set_is_uninitialized(is_uninitialized); | 543 expr->set_is_uninitialized(is_uninitialized); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
615 break; | 614 break; |
616 default: | 615 default: |
617 UNREACHABLE(); | 616 UNREACHABLE(); |
618 } | 617 } |
619 } | 618 } |
620 | 619 |
621 | 620 |
622 void AstTyper::VisitCountOperation(CountOperation* expr) { | 621 void AstTyper::VisitCountOperation(CountOperation* expr) { |
623 // Collect type feedback. | 622 // Collect type feedback. |
624 TypeFeedbackId store_id = expr->CountStoreFeedbackId(); | 623 TypeFeedbackId store_id = expr->CountStoreFeedbackId(); |
625 FeedbackVectorICSlot slot = expr->CountSlot(); | 624 FeedbackVectorSlot slot = expr->CountSlot(); |
626 KeyedAccessStoreMode store_mode; | 625 KeyedAccessStoreMode store_mode; |
627 IcCheckType key_type; | 626 IcCheckType key_type; |
628 if (FLAG_vector_stores) { | 627 if (FLAG_vector_stores) { |
629 oracle()->GetStoreModeAndKeyType(slot, &store_mode, &key_type); | 628 oracle()->GetStoreModeAndKeyType(slot, &store_mode, &key_type); |
630 oracle()->CountReceiverTypes(slot, expr->GetReceiverTypes()); | 629 oracle()->CountReceiverTypes(slot, expr->GetReceiverTypes()); |
631 } else { | 630 } else { |
632 oracle()->GetStoreModeAndKeyType(store_id, &store_mode, &key_type); | 631 oracle()->GetStoreModeAndKeyType(store_id, &store_mode, &key_type); |
633 oracle()->CountReceiverTypes(store_id, expr->GetReceiverTypes()); | 632 oracle()->CountReceiverTypes(store_id, expr->GetReceiverTypes()); |
634 } | 633 } |
635 expr->set_store_mode(store_mode); | 634 expr->set_store_mode(store_mode); |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
805 void AstTyper::VisitImportDeclaration(ImportDeclaration* declaration) { | 804 void AstTyper::VisitImportDeclaration(ImportDeclaration* declaration) { |
806 } | 805 } |
807 | 806 |
808 | 807 |
809 void AstTyper::VisitExportDeclaration(ExportDeclaration* declaration) { | 808 void AstTyper::VisitExportDeclaration(ExportDeclaration* declaration) { |
810 } | 809 } |
811 | 810 |
812 | 811 |
813 } // namespace internal | 812 } // namespace internal |
814 } // namespace v8 | 813 } // namespace v8 |
OLD | NEW |