Internalize names before using them in slow-mode objects.

R=yangguo@chromium.org

Review URL: https://chromiumcodereview.appspot.com/24566005

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@16944 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
verwaest@chromium.org 2013-09-25 15:11:48 +00:00
parent 3ee82ddc3f
commit 344e1d9003
3 changed files with 15 additions and 1 deletions

View File

@ -1043,7 +1043,7 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global,
} }
{ // -- J S O N { // -- J S O N
Handle<String> name = factory->NewStringFromAscii(CStrVector("JSON")); Handle<String> name = factory->InternalizeUtf8String("JSON");
Handle<JSFunction> cons = factory->NewFunction(name, Handle<JSFunction> cons = factory->NewFunction(name,
factory->the_hole_value()); factory->the_hole_value());
JSFunction::SetInstancePrototype(cons, JSFunction::SetInstancePrototype(cons,

View File

@ -5921,6 +5921,7 @@ uint32_t NameDictionaryShape::HashForObject(Name* key, Object* other) {
MaybeObject* NameDictionaryShape::AsObject(Heap* heap, Name* key) { MaybeObject* NameDictionaryShape::AsObject(Heap* heap, Name* key) {
ASSERT(key->IsUniqueName());
return key; return key;
} }

View File

@ -672,12 +672,19 @@ void JSObject::SetNormalizedProperty(Handle<JSObject> object,
PropertyDetails details) { PropertyDetails details) {
ASSERT(!object->HasFastProperties()); ASSERT(!object->HasFastProperties());
Handle<NameDictionary> property_dictionary(object->property_dictionary()); Handle<NameDictionary> property_dictionary(object->property_dictionary());
if (!name->IsUniqueName()) {
name = object->GetIsolate()->factory()->InternalizedStringFromString(
Handle<String>::cast(name));
}
int entry = property_dictionary->FindEntry(*name); int entry = property_dictionary->FindEntry(*name);
if (entry == NameDictionary::kNotFound) { if (entry == NameDictionary::kNotFound) {
Handle<Object> store_value = value; Handle<Object> store_value = value;
if (object->IsGlobalObject()) { if (object->IsGlobalObject()) {
store_value = object->GetIsolate()->factory()->NewPropertyCell(value); store_value = object->GetIsolate()->factory()->NewPropertyCell(value);
} }
property_dictionary = property_dictionary =
NameDictionaryAdd(property_dictionary, name, store_value, details); NameDictionaryAdd(property_dictionary, name, store_value, details);
object->set_properties(*property_dictionary); object->set_properties(*property_dictionary);
@ -2044,6 +2051,12 @@ Handle<Object> JSObject::AddProperty(Handle<JSObject> object,
TransitionFlag transition_flag) { TransitionFlag transition_flag) {
ASSERT(!object->IsJSGlobalProxy()); ASSERT(!object->IsJSGlobalProxy());
Isolate* isolate = object->GetIsolate(); Isolate* isolate = object->GetIsolate();
if (!name->IsUniqueName()) {
name = isolate->factory()->InternalizedStringFromString(
Handle<String>::cast(name));
}
if (extensibility_check == PERFORM_EXTENSIBILITY_CHECK && if (extensibility_check == PERFORM_EXTENSIBILITY_CHECK &&
!object->map()->is_extensible()) { !object->map()->is_extensible()) {
if (strict_mode == kNonStrictMode) { if (strict_mode == kNonStrictMode) {