| 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 654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 665 NameDictionary); | 665 NameDictionary); |
| 666 } | 666 } |
| 667 | 667 |
| 668 | 668 |
| 669 void JSObject::SetNormalizedProperty(Handle<JSObject> object, | 669 void JSObject::SetNormalizedProperty(Handle<JSObject> object, |
| 670 Handle<Name> name, | 670 Handle<Name> name, |
| 671 Handle<Object> value, | 671 Handle<Object> value, |
| 672 PropertyDetails details) { | 672 PropertyDetails details) { |
| 673 ASSERT(!object->HasFastProperties()); | 673 ASSERT(!object->HasFastProperties()); |
| 674 Handle<NameDictionary> property_dictionary(object->property_dictionary()); | 674 Handle<NameDictionary> property_dictionary(object->property_dictionary()); |
| 675 |
| 676 if (!name->IsUniqueName()) { |
| 677 name = object->GetIsolate()->factory()->InternalizedStringFromString( |
| 678 Handle<String>::cast(name)); |
| 679 } |
| 680 |
| 675 int entry = property_dictionary->FindEntry(*name); | 681 int entry = property_dictionary->FindEntry(*name); |
| 676 if (entry == NameDictionary::kNotFound) { | 682 if (entry == NameDictionary::kNotFound) { |
| 677 Handle<Object> store_value = value; | 683 Handle<Object> store_value = value; |
| 678 if (object->IsGlobalObject()) { | 684 if (object->IsGlobalObject()) { |
| 679 store_value = object->GetIsolate()->factory()->NewPropertyCell(value); | 685 store_value = object->GetIsolate()->factory()->NewPropertyCell(value); |
| 680 } | 686 } |
| 687 |
| 681 property_dictionary = | 688 property_dictionary = |
| 682 NameDictionaryAdd(property_dictionary, name, store_value, details); | 689 NameDictionaryAdd(property_dictionary, name, store_value, details); |
| 683 object->set_properties(*property_dictionary); | 690 object->set_properties(*property_dictionary); |
| 684 return; | 691 return; |
| 685 } | 692 } |
| 686 | 693 |
| 687 PropertyDetails original_details = property_dictionary->DetailsAt(entry); | 694 PropertyDetails original_details = property_dictionary->DetailsAt(entry); |
| 688 int enumeration_index; | 695 int enumeration_index; |
| 689 // Preserve the enumeration index unless the property was deleted. | 696 // Preserve the enumeration index unless the property was deleted. |
| 690 if (original_details.IsDeleted()) { | 697 if (original_details.IsDeleted()) { |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 998 | 1005 |
| 999 | 1006 |
| 1000 bool Object::SameValue(Object* other) { | 1007 bool Object::SameValue(Object* other) { |
| 1001 if (other == this) return true; | 1008 if (other == this) return true; |
| 1002 | 1009 |
| 1003 // The object is either a number, a name, an odd-ball, | 1010 // The object is either a number, a name, an odd-ball, |
| 1004 // a real JS object, or a Harmony proxy. | 1011 // a real JS object, or a Harmony proxy. |
| 1005 if (IsNumber() && other->IsNumber()) { | 1012 if (IsNumber() && other->IsNumber()) { |
| 1006 double this_value = Number(); | 1013 double this_value = Number(); |
| 1007 double other_value = other->Number(); | 1014 double other_value = other->Number(); |
| 1008 return (this_value == other_value) || | 1015 bool equal = this_value == other_value; |
| 1009 (std::isnan(this_value) && std::isnan(other_value)); | 1016 // SameValue(NaN, NaN) is true. |
| 1017 if (!equal) return std::isnan(this_value) && std::isnan(other_value); |
| 1018 // SameValue(0.0, -0.0) is false. |
| 1019 return (this_value != 0) || ((1 / this_value) == (1 / other_value)); |
| 1010 } | 1020 } |
| 1011 if (IsString() && other->IsString()) { | 1021 if (IsString() && other->IsString()) { |
| 1012 return String::cast(this)->Equals(String::cast(other)); | 1022 return String::cast(this)->Equals(String::cast(other)); |
| 1013 } | 1023 } |
| 1014 return false; | 1024 return false; |
| 1015 } | 1025 } |
| 1016 | 1026 |
| 1017 | 1027 |
| 1018 void Object::ShortPrint(FILE* out) { | 1028 void Object::ShortPrint(FILE* out) { |
| 1019 HeapStringAllocator allocator; | 1029 HeapStringAllocator allocator; |
| (...skipping 1014 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2034 Handle<Object> value, | 2044 Handle<Object> value, |
| 2035 PropertyAttributes attributes, | 2045 PropertyAttributes attributes, |
| 2036 StrictModeFlag strict_mode, | 2046 StrictModeFlag strict_mode, |
| 2037 JSReceiver::StoreFromKeyed store_mode, | 2047 JSReceiver::StoreFromKeyed store_mode, |
| 2038 ExtensibilityCheck extensibility_check, | 2048 ExtensibilityCheck extensibility_check, |
| 2039 ValueType value_type, | 2049 ValueType value_type, |
| 2040 StoreMode mode, | 2050 StoreMode mode, |
| 2041 TransitionFlag transition_flag) { | 2051 TransitionFlag transition_flag) { |
| 2042 ASSERT(!object->IsJSGlobalProxy()); | 2052 ASSERT(!object->IsJSGlobalProxy()); |
| 2043 Isolate* isolate = object->GetIsolate(); | 2053 Isolate* isolate = object->GetIsolate(); |
| 2054 |
| 2055 if (!name->IsUniqueName()) { |
| 2056 name = isolate->factory()->InternalizedStringFromString( |
| 2057 Handle<String>::cast(name)); |
| 2058 } |
| 2059 |
| 2044 if (extensibility_check == PERFORM_EXTENSIBILITY_CHECK && | 2060 if (extensibility_check == PERFORM_EXTENSIBILITY_CHECK && |
| 2045 !object->map()->is_extensible()) { | 2061 !object->map()->is_extensible()) { |
| 2046 if (strict_mode == kNonStrictMode) { | 2062 if (strict_mode == kNonStrictMode) { |
| 2047 return value; | 2063 return value; |
| 2048 } else { | 2064 } else { |
| 2049 Handle<Object> args[1] = { name }; | 2065 Handle<Object> args[1] = { name }; |
| 2050 Handle<Object> error = isolate->factory()->NewTypeError( | 2066 Handle<Object> error = isolate->factory()->NewTypeError( |
| 2051 "object_not_extensible", HandleVector(args, ARRAY_SIZE(args))); | 2067 "object_not_extensible", HandleVector(args, ARRAY_SIZE(args))); |
| 2052 isolate->Throw(*error); | 2068 isolate->Throw(*error); |
| 2053 return Handle<Object>(); | 2069 return Handle<Object>(); |
| (...skipping 7670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9724 | 9740 |
| 9725 bool SharedFunctionInfo::HasSourceCode() { | 9741 bool SharedFunctionInfo::HasSourceCode() { |
| 9726 return !script()->IsUndefined() && | 9742 return !script()->IsUndefined() && |
| 9727 !reinterpret_cast<Script*>(script())->source()->IsUndefined(); | 9743 !reinterpret_cast<Script*>(script())->source()->IsUndefined(); |
| 9728 } | 9744 } |
| 9729 | 9745 |
| 9730 | 9746 |
| 9731 Handle<Object> SharedFunctionInfo::GetSourceCode() { | 9747 Handle<Object> SharedFunctionInfo::GetSourceCode() { |
| 9732 if (!HasSourceCode()) return GetIsolate()->factory()->undefined_value(); | 9748 if (!HasSourceCode()) return GetIsolate()->factory()->undefined_value(); |
| 9733 Handle<String> source(String::cast(Script::cast(script())->source())); | 9749 Handle<String> source(String::cast(Script::cast(script())->source())); |
| 9734 return SubString(source, start_position(), end_position()); | 9750 return GetIsolate()->factory()->NewSubString( |
| 9751 source, start_position(), end_position()); |
| 9735 } | 9752 } |
| 9736 | 9753 |
| 9737 | 9754 |
| 9738 int SharedFunctionInfo::SourceSize() { | 9755 int SharedFunctionInfo::SourceSize() { |
| 9739 return end_position() - start_position(); | 9756 return end_position() - start_position(); |
| 9740 } | 9757 } |
| 9741 | 9758 |
| 9742 | 9759 |
| 9743 int SharedFunctionInfo::CalculateInstanceSize() { | 9760 int SharedFunctionInfo::CalculateInstanceSize() { |
| 9744 int instance_size = | 9761 int instance_size = |
| (...skipping 6357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16102 #define ERROR_MESSAGES_TEXTS(C, T) T, | 16119 #define ERROR_MESSAGES_TEXTS(C, T) T, |
| 16103 static const char* error_messages_[] = { | 16120 static const char* error_messages_[] = { |
| 16104 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) | 16121 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) |
| 16105 }; | 16122 }; |
| 16106 #undef ERROR_MESSAGES_TEXTS | 16123 #undef ERROR_MESSAGES_TEXTS |
| 16107 return error_messages_[reason]; | 16124 return error_messages_[reason]; |
| 16108 } | 16125 } |
| 16109 | 16126 |
| 16110 | 16127 |
| 16111 } } // namespace v8::internal | 16128 } } // namespace v8::internal |
| OLD | NEW |