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

Side by Side Diff: src/objects.cc

Issue 2622723003: [compiler] Support Object.create(null) inlining in TF (Closed)
Patch Set: initializing all object fields Created 3 years, 11 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
« no previous file with comments | « src/objects.h ('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 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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/objects.h" 5 #include "src/objects.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 #include <iomanip> 8 #include <iomanip>
9 #include <memory> 9 #include <memory>
10 #include <sstream> 10 #include <sstream>
(...skipping 4706 matching lines...) Expand 10 before | Expand all | Expand 10 after
4717 Map* current = *map; 4717 Map* current = *map;
4718 while (current->instance_descriptors() == *descriptors) { 4718 while (current->instance_descriptors() == *descriptors) {
4719 Object* next = current->GetBackPointer(); 4719 Object* next = current->GetBackPointer();
4720 if (next->IsUndefined(isolate)) break; // Stop overwriting at initial map. 4720 if (next->IsUndefined(isolate)) break; // Stop overwriting at initial map.
4721 current->UpdateDescriptors(*new_descriptors, layout_descriptor); 4721 current->UpdateDescriptors(*new_descriptors, layout_descriptor);
4722 current = Map::cast(next); 4722 current = Map::cast(next);
4723 } 4723 }
4724 map->UpdateDescriptors(*new_descriptors, layout_descriptor); 4724 map->UpdateDescriptors(*new_descriptors, layout_descriptor);
4725 } 4725 }
4726 4726
4727 // static
4728 Handle<Map> Map::GetObjectCreateMap(Handle<HeapObject> prototype) {
4729 Isolate* isolate = prototype->GetIsolate();
4730 Handle<Map> map(isolate->native_context()->object_function()->initial_map(),
4731 isolate);
4732 if (map->prototype() == *prototype) return map;
4733 if (prototype->IsNull(isolate)) {
4734 return isolate->slow_object_with_null_prototype_map();
4735 }
4736 if (prototype->IsJSObject()) {
4737 Handle<JSObject> js_prototype = Handle<JSObject>::cast(prototype);
4738 if (!js_prototype->map()->is_prototype_map()) {
4739 JSObject::OptimizeAsPrototype(js_prototype, FAST_PROTOTYPE);
4740 }
4741 Handle<PrototypeInfo> info =
4742 Map::GetOrCreatePrototypeInfo(js_prototype, isolate);
4743 // TODO(verwaest): Use inobject slack tracking for this map.
4744 if (info->HasObjectCreateMap()) {
4745 map = handle(info->ObjectCreateMap(), isolate);
4746 } else {
4747 map = Map::CopyInitialMap(map);
4748 Map::SetPrototype(map, prototype, FAST_PROTOTYPE);
4749 PrototypeInfo::SetObjectCreateMap(info, map);
4750 }
4751 return map;
4752 }
4753
4754 return Map::TransitionToPrototype(map, prototype, REGULAR_PROTOTYPE);
4755 }
4756
4727 template <class T> 4757 template <class T>
4728 static int AppendUniqueCallbacks(Handle<TemplateList> callbacks, 4758 static int AppendUniqueCallbacks(Handle<TemplateList> callbacks,
4729 Handle<typename T::Array> array, 4759 Handle<typename T::Array> array,
4730 int valid_descriptors) { 4760 int valid_descriptors) {
4731 int nof_callbacks = callbacks->length(); 4761 int nof_callbacks = callbacks->length();
4732 4762
4733 Isolate* isolate = array->GetIsolate(); 4763 Isolate* isolate = array->GetIsolate();
4734 // Ensure the keys are unique names before writing them into the 4764 // Ensure the keys are unique names before writing them into the
4735 // instance descriptor. Since it may cause a GC, it has to be done before we 4765 // instance descriptor. Since it may cause a GC, it has to be done before we
4736 // temporarily put the heap in an invalid state while appending descriptors. 4766 // temporarily put the heap in an invalid state while appending descriptors.
(...skipping 3482 matching lines...) Expand 10 before | Expand all | Expand 10 after
8219 } 8249 }
8220 } 8250 }
8221 return free_index; 8251 return free_index;
8222 } 8252 }
8223 8253
8224 8254
8225 bool Map::OnlyHasSimpleProperties() { 8255 bool Map::OnlyHasSimpleProperties() {
8226 // Wrapped string elements aren't explicitly stored in the elements backing 8256 // Wrapped string elements aren't explicitly stored in the elements backing
8227 // store, but are loaded indirectly from the underlying string. 8257 // store, but are loaded indirectly from the underlying string.
8228 return !IsStringWrapperElementsKind(elements_kind()) && 8258 return !IsStringWrapperElementsKind(elements_kind()) &&
8229 instance_type() > LAST_SPECIAL_RECEIVER_TYPE && 8259 !IsSpecialReceiverMap() && !has_hidden_prototype() &&
8230 !has_hidden_prototype() && !is_dictionary_map(); 8260 !is_dictionary_map();
8231 } 8261 }
8232 8262
8233 MUST_USE_RESULT Maybe<bool> FastGetOwnValuesOrEntries( 8263 MUST_USE_RESULT Maybe<bool> FastGetOwnValuesOrEntries(
8234 Isolate* isolate, Handle<JSReceiver> receiver, bool get_entries, 8264 Isolate* isolate, Handle<JSReceiver> receiver, bool get_entries,
8235 Handle<FixedArray>* result) { 8265 Handle<FixedArray>* result) {
8236 Handle<Map> map(JSReceiver::cast(*receiver)->map(), isolate); 8266 Handle<Map> map(JSReceiver::cast(*receiver)->map(), isolate);
8237 8267
8238 if (!map->IsJSObjectMap()) return Just(false); 8268 if (!map->IsJSObjectMap()) return Just(false);
8239 if (!map->OnlyHasSimpleProperties()) return Just(false); 8269 if (!map->OnlyHasSimpleProperties()) return Just(false);
8240 8270
(...skipping 11654 matching lines...) Expand 10 before | Expand all | Expand 10 after
19895 // depend on this. 19925 // depend on this.
19896 return DICTIONARY_ELEMENTS; 19926 return DICTIONARY_ELEMENTS;
19897 } 19927 }
19898 DCHECK_LE(kind, LAST_ELEMENTS_KIND); 19928 DCHECK_LE(kind, LAST_ELEMENTS_KIND);
19899 return kind; 19929 return kind;
19900 } 19930 }
19901 } 19931 }
19902 19932
19903 } // namespace internal 19933 } // namespace internal
19904 } // namespace v8 19934 } // namespace v8
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698