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:
parent
3ee82ddc3f
commit
344e1d9003
@ -1043,7 +1043,7 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global,
|
||||
}
|
||||
|
||||
{ // -- J S O N
|
||||
Handle<String> name = factory->NewStringFromAscii(CStrVector("JSON"));
|
||||
Handle<String> name = factory->InternalizeUtf8String("JSON");
|
||||
Handle<JSFunction> cons = factory->NewFunction(name,
|
||||
factory->the_hole_value());
|
||||
JSFunction::SetInstancePrototype(cons,
|
||||
|
@ -5921,6 +5921,7 @@ uint32_t NameDictionaryShape::HashForObject(Name* key, Object* other) {
|
||||
|
||||
|
||||
MaybeObject* NameDictionaryShape::AsObject(Heap* heap, Name* key) {
|
||||
ASSERT(key->IsUniqueName());
|
||||
return key;
|
||||
}
|
||||
|
||||
|
@ -672,12 +672,19 @@ void JSObject::SetNormalizedProperty(Handle<JSObject> object,
|
||||
PropertyDetails details) {
|
||||
ASSERT(!object->HasFastProperties());
|
||||
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);
|
||||
if (entry == NameDictionary::kNotFound) {
|
||||
Handle<Object> store_value = value;
|
||||
if (object->IsGlobalObject()) {
|
||||
store_value = object->GetIsolate()->factory()->NewPropertyCell(value);
|
||||
}
|
||||
|
||||
property_dictionary =
|
||||
NameDictionaryAdd(property_dictionary, name, store_value, details);
|
||||
object->set_properties(*property_dictionary);
|
||||
@ -2044,6 +2051,12 @@ Handle<Object> JSObject::AddProperty(Handle<JSObject> object,
|
||||
TransitionFlag transition_flag) {
|
||||
ASSERT(!object->IsJSGlobalProxy());
|
||||
Isolate* isolate = object->GetIsolate();
|
||||
|
||||
if (!name->IsUniqueName()) {
|
||||
name = isolate->factory()->InternalizedStringFromString(
|
||||
Handle<String>::cast(name));
|
||||
}
|
||||
|
||||
if (extensibility_check == PERFORM_EXTENSIBILITY_CHECK &&
|
||||
!object->map()->is_extensible()) {
|
||||
if (strict_mode == kNonStrictMode) {
|
||||
|
Loading…
Reference in New Issue
Block a user