| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 emit_store_ = emit_store; | 208 emit_store_ = emit_store; |
| 209 } | 209 } |
| 210 | 210 |
| 211 | 211 |
| 212 bool ObjectLiteral::Property::emit_store() { | 212 bool ObjectLiteral::Property::emit_store() { |
| 213 return emit_store_; | 213 return emit_store_; |
| 214 } | 214 } |
| 215 | 215 |
| 216 | 216 |
| 217 bool IsEqualString(void* first, void* second) { | 217 bool IsEqualString(void* first, void* second) { |
| 218 ASSERT((*reinterpret_cast<String**>(first))->IsString()); |
| 219 ASSERT((*reinterpret_cast<String**>(second))->IsString()); |
| 218 Handle<String> h1(reinterpret_cast<String**>(first)); | 220 Handle<String> h1(reinterpret_cast<String**>(first)); |
| 219 Handle<String> h2(reinterpret_cast<String**>(second)); | 221 Handle<String> h2(reinterpret_cast<String**>(second)); |
| 220 return (*h1)->Equals(*h2); | 222 return (*h1)->Equals(*h2); |
| 221 } | 223 } |
| 222 | 224 |
| 223 bool IsEqualSmi(void* first, void* second) { | 225 bool IsEqualSmi(void* first, void* second) { |
| 226 ASSERT((*reinterpret_cast<Smi**>(first))->IsSmi()); |
| 227 ASSERT((*reinterpret_cast<Smi**>(second))->IsSmi()); |
| 224 Handle<Smi> h1(reinterpret_cast<Smi**>(first)); | 228 Handle<Smi> h1(reinterpret_cast<Smi**>(first)); |
| 225 Handle<Smi> h2(reinterpret_cast<Smi**>(second)); | 229 Handle<Smi> h2(reinterpret_cast<Smi**>(second)); |
| 226 return (*h1)->value() == (*h2)->value(); | 230 return (*h1)->value() == (*h2)->value(); |
| 227 } | 231 } |
| 228 | 232 |
| 229 void ObjectLiteral::CalculateEmitStore() { | 233 void ObjectLiteral::CalculateEmitStore() { |
| 230 HashMap properties(&IsEqualString); | 234 HashMap properties(&IsEqualString); |
| 231 HashMap elements(&IsEqualSmi); | 235 HashMap elements(&IsEqualSmi); |
| 232 for (int i = this->properties()->length() - 1; i >= 0; i--) { | 236 for (int i = this->properties()->length() - 1; i >= 0; i--) { |
| 233 ObjectLiteral::Property* property = this->properties()->at(i); | 237 ObjectLiteral::Property* property = this->properties()->at(i); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 259 Vector<char> buffer(arr, ARRAY_SIZE(arr)); | 263 Vector<char> buffer(arr, ARRAY_SIZE(arr)); |
| 260 const char* str = DoubleToCString(num, buffer); | 264 const char* str = DoubleToCString(num, buffer); |
| 261 Handle<String> name = FACTORY->NewStringFromAscii(CStrVector(str)); | 265 Handle<String> name = FACTORY->NewStringFromAscii(CStrVector(str)); |
| 262 key = name.location(); | 266 key = name.location(); |
| 263 hash = name->Hash(); | 267 hash = name->Hash(); |
| 264 table = &properties; | 268 table = &properties; |
| 265 } | 269 } |
| 266 // If the key of a computed property is in the table, do not emit | 270 // If the key of a computed property is in the table, do not emit |
| 267 // a store for the property later. | 271 // a store for the property later. |
| 268 if (property->kind() == ObjectLiteral::Property::COMPUTED) { | 272 if (property->kind() == ObjectLiteral::Property::COMPUTED) { |
| 269 if (table->Lookup(literal, hash, false) != NULL) { | 273 if (table->Lookup(key, hash, false) != NULL) { |
| 270 property->set_emit_store(false); | 274 property->set_emit_store(false); |
| 271 } | 275 } |
| 272 } | 276 } |
| 273 // Add key to the table. | 277 // Add key to the table. |
| 274 table->Lookup(literal, hash, true); | 278 table->Lookup(key, hash, true); |
| 275 } | 279 } |
| 276 } | 280 } |
| 277 | 281 |
| 278 | 282 |
| 279 void TargetCollector::AddTarget(BreakTarget* target) { | 283 void TargetCollector::AddTarget(BreakTarget* target) { |
| 280 // Add the label to the collector, but discard duplicates. | 284 // Add the label to the collector, but discard duplicates. |
| 281 int length = targets_->length(); | 285 int length = targets_->length(); |
| 282 for (int i = 0; i < length; i++) { | 286 for (int i = 0; i < length; i++) { |
| 283 if (targets_->at(i) == target) return; | 287 if (targets_->at(i) == target) return; |
| 284 } | 288 } |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 510 | 514 |
| 511 // ---------------------------------------------------------------------------- | 515 // ---------------------------------------------------------------------------- |
| 512 // Recording of type feedback | 516 // Recording of type feedback |
| 513 | 517 |
| 514 void Property::RecordTypeFeedback(TypeFeedbackOracle* oracle) { | 518 void Property::RecordTypeFeedback(TypeFeedbackOracle* oracle) { |
| 515 // Record type feedback from the oracle in the AST. | 519 // Record type feedback from the oracle in the AST. |
| 516 is_monomorphic_ = oracle->LoadIsMonomorphic(this); | 520 is_monomorphic_ = oracle->LoadIsMonomorphic(this); |
| 517 if (key()->IsPropertyName()) { | 521 if (key()->IsPropertyName()) { |
| 518 if (oracle->LoadIsBuiltin(this, Builtins::LoadIC_ArrayLength)) { | 522 if (oracle->LoadIsBuiltin(this, Builtins::LoadIC_ArrayLength)) { |
| 519 is_array_length_ = true; | 523 is_array_length_ = true; |
| 524 } else if (oracle->LoadIsBuiltin(this, |
| 525 Builtins::LoadIC_FunctionPrototype)) { |
| 526 is_function_prototype_ = true; |
| 520 } else { | 527 } else { |
| 521 Literal* lit_key = key()->AsLiteral(); | 528 Literal* lit_key = key()->AsLiteral(); |
| 522 ASSERT(lit_key != NULL && lit_key->handle()->IsString()); | 529 ASSERT(lit_key != NULL && lit_key->handle()->IsString()); |
| 523 Handle<String> name = Handle<String>::cast(lit_key->handle()); | 530 Handle<String> name = Handle<String>::cast(lit_key->handle()); |
| 524 ZoneMapList* types = oracle->LoadReceiverTypes(this, name); | 531 ZoneMapList* types = oracle->LoadReceiverTypes(this, name); |
| 525 receiver_types_ = types; | 532 receiver_types_ = types; |
| 526 } | 533 } |
| 527 } else if (is_monomorphic_) { | 534 } else if (is_monomorphic_) { |
| 528 monomorphic_receiver_type_ = oracle->LoadMonomorphicReceiverType(this); | 535 monomorphic_receiver_type_ = oracle->LoadMonomorphicReceiverType(this); |
| 529 } | 536 } |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 631 if (FLAG_enable_slow_asserts) { | 638 if (FLAG_enable_slow_asserts) { |
| 632 if (receiver_types_ != NULL) { | 639 if (receiver_types_ != NULL) { |
| 633 int length = receiver_types_->length(); | 640 int length = receiver_types_->length(); |
| 634 for (int i = 0; i < length; i++) { | 641 for (int i = 0; i < length; i++) { |
| 635 Handle<Map> map = receiver_types_->at(i); | 642 Handle<Map> map = receiver_types_->at(i); |
| 636 ASSERT(!map.is_null() && *map != NULL); | 643 ASSERT(!map.is_null() && *map != NULL); |
| 637 } | 644 } |
| 638 } | 645 } |
| 639 } | 646 } |
| 640 #endif | 647 #endif |
| 641 if (receiver_types_ != NULL && receiver_types_->length() > 0) { | 648 is_monomorphic_ = oracle->CallIsMonomorphic(this); |
| 642 Handle<Map> type = receiver_types_->at(0); | 649 check_type_ = oracle->GetCallCheckType(this); |
| 643 is_monomorphic_ = oracle->CallIsMonomorphic(this); | 650 if (is_monomorphic_) { |
| 644 if (is_monomorphic_) is_monomorphic_ = ComputeTarget(type, name); | 651 Handle<Map> map; |
| 652 if (receiver_types_ != NULL && receiver_types_->length() > 0) { |
| 653 ASSERT(check_type_ == RECEIVER_MAP_CHECK); |
| 654 map = receiver_types_->at(0); |
| 655 } else { |
| 656 ASSERT(check_type_ != RECEIVER_MAP_CHECK); |
| 657 map = Handle<Map>( |
| 658 oracle->GetPrototypeForPrimitiveCheck(check_type_)->map()); |
| 659 } |
| 660 is_monomorphic_ = ComputeTarget(map, name); |
| 645 } | 661 } |
| 646 } | 662 } |
| 647 | 663 |
| 648 | 664 |
| 649 void BinaryOperation::RecordTypeFeedback(TypeFeedbackOracle* oracle) { | 665 void BinaryOperation::RecordTypeFeedback(TypeFeedbackOracle* oracle) { |
| 650 TypeInfo left = oracle->BinaryType(this, TypeFeedbackOracle::LEFT); | 666 TypeInfo left = oracle->BinaryType(this, TypeFeedbackOracle::LEFT); |
| 651 TypeInfo right = oracle->BinaryType(this, TypeFeedbackOracle::RIGHT); | 667 TypeInfo right = oracle->BinaryType(this, TypeFeedbackOracle::RIGHT); |
| 652 is_smi_only_ = left.IsSmi() && right.IsSmi(); | 668 is_smi_only_ = left.IsSmi() && right.IsSmi(); |
| 653 } | 669 } |
| 654 | 670 |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1038 | 1054 |
| 1039 CaseClause::CaseClause(Expression* label, | 1055 CaseClause::CaseClause(Expression* label, |
| 1040 ZoneList<Statement*>* statements, | 1056 ZoneList<Statement*>* statements, |
| 1041 int pos) | 1057 int pos) |
| 1042 : label_(label), | 1058 : label_(label), |
| 1043 statements_(statements), | 1059 statements_(statements), |
| 1044 position_(pos), | 1060 position_(pos), |
| 1045 compare_type_(NONE) {} | 1061 compare_type_(NONE) {} |
| 1046 | 1062 |
| 1047 } } // namespace v8::internal | 1063 } } // namespace v8::internal |
| OLD | NEW |