| 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 |
| 11 // with the distribution. | 11 // with the distribution. |
| 12 // * Neither the name of Google Inc. nor the names of its | 12 // * Neither the name of Google Inc. nor the names of its |
| 13 // contributors may be used to endorse or promote products derived | 13 // contributors may be used to endorse or promote products derived |
| 14 // from this software without specific prior written permission. | 14 // from this software without specific prior written permission. |
| 15 // | 15 // |
| 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 #include "typing.h" | 28 #include "typing.h" |
| 29 | 29 |
| 30 #include "frames.h" |
| 31 #include "frames-inl.h" |
| 30 #include "parser.h" // for CompileTimeValue; TODO(rossberg): should move | 32 #include "parser.h" // for CompileTimeValue; TODO(rossberg): should move |
| 31 #include "scopes.h" | 33 #include "scopes.h" |
| 32 | 34 |
| 33 namespace v8 { | 35 namespace v8 { |
| 34 namespace internal { | 36 namespace internal { |
| 35 | 37 |
| 36 | 38 |
| 37 AstTyper::AstTyper(CompilationInfo* info) | 39 AstTyper::AstTyper(CompilationInfo* info) |
| 38 : info_(info), | 40 : info_(info), |
| 39 oracle_( | 41 oracle_( |
| (...skipping 21 matching lines...) Expand all Loading... |
| 61 // expressions before other declarations. | 63 // expressions before other declarations. |
| 62 if (scope->is_function_scope() && scope->function() != NULL) { | 64 if (scope->is_function_scope() && scope->function() != NULL) { |
| 63 RECURSE(visitor->VisitVariableDeclaration(scope->function())); | 65 RECURSE(visitor->VisitVariableDeclaration(scope->function())); |
| 64 } | 66 } |
| 65 RECURSE(visitor->VisitDeclarations(scope->declarations())); | 67 RECURSE(visitor->VisitDeclarations(scope->declarations())); |
| 66 RECURSE(visitor->VisitStatements(info->function()->body())); | 68 RECURSE(visitor->VisitStatements(info->function()->body())); |
| 67 } | 69 } |
| 68 | 70 |
| 69 #undef RECURSE | 71 #undef RECURSE |
| 70 | 72 |
| 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 |
| 81 static void PrintObserved(Variable* var, Object* value, Handle<Type> type) { |
| 82 PrintF(" observed %s ", var->IsParameter() ? "param" : "local"); |
| 83 var->name()->Print(); |
| 84 PrintF(" : "); |
| 85 value->ShortPrint(); |
| 86 PrintF(" -> "); |
| 87 type->TypePrint(); |
| 88 } |
| 89 #endif // OBJECT_PRINT |
| 90 |
| 91 |
| 92 void AstTyper::ObserveTypesAtOsrEntry(IterationStatement* stmt) { |
| 93 if (stmt->OsrEntryId() != info_->osr_ast_id()) return; |
| 94 |
| 95 DisallowHeapAllocation no_gc; |
| 96 JavaScriptFrameIterator it(isolate()); |
| 97 JavaScriptFrame* frame = it.frame(); |
| 98 Scope* scope = info_->scope(); |
| 99 |
| 100 // Assert that the frame on the stack belongs to the function we want to OSR. |
| 101 ASSERT_EQ(*info_->closure(), frame->function()); |
| 102 |
| 103 int params = scope->num_parameters(); |
| 104 int locals = scope->StackLocalCount(); |
| 105 |
| 106 // Use sequential composition to achieve desired narrowing. |
| 107 // The receiver is a parameter with index -1. |
| 108 store_.Seq(parameter_index(-1), ObservedOnStack(frame->receiver())); |
| 109 for (int i = 0; i < params; i++) { |
| 110 store_.Seq(parameter_index(i), ObservedOnStack(frame->GetParameter(i))); |
| 111 } |
| 112 |
| 113 for (int i = 0; i < locals; i++) { |
| 114 store_.Seq(stack_local_index(i), ObservedOnStack(frame->GetExpression(i))); |
| 115 } |
| 116 |
| 117 #ifdef OBJECT_PRINT |
| 118 if (FLAG_trace_osr && FLAG_print_scopes) { |
| 119 PrintObserved(scope->receiver(), |
| 120 frame->receiver(), |
| 121 store_.LookupBounds(parameter_index(-1)).lower); |
| 122 |
| 123 for (int i = 0; i < params; i++) { |
| 124 PrintObserved(scope->parameter(i), |
| 125 frame->GetParameter(i), |
| 126 store_.LookupBounds(parameter_index(i)).lower); |
| 127 } |
| 128 |
| 129 ZoneList<Variable*> local_vars(locals, zone()); |
| 130 ZoneList<Variable*> context_vars(scope->ContextLocalCount(), zone()); |
| 131 scope->CollectStackAndContextLocals(&local_vars, &context_vars); |
| 132 for (int i = 0; i < locals; i++) { |
| 133 PrintObserved(local_vars.at(i), |
| 134 frame->GetExpression(i), |
| 135 store_.LookupBounds(stack_local_index(i)).lower); |
| 136 } |
| 137 } |
| 138 #endif // OBJECT_PRINT |
| 139 } |
| 140 |
| 141 |
| 71 #define RECURSE(call) \ | 142 #define RECURSE(call) \ |
| 72 do { \ | 143 do { \ |
| 73 ASSERT(!HasStackOverflow()); \ | 144 ASSERT(!HasStackOverflow()); \ |
| 74 call; \ | 145 call; \ |
| 75 if (HasStackOverflow()) return; \ | 146 if (HasStackOverflow()) return; \ |
| 76 } while (false) | 147 } while (false) |
| 77 | 148 |
| 78 | 149 |
| 79 void AstTyper::VisitStatements(ZoneList<Statement*>* stmts) { | 150 void AstTyper::VisitStatements(ZoneList<Statement*>* stmts) { |
| 80 for (int i = 0; i < stmts->length(); ++i) { | 151 for (int i = 0; i < stmts->length(); ++i) { |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 void AstTyper::VisitWithStatement(WithStatement* stmt) { | 215 void AstTyper::VisitWithStatement(WithStatement* stmt) { |
| 145 RECURSE(stmt->expression()); | 216 RECURSE(stmt->expression()); |
| 146 RECURSE(stmt->statement()); | 217 RECURSE(stmt->statement()); |
| 147 } | 218 } |
| 148 | 219 |
| 149 | 220 |
| 150 void AstTyper::VisitSwitchStatement(SwitchStatement* stmt) { | 221 void AstTyper::VisitSwitchStatement(SwitchStatement* stmt) { |
| 151 RECURSE(Visit(stmt->tag())); | 222 RECURSE(Visit(stmt->tag())); |
| 152 | 223 |
| 153 ZoneList<CaseClause*>* clauses = stmt->cases(); | 224 ZoneList<CaseClause*>* clauses = stmt->cases(); |
| 154 SwitchStatement::SwitchType switch_type = stmt->switch_type(); | |
| 155 Effects local_effects(zone()); | 225 Effects local_effects(zone()); |
| 156 bool complex_effects = false; // True for label effects or fall-through. | 226 bool complex_effects = false; // True for label effects or fall-through. |
| 157 | 227 |
| 158 for (int i = 0; i < clauses->length(); ++i) { | 228 for (int i = 0; i < clauses->length(); ++i) { |
| 159 CaseClause* clause = clauses->at(i); | 229 CaseClause* clause = clauses->at(i); |
| 230 |
| 160 Effects clause_effects = EnterEffects(); | 231 Effects clause_effects = EnterEffects(); |
| 161 | 232 |
| 162 if (!clause->is_default()) { | 233 if (!clause->is_default()) { |
| 163 Expression* label = clause->label(); | 234 Expression* label = clause->label(); |
| 164 SwitchStatement::SwitchType label_switch_type = | 235 // Collect type feedback. |
| 165 label->IsSmiLiteral() ? SwitchStatement::SMI_SWITCH : | 236 Handle<Type> tag_type, label_type, combined_type; |
| 166 label->IsStringLiteral() ? SwitchStatement::STRING_SWITCH : | 237 oracle()->CompareType(clause->CompareId(), |
| 167 SwitchStatement::GENERIC_SWITCH; | 238 &tag_type, &label_type, &combined_type); |
| 168 if (switch_type == SwitchStatement::UNKNOWN_SWITCH) | 239 NarrowLowerType(stmt->tag(), tag_type); |
| 169 switch_type = label_switch_type; | 240 NarrowLowerType(label, label_type); |
| 170 else if (switch_type != label_switch_type) | 241 clause->set_compare_type(combined_type); |
| 171 switch_type = SwitchStatement::GENERIC_SWITCH; | |
| 172 | 242 |
| 173 RECURSE(Visit(label)); | 243 RECURSE(Visit(label)); |
| 174 if (!clause_effects.IsEmpty()) complex_effects = true; | 244 if (!clause_effects.IsEmpty()) complex_effects = true; |
| 175 } | 245 } |
| 176 | 246 |
| 177 ZoneList<Statement*>* stmts = clause->statements(); | 247 ZoneList<Statement*>* stmts = clause->statements(); |
| 178 RECURSE(VisitStatements(stmts)); | 248 RECURSE(VisitStatements(stmts)); |
| 179 ExitEffects(); | 249 ExitEffects(); |
| 180 if (stmts->is_empty() || stmts->last()->IsJump()) { | 250 if (stmts->is_empty() || stmts->last()->IsJump()) { |
| 181 local_effects.Alt(clause_effects); | 251 local_effects.Alt(clause_effects); |
| 182 } else { | 252 } else { |
| 183 complex_effects = true; | 253 complex_effects = true; |
| 184 } | 254 } |
| 185 } | 255 } |
| 186 | 256 |
| 187 if (complex_effects) { | 257 if (complex_effects) { |
| 188 store_.Forget(); // Reached this in unknown state. | 258 store_.Forget(); // Reached this in unknown state. |
| 189 } else { | 259 } else { |
| 190 store_.Seq(local_effects); | 260 store_.Seq(local_effects); |
| 191 } | 261 } |
| 192 | |
| 193 if (switch_type == SwitchStatement::UNKNOWN_SWITCH) | |
| 194 switch_type = SwitchStatement::GENERIC_SWITCH; | |
| 195 stmt->set_switch_type(switch_type); | |
| 196 | |
| 197 // Collect type feedback. | |
| 198 // TODO(rossberg): can we eliminate this special case and extra loop? | |
| 199 if (switch_type == SwitchStatement::SMI_SWITCH) { | |
| 200 for (int i = 0; i < clauses->length(); ++i) { | |
| 201 CaseClause* clause = clauses->at(i); | |
| 202 if (!clause->is_default()) | |
| 203 clause->set_compare_type(oracle()->ClauseType(clause->CompareId())); | |
| 204 } | |
| 205 } | |
| 206 } | 262 } |
| 207 | 263 |
| 208 | 264 |
| 209 void AstTyper::VisitCaseClause(CaseClause* clause) { | 265 void AstTyper::VisitCaseClause(CaseClause* clause) { |
| 210 UNREACHABLE(); | 266 UNREACHABLE(); |
| 211 } | 267 } |
| 212 | 268 |
| 213 | 269 |
| 214 void AstTyper::VisitDoWhileStatement(DoWhileStatement* stmt) { | 270 void AstTyper::VisitDoWhileStatement(DoWhileStatement* stmt) { |
| 215 // Collect type feedback. | 271 // Collect type feedback. |
| 216 if (!stmt->cond()->ToBooleanIsTrue()) { | 272 if (!stmt->cond()->ToBooleanIsTrue()) { |
| 217 stmt->cond()->RecordToBooleanTypeFeedback(oracle()); | 273 stmt->cond()->RecordToBooleanTypeFeedback(oracle()); |
| 218 } | 274 } |
| 219 | 275 |
| 220 // TODO(rossberg): refine the unconditional Forget (here and elsewhere) by | 276 // TODO(rossberg): refine the unconditional Forget (here and elsewhere) by |
| 221 // computing the set of variables assigned in only some of the origins of the | 277 // computing the set of variables assigned in only some of the origins of the |
| 222 // control transfer (such as the loop body here). | 278 // control transfer (such as the loop body here). |
| 223 store_.Forget(); // Control may transfer here via looping or 'continue'. | 279 store_.Forget(); // Control may transfer here via looping or 'continue'. |
| 280 ObserveTypesAtOsrEntry(stmt); |
| 224 RECURSE(Visit(stmt->body())); | 281 RECURSE(Visit(stmt->body())); |
| 225 RECURSE(Visit(stmt->cond())); | 282 RECURSE(Visit(stmt->cond())); |
| 226 store_.Forget(); // Control may transfer here via 'break'. | 283 store_.Forget(); // Control may transfer here via 'break'. |
| 227 } | 284 } |
| 228 | 285 |
| 229 | 286 |
| 230 void AstTyper::VisitWhileStatement(WhileStatement* stmt) { | 287 void AstTyper::VisitWhileStatement(WhileStatement* stmt) { |
| 231 // Collect type feedback. | 288 // Collect type feedback. |
| 232 if (!stmt->cond()->ToBooleanIsTrue()) { | 289 if (!stmt->cond()->ToBooleanIsTrue()) { |
| 233 stmt->cond()->RecordToBooleanTypeFeedback(oracle()); | 290 stmt->cond()->RecordToBooleanTypeFeedback(oracle()); |
| 234 } | 291 } |
| 235 | 292 |
| 236 store_.Forget(); // Control may transfer here via looping or 'continue'. | 293 store_.Forget(); // Control may transfer here via looping or 'continue'. |
| 237 RECURSE(Visit(stmt->cond())); | 294 RECURSE(Visit(stmt->cond())); |
| 295 ObserveTypesAtOsrEntry(stmt); |
| 238 RECURSE(Visit(stmt->body())); | 296 RECURSE(Visit(stmt->body())); |
| 239 store_.Forget(); // Control may transfer here via termination or 'break'. | 297 store_.Forget(); // Control may transfer here via termination or 'break'. |
| 240 } | 298 } |
| 241 | 299 |
| 242 | 300 |
| 243 void AstTyper::VisitForStatement(ForStatement* stmt) { | 301 void AstTyper::VisitForStatement(ForStatement* stmt) { |
| 244 if (stmt->init() != NULL) { | 302 if (stmt->init() != NULL) { |
| 245 RECURSE(Visit(stmt->init())); | 303 RECURSE(Visit(stmt->init())); |
| 246 } | 304 } |
| 247 store_.Forget(); // Control may transfer here via looping. | 305 store_.Forget(); // Control may transfer here via looping. |
| 248 if (stmt->cond() != NULL) { | 306 if (stmt->cond() != NULL) { |
| 249 // Collect type feedback. | 307 // Collect type feedback. |
| 250 stmt->cond()->RecordToBooleanTypeFeedback(oracle()); | 308 stmt->cond()->RecordToBooleanTypeFeedback(oracle()); |
| 251 | 309 |
| 252 RECURSE(Visit(stmt->cond())); | 310 RECURSE(Visit(stmt->cond())); |
| 253 } | 311 } |
| 312 ObserveTypesAtOsrEntry(stmt); |
| 254 RECURSE(Visit(stmt->body())); | 313 RECURSE(Visit(stmt->body())); |
| 255 if (stmt->next() != NULL) { | 314 if (stmt->next() != NULL) { |
| 256 store_.Forget(); // Control may transfer here via 'continue'. | 315 store_.Forget(); // Control may transfer here via 'continue'. |
| 257 RECURSE(Visit(stmt->next())); | 316 RECURSE(Visit(stmt->next())); |
| 258 } | 317 } |
| 259 store_.Forget(); // Control may transfer here via termination or 'break'. | 318 store_.Forget(); // Control may transfer here via termination or 'break'. |
| 260 } | 319 } |
| 261 | 320 |
| 262 | 321 |
| 263 void AstTyper::VisitForInStatement(ForInStatement* stmt) { | 322 void AstTyper::VisitForInStatement(ForInStatement* stmt) { |
| 264 // Collect type feedback. | 323 // Collect type feedback. |
| 265 stmt->set_for_in_type(static_cast<ForInStatement::ForInType>( | 324 stmt->set_for_in_type(static_cast<ForInStatement::ForInType>( |
| 266 oracle()->ForInType(stmt->ForInFeedbackId()))); | 325 oracle()->ForInType(stmt->ForInFeedbackId()))); |
| 267 | 326 |
| 268 RECURSE(Visit(stmt->enumerable())); | 327 RECURSE(Visit(stmt->enumerable())); |
| 269 store_.Forget(); // Control may transfer here via looping or 'continue'. | 328 store_.Forget(); // Control may transfer here via looping or 'continue'. |
| 329 ObserveTypesAtOsrEntry(stmt); |
| 270 RECURSE(Visit(stmt->body())); | 330 RECURSE(Visit(stmt->body())); |
| 271 store_.Forget(); // Control may transfer here via 'break'. | 331 store_.Forget(); // Control may transfer here via 'break'. |
| 272 } | 332 } |
| 273 | 333 |
| 274 | 334 |
| 275 void AstTyper::VisitForOfStatement(ForOfStatement* stmt) { | 335 void AstTyper::VisitForOfStatement(ForOfStatement* stmt) { |
| 276 RECURSE(Visit(stmt->iterable())); | 336 RECURSE(Visit(stmt->iterable())); |
| 277 store_.Forget(); // Control may transfer here via looping or 'continue'. | 337 store_.Forget(); // Control may transfer here via looping or 'continue'. |
| 278 RECURSE(Visit(stmt->body())); | 338 RECURSE(Visit(stmt->body())); |
| 279 store_.Forget(); // Control may transfer here via 'break'. | 339 store_.Forget(); // Control may transfer here via 'break'. |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 | 447 |
| 388 | 448 |
| 389 void AstTyper::VisitAssignment(Assignment* expr) { | 449 void AstTyper::VisitAssignment(Assignment* expr) { |
| 390 // Collect type feedback. | 450 // Collect type feedback. |
| 391 Property* prop = expr->target()->AsProperty(); | 451 Property* prop = expr->target()->AsProperty(); |
| 392 if (prop != NULL) { | 452 if (prop != NULL) { |
| 393 TypeFeedbackId id = expr->AssignmentFeedbackId(); | 453 TypeFeedbackId id = expr->AssignmentFeedbackId(); |
| 394 expr->set_is_uninitialized(oracle()->StoreIsUninitialized(id)); | 454 expr->set_is_uninitialized(oracle()->StoreIsUninitialized(id)); |
| 395 if (!expr->IsUninitialized()) { | 455 if (!expr->IsUninitialized()) { |
| 396 expr->set_is_pre_monomorphic(oracle()->StoreIsPreMonomorphic(id)); | 456 expr->set_is_pre_monomorphic(oracle()->StoreIsPreMonomorphic(id)); |
| 397 expr->set_is_monomorphic(oracle()->StoreIsMonomorphicNormal(id)); | |
| 398 ASSERT(!expr->IsPreMonomorphic() || !expr->IsMonomorphic()); | |
| 399 if (prop->key()->IsPropertyName()) { | 457 if (prop->key()->IsPropertyName()) { |
| 400 Literal* lit_key = prop->key()->AsLiteral(); | 458 Literal* lit_key = prop->key()->AsLiteral(); |
| 401 ASSERT(lit_key != NULL && lit_key->value()->IsString()); | 459 ASSERT(lit_key != NULL && lit_key->value()->IsString()); |
| 402 Handle<String> name = Handle<String>::cast(lit_key->value()); | 460 Handle<String> name = Handle<String>::cast(lit_key->value()); |
| 403 oracle()->AssignmentReceiverTypes(id, name, expr->GetReceiverTypes()); | 461 oracle()->AssignmentReceiverTypes(id, name, expr->GetReceiverTypes()); |
| 404 } else { | 462 } else { |
| 405 KeyedAccessStoreMode store_mode; | 463 KeyedAccessStoreMode store_mode; |
| 406 oracle()->KeyedAssignmentReceiverTypes( | 464 oracle()->KeyedAssignmentReceiverTypes( |
| 407 id, expr->GetReceiverTypes(), &store_mode); | 465 id, expr->GetReceiverTypes(), &store_mode); |
| 408 expr->set_store_mode(store_mode); | 466 expr->set_store_mode(store_mode); |
| 409 } | 467 } |
| 468 ASSERT(!expr->IsPreMonomorphic() || !expr->IsMonomorphic()); |
| 410 } | 469 } |
| 411 } | 470 } |
| 412 | 471 |
| 413 Expression* rhs = | 472 Expression* rhs = |
| 414 expr->is_compound() ? expr->binary_operation() : expr->value(); | 473 expr->is_compound() ? expr->binary_operation() : expr->value(); |
| 415 RECURSE(Visit(expr->target())); | 474 RECURSE(Visit(expr->target())); |
| 416 RECURSE(Visit(rhs)); | 475 RECURSE(Visit(rhs)); |
| 417 NarrowType(expr, rhs->bounds()); | 476 NarrowType(expr, rhs->bounds()); |
| 418 | 477 |
| 419 VariableProxy* proxy = expr->target()->AsVariableProxy(); | 478 VariableProxy* proxy = expr->target()->AsVariableProxy(); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 438 NarrowType(expr, Bounds(Type::None(), isolate_)); | 497 NarrowType(expr, Bounds(Type::None(), isolate_)); |
| 439 } | 498 } |
| 440 | 499 |
| 441 | 500 |
| 442 void AstTyper::VisitProperty(Property* expr) { | 501 void AstTyper::VisitProperty(Property* expr) { |
| 443 // Collect type feedback. | 502 // Collect type feedback. |
| 444 TypeFeedbackId id = expr->PropertyFeedbackId(); | 503 TypeFeedbackId id = expr->PropertyFeedbackId(); |
| 445 expr->set_is_uninitialized(oracle()->LoadIsUninitialized(id)); | 504 expr->set_is_uninitialized(oracle()->LoadIsUninitialized(id)); |
| 446 if (!expr->IsUninitialized()) { | 505 if (!expr->IsUninitialized()) { |
| 447 expr->set_is_pre_monomorphic(oracle()->LoadIsPreMonomorphic(id)); | 506 expr->set_is_pre_monomorphic(oracle()->LoadIsPreMonomorphic(id)); |
| 448 expr->set_is_monomorphic(oracle()->LoadIsMonomorphicNormal(id)); | |
| 449 ASSERT(!expr->IsPreMonomorphic() || !expr->IsMonomorphic()); | |
| 450 if (expr->key()->IsPropertyName()) { | 507 if (expr->key()->IsPropertyName()) { |
| 451 Literal* lit_key = expr->key()->AsLiteral(); | 508 Literal* lit_key = expr->key()->AsLiteral(); |
| 452 ASSERT(lit_key != NULL && lit_key->value()->IsString()); | 509 ASSERT(lit_key != NULL && lit_key->value()->IsString()); |
| 453 Handle<String> name = Handle<String>::cast(lit_key->value()); | 510 Handle<String> name = Handle<String>::cast(lit_key->value()); |
| 454 bool is_prototype; | 511 bool is_prototype; |
| 455 oracle()->PropertyReceiverTypes( | 512 oracle()->PropertyReceiverTypes( |
| 456 id, name, expr->GetReceiverTypes(), &is_prototype); | 513 id, name, expr->GetReceiverTypes(), &is_prototype); |
| 457 expr->set_is_function_prototype(is_prototype); | 514 expr->set_is_function_prototype(is_prototype); |
| 458 } else { | 515 } else { |
| 459 bool is_string; | 516 bool is_string; |
| 460 oracle()->KeyedPropertyReceiverTypes( | 517 oracle()->KeyedPropertyReceiverTypes( |
| 461 id, expr->GetReceiverTypes(), &is_string); | 518 id, expr->GetReceiverTypes(), &is_string); |
| 462 expr->set_is_string_access(is_string); | 519 expr->set_is_string_access(is_string); |
| 463 } | 520 } |
| 521 ASSERT(!expr->IsPreMonomorphic() || !expr->IsMonomorphic()); |
| 464 } | 522 } |
| 465 | 523 |
| 466 RECURSE(Visit(expr->obj())); | 524 RECURSE(Visit(expr->obj())); |
| 467 RECURSE(Visit(expr->key())); | 525 RECURSE(Visit(expr->key())); |
| 468 | 526 |
| 469 // We don't know anything about the result type. | 527 // We don't know anything about the result type. |
| 470 } | 528 } |
| 471 | 529 |
| 472 | 530 |
| 473 void AstTyper::VisitCall(Call* expr) { | 531 void AstTyper::VisitCall(Call* expr) { |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 544 break; | 602 break; |
| 545 default: | 603 default: |
| 546 UNREACHABLE(); | 604 UNREACHABLE(); |
| 547 } | 605 } |
| 548 } | 606 } |
| 549 | 607 |
| 550 | 608 |
| 551 void AstTyper::VisitCountOperation(CountOperation* expr) { | 609 void AstTyper::VisitCountOperation(CountOperation* expr) { |
| 552 // Collect type feedback. | 610 // Collect type feedback. |
| 553 TypeFeedbackId store_id = expr->CountStoreFeedbackId(); | 611 TypeFeedbackId store_id = expr->CountStoreFeedbackId(); |
| 554 expr->set_is_monomorphic(oracle()->StoreIsMonomorphicNormal(store_id)); | |
| 555 expr->set_store_mode(oracle()->GetStoreMode(store_id)); | 612 expr->set_store_mode(oracle()->GetStoreMode(store_id)); |
| 556 oracle()->CountReceiverTypes(store_id, expr->GetReceiverTypes()); | 613 oracle()->CountReceiverTypes(store_id, expr->GetReceiverTypes()); |
| 557 expr->set_type(oracle()->CountType(expr->CountBinOpFeedbackId())); | 614 expr->set_type(oracle()->CountType(expr->CountBinOpFeedbackId())); |
| 558 // TODO(rossberg): merge the count type with the generic expression type. | 615 // TODO(rossberg): merge the count type with the generic expression type. |
| 559 | 616 |
| 560 RECURSE(Visit(expr->expression())); | 617 RECURSE(Visit(expr->expression())); |
| 561 | 618 |
| 562 NarrowType(expr, Bounds(Type::Smi(), Type::Number(), isolate_)); | 619 NarrowType(expr, Bounds(Type::Smi(), Type::Number(), isolate_)); |
| 563 | 620 |
| 564 VariableProxy* proxy = expr->expression()->AsVariableProxy(); | 621 VariableProxy* proxy = expr->expression()->AsVariableProxy(); |
| 565 if (proxy != NULL && proxy->var()->IsStackAllocated()) { | 622 if (proxy != NULL && proxy->var()->IsStackAllocated()) { |
| 566 store_.Seq(variable_index(proxy->var()), Effect(expr->bounds())); | 623 store_.Seq(variable_index(proxy->var()), Effect(expr->bounds())); |
| 567 } | 624 } |
| 568 } | 625 } |
| 569 | 626 |
| 570 | 627 |
| 571 void AstTyper::VisitBinaryOperation(BinaryOperation* expr) { | 628 void AstTyper::VisitBinaryOperation(BinaryOperation* expr) { |
| 572 // Collect type feedback. | 629 // Collect type feedback. |
| 573 Handle<Type> type, left_type, right_type; | 630 Handle<Type> type, left_type, right_type; |
| 574 Maybe<int> fixed_right_arg; | 631 Maybe<int> fixed_right_arg; |
| 632 Handle<AllocationSite> allocation_site; |
| 575 oracle()->BinaryType(expr->BinaryOperationFeedbackId(), | 633 oracle()->BinaryType(expr->BinaryOperationFeedbackId(), |
| 576 &left_type, &right_type, &type, &fixed_right_arg, expr->op()); | 634 &left_type, &right_type, &type, &fixed_right_arg, |
| 635 &allocation_site, expr->op()); |
| 577 NarrowLowerType(expr, type); | 636 NarrowLowerType(expr, type); |
| 578 NarrowLowerType(expr->left(), left_type); | 637 NarrowLowerType(expr->left(), left_type); |
| 579 NarrowLowerType(expr->right(), right_type); | 638 NarrowLowerType(expr->right(), right_type); |
| 639 expr->set_allocation_site(allocation_site); |
| 580 expr->set_fixed_right_arg(fixed_right_arg); | 640 expr->set_fixed_right_arg(fixed_right_arg); |
| 581 if (expr->op() == Token::OR || expr->op() == Token::AND) { | 641 if (expr->op() == Token::OR || expr->op() == Token::AND) { |
| 582 expr->left()->RecordToBooleanTypeFeedback(oracle()); | 642 expr->left()->RecordToBooleanTypeFeedback(oracle()); |
| 583 } | 643 } |
| 584 | 644 |
| 585 switch (expr->op()) { | 645 switch (expr->op()) { |
| 586 case Token::COMMA: | 646 case Token::COMMA: |
| 587 RECURSE(Visit(expr->left())); | 647 RECURSE(Visit(expr->left())); |
| 588 RECURSE(Visit(expr->right())); | 648 RECURSE(Visit(expr->right())); |
| 589 NarrowType(expr, expr->right()->bounds()); | 649 NarrowType(expr, expr->right()->bounds()); |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 735 void AstTyper::VisitModuleUrl(ModuleUrl* module) { | 795 void AstTyper::VisitModuleUrl(ModuleUrl* module) { |
| 736 } | 796 } |
| 737 | 797 |
| 738 | 798 |
| 739 void AstTyper::VisitModuleStatement(ModuleStatement* stmt) { | 799 void AstTyper::VisitModuleStatement(ModuleStatement* stmt) { |
| 740 RECURSE(Visit(stmt->body())); | 800 RECURSE(Visit(stmt->body())); |
| 741 } | 801 } |
| 742 | 802 |
| 743 | 803 |
| 744 } } // namespace v8::internal | 804 } } // namespace v8::internal |
| OLD | NEW |