Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #include "src/arguments.h" | 7 #include "src/arguments.h" |
| 8 #include "src/bootstrapper.h" | 8 #include "src/bootstrapper.h" |
| 9 #include "src/debug.h" | 9 #include "src/debug.h" |
| 10 #include "src/runtime/runtime.h" | 10 #include "src/runtime/runtime.h" |
| (...skipping 972 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 983 // Get the property names. | 983 // Get the property names. |
| 984 int next_copy_index = 0; | 984 int next_copy_index = 0; |
| 985 int hidden_strings = 0; | 985 int hidden_strings = 0; |
| 986 { | 986 { |
| 987 PrototypeIterator iter(isolate, obj, PrototypeIterator::START_AT_RECEIVER); | 987 PrototypeIterator iter(isolate, obj, PrototypeIterator::START_AT_RECEIVER); |
| 988 for (int i = 0; i < length; i++) { | 988 for (int i = 0; i < length; i++) { |
| 989 DCHECK(!iter.IsAtEnd()); | 989 DCHECK(!iter.IsAtEnd()); |
| 990 Handle<JSObject> jsproto = | 990 Handle<JSObject> jsproto = |
| 991 Handle<JSObject>::cast(PrototypeIterator::GetCurrent(iter)); | 991 Handle<JSObject>::cast(PrototypeIterator::GetCurrent(iter)); |
| 992 jsproto->GetOwnPropertyNames(*names, next_copy_index, filter); | 992 jsproto->GetOwnPropertyNames(*names, next_copy_index, filter); |
| 993 if (i > 0) { | 993 // Names from hidden prototypes may already have been added |
| 994 // Names from hidden prototypes may already have been added | 994 // for inherited function template instances. Count the duplicates |
| 995 // for inherited function template instances. Count the duplicates | 995 // and stub them out; the final copy pass at the end ignores holes. |
| 996 // and stub them out; the final copy pass at the end ignores holes. | 996 for (int j = next_copy_index; j < next_copy_index + own_property_count[i]; |
| 997 for (int j = next_copy_index; | 997 j++) { |
| 998 j < next_copy_index + own_property_count[i]; j++) { | 998 Object* name_from_hidden_proto = names->get(j); |
| 999 Object* name_from_hidden_proto = names->get(j); | 999 if (isolate->IsInternallyUsedPropertyName(name_from_hidden_proto)) { |
|
ulan
2014/12/15 15:40:36
Shouldn't this also check (filter & STRING) == 0?
Jakob Kummerow
2014/12/15 16:18:49
No, we don't need to do that any more, because cal
| |
| 1000 hidden_strings++; | |
| 1001 } else { | |
| 1000 for (int k = 0; k < next_copy_index; k++) { | 1002 for (int k = 0; k < next_copy_index; k++) { |
| 1001 if (names->get(k) != isolate->heap()->hidden_string()) { | 1003 Object* name = names->get(k); |
| 1002 Object* name = names->get(k); | 1004 if (name_from_hidden_proto == name) { |
| 1003 if (name_from_hidden_proto == name) { | 1005 names->set(j, isolate->heap()->hidden_string()); |
| 1004 names->set(j, isolate->heap()->hidden_string()); | 1006 hidden_strings++; |
| 1005 hidden_strings++; | 1007 break; |
| 1006 break; | |
| 1007 } | |
| 1008 } | 1008 } |
| 1009 } | 1009 } |
| 1010 } | 1010 } |
| 1011 } | 1011 } |
| 1012 next_copy_index += own_property_count[i]; | 1012 next_copy_index += own_property_count[i]; |
| 1013 | 1013 |
| 1014 // Hidden properties only show up if the filter does not skip strings. | |
| 1015 if ((filter & STRING) == 0 && JSObject::HasHiddenProperties(jsproto)) { | |
| 1016 hidden_strings++; | |
| 1017 } | |
| 1018 iter.Advance(); | 1014 iter.Advance(); |
| 1019 } | 1015 } |
| 1020 } | 1016 } |
| 1021 | 1017 |
| 1022 // Filter out name of hidden properties object and | 1018 // Filter out name of hidden properties object and |
| 1023 // hidden prototype duplicates. | 1019 // hidden prototype duplicates. |
| 1024 if (hidden_strings > 0) { | 1020 if (hidden_strings > 0) { |
| 1025 Handle<FixedArray> old_names = names; | 1021 Handle<FixedArray> old_names = names; |
| 1026 names = isolate->factory()->NewFixedArray(names->length() - hidden_strings); | 1022 names = isolate->factory()->NewFixedArray(names->length() - hidden_strings); |
| 1027 int dest_pos = 0; | 1023 int dest_pos = 0; |
| 1028 for (int i = 0; i < total_property_count; i++) { | 1024 for (int i = 0; i < total_property_count; i++) { |
| 1029 Object* name = old_names->get(i); | 1025 Object* name = old_names->get(i); |
| 1030 if (name == isolate->heap()->hidden_string()) { | 1026 if (isolate->IsInternallyUsedPropertyName(name)) { |
| 1031 hidden_strings--; | 1027 hidden_strings--; |
| 1032 continue; | 1028 continue; |
| 1033 } | 1029 } |
| 1034 names->set(dest_pos++, name); | 1030 names->set(dest_pos++, name); |
| 1035 } | 1031 } |
| 1036 DCHECK_EQ(0, hidden_strings); | 1032 DCHECK_EQ(0, hidden_strings); |
| 1037 } | 1033 } |
| 1038 | 1034 |
| 1039 return *isolate->factory()->NewJSArrayWithElements(names); | 1035 return *isolate->factory()->NewJSArrayWithElements(names); |
| 1040 } | 1036 } |
| (...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1586 | 1582 |
| 1587 RUNTIME_FUNCTION(RuntimeReference_ClassOf) { | 1583 RUNTIME_FUNCTION(RuntimeReference_ClassOf) { |
| 1588 SealHandleScope shs(isolate); | 1584 SealHandleScope shs(isolate); |
| 1589 DCHECK(args.length() == 1); | 1585 DCHECK(args.length() == 1); |
| 1590 CONVERT_ARG_CHECKED(Object, obj, 0); | 1586 CONVERT_ARG_CHECKED(Object, obj, 0); |
| 1591 if (!obj->IsJSReceiver()) return isolate->heap()->null_value(); | 1587 if (!obj->IsJSReceiver()) return isolate->heap()->null_value(); |
| 1592 return JSReceiver::cast(obj)->class_name(); | 1588 return JSReceiver::cast(obj)->class_name(); |
| 1593 } | 1589 } |
| 1594 } | 1590 } |
| 1595 } // namespace v8::internal | 1591 } // namespace v8::internal |
| OLD | NEW |