| 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 10 matching lines...) Expand all Loading... |
| 21 handle(info->closure()->shared()->feedback_vector()), | 21 handle(info->closure()->shared()->feedback_vector()), |
| 22 handle(info->closure()->context()->native_context()), | 22 handle(info->closure()->context()->native_context()), |
| 23 info->zone()), | 23 info->zone()), |
| 24 store_(info->zone()) { | 24 store_(info->zone()) { |
| 25 InitializeAstVisitor(info->zone()); | 25 InitializeAstVisitor(info->zone()); |
| 26 } | 26 } |
| 27 | 27 |
| 28 | 28 |
| 29 #define RECURSE(call) \ | 29 #define RECURSE(call) \ |
| 30 do { \ | 30 do { \ |
| 31 ASSERT(!visitor->HasStackOverflow()); \ | 31 DCHECK(!visitor->HasStackOverflow()); \ |
| 32 call; \ | 32 call; \ |
| 33 if (visitor->HasStackOverflow()) return; \ | 33 if (visitor->HasStackOverflow()) return; \ |
| 34 } while (false) | 34 } while (false) |
| 35 | 35 |
| 36 void AstTyper::Run(CompilationInfo* info) { | 36 void AstTyper::Run(CompilationInfo* info) { |
| 37 AstTyper* visitor = new(info->zone()) AstTyper(info); | 37 AstTyper* visitor = new(info->zone()) AstTyper(info); |
| 38 Scope* scope = info->scope(); | 38 Scope* scope = info->scope(); |
| 39 | 39 |
| 40 // Handle implicit declaration of the function name in named function | 40 // Handle implicit declaration of the function name in named function |
| 41 // expressions before other declarations. | 41 // expressions before other declarations. |
| (...skipping 27 matching lines...) Expand all Loading... |
| 69 | 69 |
| 70 void AstTyper::ObserveTypesAtOsrEntry(IterationStatement* stmt) { | 70 void AstTyper::ObserveTypesAtOsrEntry(IterationStatement* stmt) { |
| 71 if (stmt->OsrEntryId() != info_->osr_ast_id()) return; | 71 if (stmt->OsrEntryId() != info_->osr_ast_id()) return; |
| 72 | 72 |
| 73 DisallowHeapAllocation no_gc; | 73 DisallowHeapAllocation no_gc; |
| 74 JavaScriptFrameIterator it(isolate()); | 74 JavaScriptFrameIterator it(isolate()); |
| 75 JavaScriptFrame* frame = it.frame(); | 75 JavaScriptFrame* frame = it.frame(); |
| 76 Scope* scope = info_->scope(); | 76 Scope* scope = info_->scope(); |
| 77 | 77 |
| 78 // Assert that the frame on the stack belongs to the function we want to OSR. | 78 // Assert that the frame on the stack belongs to the function we want to OSR. |
| 79 ASSERT_EQ(*info_->closure(), frame->function()); | 79 DCHECK_EQ(*info_->closure(), frame->function()); |
| 80 | 80 |
| 81 int params = scope->num_parameters(); | 81 int params = scope->num_parameters(); |
| 82 int locals = scope->StackLocalCount(); | 82 int locals = scope->StackLocalCount(); |
| 83 | 83 |
| 84 // Use sequential composition to achieve desired narrowing. | 84 // Use sequential composition to achieve desired narrowing. |
| 85 // The receiver is a parameter with index -1. | 85 // The receiver is a parameter with index -1. |
| 86 store_.Seq(parameter_index(-1), ObservedOnStack(frame->receiver())); | 86 store_.Seq(parameter_index(-1), ObservedOnStack(frame->receiver())); |
| 87 for (int i = 0; i < params; i++) { | 87 for (int i = 0; i < params; i++) { |
| 88 store_.Seq(parameter_index(i), ObservedOnStack(frame->GetParameter(i))); | 88 store_.Seq(parameter_index(i), ObservedOnStack(frame->GetParameter(i))); |
| 89 } | 89 } |
| (...skipping 22 matching lines...) Expand all Loading... |
| 112 frame->GetExpression(i), | 112 frame->GetExpression(i), |
| 113 store_.LookupBounds(stack_local_index(i)).lower); | 113 store_.LookupBounds(stack_local_index(i)).lower); |
| 114 } | 114 } |
| 115 } | 115 } |
| 116 #endif // OBJECT_PRINT | 116 #endif // OBJECT_PRINT |
| 117 } | 117 } |
| 118 | 118 |
| 119 | 119 |
| 120 #define RECURSE(call) \ | 120 #define RECURSE(call) \ |
| 121 do { \ | 121 do { \ |
| 122 ASSERT(!HasStackOverflow()); \ | 122 DCHECK(!HasStackOverflow()); \ |
| 123 call; \ | 123 call; \ |
| 124 if (HasStackOverflow()) return; \ | 124 if (HasStackOverflow()) return; \ |
| 125 } while (false) | 125 } while (false) |
| 126 | 126 |
| 127 | 127 |
| 128 void AstTyper::VisitStatements(ZoneList<Statement*>* stmts) { | 128 void AstTyper::VisitStatements(ZoneList<Statement*>* stmts) { |
| 129 for (int i = 0; i < stmts->length(); ++i) { | 129 for (int i = 0; i < stmts->length(); ++i) { |
| 130 Statement* stmt = stmts->at(i); | 130 Statement* stmt = stmts->at(i); |
| 131 RECURSE(Visit(stmt)); | 131 RECURSE(Visit(stmt)); |
| 132 if (stmt->IsJump()) break; | 132 if (stmt->IsJump()) break; |
| (...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 | 429 |
| 430 void AstTyper::VisitAssignment(Assignment* expr) { | 430 void AstTyper::VisitAssignment(Assignment* expr) { |
| 431 // Collect type feedback. | 431 // Collect type feedback. |
| 432 Property* prop = expr->target()->AsProperty(); | 432 Property* prop = expr->target()->AsProperty(); |
| 433 if (prop != NULL) { | 433 if (prop != NULL) { |
| 434 TypeFeedbackId id = expr->AssignmentFeedbackId(); | 434 TypeFeedbackId id = expr->AssignmentFeedbackId(); |
| 435 expr->set_is_uninitialized(oracle()->StoreIsUninitialized(id)); | 435 expr->set_is_uninitialized(oracle()->StoreIsUninitialized(id)); |
| 436 if (!expr->IsUninitialized()) { | 436 if (!expr->IsUninitialized()) { |
| 437 if (prop->key()->IsPropertyName()) { | 437 if (prop->key()->IsPropertyName()) { |
| 438 Literal* lit_key = prop->key()->AsLiteral(); | 438 Literal* lit_key = prop->key()->AsLiteral(); |
| 439 ASSERT(lit_key != NULL && lit_key->value()->IsString()); | 439 DCHECK(lit_key != NULL && lit_key->value()->IsString()); |
| 440 Handle<String> name = Handle<String>::cast(lit_key->value()); | 440 Handle<String> name = Handle<String>::cast(lit_key->value()); |
| 441 oracle()->AssignmentReceiverTypes(id, name, expr->GetReceiverTypes()); | 441 oracle()->AssignmentReceiverTypes(id, name, expr->GetReceiverTypes()); |
| 442 } else { | 442 } else { |
| 443 KeyedAccessStoreMode store_mode; | 443 KeyedAccessStoreMode store_mode; |
| 444 oracle()->KeyedAssignmentReceiverTypes( | 444 oracle()->KeyedAssignmentReceiverTypes( |
| 445 id, expr->GetReceiverTypes(), &store_mode); | 445 id, expr->GetReceiverTypes(), &store_mode); |
| 446 expr->set_store_mode(store_mode); | 446 expr->set_store_mode(store_mode); |
| 447 } | 447 } |
| 448 } | 448 } |
| 449 } | 449 } |
| (...skipping 27 matching lines...) Expand all Loading... |
| 477 } | 477 } |
| 478 | 478 |
| 479 | 479 |
| 480 void AstTyper::VisitProperty(Property* expr) { | 480 void AstTyper::VisitProperty(Property* expr) { |
| 481 // Collect type feedback. | 481 // Collect type feedback. |
| 482 TypeFeedbackId id = expr->PropertyFeedbackId(); | 482 TypeFeedbackId id = expr->PropertyFeedbackId(); |
| 483 expr->set_is_uninitialized(oracle()->LoadIsUninitialized(id)); | 483 expr->set_is_uninitialized(oracle()->LoadIsUninitialized(id)); |
| 484 if (!expr->IsUninitialized()) { | 484 if (!expr->IsUninitialized()) { |
| 485 if (expr->key()->IsPropertyName()) { | 485 if (expr->key()->IsPropertyName()) { |
| 486 Literal* lit_key = expr->key()->AsLiteral(); | 486 Literal* lit_key = expr->key()->AsLiteral(); |
| 487 ASSERT(lit_key != NULL && lit_key->value()->IsString()); | 487 DCHECK(lit_key != NULL && lit_key->value()->IsString()); |
| 488 Handle<String> name = Handle<String>::cast(lit_key->value()); | 488 Handle<String> name = Handle<String>::cast(lit_key->value()); |
| 489 oracle()->PropertyReceiverTypes(id, name, expr->GetReceiverTypes()); | 489 oracle()->PropertyReceiverTypes(id, name, expr->GetReceiverTypes()); |
| 490 } else { | 490 } else { |
| 491 bool is_string; | 491 bool is_string; |
| 492 oracle()->KeyedPropertyReceiverTypes( | 492 oracle()->KeyedPropertyReceiverTypes( |
| 493 id, expr->GetReceiverTypes(), &is_string); | 493 id, expr->GetReceiverTypes(), &is_string); |
| 494 expr->set_is_string_access(is_string); | 494 expr->set_is_string_access(is_string); |
| 495 } | 495 } |
| 496 } | 496 } |
| 497 | 497 |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 771 void AstTyper::VisitModuleUrl(ModuleUrl* module) { | 771 void AstTyper::VisitModuleUrl(ModuleUrl* module) { |
| 772 } | 772 } |
| 773 | 773 |
| 774 | 774 |
| 775 void AstTyper::VisitModuleStatement(ModuleStatement* stmt) { | 775 void AstTyper::VisitModuleStatement(ModuleStatement* stmt) { |
| 776 RECURSE(Visit(stmt->body())); | 776 RECURSE(Visit(stmt->body())); |
| 777 } | 777 } |
| 778 | 778 |
| 779 | 779 |
| 780 } } // namespace v8::internal | 780 } } // namespace v8::internal |
| OLD | NEW |