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

Side by Side Diff: src/runtime/runtime-object.cc

Issue 768633002: Add infrastructure to keep track of references to prototypes. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: use WeakCellForMap() when appropriate Created 6 years 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
« no previous file with comments | « src/runtime/runtime-debug.cc ('k') | src/x64/lithium-codegen-x64.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 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 992 matching lines...) Expand 10 before | Expand all | Expand 10 after
1003 // Get the property names. 1003 // Get the property names.
1004 int next_copy_index = 0; 1004 int next_copy_index = 0;
1005 int hidden_strings = 0; 1005 int hidden_strings = 0;
1006 { 1006 {
1007 PrototypeIterator iter(isolate, obj, PrototypeIterator::START_AT_RECEIVER); 1007 PrototypeIterator iter(isolate, obj, PrototypeIterator::START_AT_RECEIVER);
1008 for (int i = 0; i < length; i++) { 1008 for (int i = 0; i < length; i++) {
1009 DCHECK(!iter.IsAtEnd()); 1009 DCHECK(!iter.IsAtEnd());
1010 Handle<JSObject> jsproto = 1010 Handle<JSObject> jsproto =
1011 Handle<JSObject>::cast(PrototypeIterator::GetCurrent(iter)); 1011 Handle<JSObject>::cast(PrototypeIterator::GetCurrent(iter));
1012 jsproto->GetOwnPropertyNames(*names, next_copy_index, filter); 1012 jsproto->GetOwnPropertyNames(*names, next_copy_index, filter);
1013 if (i > 0) { 1013 // Names from hidden prototypes may already have been added
1014 // Names from hidden prototypes may already have been added 1014 // for inherited function template instances. Count the duplicates
1015 // for inherited function template instances. Count the duplicates 1015 // and stub them out; the final copy pass at the end ignores holes.
1016 // and stub them out; the final copy pass at the end ignores holes. 1016 for (int j = next_copy_index; j < next_copy_index + own_property_count[i];
1017 for (int j = next_copy_index; 1017 j++) {
1018 j < next_copy_index + own_property_count[i]; j++) { 1018 Object* name_from_hidden_proto = names->get(j);
1019 Object* name_from_hidden_proto = names->get(j); 1019 if (isolate->IsInternallyUsedPropertyName(name_from_hidden_proto)) {
1020 hidden_strings++;
1021 } else {
1020 for (int k = 0; k < next_copy_index; k++) { 1022 for (int k = 0; k < next_copy_index; k++) {
1021 if (names->get(k) != isolate->heap()->hidden_string()) { 1023 Object* name = names->get(k);
1022 Object* name = names->get(k); 1024 if (name_from_hidden_proto == name) {
1023 if (name_from_hidden_proto == name) { 1025 names->set(j, isolate->heap()->hidden_string());
1024 names->set(j, isolate->heap()->hidden_string()); 1026 hidden_strings++;
1025 hidden_strings++; 1027 break;
1026 break;
1027 }
1028 } 1028 }
1029 } 1029 }
1030 } 1030 }
1031 } 1031 }
1032 next_copy_index += own_property_count[i]; 1032 next_copy_index += own_property_count[i];
1033 1033
1034 // Hidden properties only show up if the filter does not skip strings.
1035 if ((filter & STRING) == 0 && JSObject::HasHiddenProperties(jsproto)) {
1036 hidden_strings++;
1037 }
1038 iter.Advance(); 1034 iter.Advance();
1039 } 1035 }
1040 } 1036 }
1041 1037
1042 // Filter out name of hidden properties object and 1038 // Filter out name of hidden properties object and
1043 // hidden prototype duplicates. 1039 // hidden prototype duplicates.
1044 if (hidden_strings > 0) { 1040 if (hidden_strings > 0) {
1045 Handle<FixedArray> old_names = names; 1041 Handle<FixedArray> old_names = names;
1046 names = isolate->factory()->NewFixedArray(names->length() - hidden_strings); 1042 names = isolate->factory()->NewFixedArray(names->length() - hidden_strings);
1047 int dest_pos = 0; 1043 int dest_pos = 0;
1048 for (int i = 0; i < total_property_count; i++) { 1044 for (int i = 0; i < total_property_count; i++) {
1049 Object* name = old_names->get(i); 1045 Object* name = old_names->get(i);
1050 if (name == isolate->heap()->hidden_string()) { 1046 if (isolate->IsInternallyUsedPropertyName(name)) {
1051 hidden_strings--; 1047 hidden_strings--;
1052 continue; 1048 continue;
1053 } 1049 }
1054 names->set(dest_pos++, name); 1050 names->set(dest_pos++, name);
1055 } 1051 }
1056 DCHECK_EQ(0, hidden_strings); 1052 DCHECK_EQ(0, hidden_strings);
1057 } 1053 }
1058 1054
1059 return *isolate->factory()->NewJSArrayWithElements(names); 1055 return *isolate->factory()->NewJSArrayWithElements(names);
1060 } 1056 }
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after
1635 CONVERT_ARG_HANDLE_CHECKED(JSFunction, setter, 2); 1631 CONVERT_ARG_HANDLE_CHECKED(JSFunction, setter, 2);
1636 1632
1637 RETURN_FAILURE_ON_EXCEPTION( 1633 RETURN_FAILURE_ON_EXCEPTION(
1638 isolate, 1634 isolate,
1639 JSObject::DefineAccessor(object, name, isolate->factory()->null_value(), 1635 JSObject::DefineAccessor(object, name, isolate->factory()->null_value(),
1640 setter, NONE)); 1636 setter, NONE));
1641 return isolate->heap()->undefined_value(); 1637 return isolate->heap()->undefined_value();
1642 } 1638 }
1643 } 1639 }
1644 } // namespace v8::internal 1640 } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/runtime/runtime-debug.cc ('k') | src/x64/lithium-codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698