 Chromium Code Reviews
 Chromium Code Reviews Issue 116533003:
  Avoid duplication of a hidden & inherited prototype's properties.  (Closed) 
  Base URL: git://github.com/v8/v8.git@bleeding_edge
    
  
    Issue 116533003:
  Avoid duplication of a hidden & inherited prototype's properties.  (Closed) 
  Base URL: git://github.com/v8/v8.git@bleeding_edge| Index: src/runtime.cc | 
| diff --git a/src/runtime.cc b/src/runtime.cc | 
| index a175836adb2a8a83eaac8b3e0342ee2b19b4c8eb..103cc48a473de32d28ea535078f1ac56d9454593 100644 | 
| --- a/src/runtime.cc | 
| +++ b/src/runtime.cc | 
| @@ -5801,30 +5801,49 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_GetLocalPropertyNames) { | 
| // Get the property names. | 
| jsproto = obj; | 
| - int proto_with_hidden_properties = 0; | 
| int next_copy_index = 0; | 
| + int hidden_strings = 0; | 
| for (int i = 0; i < length; i++) { | 
| jsproto->GetLocalPropertyNames(*names, next_copy_index, filter); | 
| + if (i > 0) { | 
| + // Names from hidden prototypes may already have been added | 
| + // for inherited function template instances. Count the duplicates | 
| + // and stub them out; the final copy pass at the end ignores holes. | 
| + for (int j = next_copy_index; | 
| + j < next_copy_index + local_property_count[i]; | 
| + j++) { | 
| + String* name_from_hidden_proto = String::cast(names->get(j)); | 
| 
dcarney
2013/12/27 09:32:23
You can't cast to String here. It would have to be
 | 
| + for (int k = 0; k < next_copy_index; k++) { | 
| + if (names->get(k) != isolate->heap()->hidden_string()) { | 
| + String* name = String::cast(names->get(k)); | 
| 
dcarney
2013/12/27 09:32:23
same here
 | 
| + if (name_from_hidden_proto == name) { | 
| + names->set(j, isolate->heap()->hidden_string()); | 
| + hidden_strings++; | 
| + break; | 
| + } | 
| + } | 
| + } | 
| + } | 
| + } | 
| next_copy_index += local_property_count[i]; | 
| if (jsproto->HasHiddenProperties()) { | 
| - proto_with_hidden_properties++; | 
| + hidden_strings++; | 
| } | 
| if (i < length - 1) { | 
| jsproto = Handle<JSObject>(JSObject::cast(jsproto->GetPrototype())); | 
| } | 
| } | 
| - // Filter out name of hidden properties object. | 
| - if (proto_with_hidden_properties > 0) { | 
| + // Filter out name of hidden properties object and | 
| + // hidden prototype duplicates. | 
| + if (hidden_strings > 0) { | 
| Handle<FixedArray> old_names = names; | 
| names = isolate->factory()->NewFixedArray( | 
| - names->length() - proto_with_hidden_properties); | 
| + names->length() - hidden_strings); | 
| int dest_pos = 0; | 
| for (int i = 0; i < total_property_count; i++) { | 
| Object* name = old_names->get(i); | 
| - if (name == isolate->heap()->hidden_string()) { | 
| - continue; | 
| - } | 
| + if (name == isolate->heap()->hidden_string()) continue; | 
| 
dcarney
2013/12/27 09:32:23
would you please add a hidden_strings-- here and a
 
sof
2013/12/27 10:52:43
Done (under DEBUG.)
 | 
| names->set(dest_pos++, name); | 
| } | 
| } |