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

Side by Side Diff: src/objects.cc

Issue 335553004: Keep maps when resetting elements. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: simplified as suggested Created 6 years, 6 months 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 | Annotate | Revision Log
« no previous file with comments | « src/elements.cc ('k') | src/objects-inl.h » ('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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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/accessors.h" 7 #include "src/accessors.h"
8 #include "src/allocation-site-scopes.h" 8 #include "src/allocation-site-scopes.h"
9 #include "src/api.h" 9 #include "src/api.h"
10 #include "src/arguments.h" 10 #include "src/arguments.h"
(...skipping 4839 matching lines...) Expand 10 before | Expand all | Expand 10 after
4850 4850
4851 object->set_properties(*fields); 4851 object->set_properties(*fields);
4852 ASSERT(object->IsJSObject()); 4852 ASSERT(object->IsJSObject());
4853 4853
4854 // Check that it really works. 4854 // Check that it really works.
4855 ASSERT(object->HasFastProperties()); 4855 ASSERT(object->HasFastProperties());
4856 } 4856 }
4857 4857
4858 4858
4859 void JSObject::ResetElements(Handle<JSObject> object) { 4859 void JSObject::ResetElements(Handle<JSObject> object) {
4860 if (object->map()->is_observed()) { 4860 Heap* heap = object->GetIsolate()->heap();
4861 // Maintain invariant that observed elements are always in dictionary mode. 4861 CHECK(object->map() != heap->sloppy_arguments_elements_map());
4862 Isolate* isolate = object->GetIsolate(); 4862 object->set_elements(object->map()->GetInitialElements());
4863 Factory* factory = isolate->factory();
4864 Handle<SeededNumberDictionary> dictionary =
4865 SeededNumberDictionary::New(isolate, 0);
4866 if (object->map() == *factory->sloppy_arguments_elements_map()) {
4867 FixedArray::cast(object->elements())->set(1, *dictionary);
4868 } else {
4869 object->set_elements(*dictionary);
4870 }
4871 return;
4872 }
4873
4874 ElementsKind elements_kind = GetInitialFastElementsKind();
4875 if (!FLAG_smi_only_arrays) {
4876 elements_kind = FastSmiToObjectElementsKind(elements_kind);
4877 }
4878 Handle<Map> map = JSObject::GetElementsTransitionMap(object, elements_kind);
4879 DisallowHeapAllocation no_gc;
4880 Handle<FixedArrayBase> elements(map->GetInitialElements());
4881 JSObject::SetMapAndElements(object, map, elements);
4882 } 4863 }
4883 4864
4884 4865
4885 static Handle<SeededNumberDictionary> CopyFastElementsToDictionary( 4866 static Handle<SeededNumberDictionary> CopyFastElementsToDictionary(
4886 Handle<FixedArrayBase> array, 4867 Handle<FixedArrayBase> array,
4887 int length, 4868 int length,
4888 Handle<SeededNumberDictionary> dictionary) { 4869 Handle<SeededNumberDictionary> dictionary) {
4889 Isolate* isolate = array->GetIsolate(); 4870 Isolate* isolate = array->GetIsolate();
4890 Factory* factory = isolate->factory(); 4871 Factory* factory = isolate->factory();
4891 bool has_double_elements = array->IsFixedDoubleArray(); 4872 bool has_double_elements = array->IsFixedDoubleArray();
(...skipping 12202 matching lines...) Expand 10 before | Expand all | Expand 10 after
17094 #define ERROR_MESSAGES_TEXTS(C, T) T, 17075 #define ERROR_MESSAGES_TEXTS(C, T) T,
17095 static const char* error_messages_[] = { 17076 static const char* error_messages_[] = {
17096 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) 17077 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS)
17097 }; 17078 };
17098 #undef ERROR_MESSAGES_TEXTS 17079 #undef ERROR_MESSAGES_TEXTS
17099 return error_messages_[reason]; 17080 return error_messages_[reason];
17100 } 17081 }
17101 17082
17102 17083
17103 } } // namespace v8::internal 17084 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/elements.cc ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698