| 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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 if (switch_type == SwitchStatement::UNKNOWN_SWITCH) | 193 if (switch_type == SwitchStatement::UNKNOWN_SWITCH) |
| 194 switch_type = SwitchStatement::GENERIC_SWITCH; | 194 switch_type = SwitchStatement::GENERIC_SWITCH; |
| 195 stmt->set_switch_type(switch_type); | 195 stmt->set_switch_type(switch_type); |
| 196 | 196 |
| 197 // Collect type feedback. | 197 // Collect type feedback. |
| 198 // TODO(rossberg): can we eliminate this special case and extra loop? | 198 // TODO(rossberg): can we eliminate this special case and extra loop? |
| 199 if (switch_type == SwitchStatement::SMI_SWITCH) { | 199 if (switch_type == SwitchStatement::SMI_SWITCH) { |
| 200 for (int i = 0; i < clauses->length(); ++i) { | 200 for (int i = 0; i < clauses->length(); ++i) { |
| 201 CaseClause* clause = clauses->at(i); | 201 CaseClause* clause = clauses->at(i); |
| 202 if (!clause->is_default()) | 202 if (!clause->is_default()) |
| 203 clause->RecordTypeFeedback(oracle()); | 203 clause->set_compare_type(oracle()->ClauseType(clause->CompareId())); |
| 204 } | 204 } |
| 205 } | 205 } |
| 206 } | 206 } |
| 207 | 207 |
| 208 | 208 |
| 209 void AstTyper::VisitCaseClause(CaseClause* clause) { | 209 void AstTyper::VisitCaseClause(CaseClause* clause) { |
| 210 UNREACHABLE(); | 210 UNREACHABLE(); |
| 211 } | 211 } |
| 212 | 212 |
| 213 | 213 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 if (stmt->next() != NULL) { | 255 if (stmt->next() != NULL) { |
| 256 store_.Forget(); // Control may transfer here via 'continue'. | 256 store_.Forget(); // Control may transfer here via 'continue'. |
| 257 RECURSE(Visit(stmt->next())); | 257 RECURSE(Visit(stmt->next())); |
| 258 } | 258 } |
| 259 store_.Forget(); // Control may transfer here via termination or 'break'. | 259 store_.Forget(); // Control may transfer here via termination or 'break'. |
| 260 } | 260 } |
| 261 | 261 |
| 262 | 262 |
| 263 void AstTyper::VisitForInStatement(ForInStatement* stmt) { | 263 void AstTyper::VisitForInStatement(ForInStatement* stmt) { |
| 264 // Collect type feedback. | 264 // Collect type feedback. |
| 265 stmt->RecordTypeFeedback(oracle()); | 265 stmt->set_for_in_type(static_cast<ForInStatement::ForInType>( |
| 266 oracle()->ForInType(stmt->ForInFeedbackId()))); |
| 266 | 267 |
| 267 RECURSE(Visit(stmt->enumerable())); | 268 RECURSE(Visit(stmt->enumerable())); |
| 268 store_.Forget(); // Control may transfer here via looping or 'continue'. | 269 store_.Forget(); // Control may transfer here via looping or 'continue'. |
| 269 RECURSE(Visit(stmt->body())); | 270 RECURSE(Visit(stmt->body())); |
| 270 store_.Forget(); // Control may transfer here via 'break'. | 271 store_.Forget(); // Control may transfer here via 'break'. |
| 271 } | 272 } |
| 272 | 273 |
| 273 | 274 |
| 274 void AstTyper::VisitForOfStatement(ForOfStatement* stmt) { | 275 void AstTyper::VisitForOfStatement(ForOfStatement* stmt) { |
| 275 RECURSE(Visit(stmt->iterable())); | 276 RECURSE(Visit(stmt->iterable())); |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 } | 386 } |
| 386 | 387 |
| 387 | 388 |
| 388 void AstTyper::VisitAssignment(Assignment* expr) { | 389 void AstTyper::VisitAssignment(Assignment* expr) { |
| 389 // TODO(rossberg): Can we clean this up? | 390 // TODO(rossberg): Can we clean this up? |
| 390 if (expr->is_compound()) { | 391 if (expr->is_compound()) { |
| 391 // Collect type feedback. | 392 // Collect type feedback. |
| 392 Expression* target = expr->target(); | 393 Expression* target = expr->target(); |
| 393 Property* prop = target->AsProperty(); | 394 Property* prop = target->AsProperty(); |
| 394 if (prop != NULL) { | 395 if (prop != NULL) { |
| 395 prop->RecordTypeFeedback(oracle(), zone()); | 396 RECURSE(Visit(expr->target())); |
| 396 expr->RecordTypeFeedback(oracle(), zone()); | 397 expr->RecordTypeFeedback(oracle(), zone()); |
| 397 } | 398 } |
| 398 | 399 |
| 399 RECURSE(Visit(expr->binary_operation())); | 400 RECURSE(Visit(expr->binary_operation())); |
| 400 | 401 |
| 401 NarrowType(expr, expr->binary_operation()->bounds()); | 402 NarrowType(expr, expr->binary_operation()->bounds()); |
| 402 } else { | 403 } else { |
| 403 // Collect type feedback. | 404 // Collect type feedback. |
| 404 if (expr->target()->IsProperty()) { | 405 if (expr->target()->IsProperty()) { |
| 405 expr->RecordTypeFeedback(oracle(), zone()); | 406 expr->RecordTypeFeedback(oracle(), zone()); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 429 void AstTyper::VisitThrow(Throw* expr) { | 430 void AstTyper::VisitThrow(Throw* expr) { |
| 430 RECURSE(Visit(expr->exception())); | 431 RECURSE(Visit(expr->exception())); |
| 431 // TODO(rossberg): is it worth having a non-termination effect? | 432 // TODO(rossberg): is it worth having a non-termination effect? |
| 432 | 433 |
| 433 NarrowType(expr, Bounds(Type::None(), isolate_)); | 434 NarrowType(expr, Bounds(Type::None(), isolate_)); |
| 434 } | 435 } |
| 435 | 436 |
| 436 | 437 |
| 437 void AstTyper::VisitProperty(Property* expr) { | 438 void AstTyper::VisitProperty(Property* expr) { |
| 438 // Collect type feedback. | 439 // Collect type feedback. |
| 439 expr->RecordTypeFeedback(oracle(), zone()); | 440 TypeFeedbackId id = expr->PropertyFeedbackId(); |
| 441 expr->set_is_uninitialized(oracle()->LoadIsUninitialized(id)); |
| 442 if (!expr->IsUninitialized()) { |
| 443 expr->set_is_pre_monomorphic(oracle()->LoadIsPreMonomorphic(id)); |
| 444 expr->set_is_monomorphic(oracle()->LoadIsMonomorphicNormal(id)); |
| 445 ASSERT(!expr->IsPreMonomorphic() || !expr->IsMonomorphic()); |
| 446 if (expr->key()->IsPropertyName()) { |
| 447 Literal* lit_key = expr->key()->AsLiteral(); |
| 448 ASSERT(lit_key != NULL && lit_key->value()->IsString()); |
| 449 Handle<String> name = Handle<String>::cast(lit_key->value()); |
| 450 bool is_prototype; |
| 451 oracle()->PropertyReceiverTypes( |
| 452 id, name, expr->GetReceiverTypes(), &is_prototype); |
| 453 expr->set_is_function_prototype(is_prototype); |
| 454 } else { |
| 455 bool is_string; |
| 456 oracle()->KeyedPropertyReceiverTypes( |
| 457 id, expr->GetReceiverTypes(), &is_string); |
| 458 expr->set_is_string_access(is_string); |
| 459 } |
| 460 } |
| 440 | 461 |
| 441 RECURSE(Visit(expr->obj())); | 462 RECURSE(Visit(expr->obj())); |
| 442 RECURSE(Visit(expr->key())); | 463 RECURSE(Visit(expr->key())); |
| 443 | 464 |
| 444 // We don't know anything about the result type. | 465 // We don't know anything about the result type. |
| 445 } | 466 } |
| 446 | 467 |
| 447 | 468 |
| 448 void AstTyper::VisitCall(Call* expr) { | 469 void AstTyper::VisitCall(Call* expr) { |
| 449 // Collect type feedback. | 470 // Collect type feedback. |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 518 NarrowType(expr, Bounds(Type::InternalizedString(), isolate_)); | 539 NarrowType(expr, Bounds(Type::InternalizedString(), isolate_)); |
| 519 break; | 540 break; |
| 520 default: | 541 default: |
| 521 UNREACHABLE(); | 542 UNREACHABLE(); |
| 522 } | 543 } |
| 523 } | 544 } |
| 524 | 545 |
| 525 | 546 |
| 526 void AstTyper::VisitCountOperation(CountOperation* expr) { | 547 void AstTyper::VisitCountOperation(CountOperation* expr) { |
| 527 // Collect type feedback. | 548 // Collect type feedback. |
| 528 expr->RecordTypeFeedback(oracle(), zone()); | 549 TypeFeedbackId store_id = expr->CountStoreFeedbackId(); |
| 529 Property* prop = expr->expression()->AsProperty(); | 550 expr->set_is_monomorphic(oracle()->StoreIsMonomorphicNormal(store_id)); |
| 530 if (prop != NULL) { | 551 expr->set_store_mode(oracle()->GetStoreMode(store_id)); |
| 531 prop->RecordTypeFeedback(oracle(), zone()); | 552 oracle()->CountReceiverTypes(store_id, expr->GetReceiverTypes()); |
| 532 } | 553 expr->set_type(oracle()->CountType(expr->CountBinOpFeedbackId())); |
| 554 // TODO(rossberg): merge the count type with the generic expression type. |
| 533 | 555 |
| 534 RECURSE(Visit(expr->expression())); | 556 RECURSE(Visit(expr->expression())); |
| 535 | 557 |
| 536 NarrowType(expr, Bounds(Type::Smi(), Type::Number(), isolate_)); | 558 NarrowType(expr, Bounds(Type::Smi(), Type::Number(), isolate_)); |
| 537 | 559 |
| 538 VariableProxy* proxy = expr->expression()->AsVariableProxy(); | 560 VariableProxy* proxy = expr->expression()->AsVariableProxy(); |
| 539 if (proxy != NULL && proxy->var()->IsStackAllocated()) { | 561 if (proxy != NULL && proxy->var()->IsStackAllocated()) { |
| 540 store_.Seq(variable_index(proxy->var()), Effect(expr->bounds())); | 562 store_.Seq(variable_index(proxy->var()), Effect(expr->bounds())); |
| 541 } | 563 } |
| 542 } | 564 } |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 709 void AstTyper::VisitModuleUrl(ModuleUrl* module) { | 731 void AstTyper::VisitModuleUrl(ModuleUrl* module) { |
| 710 } | 732 } |
| 711 | 733 |
| 712 | 734 |
| 713 void AstTyper::VisitModuleStatement(ModuleStatement* stmt) { | 735 void AstTyper::VisitModuleStatement(ModuleStatement* stmt) { |
| 714 RECURSE(Visit(stmt->body())); | 736 RECURSE(Visit(stmt->body())); |
| 715 } | 737 } |
| 716 | 738 |
| 717 | 739 |
| 718 } } // namespace v8::internal | 740 } } // namespace v8::internal |
| OLD | NEW |