Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(296)

Side by Side Diff: src/objects.cc

Issue 162983003: Internalize string keys in Keyed{Store,Load}IC. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/ic.cc ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 714 matching lines...) Expand 10 before | Expand all | Expand 10 after
725 725
726 726
727 void JSObject::SetNormalizedProperty(Handle<JSObject> object, 727 void JSObject::SetNormalizedProperty(Handle<JSObject> object,
728 Handle<Name> name, 728 Handle<Name> name,
729 Handle<Object> value, 729 Handle<Object> value,
730 PropertyDetails details) { 730 PropertyDetails details) {
731 ASSERT(!object->HasFastProperties()); 731 ASSERT(!object->HasFastProperties());
732 Handle<NameDictionary> property_dictionary(object->property_dictionary()); 732 Handle<NameDictionary> property_dictionary(object->property_dictionary());
733 733
734 if (!name->IsUniqueName()) { 734 if (!name->IsUniqueName()) {
735 name = object->GetIsolate()->factory()->InternalizedStringFromString( 735 name = object->GetIsolate()->factory()->InternalizeString(
736 Handle<String>::cast(name)); 736 Handle<String>::cast(name));
737 } 737 }
738 738
739 int entry = property_dictionary->FindEntry(*name); 739 int entry = property_dictionary->FindEntry(*name);
740 if (entry == NameDictionary::kNotFound) { 740 if (entry == NameDictionary::kNotFound) {
741 Handle<Object> store_value = value; 741 Handle<Object> store_value = value;
742 if (object->IsGlobalObject()) { 742 if (object->IsGlobalObject()) {
743 store_value = object->GetIsolate()->factory()->NewPropertyCell(value); 743 store_value = object->GetIsolate()->factory()->NewPropertyCell(value);
744 } 744 }
745 745
(...skipping 1399 matching lines...) Expand 10 before | Expand all | Expand 10 after
2145 StrictModeFlag strict_mode, 2145 StrictModeFlag strict_mode,
2146 JSReceiver::StoreFromKeyed store_mode, 2146 JSReceiver::StoreFromKeyed store_mode,
2147 ExtensibilityCheck extensibility_check, 2147 ExtensibilityCheck extensibility_check,
2148 ValueType value_type, 2148 ValueType value_type,
2149 StoreMode mode, 2149 StoreMode mode,
2150 TransitionFlag transition_flag) { 2150 TransitionFlag transition_flag) {
2151 ASSERT(!object->IsJSGlobalProxy()); 2151 ASSERT(!object->IsJSGlobalProxy());
2152 Isolate* isolate = object->GetIsolate(); 2152 Isolate* isolate = object->GetIsolate();
2153 2153
2154 if (!name->IsUniqueName()) { 2154 if (!name->IsUniqueName()) {
2155 name = isolate->factory()->InternalizedStringFromString( 2155 name = isolate->factory()->InternalizeString(
2156 Handle<String>::cast(name)); 2156 Handle<String>::cast(name));
2157 } 2157 }
2158 2158
2159 if (extensibility_check == PERFORM_EXTENSIBILITY_CHECK && 2159 if (extensibility_check == PERFORM_EXTENSIBILITY_CHECK &&
2160 !object->map()->is_extensible()) { 2160 !object->map()->is_extensible()) {
2161 if (strict_mode == kNonStrictMode) { 2161 if (strict_mode == kNonStrictMode) {
2162 return value; 2162 return value;
2163 } else { 2163 } else {
2164 Handle<Object> args[1] = { name }; 2164 Handle<Object> args[1] = { name };
2165 Handle<Object> error = isolate->factory()->NewTypeError( 2165 Handle<Object> error = isolate->factory()->NewTypeError(
(...skipping 962 matching lines...) Expand 10 before | Expand all | Expand 10 after
3128 int nof_callbacks = callbacks->length(); 3128 int nof_callbacks = callbacks->length();
3129 3129
3130 Isolate* isolate = array->GetIsolate(); 3130 Isolate* isolate = array->GetIsolate();
3131 // Ensure the keys are unique names before writing them into the 3131 // Ensure the keys are unique names before writing them into the
3132 // instance descriptor. Since it may cause a GC, it has to be done before we 3132 // instance descriptor. Since it may cause a GC, it has to be done before we
3133 // temporarily put the heap in an invalid state while appending descriptors. 3133 // temporarily put the heap in an invalid state while appending descriptors.
3134 for (int i = 0; i < nof_callbacks; ++i) { 3134 for (int i = 0; i < nof_callbacks; ++i) {
3135 Handle<AccessorInfo> entry(AccessorInfo::cast(callbacks->get(i))); 3135 Handle<AccessorInfo> entry(AccessorInfo::cast(callbacks->get(i)));
3136 if (entry->name()->IsUniqueName()) continue; 3136 if (entry->name()->IsUniqueName()) continue;
3137 Handle<String> key = 3137 Handle<String> key =
3138 isolate->factory()->InternalizedStringFromString( 3138 isolate->factory()->InternalizeString(
3139 Handle<String>(String::cast(entry->name()))); 3139 Handle<String>(String::cast(entry->name())));
3140 entry->set_name(*key); 3140 entry->set_name(*key);
3141 } 3141 }
3142 3142
3143 // Fill in new callback descriptors. Process the callbacks from 3143 // Fill in new callback descriptors. Process the callbacks from
3144 // back to front so that the last callback with a given name takes 3144 // back to front so that the last callback with a given name takes
3145 // precedence over previously added callbacks with that name. 3145 // precedence over previously added callbacks with that name.
3146 for (int i = nof_callbacks - 1; i >= 0; i--) { 3146 for (int i = nof_callbacks - 1; i >= 0; i--) {
3147 AccessorInfo* entry = AccessorInfo::cast(callbacks->get(i)); 3147 AccessorInfo* entry = AccessorInfo::cast(callbacks->get(i));
3148 Name* key = Name::cast(entry->name()); 3148 Name* key = Name::cast(entry->name());
(...skipping 13347 matching lines...) Expand 10 before | Expand all | Expand 10 after
16496 #define ERROR_MESSAGES_TEXTS(C, T) T, 16496 #define ERROR_MESSAGES_TEXTS(C, T) T,
16497 static const char* error_messages_[] = { 16497 static const char* error_messages_[] = {
16498 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) 16498 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS)
16499 }; 16499 };
16500 #undef ERROR_MESSAGES_TEXTS 16500 #undef ERROR_MESSAGES_TEXTS
16501 return error_messages_[reason]; 16501 return error_messages_[reason];
16502 } 16502 }
16503 16503
16504 16504
16505 } } // namespace v8::internal 16505 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ic.cc ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698