| OLD | NEW |
| 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 23 matching lines...) Expand all Loading... |
| 34 | 34 |
| 35 namespace v8 { | 35 namespace v8 { |
| 36 namespace internal { | 36 namespace internal { |
| 37 | 37 |
| 38 | 38 |
| 39 AstTyper::AstTyper(CompilationInfo* info) | 39 AstTyper::AstTyper(CompilationInfo* info) |
| 40 : info_(info), | 40 : info_(info), |
| 41 oracle_( | 41 oracle_( |
| 42 Handle<Code>(info->closure()->shared()->code()), | 42 Handle<Code>(info->closure()->shared()->code()), |
| 43 Handle<Context>(info->closure()->context()->native_context()), | 43 Handle<Context>(info->closure()->context()->native_context()), |
| 44 info->isolate(), | |
| 45 info->zone()), | 44 info->zone()), |
| 46 store_(info->zone()) { | 45 store_(info->zone()) { |
| 47 InitializeAstVisitor(info->isolate()); | 46 InitializeAstVisitor(info->zone()); |
| 48 } | 47 } |
| 49 | 48 |
| 50 | 49 |
| 51 #define RECURSE(call) \ | 50 #define RECURSE(call) \ |
| 52 do { \ | 51 do { \ |
| 53 ASSERT(!visitor->HasStackOverflow()); \ | 52 ASSERT(!visitor->HasStackOverflow()); \ |
| 54 call; \ | 53 call; \ |
| 55 if (visitor->HasStackOverflow()) return; \ | 54 if (visitor->HasStackOverflow()) return; \ |
| 56 } while (false) | 55 } while (false) |
| 57 | 56 |
| 58 void AstTyper::Run(CompilationInfo* info) { | 57 void AstTyper::Run(CompilationInfo* info) { |
| 59 AstTyper* visitor = new(info->zone()) AstTyper(info); | 58 AstTyper* visitor = new(info->zone()) AstTyper(info); |
| 60 Scope* scope = info->scope(); | 59 Scope* scope = info->scope(); |
| 61 | 60 |
| 62 // Handle implicit declaration of the function name in named function | 61 // Handle implicit declaration of the function name in named function |
| 63 // expressions before other declarations. | 62 // expressions before other declarations. |
| 64 if (scope->is_function_scope() && scope->function() != NULL) { | 63 if (scope->is_function_scope() && scope->function() != NULL) { |
| 65 RECURSE(visitor->VisitVariableDeclaration(scope->function())); | 64 RECURSE(visitor->VisitVariableDeclaration(scope->function())); |
| 66 } | 65 } |
| 67 RECURSE(visitor->VisitDeclarations(scope->declarations())); | 66 RECURSE(visitor->VisitDeclarations(scope->declarations())); |
| 68 RECURSE(visitor->VisitStatements(info->function()->body())); | 67 RECURSE(visitor->VisitStatements(info->function()->body())); |
| 69 } | 68 } |
| 70 | 69 |
| 71 #undef RECURSE | 70 #undef RECURSE |
| 72 | 71 |
| 73 | 72 |
| 74 #ifdef OBJECT_PRINT | 73 #ifdef OBJECT_PRINT |
| 75 static void PrintObserved(Variable* var, Object* value, Handle<Type> type) { | 74 static void PrintObserved(Variable* var, Object* value, Type* type) { |
| 76 PrintF(" observed %s ", var->IsParameter() ? "param" : "local"); | 75 PrintF(" observed %s ", var->IsParameter() ? "param" : "local"); |
| 77 var->name()->Print(); | 76 var->name()->Print(); |
| 78 PrintF(" : "); | 77 PrintF(" : "); |
| 79 value->ShortPrint(); | 78 value->ShortPrint(); |
| 80 PrintF(" -> "); | 79 PrintF(" -> "); |
| 81 type->TypePrint(); | 80 type->TypePrint(); |
| 82 } | 81 } |
| 83 #endif // OBJECT_PRINT | 82 #endif // OBJECT_PRINT |
| 84 | 83 |
| 85 | 84 |
| 86 Effect AstTyper::ObservedOnStack(Object* value) { | 85 Effect AstTyper::ObservedOnStack(Object* value) { |
| 87 Handle<Type> lower = Type::OfCurrently(handle(value, isolate()), isolate()); | 86 Type* lower = Type::OfCurrently(handle(value, isolate()), zone()); |
| 88 return Effect(Bounds(lower, Type::Any(isolate()))); | 87 return Effect(Bounds(lower, Type::Any(zone()))); |
| 89 } | 88 } |
| 90 | 89 |
| 91 | 90 |
| 92 void AstTyper::ObserveTypesAtOsrEntry(IterationStatement* stmt) { | 91 void AstTyper::ObserveTypesAtOsrEntry(IterationStatement* stmt) { |
| 93 if (stmt->OsrEntryId() != info_->osr_ast_id()) return; | 92 if (stmt->OsrEntryId() != info_->osr_ast_id()) return; |
| 94 | 93 |
| 95 DisallowHeapAllocation no_gc; | 94 DisallowHeapAllocation no_gc; |
| 96 JavaScriptFrameIterator it(isolate()); | 95 JavaScriptFrameIterator it(isolate()); |
| 97 JavaScriptFrame* frame = it.frame(); | 96 JavaScriptFrame* frame = it.frame(); |
| 98 Scope* scope = info_->scope(); | 97 Scope* scope = info_->scope(); |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 bool complex_effects = false; // True for label effects or fall-through. | 225 bool complex_effects = false; // True for label effects or fall-through. |
| 227 | 226 |
| 228 for (int i = 0; i < clauses->length(); ++i) { | 227 for (int i = 0; i < clauses->length(); ++i) { |
| 229 CaseClause* clause = clauses->at(i); | 228 CaseClause* clause = clauses->at(i); |
| 230 | 229 |
| 231 Effects clause_effects = EnterEffects(); | 230 Effects clause_effects = EnterEffects(); |
| 232 | 231 |
| 233 if (!clause->is_default()) { | 232 if (!clause->is_default()) { |
| 234 Expression* label = clause->label(); | 233 Expression* label = clause->label(); |
| 235 // Collect type feedback. | 234 // Collect type feedback. |
| 236 Handle<Type> tag_type, label_type, combined_type; | 235 Type* tag_type; |
| 236 Type* label_type; |
| 237 Type* combined_type; |
| 237 oracle()->CompareType(clause->CompareId(), | 238 oracle()->CompareType(clause->CompareId(), |
| 238 &tag_type, &label_type, &combined_type); | 239 &tag_type, &label_type, &combined_type); |
| 239 NarrowLowerType(stmt->tag(), tag_type); | 240 NarrowLowerType(stmt->tag(), tag_type); |
| 240 NarrowLowerType(label, label_type); | 241 NarrowLowerType(label, label_type); |
| 241 clause->set_compare_type(combined_type); | 242 clause->set_compare_type(combined_type); |
| 242 | 243 |
| 243 RECURSE(Visit(label)); | 244 RECURSE(Visit(label)); |
| 244 if (!clause_effects.IsEmpty()) complex_effects = true; | 245 if (!clause_effects.IsEmpty()) complex_effects = true; |
| 245 } | 246 } |
| 246 | 247 |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 RECURSE(Visit(expr->then_expression())); | 385 RECURSE(Visit(expr->then_expression())); |
| 385 ExitEffects(); | 386 ExitEffects(); |
| 386 Effects else_effects = EnterEffects(); | 387 Effects else_effects = EnterEffects(); |
| 387 RECURSE(Visit(expr->else_expression())); | 388 RECURSE(Visit(expr->else_expression())); |
| 388 ExitEffects(); | 389 ExitEffects(); |
| 389 then_effects.Alt(else_effects); | 390 then_effects.Alt(else_effects); |
| 390 store_.Seq(then_effects); | 391 store_.Seq(then_effects); |
| 391 | 392 |
| 392 NarrowType(expr, Bounds::Either( | 393 NarrowType(expr, Bounds::Either( |
| 393 expr->then_expression()->bounds(), | 394 expr->then_expression()->bounds(), |
| 394 expr->else_expression()->bounds(), isolate_)); | 395 expr->else_expression()->bounds(), zone())); |
| 395 } | 396 } |
| 396 | 397 |
| 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 Handle<Type> type = Type::Constant(expr->value(), isolate_); | 408 Type* type = Type::Constant(expr->value(), zone()); |
| 408 NarrowType(expr, Bounds(type)); | 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(zone()))); |
| 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(zone()))); |
| 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(zone()))); |
| 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 Loading... |
| 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(zone()))); |
| 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 Loading... |
| 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(zone()))); |
| 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(zone()))); |
| 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(zone()))); |
| 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(isolate_), Type::Number(isolate_))); | 620 NarrowType(expr, Bounds(Type::Smi(zone()), Type::Number(zone()))); |
| 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. |
| 630 Handle<Type> type, left_type, right_type; | 631 Type* type; |
| 632 Type* left_type; |
| 633 Type* right_type; |
| 631 Maybe<int> fixed_right_arg; | 634 Maybe<int> fixed_right_arg; |
| 632 oracle()->BinaryType(expr->BinaryOperationFeedbackId(), | 635 oracle()->BinaryType(expr->BinaryOperationFeedbackId(), |
| 633 &left_type, &right_type, &type, &fixed_right_arg, expr->op()); | 636 &left_type, &right_type, &type, &fixed_right_arg, expr->op()); |
| 634 NarrowLowerType(expr, type); | 637 NarrowLowerType(expr, type); |
| 635 NarrowLowerType(expr->left(), left_type); | 638 NarrowLowerType(expr->left(), left_type); |
| 636 NarrowLowerType(expr->right(), right_type); | 639 NarrowLowerType(expr->right(), right_type); |
| 637 expr->set_fixed_right_arg(fixed_right_arg); | 640 expr->set_fixed_right_arg(fixed_right_arg); |
| 638 if (expr->op() == Token::OR || expr->op() == Token::AND) { | 641 if (expr->op() == Token::OR || expr->op() == Token::AND) { |
| 639 expr->left()->RecordToBooleanTypeFeedback(oracle()); | 642 expr->left()->RecordToBooleanTypeFeedback(oracle()); |
| 640 } | 643 } |
| 641 | 644 |
| 642 switch (expr->op()) { | 645 switch (expr->op()) { |
| 643 case Token::COMMA: | 646 case Token::COMMA: |
| 644 RECURSE(Visit(expr->left())); | 647 RECURSE(Visit(expr->left())); |
| 645 RECURSE(Visit(expr->right())); | 648 RECURSE(Visit(expr->right())); |
| 646 NarrowType(expr, expr->right()->bounds()); | 649 NarrowType(expr, expr->right()->bounds()); |
| 647 break; | 650 break; |
| 648 case Token::OR: | 651 case Token::OR: |
| 649 case Token::AND: { | 652 case Token::AND: { |
| 650 Effects left_effects = EnterEffects(); | 653 Effects left_effects = EnterEffects(); |
| 651 RECURSE(Visit(expr->left())); | 654 RECURSE(Visit(expr->left())); |
| 652 ExitEffects(); | 655 ExitEffects(); |
| 653 Effects right_effects = EnterEffects(); | 656 Effects right_effects = EnterEffects(); |
| 654 RECURSE(Visit(expr->right())); | 657 RECURSE(Visit(expr->right())); |
| 655 ExitEffects(); | 658 ExitEffects(); |
| 656 left_effects.Alt(right_effects); | 659 left_effects.Alt(right_effects); |
| 657 store_.Seq(left_effects); | 660 store_.Seq(left_effects); |
| 658 | 661 |
| 659 NarrowType(expr, Bounds::Either( | 662 NarrowType(expr, Bounds::Either( |
| 660 expr->left()->bounds(), expr->right()->bounds(), isolate_)); | 663 expr->left()->bounds(), expr->right()->bounds(), zone())); |
| 661 break; | 664 break; |
| 662 } | 665 } |
| 663 case Token::BIT_OR: | 666 case Token::BIT_OR: |
| 664 case Token::BIT_AND: { | 667 case Token::BIT_AND: { |
| 665 RECURSE(Visit(expr->left())); | 668 RECURSE(Visit(expr->left())); |
| 666 RECURSE(Visit(expr->right())); | 669 RECURSE(Visit(expr->right())); |
| 667 Handle<Type> upper = Type::Union( | 670 Type* upper = Type::Union( |
| 668 expr->left()->bounds().upper, expr->right()->bounds().upper, | 671 expr->left()->bounds().upper, expr->right()->bounds().upper, zone()); |
| 669 isolate_); | 672 if (!upper->Is(Type::Signed32())) upper = Type::Signed32(zone()); |
| 670 if (!upper->Is(Type::Signed32())) | 673 Type* lower = Type::Intersect(Type::Smi(zone()), upper, zone()); |
| 671 upper = Type::Signed32(isolate_); | |
| 672 Handle<Type> lower = | |
| 673 Type::Intersect(Type::Smi(isolate_), upper, isolate_); | |
| 674 NarrowType(expr, Bounds(lower, upper)); | 674 NarrowType(expr, Bounds(lower, upper)); |
| 675 break; | 675 break; |
| 676 } | 676 } |
| 677 case Token::BIT_XOR: | 677 case Token::BIT_XOR: |
| 678 case Token::SHL: | 678 case Token::SHL: |
| 679 case Token::SAR: | 679 case Token::SAR: |
| 680 RECURSE(Visit(expr->left())); | 680 RECURSE(Visit(expr->left())); |
| 681 RECURSE(Visit(expr->right())); | 681 RECURSE(Visit(expr->right())); |
| 682 NarrowType(expr, Bounds(Type::Smi(isolate_), Type::Signed32(isolate_))); | 682 NarrowType(expr, Bounds(Type::Smi(zone()), Type::Signed32(zone()))); |
| 683 break; | 683 break; |
| 684 case Token::SHR: | 684 case Token::SHR: |
| 685 RECURSE(Visit(expr->left())); | 685 RECURSE(Visit(expr->left())); |
| 686 RECURSE(Visit(expr->right())); | 686 RECURSE(Visit(expr->right())); |
| 687 // TODO(rossberg): The upper bound would be Unsigned32, but since there | 687 // TODO(rossberg): The upper bound would be Unsigned32, but since there |
| 688 // is no 'positive Smi' type for the lower bound, we use the smallest | 688 // is no 'positive Smi' type for the lower bound, we use the smallest |
| 689 // union of Smi and Unsigned32 as upper bound instead. | 689 // union of Smi and Unsigned32 as upper bound instead. |
| 690 NarrowType(expr, Bounds(Type::Smi(isolate_), Type::Number(isolate_))); | 690 NarrowType(expr, Bounds(Type::Smi(zone()), Type::Number(zone()))); |
| 691 break; | 691 break; |
| 692 case Token::ADD: { | 692 case Token::ADD: { |
| 693 RECURSE(Visit(expr->left())); | 693 RECURSE(Visit(expr->left())); |
| 694 RECURSE(Visit(expr->right())); | 694 RECURSE(Visit(expr->right())); |
| 695 Bounds l = expr->left()->bounds(); | 695 Bounds l = expr->left()->bounds(); |
| 696 Bounds r = expr->right()->bounds(); | 696 Bounds r = expr->right()->bounds(); |
| 697 Handle<Type> lower = | 697 Type* lower = |
| 698 l.lower->Is(Type::None()) || r.lower->Is(Type::None()) ? | 698 l.lower->Is(Type::None()) || r.lower->Is(Type::None()) ? |
| 699 Type::None(isolate_) : | 699 Type::None(zone()) : |
| 700 l.lower->Is(Type::String()) || r.lower->Is(Type::String()) ? | 700 l.lower->Is(Type::String()) || r.lower->Is(Type::String()) ? |
| 701 Type::String(isolate_) : | 701 Type::String(zone()) : |
| 702 l.lower->Is(Type::Number()) && r.lower->Is(Type::Number()) ? | 702 l.lower->Is(Type::Number()) && r.lower->Is(Type::Number()) ? |
| 703 Type::Smi(isolate_) : Type::None(isolate_); | 703 Type::Smi(zone()) : Type::None(zone()); |
| 704 Handle<Type> upper = | 704 Type* upper = |
| 705 l.upper->Is(Type::String()) || r.upper->Is(Type::String()) ? | 705 l.upper->Is(Type::String()) || r.upper->Is(Type::String()) ? |
| 706 Type::String(isolate_) : | 706 Type::String(zone()) : |
| 707 l.upper->Is(Type::Number()) && r.upper->Is(Type::Number()) ? | 707 l.upper->Is(Type::Number()) && r.upper->Is(Type::Number()) ? |
| 708 Type::Number(isolate_) : Type::NumberOrString(isolate_); | 708 Type::Number(zone()) : Type::NumberOrString(zone()); |
| 709 NarrowType(expr, Bounds(lower, upper)); | 709 NarrowType(expr, Bounds(lower, upper)); |
| 710 break; | 710 break; |
| 711 } | 711 } |
| 712 case Token::SUB: | 712 case Token::SUB: |
| 713 case Token::MUL: | 713 case Token::MUL: |
| 714 case Token::DIV: | 714 case Token::DIV: |
| 715 case Token::MOD: | 715 case Token::MOD: |
| 716 RECURSE(Visit(expr->left())); | 716 RECURSE(Visit(expr->left())); |
| 717 RECURSE(Visit(expr->right())); | 717 RECURSE(Visit(expr->right())); |
| 718 NarrowType(expr, Bounds(Type::Smi(isolate_), Type::Number(isolate_))); | 718 NarrowType(expr, Bounds(Type::Smi(zone()), Type::Number(zone()))); |
| 719 break; | 719 break; |
| 720 default: | 720 default: |
| 721 UNREACHABLE(); | 721 UNREACHABLE(); |
| 722 } | 722 } |
| 723 } | 723 } |
| 724 | 724 |
| 725 | 725 |
| 726 void AstTyper::VisitCompareOperation(CompareOperation* expr) { | 726 void AstTyper::VisitCompareOperation(CompareOperation* expr) { |
| 727 // Collect type feedback. | 727 // Collect type feedback. |
| 728 Handle<Type> left_type, right_type, combined_type; | 728 Type* left_type; |
| 729 Type* right_type; |
| 730 Type* combined_type; |
| 729 oracle()->CompareType(expr->CompareOperationFeedbackId(), | 731 oracle()->CompareType(expr->CompareOperationFeedbackId(), |
| 730 &left_type, &right_type, &combined_type); | 732 &left_type, &right_type, &combined_type); |
| 731 NarrowLowerType(expr->left(), left_type); | 733 NarrowLowerType(expr->left(), left_type); |
| 732 NarrowLowerType(expr->right(), right_type); | 734 NarrowLowerType(expr->right(), right_type); |
| 733 expr->set_combined_type(combined_type); | 735 expr->set_combined_type(combined_type); |
| 734 | 736 |
| 735 RECURSE(Visit(expr->left())); | 737 RECURSE(Visit(expr->left())); |
| 736 RECURSE(Visit(expr->right())); | 738 RECURSE(Visit(expr->right())); |
| 737 | 739 |
| 738 NarrowType(expr, Bounds(Type::Boolean(isolate_))); | 740 NarrowType(expr, Bounds(Type::Boolean(zone()))); |
| 739 } | 741 } |
| 740 | 742 |
| 741 | 743 |
| 742 void AstTyper::VisitThisFunction(ThisFunction* expr) { | 744 void AstTyper::VisitThisFunction(ThisFunction* expr) { |
| 743 } | 745 } |
| 744 | 746 |
| 745 | 747 |
| 746 void AstTyper::VisitDeclarations(ZoneList<Declaration*>* decls) { | 748 void AstTyper::VisitDeclarations(ZoneList<Declaration*>* decls) { |
| 747 for (int i = 0; i < decls->length(); ++i) { | 749 for (int i = 0; i < decls->length(); ++i) { |
| 748 Declaration* decl = decls->at(i); | 750 Declaration* decl = decls->at(i); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 791 void AstTyper::VisitModuleUrl(ModuleUrl* module) { | 793 void AstTyper::VisitModuleUrl(ModuleUrl* module) { |
| 792 } | 794 } |
| 793 | 795 |
| 794 | 796 |
| 795 void AstTyper::VisitModuleStatement(ModuleStatement* stmt) { | 797 void AstTyper::VisitModuleStatement(ModuleStatement* stmt) { |
| 796 RECURSE(Visit(stmt->body())); | 798 RECURSE(Visit(stmt->body())); |
| 797 } | 799 } |
| 798 | 800 |
| 799 | 801 |
| 800 } } // namespace v8::internal | 802 } } // namespace v8::internal |
| OLD | NEW |