| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 void type::Accept(AstVisitor* v) { v->Visit##type(this); } | 50 void type::Accept(AstVisitor* v) { v->Visit##type(this); } |
| 51 AST_NODE_LIST(DECL_ACCEPT) | 51 AST_NODE_LIST(DECL_ACCEPT) |
| 52 #undef DECL_ACCEPT | 52 #undef DECL_ACCEPT |
| 53 | 53 |
| 54 | 54 |
| 55 // ---------------------------------------------------------------------------- | 55 // ---------------------------------------------------------------------------- |
| 56 // Implementation of other node functionality. | 56 // Implementation of other node functionality. |
| 57 | 57 |
| 58 | 58 |
| 59 bool Expression::IsSmiLiteral() { | 59 bool Expression::IsSmiLiteral() { |
| 60 return AsLiteral() != NULL && AsLiteral()->handle()->IsSmi(); | 60 return AsLiteral() != NULL && AsLiteral()->value()->IsSmi(); |
| 61 } | 61 } |
| 62 | 62 |
| 63 | 63 |
| 64 bool Expression::IsStringLiteral() { | 64 bool Expression::IsStringLiteral() { |
| 65 return AsLiteral() != NULL && AsLiteral()->handle()->IsString(); | 65 return AsLiteral() != NULL && AsLiteral()->value()->IsString(); |
| 66 } | 66 } |
| 67 | 67 |
| 68 | 68 |
| 69 bool Expression::IsNullLiteral() { | 69 bool Expression::IsNullLiteral() { |
| 70 return AsLiteral() != NULL && AsLiteral()->handle()->IsNull(); | 70 return AsLiteral() != NULL && AsLiteral()->value()->IsNull(); |
| 71 } | 71 } |
| 72 | 72 |
| 73 | 73 |
| 74 bool Expression::IsUndefinedLiteral() { | 74 bool Expression::IsUndefinedLiteral() { |
| 75 return AsLiteral() != NULL && AsLiteral()->handle()->IsUndefined(); | 75 return AsLiteral() != NULL && AsLiteral()->value()->IsUndefined(); |
| 76 } | 76 } |
| 77 | 77 |
| 78 | 78 |
| 79 VariableProxy::VariableProxy(Isolate* isolate, Variable* var) | 79 VariableProxy::VariableProxy(Isolate* isolate, Variable* var) |
| 80 : Expression(isolate), | 80 : Expression(isolate), |
| 81 name_(var->name()), | 81 name_(var->name()), |
| 82 var_(NULL), // Will be set by the call to BindTo. | 82 var_(NULL), // Will be set by the call to BindTo. |
| 83 is_this_(var->is_this()), | 83 is_this_(var->is_this()), |
| 84 is_trivial_(false), | 84 is_trivial_(false), |
| 85 is_lvalue_(false), | 85 is_lvalue_(false), |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 Expression* value, | 128 Expression* value, |
| 129 int pos) | 129 int pos) |
| 130 : Expression(isolate), | 130 : Expression(isolate), |
| 131 op_(op), | 131 op_(op), |
| 132 target_(target), | 132 target_(target), |
| 133 value_(value), | 133 value_(value), |
| 134 pos_(pos), | 134 pos_(pos), |
| 135 binary_operation_(NULL), | 135 binary_operation_(NULL), |
| 136 assignment_id_(GetNextId(isolate)), | 136 assignment_id_(GetNextId(isolate)), |
| 137 is_monomorphic_(false), | 137 is_monomorphic_(false), |
| 138 is_uninitialized_(false), |
| 138 store_mode_(STANDARD_STORE) { } | 139 store_mode_(STANDARD_STORE) { } |
| 139 | 140 |
| 140 | 141 |
| 141 Token::Value Assignment::binary_op() const { | 142 Token::Value Assignment::binary_op() const { |
| 142 switch (op_) { | 143 switch (op_) { |
| 143 case Token::ASSIGN_BIT_OR: return Token::BIT_OR; | 144 case Token::ASSIGN_BIT_OR: return Token::BIT_OR; |
| 144 case Token::ASSIGN_BIT_XOR: return Token::BIT_XOR; | 145 case Token::ASSIGN_BIT_XOR: return Token::BIT_XOR; |
| 145 case Token::ASSIGN_BIT_AND: return Token::BIT_AND; | 146 case Token::ASSIGN_BIT_AND: return Token::BIT_AND; |
| 146 case Token::ASSIGN_SHL: return Token::SHL; | 147 case Token::ASSIGN_SHL: return Token::SHL; |
| 147 case Token::ASSIGN_SAR: return Token::SAR; | 148 case Token::ASSIGN_SAR: return Token::SAR; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 return scope()->language_mode(); | 182 return scope()->language_mode(); |
| 182 } | 183 } |
| 183 | 184 |
| 184 | 185 |
| 185 ObjectLiteralProperty::ObjectLiteralProperty(Literal* key, | 186 ObjectLiteralProperty::ObjectLiteralProperty(Literal* key, |
| 186 Expression* value, | 187 Expression* value, |
| 187 Isolate* isolate) { | 188 Isolate* isolate) { |
| 188 emit_store_ = true; | 189 emit_store_ = true; |
| 189 key_ = key; | 190 key_ = key; |
| 190 value_ = value; | 191 value_ = value; |
| 191 Object* k = *key->handle(); | 192 Object* k = *key->value(); |
| 192 if (k->IsInternalizedString() && | 193 if (k->IsInternalizedString() && |
| 193 isolate->heap()->proto_string()->Equals(String::cast(k))) { | 194 isolate->heap()->proto_string()->Equals(String::cast(k))) { |
| 194 kind_ = PROTOTYPE; | 195 kind_ = PROTOTYPE; |
| 195 } else if (value_->AsMaterializedLiteral() != NULL) { | 196 } else if (value_->AsMaterializedLiteral() != NULL) { |
| 196 kind_ = MATERIALIZED_LITERAL; | 197 kind_ = MATERIALIZED_LITERAL; |
| 197 } else if (value_->AsLiteral() != NULL) { | 198 } else if (value_->AsLiteral() != NULL) { |
| 198 kind_ = CONSTANT; | 199 kind_ = CONSTANT; |
| 199 } else { | 200 } else { |
| 200 kind_ = COMPUTED; | 201 kind_ = COMPUTED; |
| 201 } | 202 } |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 | 256 |
| 256 | 257 |
| 257 void ObjectLiteral::CalculateEmitStore(Zone* zone) { | 258 void ObjectLiteral::CalculateEmitStore(Zone* zone) { |
| 258 ZoneAllocationPolicy allocator(zone); | 259 ZoneAllocationPolicy allocator(zone); |
| 259 | 260 |
| 260 ZoneHashMap table(Literal::Match, ZoneHashMap::kDefaultHashMapCapacity, | 261 ZoneHashMap table(Literal::Match, ZoneHashMap::kDefaultHashMapCapacity, |
| 261 allocator); | 262 allocator); |
| 262 for (int i = properties()->length() - 1; i >= 0; i--) { | 263 for (int i = properties()->length() - 1; i >= 0; i--) { |
| 263 ObjectLiteral::Property* property = properties()->at(i); | 264 ObjectLiteral::Property* property = properties()->at(i); |
| 264 Literal* literal = property->key(); | 265 Literal* literal = property->key(); |
| 265 if (literal->handle()->IsNull()) continue; | 266 if (literal->value()->IsNull()) continue; |
| 266 uint32_t hash = literal->Hash(); | 267 uint32_t hash = literal->Hash(); |
| 267 // If the key of a computed property is in the table, do not emit | 268 // If the key of a computed property is in the table, do not emit |
| 268 // a store for the property later. | 269 // a store for the property later. |
| 269 if (property->kind() == ObjectLiteral::Property::COMPUTED && | 270 if (property->kind() == ObjectLiteral::Property::COMPUTED && |
| 270 table.Lookup(literal, hash, false, allocator) != NULL) { | 271 table.Lookup(literal, hash, false, allocator) != NULL) { |
| 271 property->set_emit_store(false); | 272 property->set_emit_store(false); |
| 272 } else { | 273 } else { |
| 273 // Add key to the table. | 274 // Add key to the table. |
| 274 table.Lookup(literal, hash, true, allocator); | 275 table.Lookup(literal, hash, true, allocator); |
| 275 } | 276 } |
| 276 } | 277 } |
| 277 } | 278 } |
| 278 | 279 |
| 279 | 280 |
| 280 void TargetCollector::AddTarget(Label* target, Zone* zone) { | 281 void TargetCollector::AddTarget(Label* target, Zone* zone) { |
| 281 // Add the label to the collector, but discard duplicates. | 282 // Add the label to the collector, but discard duplicates. |
| 282 int length = targets_.length(); | 283 int length = targets_.length(); |
| 283 for (int i = 0; i < length; i++) { | 284 for (int i = 0; i < length; i++) { |
| 284 if (targets_[i] == target) return; | 285 if (targets_[i] == target) return; |
| 285 } | 286 } |
| 286 targets_.Add(target, zone); | 287 targets_.Add(target, zone); |
| 287 } | 288 } |
| 288 | 289 |
| 289 | 290 |
| 291 void UnaryOperation::RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle) { |
| 292 // TODO(olivf) If this Operation is used in a test context, then the |
| 293 // expression has a ToBoolean stub and we want to collect the type |
| 294 // information. However the GraphBuilder expects it to be on the instruction |
| 295 // corresponding to the TestContext, therefore we have to store it here and |
| 296 // not on the operand. |
| 297 set_to_boolean_types(oracle->ToBooleanTypes(expression()->test_id())); |
| 298 } |
| 299 |
| 300 |
| 290 bool UnaryOperation::ResultOverwriteAllowed() { | 301 bool UnaryOperation::ResultOverwriteAllowed() { |
| 291 switch (op_) { | 302 switch (op_) { |
| 292 case Token::BIT_NOT: | 303 case Token::BIT_NOT: |
| 293 case Token::SUB: | 304 case Token::SUB: |
| 294 return true; | 305 return true; |
| 295 default: | 306 default: |
| 296 return false; | 307 return false; |
| 297 } | 308 } |
| 298 } | 309 } |
| 299 | 310 |
| 300 | 311 |
| 312 void BinaryOperation::RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle) { |
| 313 // TODO(olivf) If this Operation is used in a test context, then the right |
| 314 // hand side has a ToBoolean stub and we want to collect the type information. |
| 315 // However the GraphBuilder expects it to be on the instruction corresponding |
| 316 // to the TestContext, therefore we have to store it here and not on the |
| 317 // right hand operand. |
| 318 set_to_boolean_types(oracle->ToBooleanTypes(right()->test_id())); |
| 319 } |
| 320 |
| 321 |
| 301 bool BinaryOperation::ResultOverwriteAllowed() { | 322 bool BinaryOperation::ResultOverwriteAllowed() { |
| 302 switch (op_) { | 323 switch (op_) { |
| 303 case Token::COMMA: | 324 case Token::COMMA: |
| 304 case Token::OR: | 325 case Token::OR: |
| 305 case Token::AND: | 326 case Token::AND: |
| 306 return false; | 327 return false; |
| 307 case Token::BIT_OR: | 328 case Token::BIT_OR: |
| 308 case Token::BIT_XOR: | 329 case Token::BIT_XOR: |
| 309 case Token::BIT_AND: | 330 case Token::BIT_AND: |
| 310 case Token::SHL: | 331 case Token::SHL: |
| (...skipping 19 matching lines...) Expand all Loading... |
| 330 | 351 |
| 331 | 352 |
| 332 // Check for the pattern: typeof <expression> equals <string literal>. | 353 // Check for the pattern: typeof <expression> equals <string literal>. |
| 333 static bool MatchLiteralCompareTypeof(Expression* left, | 354 static bool MatchLiteralCompareTypeof(Expression* left, |
| 334 Token::Value op, | 355 Token::Value op, |
| 335 Expression* right, | 356 Expression* right, |
| 336 Expression** expr, | 357 Expression** expr, |
| 337 Handle<String>* check) { | 358 Handle<String>* check) { |
| 338 if (IsTypeof(left) && right->IsStringLiteral() && Token::IsEqualityOp(op)) { | 359 if (IsTypeof(left) && right->IsStringLiteral() && Token::IsEqualityOp(op)) { |
| 339 *expr = left->AsUnaryOperation()->expression(); | 360 *expr = left->AsUnaryOperation()->expression(); |
| 340 *check = Handle<String>::cast(right->AsLiteral()->handle()); | 361 *check = Handle<String>::cast(right->AsLiteral()->value()); |
| 341 return true; | 362 return true; |
| 342 } | 363 } |
| 343 return false; | 364 return false; |
| 344 } | 365 } |
| 345 | 366 |
| 346 | 367 |
| 347 bool CompareOperation::IsLiteralCompareTypeof(Expression** expr, | 368 bool CompareOperation::IsLiteralCompareTypeof(Expression** expr, |
| 348 Handle<String>* check) { | 369 Handle<String>* check) { |
| 349 return MatchLiteralCompareTypeof(left_, op_, right_, expr, check) || | 370 return MatchLiteralCompareTypeof(left_, op_, right_, expr, check) || |
| 350 MatchLiteralCompareTypeof(right_, op_, left_, expr, check); | 371 MatchLiteralCompareTypeof(right_, op_, left_, expr, check); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 410 } | 431 } |
| 411 | 432 |
| 412 bool FunctionDeclaration::IsInlineable() const { | 433 bool FunctionDeclaration::IsInlineable() const { |
| 413 return false; | 434 return false; |
| 414 } | 435 } |
| 415 | 436 |
| 416 | 437 |
| 417 // ---------------------------------------------------------------------------- | 438 // ---------------------------------------------------------------------------- |
| 418 // Recording of type feedback | 439 // Recording of type feedback |
| 419 | 440 |
| 441 // TODO(rossberg): all RecordTypeFeedback functions should disappear |
| 442 // once we use the common type field in the AST consistently. |
| 443 |
| 444 |
| 420 void ForInStatement::RecordTypeFeedback(TypeFeedbackOracle* oracle) { | 445 void ForInStatement::RecordTypeFeedback(TypeFeedbackOracle* oracle) { |
| 421 for_in_type_ = static_cast<ForInType>(oracle->ForInType(this)); | 446 for_in_type_ = static_cast<ForInType>(oracle->ForInType(this)); |
| 422 } | 447 } |
| 423 | 448 |
| 424 | 449 |
| 425 void Expression::RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle) { | 450 void Expression::RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle) { |
| 426 to_boolean_types_ = oracle->ToBooleanTypes(test_id()); | 451 to_boolean_types_ = oracle->ToBooleanTypes(test_id()); |
| 427 } | 452 } |
| 428 | 453 |
| 429 | 454 |
| 430 void Property::RecordTypeFeedback(TypeFeedbackOracle* oracle, | 455 void Property::RecordTypeFeedback(TypeFeedbackOracle* oracle, |
| 431 Zone* zone) { | 456 Zone* zone) { |
| 432 // Record type feedback from the oracle in the AST. | 457 // Record type feedback from the oracle in the AST. |
| 433 is_uninitialized_ = oracle->LoadIsUninitialized(this); | 458 is_uninitialized_ = oracle->LoadIsUninitialized(this); |
| 434 if (is_uninitialized_) return; | 459 if (is_uninitialized_) return; |
| 435 | 460 |
| 436 is_monomorphic_ = oracle->LoadIsMonomorphicNormal(this); | 461 is_monomorphic_ = oracle->LoadIsMonomorphicNormal(this); |
| 437 receiver_types_.Clear(); | 462 receiver_types_.Clear(); |
| 438 if (key()->IsPropertyName()) { | 463 if (key()->IsPropertyName()) { |
| 439 FunctionPrototypeStub proto_stub(Code::LOAD_IC); | 464 FunctionPrototypeStub proto_stub(Code::LOAD_IC); |
| 440 StringLengthStub string_stub(Code::LOAD_IC, false); | 465 StringLengthStub string_stub(Code::LOAD_IC, false); |
| 441 if (oracle->LoadIsStub(this, &string_stub)) { | 466 if (oracle->LoadIsStub(this, &string_stub)) { |
| 442 is_string_length_ = true; | 467 is_string_length_ = true; |
| 443 } else if (oracle->LoadIsStub(this, &proto_stub)) { | 468 } else if (oracle->LoadIsStub(this, &proto_stub)) { |
| 444 is_function_prototype_ = true; | 469 is_function_prototype_ = true; |
| 445 } else { | 470 } else { |
| 446 Literal* lit_key = key()->AsLiteral(); | 471 Literal* lit_key = key()->AsLiteral(); |
| 447 ASSERT(lit_key != NULL && lit_key->handle()->IsString()); | 472 ASSERT(lit_key != NULL && lit_key->value()->IsString()); |
| 448 Handle<String> name = Handle<String>::cast(lit_key->handle()); | 473 Handle<String> name = Handle<String>::cast(lit_key->value()); |
| 449 oracle->LoadReceiverTypes(this, name, &receiver_types_); | 474 oracle->LoadReceiverTypes(this, name, &receiver_types_); |
| 450 } | 475 } |
| 451 } else if (oracle->LoadIsBuiltin(this, Builtins::kKeyedLoadIC_String)) { | 476 } else if (oracle->LoadIsBuiltin(this, Builtins::kKeyedLoadIC_String)) { |
| 452 is_string_access_ = true; | 477 is_string_access_ = true; |
| 453 } else if (is_monomorphic_) { | 478 } else if (is_monomorphic_) { |
| 454 receiver_types_.Add(oracle->LoadMonomorphicReceiverType(this), | 479 receiver_types_.Add(oracle->LoadMonomorphicReceiverType(this), |
| 455 zone); | 480 zone); |
| 456 } else if (oracle->LoadIsPolymorphic(this)) { | 481 } else if (oracle->LoadIsPolymorphic(this)) { |
| 457 receiver_types_.Reserve(kMaxKeyedPolymorphism, zone); | 482 receiver_types_.Reserve(kMaxKeyedPolymorphism, zone); |
| 458 oracle->CollectKeyedReceiverTypes(PropertyFeedbackId(), &receiver_types_); | 483 oracle->CollectKeyedReceiverTypes(PropertyFeedbackId(), &receiver_types_); |
| 459 } | 484 } |
| 460 } | 485 } |
| 461 | 486 |
| 462 | 487 |
| 463 void Assignment::RecordTypeFeedback(TypeFeedbackOracle* oracle, | 488 void Assignment::RecordTypeFeedback(TypeFeedbackOracle* oracle, |
| 464 Zone* zone) { | 489 Zone* zone) { |
| 465 Property* prop = target()->AsProperty(); | 490 Property* prop = target()->AsProperty(); |
| 466 ASSERT(prop != NULL); | 491 ASSERT(prop != NULL); |
| 467 TypeFeedbackId id = AssignmentFeedbackId(); | 492 TypeFeedbackId id = AssignmentFeedbackId(); |
| 493 is_uninitialized_ = oracle->StoreIsUninitialized(id); |
| 494 if (is_uninitialized_) return; |
| 468 is_monomorphic_ = oracle->StoreIsMonomorphicNormal(id); | 495 is_monomorphic_ = oracle->StoreIsMonomorphicNormal(id); |
| 469 receiver_types_.Clear(); | 496 receiver_types_.Clear(); |
| 470 if (prop->key()->IsPropertyName()) { | 497 if (prop->key()->IsPropertyName()) { |
| 471 Literal* lit_key = prop->key()->AsLiteral(); | 498 Literal* lit_key = prop->key()->AsLiteral(); |
| 472 ASSERT(lit_key != NULL && lit_key->handle()->IsString()); | 499 ASSERT(lit_key != NULL && lit_key->value()->IsString()); |
| 473 Handle<String> name = Handle<String>::cast(lit_key->handle()); | 500 Handle<String> name = Handle<String>::cast(lit_key->value()); |
| 474 oracle->StoreReceiverTypes(this, name, &receiver_types_); | 501 oracle->StoreReceiverTypes(this, name, &receiver_types_); |
| 475 } else if (is_monomorphic_) { | 502 } else if (is_monomorphic_) { |
| 476 // Record receiver type for monomorphic keyed stores. | 503 // Record receiver type for monomorphic keyed stores. |
| 477 receiver_types_.Add(oracle->StoreMonomorphicReceiverType(id), zone); | 504 receiver_types_.Add(oracle->StoreMonomorphicReceiverType(id), zone); |
| 478 store_mode_ = oracle->GetStoreMode(id); | 505 store_mode_ = oracle->GetStoreMode(id); |
| 479 } else if (oracle->StoreIsPolymorphic(id)) { | 506 } else if (oracle->StoreIsPolymorphic(id)) { |
| 480 receiver_types_.Reserve(kMaxKeyedPolymorphism, zone); | 507 receiver_types_.Reserve(kMaxKeyedPolymorphism, zone); |
| 481 oracle->CollectKeyedReceiverTypes(id, &receiver_types_); | 508 oracle->CollectKeyedReceiverTypes(id, &receiver_types_); |
| 482 store_mode_ = oracle->GetStoreMode(id); | 509 store_mode_ = oracle->GetStoreMode(id); |
| 483 } | 510 } |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 605 void Call::RecordTypeFeedback(TypeFeedbackOracle* oracle, | 632 void Call::RecordTypeFeedback(TypeFeedbackOracle* oracle, |
| 606 CallKind call_kind) { | 633 CallKind call_kind) { |
| 607 is_monomorphic_ = oracle->CallIsMonomorphic(this); | 634 is_monomorphic_ = oracle->CallIsMonomorphic(this); |
| 608 Property* property = expression()->AsProperty(); | 635 Property* property = expression()->AsProperty(); |
| 609 if (property == NULL) { | 636 if (property == NULL) { |
| 610 // Function call. Specialize for monomorphic calls. | 637 // Function call. Specialize for monomorphic calls. |
| 611 if (is_monomorphic_) target_ = oracle->GetCallTarget(this); | 638 if (is_monomorphic_) target_ = oracle->GetCallTarget(this); |
| 612 } else { | 639 } else { |
| 613 // Method call. Specialize for the receiver types seen at runtime. | 640 // Method call. Specialize for the receiver types seen at runtime. |
| 614 Literal* key = property->key()->AsLiteral(); | 641 Literal* key = property->key()->AsLiteral(); |
| 615 ASSERT(key != NULL && key->handle()->IsString()); | 642 ASSERT(key != NULL && key->value()->IsString()); |
| 616 Handle<String> name = Handle<String>::cast(key->handle()); | 643 Handle<String> name = Handle<String>::cast(key->value()); |
| 617 receiver_types_.Clear(); | 644 receiver_types_.Clear(); |
| 618 oracle->CallReceiverTypes(this, name, call_kind, &receiver_types_); | 645 oracle->CallReceiverTypes(this, name, call_kind, &receiver_types_); |
| 619 #ifdef DEBUG | 646 #ifdef DEBUG |
| 620 if (FLAG_enable_slow_asserts) { | 647 if (FLAG_enable_slow_asserts) { |
| 621 int length = receiver_types_.length(); | 648 int length = receiver_types_.length(); |
| 622 for (int i = 0; i < length; i++) { | 649 for (int i = 0; i < length; i++) { |
| 623 Handle<Map> map = receiver_types_.at(i); | 650 Handle<Map> map = receiver_types_.at(i); |
| 624 ASSERT(!map.is_null() && *map != NULL); | 651 ASSERT(!map.is_null() && *map != NULL); |
| 625 } | 652 } |
| 626 } | 653 } |
| (...skipping 28 matching lines...) Expand all Loading... |
| 655 } | 682 } |
| 656 | 683 |
| 657 | 684 |
| 658 void ObjectLiteral::Property::RecordTypeFeedback(TypeFeedbackOracle* oracle) { | 685 void ObjectLiteral::Property::RecordTypeFeedback(TypeFeedbackOracle* oracle) { |
| 659 receiver_type_ = oracle->ObjectLiteralStoreIsMonomorphic(this) | 686 receiver_type_ = oracle->ObjectLiteralStoreIsMonomorphic(this) |
| 660 ? oracle->GetObjectLiteralStoreMap(this) | 687 ? oracle->GetObjectLiteralStoreMap(this) |
| 661 : Handle<Map>::null(); | 688 : Handle<Map>::null(); |
| 662 } | 689 } |
| 663 | 690 |
| 664 | 691 |
| 665 void UnaryOperation::RecordTypeFeedback(TypeFeedbackOracle* oracle) { | |
| 666 type_ = oracle->UnaryType(UnaryOperationFeedbackId()); | |
| 667 } | |
| 668 | |
| 669 | |
| 670 void BinaryOperation::RecordTypeFeedback(TypeFeedbackOracle* oracle) { | |
| 671 oracle->BinaryType(BinaryOperationFeedbackId(), | |
| 672 &left_type_, &right_type_, &result_type_, | |
| 673 &has_fixed_right_arg_, &fixed_right_arg_value_); | |
| 674 } | |
| 675 | |
| 676 | |
| 677 // TODO(rossberg): this function (and all other RecordTypeFeedback functions) | |
| 678 // should disappear once we use the common type field in the AST consistently. | |
| 679 void CompareOperation::RecordTypeFeedback(TypeFeedbackOracle* oracle) { | |
| 680 oracle->CompareTypes(CompareOperationFeedbackId(), | |
| 681 &left_type_, &right_type_, &overall_type_, &compare_nil_type_); | |
| 682 } | |
| 683 | |
| 684 | |
| 685 // ---------------------------------------------------------------------------- | 692 // ---------------------------------------------------------------------------- |
| 686 // Implementation of AstVisitor | 693 // Implementation of AstVisitor |
| 687 | 694 |
| 688 void AstVisitor::VisitDeclarations(ZoneList<Declaration*>* declarations) { | 695 void AstVisitor::VisitDeclarations(ZoneList<Declaration*>* declarations) { |
| 689 for (int i = 0; i < declarations->length(); i++) { | 696 for (int i = 0; i < declarations->length(); i++) { |
| 690 Visit(declarations->at(i)); | 697 Visit(declarations->at(i)); |
| 691 } | 698 } |
| 692 } | 699 } |
| 693 | 700 |
| 694 | 701 |
| (...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1158 } | 1165 } |
| 1159 } | 1166 } |
| 1160 | 1167 |
| 1161 #undef REGULAR_NODE | 1168 #undef REGULAR_NODE |
| 1162 #undef DONT_OPTIMIZE_NODE | 1169 #undef DONT_OPTIMIZE_NODE |
| 1163 #undef DONT_SELFOPTIMIZE_NODE | 1170 #undef DONT_SELFOPTIMIZE_NODE |
| 1164 #undef DONT_CACHE_NODE | 1171 #undef DONT_CACHE_NODE |
| 1165 | 1172 |
| 1166 | 1173 |
| 1167 Handle<String> Literal::ToString() { | 1174 Handle<String> Literal::ToString() { |
| 1168 if (handle_->IsString()) return Handle<String>::cast(handle_); | 1175 if (value_->IsString()) return Handle<String>::cast(value_); |
| 1169 Factory* factory = Isolate::Current()->factory(); | 1176 Factory* factory = Isolate::Current()->factory(); |
| 1170 ASSERT(handle_->IsNumber()); | 1177 ASSERT(value_->IsNumber()); |
| 1171 char arr[100]; | 1178 char arr[100]; |
| 1172 Vector<char> buffer(arr, ARRAY_SIZE(arr)); | 1179 Vector<char> buffer(arr, ARRAY_SIZE(arr)); |
| 1173 const char* str; | 1180 const char* str; |
| 1174 if (handle_->IsSmi()) { | 1181 if (value_->IsSmi()) { |
| 1175 // Optimization only, the heap number case would subsume this. | 1182 // Optimization only, the heap number case would subsume this. |
| 1176 OS::SNPrintF(buffer, "%d", Smi::cast(*handle_)->value()); | 1183 OS::SNPrintF(buffer, "%d", Smi::cast(*value_)->value()); |
| 1177 str = arr; | 1184 str = arr; |
| 1178 } else { | 1185 } else { |
| 1179 str = DoubleToCString(handle_->Number(), buffer); | 1186 str = DoubleToCString(value_->Number(), buffer); |
| 1180 } | 1187 } |
| 1181 return factory->NewStringFromAscii(CStrVector(str)); | 1188 return factory->NewStringFromAscii(CStrVector(str)); |
| 1182 } | 1189 } |
| 1183 | 1190 |
| 1184 | 1191 |
| 1185 } } // namespace v8::internal | 1192 } } // namespace v8::internal |
| OLD | NEW |