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

Side by Side Diff: src/typing.cc

Issue 157543002: A64: Synchronize with r18581. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « src/types.cc ('k') | src/utils.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 if (scope->is_function_scope() && scope->function() != NULL) { 64 if (scope->is_function_scope() && scope->function() != NULL) {
65 RECURSE(visitor->VisitVariableDeclaration(scope->function())); 65 RECURSE(visitor->VisitVariableDeclaration(scope->function()));
66 } 66 }
67 RECURSE(visitor->VisitDeclarations(scope->declarations())); 67 RECURSE(visitor->VisitDeclarations(scope->declarations()));
68 RECURSE(visitor->VisitStatements(info->function()->body())); 68 RECURSE(visitor->VisitStatements(info->function()->body()));
69 } 69 }
70 70
71 #undef RECURSE 71 #undef RECURSE
72 72
73 73
74 Effect AstTyper::ObservedOnStack(Object* value) {
75 Type* lower = Type::OfCurrently(Handle<Object>(value, isolate()));
76 return Effect(Bounds(lower, Type::Any(), isolate()));
77 }
78
79
80 #ifdef OBJECT_PRINT 74 #ifdef OBJECT_PRINT
81 static void PrintObserved(Variable* var, Object* value, Handle<Type> type) { 75 static void PrintObserved(Variable* var, Object* value, Handle<Type> type) {
82 PrintF(" observed %s ", var->IsParameter() ? "param" : "local"); 76 PrintF(" observed %s ", var->IsParameter() ? "param" : "local");
83 var->name()->Print(); 77 var->name()->Print();
84 PrintF(" : "); 78 PrintF(" : ");
85 value->ShortPrint(); 79 value->ShortPrint();
86 PrintF(" -> "); 80 PrintF(" -> ");
87 type->TypePrint(); 81 type->TypePrint();
88 } 82 }
89 #endif // OBJECT_PRINT 83 #endif // OBJECT_PRINT
90 84
91 85
86 Effect AstTyper::ObservedOnStack(Object* value) {
87 Handle<Type> lower = Type::OfCurrently(handle(value, isolate()), isolate());
88 return Effect(Bounds(lower, Type::Any(isolate())));
89 }
90
91
92 void AstTyper::ObserveTypesAtOsrEntry(IterationStatement* stmt) { 92 void AstTyper::ObserveTypesAtOsrEntry(IterationStatement* stmt) {
93 if (stmt->OsrEntryId() != info_->osr_ast_id()) return; 93 if (stmt->OsrEntryId() != info_->osr_ast_id()) return;
94 94
95 DisallowHeapAllocation no_gc; 95 DisallowHeapAllocation no_gc;
96 JavaScriptFrameIterator it(isolate()); 96 JavaScriptFrameIterator it(isolate());
97 JavaScriptFrame* frame = it.frame(); 97 JavaScriptFrame* frame = it.frame();
98 Scope* scope = info_->scope(); 98 Scope* scope = info_->scope();
99 99
100 // Assert that the frame on the stack belongs to the function we want to OSR. 100 // Assert that the frame on the stack belongs to the function we want to OSR.
101 ASSERT_EQ(*info_->closure(), frame->function()); 101 ASSERT_EQ(*info_->closure(), frame->function());
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 RECURSE(Visit(stmt->finally_block())); 361 RECURSE(Visit(stmt->finally_block()));
362 } 362 }
363 363
364 364
365 void AstTyper::VisitDebuggerStatement(DebuggerStatement* stmt) { 365 void AstTyper::VisitDebuggerStatement(DebuggerStatement* stmt) {
366 store_.Forget(); // May do whatever. 366 store_.Forget(); // May do whatever.
367 } 367 }
368 368
369 369
370 void AstTyper::VisitFunctionLiteral(FunctionLiteral* expr) { 370 void AstTyper::VisitFunctionLiteral(FunctionLiteral* expr) {
371 expr->InitializeSharedInfo(Handle<Code>(info_->closure()->shared()->code()));
371 } 372 }
372 373
373 374
374 void AstTyper::VisitNativeFunctionLiteral(NativeFunctionLiteral* expr) { 375 void AstTyper::VisitNativeFunctionLiteral(NativeFunctionLiteral* expr) {
375 } 376 }
376 377
377 378
378 void AstTyper::VisitConditional(Conditional* expr) { 379 void AstTyper::VisitConditional(Conditional* expr) {
379 // Collect type feedback. 380 // Collect type feedback.
380 expr->condition()->RecordToBooleanTypeFeedback(oracle()); 381 expr->condition()->RecordToBooleanTypeFeedback(oracle());
(...skipping 16 matching lines...) Expand all
397 398
398 void AstTyper::VisitVariableProxy(VariableProxy* expr) { 399 void AstTyper::VisitVariableProxy(VariableProxy* expr) {
399 Variable* var = expr->var(); 400 Variable* var = expr->var();
400 if (var->IsStackAllocated()) { 401 if (var->IsStackAllocated()) {
401 NarrowType(expr, store_.LookupBounds(variable_index(var))); 402 NarrowType(expr, store_.LookupBounds(variable_index(var)));
402 } 403 }
403 } 404 }
404 405
405 406
406 void AstTyper::VisitLiteral(Literal* expr) { 407 void AstTyper::VisitLiteral(Literal* expr) {
407 Type* type = Type::Constant(expr->value(), isolate_); 408 Handle<Type> type = Type::Constant(expr->value(), isolate_);
408 NarrowType(expr, Bounds(type, isolate_)); 409 NarrowType(expr, Bounds(type));
409 } 410 }
410 411
411 412
412 void AstTyper::VisitRegExpLiteral(RegExpLiteral* expr) { 413 void AstTyper::VisitRegExpLiteral(RegExpLiteral* expr) {
413 NarrowType(expr, Bounds(Type::RegExp(), isolate_)); 414 NarrowType(expr, Bounds(Type::RegExp(isolate_)));
414 } 415 }
415 416
416 417
417 void AstTyper::VisitObjectLiteral(ObjectLiteral* expr) { 418 void AstTyper::VisitObjectLiteral(ObjectLiteral* expr) {
418 ZoneList<ObjectLiteral::Property*>* properties = expr->properties(); 419 ZoneList<ObjectLiteral::Property*>* properties = expr->properties();
419 for (int i = 0; i < properties->length(); ++i) { 420 for (int i = 0; i < properties->length(); ++i) {
420 ObjectLiteral::Property* prop = properties->at(i); 421 ObjectLiteral::Property* prop = properties->at(i);
421 422
422 // Collect type feedback. 423 // Collect type feedback.
423 if ((prop->kind() == ObjectLiteral::Property::MATERIALIZED_LITERAL && 424 if ((prop->kind() == ObjectLiteral::Property::MATERIALIZED_LITERAL &&
424 !CompileTimeValue::IsCompileTimeValue(prop->value())) || 425 !CompileTimeValue::IsCompileTimeValue(prop->value())) ||
425 prop->kind() == ObjectLiteral::Property::COMPUTED) { 426 prop->kind() == ObjectLiteral::Property::COMPUTED) {
426 if (prop->key()->value()->IsInternalizedString() && prop->emit_store()) { 427 if (prop->key()->value()->IsInternalizedString() && prop->emit_store()) {
427 prop->RecordTypeFeedback(oracle()); 428 prop->RecordTypeFeedback(oracle());
428 } 429 }
429 } 430 }
430 431
431 RECURSE(Visit(prop->value())); 432 RECURSE(Visit(prop->value()));
432 } 433 }
433 434
434 NarrowType(expr, Bounds(Type::Object(), isolate_)); 435 NarrowType(expr, Bounds(Type::Object(isolate_)));
435 } 436 }
436 437
437 438
438 void AstTyper::VisitArrayLiteral(ArrayLiteral* expr) { 439 void AstTyper::VisitArrayLiteral(ArrayLiteral* expr) {
439 ZoneList<Expression*>* values = expr->values(); 440 ZoneList<Expression*>* values = expr->values();
440 for (int i = 0; i < values->length(); ++i) { 441 for (int i = 0; i < values->length(); ++i) {
441 Expression* value = values->at(i); 442 Expression* value = values->at(i);
442 RECURSE(Visit(value)); 443 RECURSE(Visit(value));
443 } 444 }
444 445
445 NarrowType(expr, Bounds(Type::Array(), isolate_)); 446 NarrowType(expr, Bounds(Type::Array(isolate_)));
446 } 447 }
447 448
448 449
449 void AstTyper::VisitAssignment(Assignment* expr) { 450 void AstTyper::VisitAssignment(Assignment* expr) {
450 // Collect type feedback. 451 // Collect type feedback.
451 Property* prop = expr->target()->AsProperty(); 452 Property* prop = expr->target()->AsProperty();
452 if (prop != NULL) { 453 if (prop != NULL) {
453 TypeFeedbackId id = expr->AssignmentFeedbackId(); 454 TypeFeedbackId id = expr->AssignmentFeedbackId();
454 expr->set_is_uninitialized(oracle()->StoreIsUninitialized(id)); 455 expr->set_is_uninitialized(oracle()->StoreIsUninitialized(id));
455 if (!expr->IsUninitialized()) { 456 if (!expr->IsUninitialized()) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 RECURSE(Visit(expr->expression())); 488 RECURSE(Visit(expr->expression()));
488 489
489 // We don't know anything about the result type. 490 // We don't know anything about the result type.
490 } 491 }
491 492
492 493
493 void AstTyper::VisitThrow(Throw* expr) { 494 void AstTyper::VisitThrow(Throw* expr) {
494 RECURSE(Visit(expr->exception())); 495 RECURSE(Visit(expr->exception()));
495 // TODO(rossberg): is it worth having a non-termination effect? 496 // TODO(rossberg): is it worth having a non-termination effect?
496 497
497 NarrowType(expr, Bounds(Type::None(), isolate_)); 498 NarrowType(expr, Bounds(Type::None(isolate_)));
498 } 499 }
499 500
500 501
501 void AstTyper::VisitProperty(Property* expr) { 502 void AstTyper::VisitProperty(Property* expr) {
502 // Collect type feedback. 503 // Collect type feedback.
503 TypeFeedbackId id = expr->PropertyFeedbackId(); 504 TypeFeedbackId id = expr->PropertyFeedbackId();
504 expr->set_is_uninitialized(oracle()->LoadIsUninitialized(id)); 505 expr->set_is_uninitialized(oracle()->LoadIsUninitialized(id));
505 if (!expr->IsUninitialized()) { 506 if (!expr->IsUninitialized()) {
506 expr->set_is_pre_monomorphic(oracle()->LoadIsPreMonomorphic(id)); 507 expr->set_is_pre_monomorphic(oracle()->LoadIsPreMonomorphic(id));
507 if (expr->key()->IsPropertyName()) { 508 if (expr->key()->IsPropertyName()) {
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 if (expr->op() == Token::NOT) { 586 if (expr->op() == Token::NOT) {
586 // TODO(rossberg): only do in test or value context. 587 // TODO(rossberg): only do in test or value context.
587 expr->expression()->RecordToBooleanTypeFeedback(oracle()); 588 expr->expression()->RecordToBooleanTypeFeedback(oracle());
588 } 589 }
589 590
590 RECURSE(Visit(expr->expression())); 591 RECURSE(Visit(expr->expression()));
591 592
592 switch (expr->op()) { 593 switch (expr->op()) {
593 case Token::NOT: 594 case Token::NOT:
594 case Token::DELETE: 595 case Token::DELETE:
595 NarrowType(expr, Bounds(Type::Boolean(), isolate_)); 596 NarrowType(expr, Bounds(Type::Boolean(isolate_)));
596 break; 597 break;
597 case Token::VOID: 598 case Token::VOID:
598 NarrowType(expr, Bounds(Type::Undefined(), isolate_)); 599 NarrowType(expr, Bounds(Type::Undefined(isolate_)));
599 break; 600 break;
600 case Token::TYPEOF: 601 case Token::TYPEOF:
601 NarrowType(expr, Bounds(Type::InternalizedString(), isolate_)); 602 NarrowType(expr, Bounds(Type::InternalizedString(isolate_)));
602 break; 603 break;
603 default: 604 default:
604 UNREACHABLE(); 605 UNREACHABLE();
605 } 606 }
606 } 607 }
607 608
608 609
609 void AstTyper::VisitCountOperation(CountOperation* expr) { 610 void AstTyper::VisitCountOperation(CountOperation* expr) {
610 // Collect type feedback. 611 // Collect type feedback.
611 TypeFeedbackId store_id = expr->CountStoreFeedbackId(); 612 TypeFeedbackId store_id = expr->CountStoreFeedbackId();
612 expr->set_store_mode(oracle()->GetStoreMode(store_id)); 613 expr->set_store_mode(oracle()->GetStoreMode(store_id));
613 oracle()->CountReceiverTypes(store_id, expr->GetReceiverTypes()); 614 oracle()->CountReceiverTypes(store_id, expr->GetReceiverTypes());
614 expr->set_type(oracle()->CountType(expr->CountBinOpFeedbackId())); 615 expr->set_type(oracle()->CountType(expr->CountBinOpFeedbackId()));
615 // TODO(rossberg): merge the count type with the generic expression type. 616 // TODO(rossberg): merge the count type with the generic expression type.
616 617
617 RECURSE(Visit(expr->expression())); 618 RECURSE(Visit(expr->expression()));
618 619
619 NarrowType(expr, Bounds(Type::Smi(), Type::Number(), isolate_)); 620 NarrowType(expr, Bounds(Type::Smi(isolate_), Type::Number(isolate_)));
620 621
621 VariableProxy* proxy = expr->expression()->AsVariableProxy(); 622 VariableProxy* proxy = expr->expression()->AsVariableProxy();
622 if (proxy != NULL && proxy->var()->IsStackAllocated()) { 623 if (proxy != NULL && proxy->var()->IsStackAllocated()) {
623 store_.Seq(variable_index(proxy->var()), Effect(expr->bounds())); 624 store_.Seq(variable_index(proxy->var()), Effect(expr->bounds()));
624 } 625 }
625 } 626 }
626 627
627 628
628 void AstTyper::VisitBinaryOperation(BinaryOperation* expr) { 629 void AstTyper::VisitBinaryOperation(BinaryOperation* expr) {
629 // Collect type feedback. 630 // Collect type feedback.
(...skipping 30 matching lines...) Expand all
660 store_.Seq(left_effects); 661 store_.Seq(left_effects);
661 662
662 NarrowType(expr, Bounds::Either( 663 NarrowType(expr, Bounds::Either(
663 expr->left()->bounds(), expr->right()->bounds(), isolate_)); 664 expr->left()->bounds(), expr->right()->bounds(), isolate_));
664 break; 665 break;
665 } 666 }
666 case Token::BIT_OR: 667 case Token::BIT_OR:
667 case Token::BIT_AND: { 668 case Token::BIT_AND: {
668 RECURSE(Visit(expr->left())); 669 RECURSE(Visit(expr->left()));
669 RECURSE(Visit(expr->right())); 670 RECURSE(Visit(expr->right()));
670 Handle<Type> upper( 671 Handle<Type> upper = Type::Union(
671 Type::Union( 672 expr->left()->bounds().upper, expr->right()->bounds().upper,
672 expr->left()->bounds().upper, expr->right()->bounds().upper),
673 isolate_); 673 isolate_);
674 if (!upper->Is(Type::Signed32())) 674 if (!upper->Is(Type::Signed32()))
675 upper = handle(Type::Signed32(), isolate_); 675 upper = Type::Signed32(isolate_);
676 Handle<Type> lower(Type::Intersect( 676 Handle<Type> lower =
677 handle(Type::Smi(), isolate_), upper), isolate_); 677 Type::Intersect(Type::Smi(isolate_), upper, isolate_);
678 NarrowType(expr, Bounds(lower, upper)); 678 NarrowType(expr, Bounds(lower, upper));
679 break; 679 break;
680 } 680 }
681 case Token::BIT_XOR: 681 case Token::BIT_XOR:
682 case Token::SHL: 682 case Token::SHL:
683 case Token::SAR: 683 case Token::SAR:
684 RECURSE(Visit(expr->left())); 684 RECURSE(Visit(expr->left()));
685 RECURSE(Visit(expr->right())); 685 RECURSE(Visit(expr->right()));
686 NarrowType(expr, Bounds(Type::Smi(), Type::Signed32(), isolate_)); 686 NarrowType(expr, Bounds(Type::Smi(isolate_), Type::Signed32(isolate_)));
687 break; 687 break;
688 case Token::SHR: 688 case Token::SHR:
689 RECURSE(Visit(expr->left())); 689 RECURSE(Visit(expr->left()));
690 RECURSE(Visit(expr->right())); 690 RECURSE(Visit(expr->right()));
691 // TODO(rossberg): The upper bound would be Unsigned32, but since there 691 // TODO(rossberg): The upper bound would be Unsigned32, but since there
692 // is no 'positive Smi' type for the lower bound, we use the smallest 692 // is no 'positive Smi' type for the lower bound, we use the smallest
693 // union of Smi and Unsigned32 as upper bound instead. 693 // union of Smi and Unsigned32 as upper bound instead.
694 NarrowType(expr, Bounds(Type::Smi(), Type::Number(), isolate_)); 694 NarrowType(expr, Bounds(Type::Smi(isolate_), Type::Number(isolate_)));
695 break; 695 break;
696 case Token::ADD: { 696 case Token::ADD: {
697 RECURSE(Visit(expr->left())); 697 RECURSE(Visit(expr->left()));
698 RECURSE(Visit(expr->right())); 698 RECURSE(Visit(expr->right()));
699 Bounds l = expr->left()->bounds(); 699 Bounds l = expr->left()->bounds();
700 Bounds r = expr->right()->bounds(); 700 Bounds r = expr->right()->bounds();
701 Type* lower = 701 Handle<Type> lower =
702 l.lower->Is(Type::None()) || r.lower->Is(Type::None()) ? 702 l.lower->Is(Type::None()) || r.lower->Is(Type::None()) ?
703 Type::None() : 703 Type::None(isolate_) :
704 l.lower->Is(Type::String()) || r.lower->Is(Type::String()) ? 704 l.lower->Is(Type::String()) || r.lower->Is(Type::String()) ?
705 Type::String() : 705 Type::String(isolate_) :
706 l.lower->Is(Type::Number()) && r.lower->Is(Type::Number()) ? 706 l.lower->Is(Type::Number()) && r.lower->Is(Type::Number()) ?
707 Type::Smi() : Type::None(); 707 Type::Smi(isolate_) : Type::None(isolate_);
708 Type* upper = 708 Handle<Type> upper =
709 l.upper->Is(Type::String()) || r.upper->Is(Type::String()) ? 709 l.upper->Is(Type::String()) || r.upper->Is(Type::String()) ?
710 Type::String() : 710 Type::String(isolate_) :
711 l.upper->Is(Type::Number()) && r.upper->Is(Type::Number()) ? 711 l.upper->Is(Type::Number()) && r.upper->Is(Type::Number()) ?
712 Type::Number() : Type::NumberOrString(); 712 Type::Number(isolate_) : Type::NumberOrString(isolate_);
713 NarrowType(expr, Bounds(lower, upper, isolate_)); 713 NarrowType(expr, Bounds(lower, upper));
714 break; 714 break;
715 } 715 }
716 case Token::SUB: 716 case Token::SUB:
717 case Token::MUL: 717 case Token::MUL:
718 case Token::DIV: 718 case Token::DIV:
719 case Token::MOD: 719 case Token::MOD:
720 RECURSE(Visit(expr->left())); 720 RECURSE(Visit(expr->left()));
721 RECURSE(Visit(expr->right())); 721 RECURSE(Visit(expr->right()));
722 NarrowType(expr, Bounds(Type::Smi(), Type::Number(), isolate_)); 722 NarrowType(expr, Bounds(Type::Smi(isolate_), Type::Number(isolate_)));
723 break; 723 break;
724 default: 724 default:
725 UNREACHABLE(); 725 UNREACHABLE();
726 } 726 }
727 } 727 }
728 728
729 729
730 void AstTyper::VisitCompareOperation(CompareOperation* expr) { 730 void AstTyper::VisitCompareOperation(CompareOperation* expr) {
731 // Collect type feedback. 731 // Collect type feedback.
732 Handle<Type> left_type, right_type, combined_type; 732 Handle<Type> left_type, right_type, combined_type;
733 oracle()->CompareType(expr->CompareOperationFeedbackId(), 733 oracle()->CompareType(expr->CompareOperationFeedbackId(),
734 &left_type, &right_type, &combined_type); 734 &left_type, &right_type, &combined_type);
735 NarrowLowerType(expr->left(), left_type); 735 NarrowLowerType(expr->left(), left_type);
736 NarrowLowerType(expr->right(), right_type); 736 NarrowLowerType(expr->right(), right_type);
737 expr->set_combined_type(combined_type); 737 expr->set_combined_type(combined_type);
738 738
739 RECURSE(Visit(expr->left())); 739 RECURSE(Visit(expr->left()));
740 RECURSE(Visit(expr->right())); 740 RECURSE(Visit(expr->right()));
741 741
742 NarrowType(expr, Bounds(Type::Boolean(), isolate_)); 742 NarrowType(expr, Bounds(Type::Boolean(isolate_)));
743 } 743 }
744 744
745 745
746 void AstTyper::VisitThisFunction(ThisFunction* expr) { 746 void AstTyper::VisitThisFunction(ThisFunction* expr) {
747 } 747 }
748 748
749 749
750 void AstTyper::VisitDeclarations(ZoneList<Declaration*>* decls) { 750 void AstTyper::VisitDeclarations(ZoneList<Declaration*>* decls) {
751 for (int i = 0; i < decls->length(); ++i) { 751 for (int i = 0; i < decls->length(); ++i) {
752 Declaration* decl = decls->at(i); 752 Declaration* decl = decls->at(i);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
795 void AstTyper::VisitModuleUrl(ModuleUrl* module) { 795 void AstTyper::VisitModuleUrl(ModuleUrl* module) {
796 } 796 }
797 797
798 798
799 void AstTyper::VisitModuleStatement(ModuleStatement* stmt) { 799 void AstTyper::VisitModuleStatement(ModuleStatement* stmt) {
800 RECURSE(Visit(stmt->body())); 800 RECURSE(Visit(stmt->body()));
801 } 801 }
802 802
803 803
804 } } // namespace v8::internal 804 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/types.cc ('k') | src/utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698